From e8f0578de98539ea16fea15f0033b83615192f96 Mon Sep 17 00:00:00 2001 From: asamusev Date: Sat, 1 Dec 2018 18:02:18 +0300 Subject: [PATCH 001/147] add execute ARGUMENT_DEFINITION and INPUT_FIELD_DEFINITION directive --- codegen/build.go | 2 +- codegen/codegen.go | 7 ++ codegen/config.go | 2 + codegen/directive.go | 23 ++++++ codegen/directive_build.go | 54 ++++++++++++-- codegen/input_build.go | 17 ++++- codegen/object.go | 28 ++++++- codegen/object_build.go | 13 +++- codegen/templates/args.gotpl | 56 +++++++++++++- codegen/templates/data.go | 8 +- codegen/templates/field.gotpl | 22 +++--- codegen/templates/generated.gotpl | 8 +- codegen/templates/input.gotpl | 119 ++++++++++++++++++++++++++++++ codegen/templates/templates.go | 8 +- graphql/context.go | 34 +++++++++ 15 files changed, 356 insertions(+), 45 deletions(-) diff --git a/codegen/build.go b/codegen/build.go index e05f5ad73fd..bff8769d56d 100644 --- a/codegen/build.go +++ b/codegen/build.go @@ -21,7 +21,7 @@ type Build struct { SubscriptionRoot *Object SchemaRaw map[string]string SchemaFilename SchemaFilenames - Directives []*Directive + Directives map[string]*Directive } type ModelBuild struct { diff --git a/codegen/codegen.go b/codegen/codegen.go index 773e3db7cc4..6b185dd1d38 100644 --- a/codegen/codegen.go +++ b/codegen/codegen.go @@ -21,6 +21,13 @@ func Generate(cfg Config) error { _ = syscall.Unlink(cfg.Exec.Filename) _ = syscall.Unlink(cfg.Model.Filename) + namedTypes := cfg.buildNamedTypes() + + directives, err := cfg.buildDirectives(namedTypes) + if err != nil { + return err + } + cfg.Directives = directives modelsBuild, err := cfg.models() if err != nil { diff --git a/codegen/config.go b/codegen/config.go index 8511e4f1a50..8d25aa17b94 100644 --- a/codegen/config.go +++ b/codegen/config.go @@ -85,6 +85,8 @@ type Config struct { Models TypeMap `yaml:"models,omitempty"` StructTag string `yaml:"struct_tag,omitempty"` + Directives map[string]*Directive `yaml:"-"` + FilePath string `yaml:"-"` schema *ast.Schema `yaml:"-"` diff --git a/codegen/directive.go b/codegen/directive.go index 8017da069ac..4cc30d36c56 100644 --- a/codegen/directive.go +++ b/codegen/directive.go @@ -4,6 +4,8 @@ import ( "fmt" "strconv" "strings" + + "github.com/99designs/gqlgen/codegen/templates" ) type Directive struct { @@ -29,6 +31,27 @@ func (d *Directive) CallArgs() string { return strings.Join(args, ", ") } +func (d *Directive) ResolveArgs(obj string, next string) string { + args := []string{"ctx", obj, next} + + for _, arg := range d.Args { + dArg := "&" + arg.GoVarName + if !arg.IsPtr() { + if arg.Value != nil { + dArg = templates.Dump(arg.Value) + } else { + dArg = templates.Dump(arg.Default) + } + } else if arg.Value == nil && arg.Default == nil { + dArg = "nil" + } + + args = append(args, dArg) + } + + return strings.Join(args, ", ") +} + func (d *Directive) Declaration() string { res := ucFirst(d.Name) + " func(ctx context.Context, obj interface{}, next graphql.Resolver" diff --git a/codegen/directive_build.go b/codegen/directive_build.go index af77dc441f6..18ece308635 100644 --- a/codegen/directive_build.go +++ b/codegen/directive_build.go @@ -1,15 +1,17 @@ package codegen import ( - "sort" - "github.com/pkg/errors" + "github.com/vektah/gqlparser/ast" ) -func (cfg *Config) buildDirectives(types NamedTypes) ([]*Directive, error) { - var directives []*Directive +func (cfg *Config) buildDirectives(types NamedTypes) (map[string]*Directive, error) { + directives := make(map[string]*Directive, len(cfg.schema.Directives)) for name, dir := range cfg.schema.Directives { + if _, ok := directives[name]; ok { + return nil, errors.Errorf("directive with name %s already exists", name) + } if name == "skip" || name == "include" || name == "deprecated" { continue } @@ -36,13 +38,49 @@ func (cfg *Config) buildDirectives(types NamedTypes) ([]*Directive, error) { args = append(args, newArg) } - directives = append(directives, &Directive{ + directives[name] = &Directive{ Name: name, Args: args, - }) + } } - sort.Slice(directives, func(i, j int) bool { return directives[i].Name < directives[j].Name }) - return directives, nil } + +func (cfg *Config) getDirectives(list ast.DirectiveList) ([]*Directive, error) { + + dirs := make([]*Directive, len(list)) + for i, d := range list { + argValues := make(map[string]interface{}, len(d.Arguments)) + for _, da := range d.Arguments { + val, err := da.Value.Value(nil) + if err != nil { + return nil, err + } + argValues[da.Name] = val + } + + if def, ok := cfg.Directives[d.Name]; ok { + var args []FieldArgument + for _, a := range def.Args { + + value := a.Default + if argValue, ok := argValues[a.GQLName]; ok { + value = argValue + } + args = append(args, FieldArgument{ + GQLName: a.GQLName, + Value: value, + GoVarName: a.GoVarName, + Type: a.Type, + }) + } + dirs[i] = &Directive{ + Name: d.Name, + Args: args, + } + } + } + + return dirs, nil +} diff --git a/codegen/input_build.go b/codegen/input_build.go index 06ff37a091f..374e5ba037c 100644 --- a/codegen/input_build.go +++ b/codegen/input_build.go @@ -48,10 +48,15 @@ func (cfg *Config) buildInput(types NamedTypes, typ *ast.Definition) (*Object, e typeEntry, entryExists := cfg.Models[typ.Name] for _, field := range typ.Fields { + dirs, err := cfg.getDirectives(field.Directives) + if err != nil { + return nil, err + } newField := Field{ - GQLName: field.Name, - Type: types.getType(field.Type), - Object: obj, + GQLName: field.Name, + Type: types.getType(field.Type), + Object: obj, + Directives: dirs, } if entryExists { @@ -75,6 +80,12 @@ func (cfg *Config) buildInput(types NamedTypes, typ *ast.Definition) (*Object, e obj.Fields = append(obj.Fields, newField) } + dirs, err := cfg.getDirectives(typ.Directives) + if err != nil { + return nil, err + } + obj.Directives = dirs + return obj, nil } diff --git a/codegen/object.go b/codegen/object.go index 656af297a07..484a49f918e 100644 --- a/codegen/object.go +++ b/codegen/object.go @@ -29,6 +29,7 @@ type Object struct { Root bool DisableConcurrency bool Stream bool + Directives []*Directive } type Field struct { @@ -44,15 +45,18 @@ type Field struct { NoErr bool // If this is bound to a go method, does that method have an error as the second argument Object *Object // A link back to the parent object Default interface{} // The default value + Directives []*Directive } type FieldArgument struct { *Type - GQLName string // The name of the argument in graphql - GoVarName string // The name of the var in go - Object *Object // A link back to the parent object - Default interface{} // The default value + GQLName string // The name of the argument in graphql + GoVarName string // The name of the var in go + Object *Object // A link back to the parent object + Default interface{} // The default value + Directives []*Directive + Value interface{} // value set in schema } type Objects []*Object @@ -73,6 +77,18 @@ func (o *Object) HasResolvers() bool { } return false } +func (o *Object) HasDirectives() bool { + if len(o.Directives) > 0 { + return true + } + for _, f := range o.Fields { + if f.HasDirectives() { + return true + } + } + + return false +} func (o *Object) IsConcurrent() bool { for _, f := range o.Fields { @@ -87,6 +103,10 @@ func (o *Object) IsReserved() bool { return strings.HasPrefix(o.GQLType, "__") } +func (f *Field) HasDirectives() bool { + return len(f.Directives) > 0 +} + func (f *Field) IsResolver() bool { return f.GoFieldName == "" } diff --git a/codegen/object_build.go b/codegen/object_build.go index 6f4087ee3d6..92578b01387 100644 --- a/codegen/object_build.go +++ b/codegen/object_build.go @@ -149,11 +149,16 @@ func (cfg *Config) buildObject(types NamedTypes, typ *ast.Definition, imports *I var args []FieldArgument for _, arg := range field.Arguments { + dirs, err := cfg.getDirectives(arg.Directives) + if err != nil { + return nil, err + } newArg := FieldArgument{ - GQLName: arg.Name, - Type: types.getType(arg.Type), - Object: obj, - GoVarName: sanitizeArgName(arg.Name), + GQLName: arg.Name, + Type: types.getType(arg.Type), + Object: obj, + GoVarName: sanitizeArgName(arg.Name), + Directives: dirs, } if !newArg.Type.IsInput && !newArg.Type.IsScalar { diff --git a/codegen/templates/args.gotpl b/codegen/templates/args.gotpl index 870a99edcbf..ec89c9aa112 100644 --- a/codegen/templates/args.gotpl +++ b/codegen/templates/args.gotpl @@ -1,13 +1,65 @@ args := map[string]interface{}{} + var err error {{- range $i, $arg := . }} var arg{{$i}} {{$arg.Signature }} if tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok { - var err error + {{- if or $arg.Directives $arg.IsInput }} + {{ if $arg.Directives }} + argm{{$i}}, err := graphql.ChainFieldMiddleware([]graphql.FieldMiddleware{ + {{- range $directive := $arg.Directives }} + func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { + {{- range $dArg := $directive.Args }} + {{- if and $dArg.IsPtr $dArg.Value }}{{ $dArg.GoVarName }} := {{ $dArg.Value }}{{ end -}} + {{- end }} + return e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs "tmp" "n" }}) + }, + {{- end }} + }...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){ + {{$arg.Unmarshal (print "args" $i) "tmp" }} + if err != nil { + return nil, err + } + return + }) + if err != nil { + return nil, err + } + if data, ok := argm{{$i}}.({{$arg.Signature }}); ok{ + arg{{$i}} = data + } else { + return nil, errors.New("expect {{$arg.Signature }}") + } + {{ else }} + {{$arg.Unmarshal (print "arg" $i) "tmp" }} + if err != nil { + return nil, err + } + {{ end }} + + {{- if $arg.IsInput }} + {{ if $arg.IsPtr }} + if arg{{$i}} != nil { + arg{{$i}}, err = e.{{ .GQLType }}Middleware(ctx, arg{{$i}}) + if err != nil { + return nil, err + } + } + {{ else }} + args{{$i}}, err := e.{{ .GQLType }}Middleware(ctx, &arg{{$i}}) + if err != nil { + return nil, err + } + arg{{$i}} = *args{{$i}} + {{ end }} + {{- end }} + + {{ else }} {{$arg.Unmarshal (print "arg" $i) "tmp" }} if err != nil { return nil, err } + {{- end }} } args[{{$arg.GQLName|quote}}] = arg{{$i}} {{- end }} - return args, nil + return args, err diff --git a/codegen/templates/data.go b/codegen/templates/data.go index 733c7db3954..9444aa6c867 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -1,10 +1,10 @@ package templates var data = map[string]string{ - "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\tvar err error\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", - "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := {{ $field.ArgsFunc }}(rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t})\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\n\t\tresults, err := ec.resolvers.{{ $field.ShortInvocation }}\n\t\tif err != nil {\n\t\t\tec.Error(ctx, err)\n\t\t\treturn nil\n\t\t}\n\t\treturn func() graphql.Marshaler {\n\t\t\tres, ok := <-results\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tvar out graphql.OrderedMap\n\t\t\tout.Add(field.Alias, func() graphql.Marshaler { {{ $field.WriteJson }} }())\n\t\t\treturn &out\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := {{ $field.ArgsFunc }}(rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t{{- end }}\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tArgs: {{if $field.Args }}args{{else}}nil{{end}},\n\t\t\tField: field,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\n\t\t{{ $field.WriteJson }}\n\t}\n{{ end }}\n", - "generated.gotpl": "// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.\n\npackage {{ .PackageName }}\n\nimport (\n{{- range $import := .Imports }}\n\t{{- $import.Write }}\n{{ end }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc {{ $field.ArgsFunc }}(rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc {{ $directive.ArgsFunc }}(rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := {{ $field.ArgsFunc }}(rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := {{ $directive.ArgsFunc }}(rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() *introspection.Schema {\n\treturn introspection.WrapSchema(parsedSchema)\n}\n\nfunc (ec *executionContext) introspectType(name string) *introspection.Type {\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name])\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\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", + "args.gotpl": "\targs := map[string]interface{}{}\n\tvar err error\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\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := graphql.ChainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $dArg.IsPtr $dArg.Value }}{{ $dArg.GoVarName }} := {{ $dArg.Value }}{{ end -}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){\n\t\t\t\t\t{{$arg.Unmarshal (print \"args\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t{{ if $arg.IsPtr }}\n\t\t\t\t\t\tif arg{{$i}} != nil {\n\t\t\t\t\t\t\targ{{$i}}, err = e.{{ .GQLType }}Middleware(ctx, arg{{$i}})\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t{{ else }}\n\t\t\t\t\t\targs{{$i}}, err := e.{{ .GQLType }}Middleware(ctx, &arg{{$i}})\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t\t}\n\t\t\t\t\t\targ{{$i}} = *args{{$i}}\n\t\t\t\t\t{{ end }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, err\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\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\n\t\tresults, err := ec.resolvers.{{ $field.ShortInvocation }}\n\t\tif err != nil {\n\t\t\tec.Error(ctx, err)\n\t\t\treturn nil\n\t\t}\n\t\treturn func() graphql.Marshaler {\n\t\t\tres, ok := <-results\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tvar out graphql.OrderedMap\n\t\t\tout.Add(field.Alias, func() graphql.Marshaler { {{ $field.WriteJson }} }())\n\t\t\treturn &out\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tField: field,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\n\t\t{{ $field.WriteJson }}\n\t}\n{{ end }}\n", + "generated.gotpl": "// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.\n\npackage {{ .PackageName }}\n\nimport (\n{{- range $import := .Imports }}\n\t{{- $import.Write }}\n{{ end }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() *introspection.Schema {\n\treturn introspection.WrapSchema(parsedSchema)\n}\n\nfunc (ec *executionContext) introspectType(name string) *introspection.Type {\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name])\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\tvar err error\n\t\t{{ if .Directives }}\n\t\tcObj, err := graphql.ChainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t{{ $resolveName := \"\" }}\n\t\t{{ $declareName := \"\" }}\n\t\t{{ if $field.IsPtr }}\n\t\t\t{{ $resolveName = \"*\" }}\n\t\t\t{{ $declareName = \"&\" }}\n\t\t{{ end }}\n\t\t\tc{{$field.GoFieldName}}, err := graphql.ChainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print $resolveName \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{$resolveName}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t\t\t{{ if $field.IsInput }}\n\n \t\t{{ if and $field.IsPtr (not $field.IsSlice) }}\n \t\t\tif obj.{{$field.GoFieldName}} != nil {\n \t\t\t\tobj.{{$field.GoFieldName}}, err = e.{{ $field.GQLType }}Middleware(ctx, obj.{{$field.GoFieldName}})\n \t\t\t\tif err != nil {\n \t\t\t\t\treturn obj, err\n \t\t\t\t}\n \t\t\t}\n \t\t{{ else if $field.IsSlice }}\n \t\t\tfor i := range obj.{{$field.GoFieldName}} {\n \t\t\t {{ if eq ($field.Modifiers|len) 2 }}\n \t\t\t\t if obj.{{$field.GoFieldName}}[i] != nil {\n \t\t\t\t\tobj.{{$field.GoFieldName}}[i], err = e.{{ $field.GQLType }}Middleware(ctx, obj.{{$field.GoFieldName}}[i])\n \t\t\t\t\tif err != nil {\n \t\t\t\t\t\treturn nil, err\n \t\t\t\t\t}\n \t\t\t\t }\n \t\t\t{{ else }}\n \t\t\t\titd, err := e.{{ $field.GQLType }}Middleware(ctx, &obj.{{$field.GoFieldName}}[i])\n \t\t\t\tif err != nil {\n \t\t\t\t\treturn nil, err\n \t\t\t\t}\n \t\t\t\tobj.{{$field.GoFieldName}}[i] = *itd\n \t\t\t{{ end }}\n \t\t\t}\n \t\t\t{{ else }}\n \t\t\t{{$field.GoFieldName}}, err := e.{{ $field.GQLType }}Middleware(ctx, &obj.{{$field.GoFieldName}})\n \t\t\tif err != nil {\n \t\t\t\treturn obj, err\n \t\t\t}\n \t\t\tobj.{{$field.GoFieldName}} = *{{$field.GoFieldName}}\n \t\t{{ end }}\n \t\t{{ end }}\n\n\t\t{{- end }}\n\t\treturn obj, err\n\t}\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{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .IsInterface }}\n\t\ttype {{.GoType}} interface {\n\t\t\tIs{{.GoType}}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.GoType}} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\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\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.GoType}}) Is{{$iface.GoType}}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.GoType}} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- 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\n\t{{if $object.IsConcurrent}} var wg sync.WaitGroup {{end}}\n\tout := graphql.NewOrderedMap(len(fields))\n\tinvalid := false\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\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t{{- 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\tif invalid { return graphql.Null }\n\treturn out\n}\n{{- end }}\n", diff --git a/codegen/templates/field.gotpl b/codegen/templates/field.gotpl index 3df847fa980..63920f883b7 100644 --- a/codegen/templates/field.gotpl +++ b/codegen/templates/field.gotpl @@ -3,17 +3,17 @@ {{- if $object.Stream }} func (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Field: field, + }) {{- if $field.Args }} rawArgs := field.ArgumentMap(ec.Variables) - args, err := {{ $field.ArgsFunc }}(rawArgs) + args, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs) if err != nil { ec.Error(ctx, err) return nil } {{- end }} - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Field: field, - }) // FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259 // and Tracer stack rctx := ctx @@ -37,20 +37,20 @@ func (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func () { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: {{$object.GQLType|quote}}, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) {{- if $field.Args }} rawArgs := field.ArgumentMap(ec.Variables) - args, err := {{ $field.ArgsFunc }}(rawArgs) + args, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } + rctx.Args = args {{- end }} - rctx := &graphql.ResolverContext{ - Object: {{$object.GQLType|quote}}, - Args: {{if $field.Args }}args{{else}}nil{{end}}, - Field: field, - } - ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children diff --git a/codegen/templates/generated.gotpl b/codegen/templates/generated.gotpl index 2b20d39e6c4..83aa6ef2148 100644 --- a/codegen/templates/generated.gotpl +++ b/codegen/templates/generated.gotpl @@ -64,7 +64,7 @@ type ComplexityRoot struct { {{ range $object := .Objects -}} {{ range $field := $object.Fields -}} {{ if $field.Args }} - func {{ $field.ArgsFunc }}(rawArgs map[string]interface{}) (map[string]interface{}, error) { + func (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { {{ template "args.gotpl" $field.Args }} } {{ end }} @@ -73,7 +73,7 @@ type ComplexityRoot struct { {{ range $directive := .Directives }} {{ if $directive.Args }} - func {{ $directive.ArgsFunc }}(rawArgs map[string]interface{}) (map[string]interface{}, error) { + func (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { {{ template "args.gotpl" $directive.Args }} } {{ end }} @@ -100,7 +100,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } {{ if $field.Args }} - args, err := {{ $field.ArgsFunc }}(rawArgs) + args, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs) if err != nil { return 0, false } @@ -229,7 +229,7 @@ func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{} if ec.directives.{{$directive.Name|ucFirst}} != nil { {{- if $directive.Args }} rawArgs := d.ArgumentMap(ec.Variables) - args, err := {{ $directive.ArgsFunc }}(rawArgs) + args, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs) if err != nil { ec.Error(ctx, err) return nil diff --git a/codegen/templates/input.gotpl b/codegen/templates/input.gotpl index f543608df0c..e837300c7f5 100644 --- a/codegen/templates/input.gotpl +++ b/codegen/templates/input.gotpl @@ -26,3 +26,122 @@ return it, nil } {{- end }} + + func (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) { + var err error + {{ if .Directives }} + cObj, err := graphql.ChainFieldMiddleware( + []graphql.FieldMiddleware{ + {{- range $directive := .Directives }} + func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { + {{- if $directive.Args }} + {{- range $arg := $directive.Args }} + {{- if and $arg.IsPtr $arg.Value }} + {{$arg.GoVarName}}:={{ $arg.Value | dump}} + {{ else if and $arg.IsPtr $arg.Default }} + {{$arg.GoVarName}}:={{ $arg.Default | dump}} + {{- end }} + {{- end }} + {{- end -}} + return e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs "obj" "n"}}) + }, + {{ end }} + }... + )(ctx, func(ctx context.Context)(interface{}, error){ + return obj, nil + }) + if err != nil || cObj == nil { + return nil ,err + } + obj, ok := cObj.(*{{.FullName}}) + if !ok { + return nil, errors.New("expect {{.FullName}}") + } + {{ end }} + + {{- range $field := .Fields }} + {{ if $field.HasDirectives }} + {{ $resolveName := "" }} + {{ $declareName := "" }} + {{ if $field.IsPtr }} + {{ $resolveName = "*" }} + {{ $declareName = "&" }} + {{ end }} + c{{$field.GoFieldName}}, err := graphql.ChainFieldMiddleware( + []graphql.FieldMiddleware{ + {{- range $directive := $field.Directives }} + func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { + {{- if $directive.Args }} + {{- range $arg := $directive.Args }} + {{- if and $arg.IsPtr $arg.Value }} + {{$arg.GoVarName}}:={{ $arg.Value | dump}} + {{ else if and $arg.IsPtr $arg.Default }} + {{$arg.GoVarName}}:={{ $arg.Default | dump}} + {{- end }} + {{- end }} + {{- end -}} + return e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print $resolveName "obj." $field.GoFieldName ) "n"}}) + }, + {{ end }} + }... + )(ctx, func(ctx context.Context)(interface{}, error){ + return {{$resolveName}}obj.{{$field.GoFieldName}}, nil + }) + if err != nil { + return obj ,err + } + + {{ if $field.IsPtr }} + if data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok { + obj.{{$field.GoFieldName}} = &data + } else { + return obj, errors.New("expect {{ $field.Signature }}") + } + {{else}} + if data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{ + obj.{{$field.GoFieldName}} = data + }else{ + return obj, errors.New("{{$field.GoFieldName}} expect {{$field.Signature }}") + } + {{ end }} + + {{- end }} + + {{ if $field.IsInput }} + + {{ if and $field.IsPtr (not $field.IsSlice) }} + if obj.{{$field.GoFieldName}} != nil { + obj.{{$field.GoFieldName}}, err = e.{{ $field.GQLType }}Middleware(ctx, obj.{{$field.GoFieldName}}) + if err != nil { + return obj, err + } + } + {{ else if $field.IsSlice }} + for i := range obj.{{$field.GoFieldName}} { + {{ if eq ($field.Modifiers|len) 2 }} + if obj.{{$field.GoFieldName}}[i] != nil { + obj.{{$field.GoFieldName}}[i], err = e.{{ $field.GQLType }}Middleware(ctx, obj.{{$field.GoFieldName}}[i]) + if err != nil { + return nil, err + } + } + {{ else }} + itd, err := e.{{ $field.GQLType }}Middleware(ctx, &obj.{{$field.GoFieldName}}[i]) + if err != nil { + return nil, err + } + obj.{{$field.GoFieldName}}[i] = *itd + {{ end }} + } + {{ else }} + {{$field.GoFieldName}}, err := e.{{ $field.GQLType }}Middleware(ctx, &obj.{{$field.GoFieldName}}) + if err != nil { + return obj, err + } + obj.{{$field.GoFieldName}} = *{{$field.GoFieldName}} + {{ end }} + {{ end }} + + {{- end }} + return obj, err + } diff --git a/codegen/templates/templates.go b/codegen/templates/templates.go index 64cef2d8191..18e15242e0d 100644 --- a/codegen/templates/templates.go +++ b/codegen/templates/templates.go @@ -26,7 +26,7 @@ func Run(name string, tpldata interface{}) (*bytes.Buffer, error) { "quote": strconv.Quote, "rawQuote": rawQuote, "toCamel": ToCamel, - "dump": dump, + "dump": Dump, "prefixLines": prefixLines, }) @@ -99,7 +99,7 @@ func rawQuote(s string) string { return "`" + strings.Replace(s, "`", "`+\"`\"+`", -1) + "`" } -func dump(val interface{}) string { +func Dump(val interface{}) string { switch val := val.(type) { case int: return strconv.Itoa(val) @@ -116,7 +116,7 @@ func dump(val interface{}) string { case []interface{}: var parts []string for _, part := range val { - parts = append(parts, dump(part)) + parts = append(parts, Dump(part)) } return "[]interface{}{" + strings.Join(parts, ",") + "}" case map[string]interface{}: @@ -133,7 +133,7 @@ func dump(val interface{}) string { buf.WriteString(strconv.Quote(key)) buf.WriteString(":") - buf.WriteString(dump(data)) + buf.WriteString(Dump(data)) buf.WriteString(",") } buf.WriteString("}") diff --git a/graphql/context.go b/graphql/context.go index ee80988fefe..c14896bf9c5 100644 --- a/graphql/context.go +++ b/graphql/context.go @@ -216,3 +216,37 @@ func (c *RequestContext) RegisterExtension(key string, value interface{}) error c.Extensions[key] = value return nil } + +// ChainFieldMiddleware add chain by FieldMiddleware +func ChainFieldMiddleware(handleFunc ...FieldMiddleware) FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next Resolver) (interface{}, error) { + var ( + chainHandler Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res,err + + } + return handleFunc[0](ctx, chainHandler) + } + } + + if n == 1 { + return handleFunc[0] + } + + return func(ctx context.Context, next Resolver) (interface{}, error) { + return next(ctx) + } +} From 8b3e634e5cc1ba0bf4317629f05872752d0f2ba7 Mon Sep 17 00:00:00 2001 From: asamusev Date: Sat, 1 Dec 2018 18:15:26 +0300 Subject: [PATCH 002/147] update tempate and set Dump public --- codegen/templates/data.go | 8 ++++---- codegen/templates/templates.go | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/codegen/templates/data.go b/codegen/templates/data.go index d3098aaae14..3f9239d5df1 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -1,10 +1,10 @@ package templates var data = map[string]string{ - "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\tvar err error\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", - "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := {{ $field.ArgsFunc }}(rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t})\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\n\t\tresults, err := ec.resolvers.{{ $field.ShortInvocation }}\n\t\tif err != nil {\n\t\t\tec.Error(ctx, err)\n\t\t\treturn nil\n\t\t}\n\t\treturn func() graphql.Marshaler {\n\t\t\tres, ok := <-results\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tvar out graphql.OrderedMap\n\t\t\tout.Add(field.Alias, func() graphql.Marshaler { {{ $field.WriteJson }} }())\n\t\t\treturn &out\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := {{ $field.ArgsFunc }}(rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t{{- end }}\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tArgs: {{if $field.Args }}args{{else}}nil{{end}},\n\t\t\tField: field,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc {{ $field.ArgsFunc }}(rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc {{ $directive.ArgsFunc }}(rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := {{ $field.ArgsFunc }}(rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := {{ $directive.ArgsFunc }}(rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\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", + "args.gotpl": "\targs := map[string]interface{}{}\n\tvar err error\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\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := graphql.ChainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $dArg.IsPtr $dArg.Value }}{{ $dArg.GoVarName }} := {{ $dArg.Value }}{{ end -}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){\n\t\t\t\t\t{{$arg.Unmarshal (print \"args\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t{{ if $arg.IsPtr }}\n\t\t\t\t\t\tif arg{{$i}} != nil {\n\t\t\t\t\t\t\targ{{$i}}, err = e.{{ .GQLType }}Middleware(ctx, arg{{$i}})\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t{{ else }}\n\t\t\t\t\t\targs{{$i}}, err := e.{{ .GQLType }}Middleware(ctx, &arg{{$i}})\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t\t}\n\t\t\t\t\t\targ{{$i}} = *args{{$i}}\n\t\t\t\t\t{{ end }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, err\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\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\n\t\tresults, err := ec.resolvers.{{ $field.ShortInvocation }}\n\t\tif err != nil {\n\t\t\tec.Error(ctx, err)\n\t\t\treturn nil\n\t\t}\n\t\treturn func() graphql.Marshaler {\n\t\t\tres, ok := <-results\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tvar out graphql.OrderedMap\n\t\t\tout.Add(field.Alias, func() graphql.Marshaler { {{ $field.WriteJson }} }())\n\t\t\treturn &out\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tField: field,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\tvar err error\n\t\t{{ if .Directives }}\n\t\tcObj, err := graphql.ChainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t{{ $resolveName := \"\" }}\n\t\t{{ $declareName := \"\" }}\n\t\t{{ if $field.IsPtr }}\n\t\t\t{{ $resolveName = \"*\" }}\n\t\t\t{{ $declareName = \"&\" }}\n\t\t{{ end }}\n\t\t\tc{{$field.GoFieldName}}, err := graphql.ChainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print $resolveName \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{$resolveName}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t\t\t{{ if $field.IsInput }}\n\n \t\t{{ if and $field.IsPtr (not $field.IsSlice) }}\n \t\t\tif obj.{{$field.GoFieldName}} != nil {\n \t\t\t\tobj.{{$field.GoFieldName}}, err = e.{{ $field.GQLType }}Middleware(ctx, obj.{{$field.GoFieldName}})\n \t\t\t\tif err != nil {\n \t\t\t\t\treturn obj, err\n \t\t\t\t}\n \t\t\t}\n \t\t{{ else if $field.IsSlice }}\n \t\t\tfor i := range obj.{{$field.GoFieldName}} {\n \t\t\t {{ if eq ($field.Modifiers|len) 2 }}\n \t\t\t\t if obj.{{$field.GoFieldName}}[i] != nil {\n \t\t\t\t\tobj.{{$field.GoFieldName}}[i], err = e.{{ $field.GQLType }}Middleware(ctx, obj.{{$field.GoFieldName}}[i])\n \t\t\t\t\tif err != nil {\n \t\t\t\t\t\treturn nil, err\n \t\t\t\t\t}\n \t\t\t\t }\n \t\t\t{{ else }}\n \t\t\t\titd, err := e.{{ $field.GQLType }}Middleware(ctx, &obj.{{$field.GoFieldName}}[i])\n \t\t\t\tif err != nil {\n \t\t\t\t\treturn nil, err\n \t\t\t\t}\n \t\t\t\tobj.{{$field.GoFieldName}}[i] = *itd\n \t\t\t{{ end }}\n \t\t\t}\n \t\t\t{{ else }}\n \t\t\t{{$field.GoFieldName}}, err := e.{{ $field.GQLType }}Middleware(ctx, &obj.{{$field.GoFieldName}})\n \t\t\tif err != nil {\n \t\t\t\treturn obj, err\n \t\t\t}\n \t\t\tobj.{{$field.GoFieldName}} = *{{$field.GoFieldName}}\n \t\t{{ end }}\n \t\t{{ end }}\n\n\t\t{{- end }}\n\t\treturn obj, err\n\t}\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{ range $model := .Models }}\n\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .IsInterface }}\n\t\ttype {{.GoType}} interface {\n\t\t\tIs{{.GoType}}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.GoType}} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\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\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.GoType}}) Is{{$iface.GoType}}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.GoType}} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- 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\n\t{{if $object.IsConcurrent}} var wg sync.WaitGroup {{end}}\n\tout := graphql.NewOrderedMap(len(fields))\n\tinvalid := false\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\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t{{- 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\tif invalid { return graphql.Null }\n\treturn out\n}\n{{- end }}\n", diff --git a/codegen/templates/templates.go b/codegen/templates/templates.go index 22e5d7395cb..0e6915eacf1 100644 --- a/codegen/templates/templates.go +++ b/codegen/templates/templates.go @@ -29,7 +29,7 @@ func Run(name string, tpldata interface{}) (*bytes.Buffer, error) { "quote": strconv.Quote, "rawQuote": rawQuote, "toCamel": ToCamel, - "dump": dump, + "dump": Dump, "prefixLines": prefixLines, "reserveImport": CurrentImports.Reserve, "lookupImport": CurrentImports.Lookup, @@ -104,7 +104,7 @@ func rawQuote(s string) string { return "`" + strings.Replace(s, "`", "`+\"`\"+`", -1) + "`" } -func dump(val interface{}) string { +func Dump(val interface{}) string { switch val := val.(type) { case int: return strconv.Itoa(val) @@ -121,7 +121,7 @@ func dump(val interface{}) string { case []interface{}: var parts []string for _, part := range val { - parts = append(parts, dump(part)) + parts = append(parts, Dump(part)) } return "[]interface{}{" + strings.Join(parts, ",") + "}" case map[string]interface{}: @@ -138,7 +138,7 @@ func dump(val interface{}) string { buf.WriteString(strconv.Quote(key)) buf.WriteString(":") - buf.WriteString(dump(data)) + buf.WriteString(Dump(data)) buf.WriteString(",") } buf.WriteString("}") From 3a729cc3c60f1aafdee405513d43cdf43693269d Mon Sep 17 00:00:00 2001 From: asamusev Date: Sat, 1 Dec 2018 22:54:38 +0300 Subject: [PATCH 003/147] update recursive middleware --- codegen/templates/args.gotpl | 15 +- codegen/templates/data.go | 4 +- codegen/templates/input.gotpl | 38 +--- codegen/testserver/generated.go | 368 +++++++++++++++----------------- codegen/type.go | 58 +++++ 5 files changed, 242 insertions(+), 241 deletions(-) diff --git a/codegen/templates/args.gotpl b/codegen/templates/args.gotpl index ec89c9aa112..b4f11857af5 100644 --- a/codegen/templates/args.gotpl +++ b/codegen/templates/args.gotpl @@ -37,20 +37,7 @@ {{ end }} {{- if $arg.IsInput }} - {{ if $arg.IsPtr }} - if arg{{$i}} != nil { - arg{{$i}}, err = e.{{ .GQLType }}Middleware(ctx, arg{{$i}}) - if err != nil { - return nil, err - } - } - {{ else }} - args{{$i}}, err := e.{{ .GQLType }}Middleware(ctx, &arg{{$i}}) - if err != nil { - return nil, err - } - arg{{$i}} = *args{{$i}} - {{ end }} + {{ $arg.Middleware (print "arg" $i) (print "arg" $i) }} {{- end }} {{ else }} diff --git a/codegen/templates/data.go b/codegen/templates/data.go index 3f9239d5df1..677d51ea534 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -1,10 +1,10 @@ package templates var data = map[string]string{ - "args.gotpl": "\targs := map[string]interface{}{}\n\tvar err error\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\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := graphql.ChainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $dArg.IsPtr $dArg.Value }}{{ $dArg.GoVarName }} := {{ $dArg.Value }}{{ end -}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){\n\t\t\t\t\t{{$arg.Unmarshal (print \"args\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t{{ if $arg.IsPtr }}\n\t\t\t\t\t\tif arg{{$i}} != nil {\n\t\t\t\t\t\t\targ{{$i}}, err = e.{{ .GQLType }}Middleware(ctx, arg{{$i}})\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t{{ else }}\n\t\t\t\t\t\targs{{$i}}, err := e.{{ .GQLType }}Middleware(ctx, &arg{{$i}})\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t\t}\n\t\t\t\t\t\targ{{$i}} = *args{{$i}}\n\t\t\t\t\t{{ end }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, err\n", + "args.gotpl": "\targs := map[string]interface{}{}\n\tvar err error\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\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := graphql.ChainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $dArg.IsPtr $dArg.Value }}{{ $dArg.GoVarName }} := {{ $dArg.Value }}{{ end -}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){\n\t\t\t\t\t{{$arg.Unmarshal (print \"args\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t {{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, err\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\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\n\t\tresults, err := ec.resolvers.{{ $field.ShortInvocation }}\n\t\tif err != nil {\n\t\t\tec.Error(ctx, err)\n\t\t\treturn nil\n\t\t}\n\t\treturn func() graphql.Marshaler {\n\t\t\tres, ok := <-results\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tvar out graphql.OrderedMap\n\t\t\tout.Add(field.Alias, func() graphql.Marshaler { {{ $field.WriteJson }} }())\n\t\t\treturn &out\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tField: field,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\tvar err error\n\t\t{{ if .Directives }}\n\t\tcObj, err := graphql.ChainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t{{ $resolveName := \"\" }}\n\t\t{{ $declareName := \"\" }}\n\t\t{{ if $field.IsPtr }}\n\t\t\t{{ $resolveName = \"*\" }}\n\t\t\t{{ $declareName = \"&\" }}\n\t\t{{ end }}\n\t\t\tc{{$field.GoFieldName}}, err := graphql.ChainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print $resolveName \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{$resolveName}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t\t\t{{ if $field.IsInput }}\n\n \t\t{{ if and $field.IsPtr (not $field.IsSlice) }}\n \t\t\tif obj.{{$field.GoFieldName}} != nil {\n \t\t\t\tobj.{{$field.GoFieldName}}, err = e.{{ $field.GQLType }}Middleware(ctx, obj.{{$field.GoFieldName}})\n \t\t\t\tif err != nil {\n \t\t\t\t\treturn obj, err\n \t\t\t\t}\n \t\t\t}\n \t\t{{ else if $field.IsSlice }}\n \t\t\tfor i := range obj.{{$field.GoFieldName}} {\n \t\t\t {{ if eq ($field.Modifiers|len) 2 }}\n \t\t\t\t if obj.{{$field.GoFieldName}}[i] != nil {\n \t\t\t\t\tobj.{{$field.GoFieldName}}[i], err = e.{{ $field.GQLType }}Middleware(ctx, obj.{{$field.GoFieldName}}[i])\n \t\t\t\t\tif err != nil {\n \t\t\t\t\t\treturn nil, err\n \t\t\t\t\t}\n \t\t\t\t }\n \t\t\t{{ else }}\n \t\t\t\titd, err := e.{{ $field.GQLType }}Middleware(ctx, &obj.{{$field.GoFieldName}}[i])\n \t\t\t\tif err != nil {\n \t\t\t\t\treturn nil, err\n \t\t\t\t}\n \t\t\t\tobj.{{$field.GoFieldName}}[i] = *itd\n \t\t\t{{ end }}\n \t\t\t}\n \t\t\t{{ else }}\n \t\t\t{{$field.GoFieldName}}, err := e.{{ $field.GQLType }}Middleware(ctx, &obj.{{$field.GoFieldName}})\n \t\t\tif err != nil {\n \t\t\t\treturn obj, err\n \t\t\t}\n \t\t\tobj.{{$field.GoFieldName}} = *{{$field.GoFieldName}}\n \t\t{{ end }}\n \t\t{{ end }}\n\n\t\t{{- end }}\n\t\treturn obj, err\n\t}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\tvar err error\n\t\t{{ if .Directives }}\n\t\tcObj, err := graphql.ChainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t{{ $resolveName := \"\" }}\n\t\t{{ $declareName := \"\" }}\n\t\t{{ if $field.IsPtr }}\n\t\t\t{{ $resolveName = \"*\" }}\n\t\t\t{{ $declareName = \"&\" }}\n\t\t{{ end }}\n\t\t\tc{{$field.GoFieldName}}, err := graphql.ChainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print $resolveName \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{$resolveName}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, err\n\t}\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{ range $model := .Models }}\n\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .IsInterface }}\n\t\ttype {{.GoType}} interface {\n\t\t\tIs{{.GoType}}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.GoType}} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\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\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.GoType}}) Is{{$iface.GoType}}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.GoType}} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- 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\n\t{{if $object.IsConcurrent}} var wg sync.WaitGroup {{end}}\n\tout := graphql.NewOrderedMap(len(fields))\n\tinvalid := false\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\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t{{- 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\tif invalid { return graphql.Null }\n\treturn out\n}\n{{- end }}\n", diff --git a/codegen/templates/input.gotpl b/codegen/templates/input.gotpl index e837300c7f5..4fec239adcb 100644 --- a/codegen/templates/input.gotpl +++ b/codegen/templates/input.gotpl @@ -107,41 +107,9 @@ {{- end }} - {{ if $field.IsInput }} - - {{ if and $field.IsPtr (not $field.IsSlice) }} - if obj.{{$field.GoFieldName}} != nil { - obj.{{$field.GoFieldName}}, err = e.{{ $field.GQLType }}Middleware(ctx, obj.{{$field.GoFieldName}}) - if err != nil { - return obj, err - } - } - {{ else if $field.IsSlice }} - for i := range obj.{{$field.GoFieldName}} { - {{ if eq ($field.Modifiers|len) 2 }} - if obj.{{$field.GoFieldName}}[i] != nil { - obj.{{$field.GoFieldName}}[i], err = e.{{ $field.GQLType }}Middleware(ctx, obj.{{$field.GoFieldName}}[i]) - if err != nil { - return nil, err - } - } - {{ else }} - itd, err := e.{{ $field.GQLType }}Middleware(ctx, &obj.{{$field.GoFieldName}}[i]) - if err != nil { - return nil, err - } - obj.{{$field.GoFieldName}}[i] = *itd - {{ end }} - } - {{ else }} - {{$field.GoFieldName}}, err := e.{{ $field.GQLType }}Middleware(ctx, &obj.{{$field.GoFieldName}}) - if err != nil { - return obj, err - } - obj.{{$field.GoFieldName}} = *{{$field.GoFieldName}} - {{ end }} - {{ end }} - + {{ if $field.IsInput }} + {{ $field.Middleware (print "obj." $field.GoFieldName ) (print "obj." $field.GoFieldName ) }} + {{- end }} {{- end }} return obj, err } diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 3f97c620b14..f4071db5d79 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -152,11 +152,12 @@ type UserResolver interface { Friends(ctx context.Context, obj *User) ([]User, error) } -func field_Query_mapInput_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query_mapInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 *map[string]interface{} if tmp, ok := rawArgs["input"]; ok { - var err error + var ptr1 map[string]interface{} if tmp != nil { ptr1 = tmp.(map[string]interface{}) @@ -166,17 +167,19 @@ func field_Query_mapInput_args(rawArgs map[string]interface{}) (map[string]inter if err != nil { return nil, err } + } args["input"] = arg0 - return args, nil + return args, err } -func field_Query_recursive_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query_recursive_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 *RecursiveInputSlice if tmp, ok := rawArgs["input"]; ok { - var err error + var ptr1 RecursiveInputSlice if tmp != nil { ptr1, err = UnmarshalRecursiveInputSlice(tmp) @@ -186,17 +189,24 @@ func field_Query_recursive_args(rawArgs map[string]interface{}) (map[string]inte if err != nil { return nil, err } + + arg0, err = e.RecursiveInputSliceMiddleware(ctx, arg0) + if err != nil { + return nil, err + } + } args["input"] = arg0 - return args, nil + return args, err } -func field_Query_nestedInputs_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query_nestedInputs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 [][]*OuterInput if tmp, ok := rawArgs["input"]; ok { - var err error + var rawIf1 []interface{} if tmp != nil { if tmp1, ok := tmp.([]interface{}); ok { @@ -227,17 +237,29 @@ func field_Query_nestedInputs_args(rawArgs map[string]interface{}) (map[string]i if err != nil { return nil, err } + + for idx1 := range arg0 { + for idx2 := range arg0[idx1] { + + arg0[idx1][idx2], err = e.OuterInputMiddleware(ctx, arg0[idx1][idx2]) + if err != nil { + return nil, err + } + } + } + } args["input"] = arg0 - return args, nil + return args, err } -func field_Query_keywords_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query_keywords_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 *Keywords if tmp, ok := rawArgs["input"]; ok { - var err error + var ptr1 Keywords if tmp != nil { ptr1, err = UnmarshalKeywords(tmp) @@ -247,32 +269,38 @@ func field_Query_keywords_args(rawArgs map[string]interface{}) (map[string]inter if err != nil { return nil, err } + + arg0, err = e.KeywordsMiddleware(ctx, arg0) + if err != nil { + return nil, err + } + } args["input"] = arg0 - return args, nil + return args, err } -func field_Query_user_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 int if tmp, ok := rawArgs["id"]; ok { - var err error arg0, err = graphql.UnmarshalInt(tmp) if err != nil { return nil, err } } args["id"] = arg0 - return args, nil + return args, err } -func field_Query_nullableArg_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query_nullableArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 *int if tmp, ok := rawArgs["arg"]; ok { - var err error var ptr1 int if tmp != nil { ptr1, err = graphql.UnmarshalInt(tmp) @@ -284,15 +312,15 @@ func field_Query_nullableArg_args(rawArgs map[string]interface{}) (map[string]in } } args["arg"] = arg0 - return args, nil + return args, err } -func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 string if tmp, ok := rawArgs["break"]; ok { - var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -301,7 +329,6 @@ func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]in args["break"] = arg0 var arg1 string if tmp, ok := rawArgs["default"]; ok { - var err error arg1, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -310,7 +337,6 @@ func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]in args["default"] = arg1 var arg2 string if tmp, ok := rawArgs["func"]; ok { - var err error arg2, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -319,7 +345,6 @@ func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]in args["func"] = arg2 var arg3 string if tmp, ok := rawArgs["interface"]; ok { - var err error arg3, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -328,7 +353,6 @@ func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]in args["interface"] = arg3 var arg4 string if tmp, ok := rawArgs["select"]; ok { - var err error arg4, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -337,7 +361,6 @@ func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]in args["select"] = arg4 var arg5 string if tmp, ok := rawArgs["case"]; ok { - var err error arg5, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -346,7 +369,6 @@ func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]in args["case"] = arg5 var arg6 string if tmp, ok := rawArgs["defer"]; ok { - var err error arg6, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -355,7 +377,6 @@ func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]in args["defer"] = arg6 var arg7 string if tmp, ok := rawArgs["go"]; ok { - var err error arg7, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -364,7 +385,6 @@ func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]in args["go"] = arg7 var arg8 string if tmp, ok := rawArgs["map"]; ok { - var err error arg8, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -373,7 +393,6 @@ func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]in args["map"] = arg8 var arg9 string if tmp, ok := rawArgs["struct"]; ok { - var err error arg9, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -382,7 +401,6 @@ func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]in args["struct"] = arg9 var arg10 string if tmp, ok := rawArgs["chan"]; ok { - var err error arg10, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -391,7 +409,6 @@ func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]in args["chan"] = arg10 var arg11 string if tmp, ok := rawArgs["else"]; ok { - var err error arg11, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -400,7 +417,6 @@ func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]in args["else"] = arg11 var arg12 string if tmp, ok := rawArgs["goto"]; ok { - var err error arg12, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -409,7 +425,6 @@ func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]in args["goto"] = arg12 var arg13 string if tmp, ok := rawArgs["package"]; ok { - var err error arg13, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -418,7 +433,6 @@ func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]in args["package"] = arg13 var arg14 string if tmp, ok := rawArgs["switch"]; ok { - var err error arg14, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -427,7 +441,6 @@ func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]in args["switch"] = arg14 var arg15 string if tmp, ok := rawArgs["const"]; ok { - var err error arg15, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -436,7 +449,6 @@ func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]in args["const"] = arg15 var arg16 string if tmp, ok := rawArgs["fallthrough"]; ok { - var err error arg16, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -445,7 +457,6 @@ func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]in args["fallthrough"] = arg16 var arg17 string if tmp, ok := rawArgs["if"]; ok { - var err error arg17, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -454,7 +465,6 @@ func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]in args["if"] = arg17 var arg18 string if tmp, ok := rawArgs["range"]; ok { - var err error arg18, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -463,7 +473,6 @@ func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]in args["range"] = arg18 var arg19 string if tmp, ok := rawArgs["type"]; ok { - var err error arg19, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -472,7 +481,6 @@ func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]in args["type"] = arg19 var arg20 string if tmp, ok := rawArgs["continue"]; ok { - var err error arg20, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -481,7 +489,6 @@ func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]in args["continue"] = arg20 var arg21 string if tmp, ok := rawArgs["for"]; ok { - var err error arg21, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -490,7 +497,6 @@ func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]in args["for"] = arg21 var arg22 string if tmp, ok := rawArgs["import"]; ok { - var err error arg22, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -499,7 +505,6 @@ func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]in args["import"] = arg22 var arg23 string if tmp, ok := rawArgs["return"]; ok { - var err error arg23, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -508,59 +513,58 @@ func field_Query_keywordArgs_args(rawArgs map[string]interface{}) (map[string]in args["return"] = arg23 var arg24 string if tmp, ok := rawArgs["var"]; ok { - var err error arg24, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["var"] = arg24 - return args, nil + return args, err } -func field_Query___type_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 string if tmp, ok := rawArgs["name"]; ok { - var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["name"] = arg0 - return args, nil + return args, err } -func field___Type_fields_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, nil + return args, err } -func field___Type_enumValues_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, nil + return args, err } @@ -708,7 +712,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Query_mapInput_args(rawArgs) + args, err := e.field_Query_mapInput_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -720,7 +724,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Query_recursive_args(rawArgs) + args, err := e.field_Query_recursive_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -732,7 +736,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Query_nestedInputs_args(rawArgs) + args, err := e.field_Query_nestedInputs_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -751,7 +755,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Query_keywords_args(rawArgs) + args, err := e.field_Query_keywords_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -791,7 +795,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Query_user_args(rawArgs) + args, err := e.field_Query_user_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -803,7 +807,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Query_nullableArg_args(rawArgs) + args, err := e.field_Query_nullableArg_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -815,7 +819,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Query_keywordArgs_args(rawArgs) + args, err := e.field_Query_keywordArgs_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -968,7 +972,6 @@ func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.Co defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Circle", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -992,7 +995,6 @@ func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Circle", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1045,7 +1047,6 @@ func (ec *executionContext) _EmbeddedPointer_ID(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "EmbeddedPointer", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1069,7 +1070,6 @@ func (ec *executionContext) _EmbeddedPointer_Title(ctx context.Context, field gr defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "EmbeddedPointer", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1135,7 +1135,6 @@ func (ec *executionContext) _Error_id(ctx context.Context, field graphql.Collect defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Error", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1162,7 +1161,6 @@ func (ec *executionContext) _Error_errorOnNonRequiredField(ctx context.Context, defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Error", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1186,7 +1184,6 @@ func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, fie defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Error", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1213,7 +1210,6 @@ func (ec *executionContext) _Error_nilOnRequiredField(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Error", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1279,7 +1275,6 @@ func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field gra defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "ForcedResolver", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1338,7 +1333,6 @@ func (ec *executionContext) _InnerObject_id(ctx context.Context, field graphql.C defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "InnerObject", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1395,7 +1389,6 @@ func (ec *executionContext) _InvalidIdentifier_id(ctx context.Context, field gra defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "InvalidIdentifier", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1452,7 +1445,6 @@ func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedF defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "It", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1528,7 +1520,6 @@ func (ec *executionContext) _ModelMethods_resolverField(ctx context.Context, fie defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "ModelMethods", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1555,7 +1546,6 @@ func (ec *executionContext) _ModelMethods_noContext(ctx context.Context, field g defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "ModelMethods", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1582,7 +1572,6 @@ func (ec *executionContext) _ModelMethods_withContext(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "ModelMethods", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1639,7 +1628,6 @@ func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "OuterObject", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1797,7 +1785,6 @@ func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1826,7 +1813,6 @@ func (ec *executionContext) _Query_collision(ctx context.Context, field graphql. defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1853,18 +1839,18 @@ func (ec *executionContext) _Query_collision(ctx context.Context, field graphql. func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query_mapInput_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_mapInput_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -1887,18 +1873,18 @@ func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.C func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query_recursive_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_recursive_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -1921,18 +1907,18 @@ func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql. func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query_nestedInputs_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_nestedInputs_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -1957,7 +1943,6 @@ func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field grap defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2047,18 +2032,18 @@ func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field grap func (ec *executionContext) _Query_keywords(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query_keywords_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_keywords_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2082,7 +2067,6 @@ func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2143,7 +2127,6 @@ func (ec *executionContext) _Query_errorBubble(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2172,7 +2155,6 @@ func (ec *executionContext) _Query_modelMethods(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2201,7 +2183,6 @@ func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2226,18 +2207,18 @@ func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.Coll func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query_user_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_user_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2260,18 +2241,18 @@ func (ec *executionContext) _Query_user(ctx context.Context, field graphql.Colle func (ec *executionContext) _Query_nullableArg(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query_nullableArg_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_nullableArg_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2294,18 +2275,18 @@ func (ec *executionContext) _Query_nullableArg(ctx context.Context, field graphq func (ec *executionContext) _Query_keywordArgs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query_keywordArgs_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_keywordArgs_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2327,18 +2308,18 @@ func (ec *executionContext) _Query_keywordArgs(ctx context.Context, field graphq func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query___type_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query___type_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2364,7 +2345,6 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2424,7 +2404,6 @@ func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Rectangle", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2448,7 +2427,6 @@ func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql. defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Rectangle", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2472,7 +2450,6 @@ func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.C defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Rectangle", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2605,7 +2582,6 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "User", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2632,7 +2608,6 @@ func (ec *executionContext) _User_friends(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "User", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2734,7 +2709,6 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2761,7 +2735,6 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2785,7 +2758,6 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2821,7 +2793,6 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2920,7 +2891,6 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2947,7 +2917,6 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2971,7 +2940,6 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2998,7 +2966,6 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3075,7 +3042,6 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3102,7 +3068,6 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3126,7 +3091,6 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3186,7 +3150,6 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3221,7 +3184,6 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3248,7 +3210,6 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3315,7 +3276,6 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3342,7 +3302,6 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3366,7 +3325,6 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3401,7 +3359,6 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3473,7 +3430,6 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3533,7 +3489,6 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3568,7 +3523,6 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3597,7 +3551,6 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3626,7 +3579,6 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3732,7 +3684,6 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3759,7 +3710,6 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3787,7 +3737,6 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3809,18 +3758,18 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field___Type_fields_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "__Type", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_fields_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -3874,7 +3823,6 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3931,7 +3879,6 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3986,18 +3933,18 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field___Type_enumValues_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "__Type", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -4051,7 +3998,6 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -4108,7 +4054,6 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -4157,6 +4102,12 @@ func (ec *executionContext) _ShapeUnion(ctx context.Context, sel ast.SelectionSe } } +func (e *executableSchema) ChangesMiddleware(ctx context.Context, obj *map[string]interface{}) (*map[string]interface{}, error) { + var err error + + return obj, err +} + func UnmarshalInnerInput(v interface{}) (InnerInput, error) { var it InnerInput var asMap = v.(map[string]interface{}) @@ -4175,6 +4126,12 @@ func UnmarshalInnerInput(v interface{}) (InnerInput, error) { return it, nil } +func (e *executableSchema) InnerInputMiddleware(ctx context.Context, obj *InnerInput) (*InnerInput, error) { + var err error + + return obj, err +} + func UnmarshalKeywords(v interface{}) (Keywords, error) { var it Keywords var asMap = v.(map[string]interface{}) @@ -4337,6 +4294,12 @@ func UnmarshalKeywords(v interface{}) (Keywords, error) { return it, nil } +func (e *executableSchema) KeywordsMiddleware(ctx context.Context, obj *Keywords) (*Keywords, error) { + var err error + + return obj, err +} + func UnmarshalOuterInput(v interface{}) (OuterInput, error) { var it OuterInput var asMap = v.(map[string]interface{}) @@ -4355,6 +4318,17 @@ func UnmarshalOuterInput(v interface{}) (OuterInput, error) { return it, nil } +func (e *executableSchema) OuterInputMiddleware(ctx context.Context, obj *OuterInput) (*OuterInput, error) { + var err error + + mTmp1, err := e.InnerInputMiddleware(ctx, &obj.Inner) + if err != nil { + return nil, err + } + obj.Inner = *mTmp1 + return obj, err +} + func UnmarshalRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { var it RecursiveInputSlice var asMap = v.(map[string]interface{}) @@ -4384,6 +4358,20 @@ func UnmarshalRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { return it, nil } +func (e *executableSchema) RecursiveInputSliceMiddleware(ctx context.Context, obj *RecursiveInputSlice) (*RecursiveInputSlice, error) { + var err error + + for idx1 := range obj.Self { + + mTmp2, err := e.RecursiveInputSliceMiddleware(ctx, &obj.Self[idx1]) + if err != nil { + return nil, err + } + obj.Self[idx1] = *mTmp2 + } + return obj, err +} + func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { defer func() { if r := recover(); r != nil { diff --git a/codegen/type.go b/codegen/type.go index 04d9bb2fde1..ecf52fd5beb 100644 --- a/codegen/type.go +++ b/codegen/type.go @@ -161,6 +161,64 @@ func (t Type) unmarshal(result, raw string, remainingMods []string, depth int) s }) } +func (t Type) Middleware(result, raw string) string { + return t.middleware(result, raw, t.Modifiers, 1) +} + +func (t Type) middleware(result, raw string, remainingMods []string, depth int) string { + if len(remainingMods) == 1 && remainingMods[0] == modPtr { + return tpl(`{{- if .t.Marshaler }} + {{.result}}, err = e.{{ .t.GQLType }}Middleware(ctx, {{.raw}}) + if err != nil { + return nil, err + } + {{- end }}`, map[string]interface{}{ + "result": result, + "raw": raw, + "t": t, + }) + } + switch { + case len(remainingMods) > 0 && remainingMods[0] == modPtr: + return tpl(`if {{.raw}} != nil { + {{.next}} + }`, map[string]interface{}{ + "t": t, + "raw": raw, + "result": result, + "mods": strings.Join(remainingMods[1:], ""), + "next": t.middleware(result, raw, remainingMods[1:], depth+1), + }) + + case len(remainingMods) > 0 && remainingMods[0] == modList: + var index = "idx" + strconv.Itoa(depth) + + return tpl(`for {{.index}} := range {{.raw}} { + {{ .next -}} + }`, map[string]interface{}{ + "raw": raw, + "index": index, + "result": result, + "type": strings.Join(remainingMods, "") + t.NamedType.FullName(), + "next": t.middleware(result+"["+index+"]", raw+"["+index+"]", remainingMods[1:], depth+1), + }) + } + + ptr := "mTmp" + strconv.Itoa(depth) + return tpl(`{{- if .t.Marshaler }} + {{.ptr}}, err := e.{{ .t.GQLType }}Middleware(ctx, &{{.raw}}) + if err != nil { + return nil, err + } + {{ .result }} = *{{.ptr}} + {{- end }}`, map[string]interface{}{ + "result": result, + "raw": raw, + "ptr": ptr, + "t": t, + }) +} + func (t Type) Marshal(val string) string { if t.AliasedType != nil { val = t.GoType + "(" + val + ")" From 29770d6485a69abf86585da6ecb68fb4fe75b4fa Mon Sep 17 00:00:00 2001 From: asamusev Date: Sat, 1 Dec 2018 23:04:22 +0300 Subject: [PATCH 004/147] resolve = in template --- codegen/templates/data.go | 2 +- codegen/templates/input.gotpl | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/codegen/templates/data.go b/codegen/templates/data.go index 677d51ea534..55edc71f467 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -4,7 +4,7 @@ var data = map[string]string{ "args.gotpl": "\targs := map[string]interface{}{}\n\tvar err error\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\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := graphql.ChainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $dArg.IsPtr $dArg.Value }}{{ $dArg.GoVarName }} := {{ $dArg.Value }}{{ end -}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){\n\t\t\t\t\t{{$arg.Unmarshal (print \"args\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t {{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, err\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\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\n\t\tresults, err := ec.resolvers.{{ $field.ShortInvocation }}\n\t\tif err != nil {\n\t\t\tec.Error(ctx, err)\n\t\t\treturn nil\n\t\t}\n\t\treturn func() graphql.Marshaler {\n\t\t\tres, ok := <-results\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tvar out graphql.OrderedMap\n\t\t\tout.Add(field.Alias, func() graphql.Marshaler { {{ $field.WriteJson }} }())\n\t\t\treturn &out\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tField: field,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\tvar err error\n\t\t{{ if .Directives }}\n\t\tcObj, err := graphql.ChainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t{{ $resolveName := \"\" }}\n\t\t{{ $declareName := \"\" }}\n\t\t{{ if $field.IsPtr }}\n\t\t\t{{ $resolveName = \"*\" }}\n\t\t\t{{ $declareName = \"&\" }}\n\t\t{{ end }}\n\t\t\tc{{$field.GoFieldName}}, err := graphql.ChainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print $resolveName \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{$resolveName}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, err\n\t}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\tvar err error\n\t\t{{ if .Directives }}\n\t\tcObj, err := graphql.ChainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t{{ $resolveName := \"\" }}\n\t\t{{ if $field.IsPtr }}\n\t\t\t{{ $resolveName := \"*\" }}\n\t\t{{ end }}\n\t\t\tc{{$field.GoFieldName}}, err := graphql.ChainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print $resolveName \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{$resolveName}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, err\n\t}\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{ range $model := .Models }}\n\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .IsInterface }}\n\t\ttype {{.GoType}} interface {\n\t\t\tIs{{.GoType}}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.GoType}} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\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\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.GoType}}) Is{{$iface.GoType}}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.GoType}} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- 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\n\t{{if $object.IsConcurrent}} var wg sync.WaitGroup {{end}}\n\tout := graphql.NewOrderedMap(len(fields))\n\tinvalid := false\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\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t{{- 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\tif invalid { return graphql.Null }\n\treturn out\n}\n{{- end }}\n", diff --git a/codegen/templates/input.gotpl b/codegen/templates/input.gotpl index 4fec239adcb..9197da12892 100644 --- a/codegen/templates/input.gotpl +++ b/codegen/templates/input.gotpl @@ -62,10 +62,8 @@ {{- range $field := .Fields }} {{ if $field.HasDirectives }} {{ $resolveName := "" }} - {{ $declareName := "" }} {{ if $field.IsPtr }} - {{ $resolveName = "*" }} - {{ $declareName = "&" }} + {{ $resolveName := "*" }} {{ end }} c{{$field.GoFieldName}}, err := graphql.ChainFieldMiddleware( []graphql.FieldMiddleware{ From 526bef0bafb42b15952e724570dd16c7366da34e Mon Sep 17 00:00:00 2001 From: asamusev Date: Sat, 1 Dec 2018 23:14:43 +0300 Subject: [PATCH 005/147] generate servers and add path to error --- example/chat/generated.go | 159 ++++---- example/config/generated.go | 135 +++---- example/dataloader/dataloader_test.go | 2 +- example/dataloader/generated.go | 148 +++----- example/scalars/generated.go | 158 ++++---- example/scalars/scalar_test.go | 2 +- example/selection/generated.go | 100 ++---- example/starwars/generated.go | 399 +++++++++------------ example/starwars/starwars_test.go | 2 +- example/todo/generated.go | 185 +++++----- example/type-system-extension/generated.go | 171 +++++---- integration/generated.go | 166 ++++----- 12 files changed, 675 insertions(+), 952 deletions(-) diff --git a/example/chat/generated.go b/example/chat/generated.go index d1bb62f7d3d..6c3dea5a050 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -76,11 +76,11 @@ type SubscriptionResolver interface { MessageAdded(ctx context.Context, roomName string) (<-chan Message, error) } -func field_Mutation_post_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Mutation_post_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 string if tmp, ok := rawArgs["text"]; ok { - var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -89,7 +89,6 @@ func field_Mutation_post_args(rawArgs map[string]interface{}) (map[string]interf args["text"] = arg0 var arg1 string if tmp, ok := rawArgs["username"]; ok { - var err error arg1, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -98,89 +97,88 @@ func field_Mutation_post_args(rawArgs map[string]interface{}) (map[string]interf args["username"] = arg1 var arg2 string if tmp, ok := rawArgs["roomName"]; ok { - var err error arg2, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["roomName"] = arg2 - return args, nil + return args, err } -func field_Query_room_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query_room_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 string if tmp, ok := rawArgs["name"]; ok { - var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["name"] = arg0 - return args, nil + return args, err } -func field_Query___type_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 string if tmp, ok := rawArgs["name"]; ok { - var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["name"] = arg0 - return args, nil + return args, err } -func field_Subscription_messageAdded_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Subscription_messageAdded_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 string if tmp, ok := rawArgs["roomName"]; ok { - var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["roomName"] = arg0 - return args, nil + return args, err } -func field___Type_fields_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, nil + return args, err } -func field___Type_enumValues_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, nil + return args, err } @@ -244,7 +242,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Mutation_post_args(rawArgs) + args, err := e.field_Mutation_post_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -256,7 +254,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Query_room_args(rawArgs) + args, err := e.field_Query_room_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -268,7 +266,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Subscription_messageAdded_args(rawArgs) + args, err := e.field_Subscription_messageAdded_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -391,7 +389,6 @@ func (ec *executionContext) _Chatroom_name(ctx context.Context, field graphql.Co defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Chatroom", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -418,7 +415,6 @@ func (ec *executionContext) _Chatroom_messages(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Chatroom", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -523,7 +519,6 @@ func (ec *executionContext) _Message_id(ctx context.Context, field graphql.Colle defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Message", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -550,7 +545,6 @@ func (ec *executionContext) _Message_text(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Message", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -577,7 +571,6 @@ func (ec *executionContext) _Message_createdBy(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Message", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -604,7 +597,6 @@ func (ec *executionContext) _Message_createdAt(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Message", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -663,18 +655,18 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) func (ec *executionContext) _Mutation_post(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Mutation_post_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Mutation", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_post_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -737,18 +729,18 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr func (ec *executionContext) _Query_room(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query_room_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_room_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -772,18 +764,18 @@ func (ec *executionContext) _Query_room(ctx context.Context, field graphql.Colle func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query___type_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query___type_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -809,7 +801,6 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -854,15 +845,15 @@ func (ec *executionContext) _Subscription(ctx context.Context, sel ast.Selection } func (ec *executionContext) _Subscription_messageAdded(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Field: field, + }) rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Subscription_messageAdded_args(rawArgs) + args, err := ec.field_Subscription_messageAdded_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return nil } - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Field: field, - }) // FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259 // and Tracer stack rctx := ctx @@ -932,7 +923,6 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -959,7 +949,6 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -983,7 +972,6 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1019,7 +1007,6 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1118,7 +1105,6 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1145,7 +1131,6 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1169,7 +1154,6 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1196,7 +1180,6 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1273,7 +1256,6 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1300,7 +1282,6 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1324,7 +1305,6 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1384,7 +1364,6 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1419,7 +1398,6 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1446,7 +1424,6 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1513,7 +1490,6 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1540,7 +1516,6 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1564,7 +1539,6 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1599,7 +1573,6 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1671,7 +1644,6 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1731,7 +1703,6 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1766,7 +1737,6 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1795,7 +1765,6 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1824,7 +1793,6 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1930,7 +1898,6 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1957,7 +1924,6 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1985,7 +1951,6 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2007,18 +1972,18 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field___Type_fields_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "__Type", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_fields_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2072,7 +2037,6 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2129,7 +2093,6 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2184,18 +2147,18 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field___Type_enumValues_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "__Type", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2249,7 +2212,6 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2306,7 +2268,6 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) diff --git a/example/config/generated.go b/example/config/generated.go index f408b8e5fa3..c29b0bc22ff 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -72,63 +72,71 @@ type TodoResolver interface { ID(ctx context.Context, obj *Todo) (string, error) } -func field_Mutation_createTodo_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Mutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 NewTodo if tmp, ok := rawArgs["input"]; ok { - var err error + arg0, err = UnmarshalNewTodo(tmp) if err != nil { return nil, err } + + mTmp1, err := e.NewTodoMiddleware(ctx, &arg0) + if err != nil { + return nil, err + } + arg0 = *mTmp1 + } args["input"] = arg0 - return args, nil + return args, err } -func field_Query___type_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 string if tmp, ok := rawArgs["name"]; ok { - var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["name"] = arg0 - return args, nil + return args, err } -func field___Type_fields_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, nil + return args, err } -func field___Type_enumValues_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, nil + return args, err } @@ -150,7 +158,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Mutation_createTodo_args(rawArgs) + args, err := e.field_Mutation_createTodo_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -297,18 +305,18 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) func (ec *executionContext) _Mutation_createTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Mutation_createTodo_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Mutation", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_createTodo_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -376,7 +384,6 @@ func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -434,18 +441,18 @@ func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.Coll func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query___type_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query___type_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -471,7 +478,6 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -555,7 +561,6 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Todo", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -582,7 +587,6 @@ func (ec *executionContext) _Todo_databaseId(ctx context.Context, field graphql. defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Todo", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -609,7 +613,6 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Todo", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -636,7 +639,6 @@ func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.Collec defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Todo", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -663,7 +665,6 @@ func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.Collec defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Todo", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -726,7 +727,6 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "User", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -753,7 +753,6 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "User", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -822,7 +821,6 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -849,7 +847,6 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -873,7 +870,6 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -909,7 +905,6 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1008,7 +1003,6 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1035,7 +1029,6 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1059,7 +1052,6 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1086,7 +1078,6 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1163,7 +1154,6 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1190,7 +1180,6 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1214,7 +1203,6 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1274,7 +1262,6 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1309,7 +1296,6 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1336,7 +1322,6 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1403,7 +1388,6 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1430,7 +1414,6 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1454,7 +1437,6 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1489,7 +1471,6 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1561,7 +1542,6 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1621,7 +1601,6 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1656,7 +1635,6 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1685,7 +1663,6 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1714,7 +1691,6 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1820,7 +1796,6 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1847,7 +1822,6 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1875,7 +1849,6 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1897,18 +1870,18 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field___Type_fields_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "__Type", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_fields_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -1962,7 +1935,6 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2019,7 +1991,6 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2074,18 +2045,18 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field___Type_enumValues_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "__Type", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2139,7 +2110,6 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2196,7 +2166,6 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2243,6 +2212,12 @@ func UnmarshalNewTodo(v interface{}) (NewTodo, error) { return it, nil } +func (e *executableSchema) NewTodoMiddleware(ctx context.Context, obj *NewTodo) (*NewTodo, error) { + var err error + + return obj, err +} + func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { defer func() { if r := recover(); r != nil { diff --git a/example/dataloader/dataloader_test.go b/example/dataloader/dataloader_test.go index 7be58002af0..7283f120896 100644 --- a/example/dataloader/dataloader_test.go +++ b/example/dataloader/dataloader_test.go @@ -84,7 +84,7 @@ func TestTodo(t *testing.T) { } err := c.Post(`{ torture2d(customerIds:{}) { id name } }`, &resp) - require.EqualError(t, err, "[{\"message\":\"map[string]interface {} is not an int\"}]") + require.EqualError(t, err, "[{\"message\":\"map[string]interface {} is not an int\",\"path\":[\"torture2d\"]}]") }) } diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index a3d4f0ffdb2..e215b431d24 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -85,11 +85,11 @@ type QueryResolver interface { Torture2d(ctx context.Context, customerIds [][]int) ([][]Customer, error) } -func field_Query_torture1d_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query_torture1d_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 []int if tmp, ok := rawArgs["customerIds"]; ok { - var err error var rawIf1 []interface{} if tmp != nil { if tmp1, ok := tmp.([]interface{}); ok { @@ -107,15 +107,15 @@ func field_Query_torture1d_args(rawArgs map[string]interface{}) (map[string]inte } } args["customerIds"] = arg0 - return args, nil + return args, err } -func field_Query_torture2d_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query_torture2d_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 [][]int if tmp, ok := rawArgs["customerIds"]; ok { - var err error var rawIf1 []interface{} if tmp != nil { if tmp1, ok := tmp.([]interface{}); ok { @@ -144,52 +144,52 @@ func field_Query_torture2d_args(rawArgs map[string]interface{}) (map[string]inte } } args["customerIds"] = arg0 - return args, nil + return args, err } -func field_Query___type_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 string if tmp, ok := rawArgs["name"]; ok { - var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["name"] = arg0 - return args, nil + return args, err } -func field___Type_fields_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, nil + return args, err } -func field___Type_enumValues_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, nil + return args, err } @@ -302,7 +302,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Query_torture1d_args(rawArgs) + args, err := e.field_Query_torture1d_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -314,7 +314,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Query_torture2d_args(rawArgs) + args, err := e.field_Query_torture2d_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -400,7 +400,6 @@ func (ec *executionContext) _Address_id(ctx context.Context, field graphql.Colle defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Address", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -427,7 +426,6 @@ func (ec *executionContext) _Address_street(ctx context.Context, field graphql.C defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Address", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -454,7 +452,6 @@ func (ec *executionContext) _Address_country(ctx context.Context, field graphql. defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Address", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -529,7 +526,6 @@ func (ec *executionContext) _Customer_id(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Customer", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -556,7 +552,6 @@ func (ec *executionContext) _Customer_name(ctx context.Context, field graphql.Co defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Customer", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -583,7 +578,6 @@ func (ec *executionContext) _Customer_address(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Customer", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -612,7 +606,6 @@ func (ec *executionContext) _Customer_orders(ctx context.Context, field graphql. defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Customer", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -699,7 +692,6 @@ func (ec *executionContext) _Item_name(ctx context.Context, field graphql.Collec defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Item", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -773,7 +765,6 @@ func (ec *executionContext) _Order_id(ctx context.Context, field graphql.Collect defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Order", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -800,7 +791,6 @@ func (ec *executionContext) _Order_date(ctx context.Context, field graphql.Colle defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Order", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -827,7 +817,6 @@ func (ec *executionContext) _Order_amount(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Order", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -854,7 +843,6 @@ func (ec *executionContext) _Order_items(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Order", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -963,7 +951,6 @@ func (ec *executionContext) _Query_customers(ctx context.Context, field graphql. defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1018,18 +1005,18 @@ func (ec *executionContext) _Query_customers(ctx context.Context, field graphql. func (ec *executionContext) _Query_torture1d(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query_torture1d_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_torture1d_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -1081,18 +1068,18 @@ func (ec *executionContext) _Query_torture1d(ctx context.Context, field graphql. func (ec *executionContext) _Query_torture2d(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query_torture2d_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_torture2d_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -1175,18 +1162,18 @@ func (ec *executionContext) _Query_torture2d(ctx context.Context, field graphql. func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query___type_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query___type_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -1212,7 +1199,6 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1283,7 +1269,6 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1310,7 +1295,6 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1334,7 +1318,6 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1370,7 +1353,6 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1469,7 +1451,6 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1496,7 +1477,6 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1520,7 +1500,6 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1547,7 +1526,6 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1624,7 +1602,6 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1651,7 +1628,6 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1675,7 +1651,6 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1735,7 +1710,6 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1770,7 +1744,6 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1797,7 +1770,6 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1864,7 +1836,6 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1891,7 +1862,6 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1915,7 +1885,6 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1950,7 +1919,6 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2022,7 +1990,6 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2082,7 +2049,6 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2117,7 +2083,6 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2146,7 +2111,6 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2175,7 +2139,6 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2281,7 +2244,6 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2308,7 +2270,6 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2336,7 +2297,6 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2358,18 +2318,18 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field___Type_fields_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "__Type", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_fields_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2423,7 +2383,6 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2480,7 +2439,6 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2535,18 +2493,18 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field___Type_enumValues_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "__Type", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2600,7 +2558,6 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2657,7 +2614,6 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) diff --git a/example/scalars/generated.go b/example/scalars/generated.go index af67c2b40dd..0c4a65ee03f 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -73,26 +73,27 @@ type UserResolver interface { CustomResolver(ctx context.Context, obj *model.User) (model.Point, error) } -func field_Query_user_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 external.ObjectID if tmp, ok := rawArgs["id"]; ok { - var err error arg0, err = model.UnmarshalID(tmp) if err != nil { return nil, err } } args["id"] = arg0 - return args, nil + return args, err } -func field_Query_search_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query_search_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 *model.SearchArgs if tmp, ok := rawArgs["input"]; ok { - var err error + var ptr1 model.SearchArgs if tmp != nil { ptr1, err = UnmarshalSearchArgs(tmp) @@ -102,54 +103,60 @@ func field_Query_search_args(rawArgs map[string]interface{}) (map[string]interfa if err != nil { return nil, err } + + arg0, err = e.SearchArgsMiddleware(ctx, arg0) + if err != nil { + return nil, err + } + } args["input"] = arg0 - return args, nil + return args, err } -func field_Query___type_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 string if tmp, ok := rawArgs["name"]; ok { - var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["name"] = arg0 - return args, nil + return args, err } -func field___Type_fields_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, nil + return args, err } -func field___Type_enumValues_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, nil + return args, err } @@ -185,7 +192,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Query_user_args(rawArgs) + args, err := e.field_Query_user_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -197,7 +204,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Query_search_args(rawArgs) + args, err := e.field_Query_search_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -331,7 +338,6 @@ func (ec *executionContext) _Address_id(ctx context.Context, field graphql.Colle defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Address", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -358,7 +364,6 @@ func (ec *executionContext) _Address_location(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Address", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -433,18 +438,18 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query_user_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_user_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -468,18 +473,18 @@ func (ec *executionContext) _Query_user(ctx context.Context, field graphql.Colle func (ec *executionContext) _Query_search(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query_search_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_search_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -534,18 +539,18 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query___type_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query___type_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -571,7 +576,6 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -665,7 +669,6 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "User", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -692,7 +695,6 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "User", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -719,7 +721,6 @@ func (ec *executionContext) _User_created(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "User", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -743,7 +744,6 @@ func (ec *executionContext) _User_isBanned(ctx context.Context, field graphql.Co defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "User", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -770,7 +770,6 @@ func (ec *executionContext) _User_primitiveResolver(ctx context.Context, field g defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "User", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -797,7 +796,6 @@ func (ec *executionContext) _User_customResolver(ctx context.Context, field grap defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "User", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -824,7 +822,6 @@ func (ec *executionContext) _User_address(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "User", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -849,7 +846,6 @@ func (ec *executionContext) _User_tier(ctx context.Context, field graphql.Collec defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "User", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -915,7 +911,6 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -942,7 +937,6 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -966,7 +960,6 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1002,7 +995,6 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1101,7 +1093,6 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1128,7 +1119,6 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1152,7 +1142,6 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1179,7 +1168,6 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1256,7 +1244,6 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1283,7 +1270,6 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1307,7 +1293,6 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1367,7 +1352,6 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1402,7 +1386,6 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1429,7 +1412,6 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1496,7 +1478,6 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1523,7 +1504,6 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1547,7 +1527,6 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1582,7 +1561,6 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1654,7 +1632,6 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1714,7 +1691,6 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1749,7 +1725,6 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1778,7 +1753,6 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1807,7 +1781,6 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1913,7 +1886,6 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1940,7 +1912,6 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1968,7 +1939,6 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1990,18 +1960,18 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field___Type_fields_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "__Type", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_fields_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2055,7 +2025,6 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2112,7 +2081,6 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2167,18 +2135,18 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field___Type_enumValues_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "__Type", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2232,7 +2200,6 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2289,7 +2256,6 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2355,6 +2321,12 @@ func UnmarshalSearchArgs(v interface{}) (model.SearchArgs, error) { return it, nil } +func (e *executableSchema) SearchArgsMiddleware(ctx context.Context, obj *model.SearchArgs) (*model.SearchArgs, error) { + var err error + + return obj, err +} + func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { defer func() { if r := recover(); r != nil { diff --git a/example/scalars/scalar_test.go b/example/scalars/scalar_test.go index 77afbdbe26f..15ac529070c 100644 --- a/example/scalars/scalar_test.go +++ b/example/scalars/scalar_test.go @@ -61,7 +61,7 @@ func TestScalars(t *testing.T) { var resp struct{ Search []RawUser } err := c.Post(`{ search(input:{createdAfter:"2014"}) { id } }`, &resp) - require.EqualError(t, err, `[{"message":"time should be a unix timestamp"}]`) + require.EqualError(t, err, `[{"message":"time should be a unix timestamp","path":["search"]}]`) }) t.Run("scalar resolver methods", func(t *testing.T) { diff --git a/example/selection/generated.go b/example/selection/generated.go index b8f99c7e32c..91134534ba9 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -63,48 +63,48 @@ type QueryResolver interface { Events(ctx context.Context) ([]Event, error) } -func field_Query___type_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 string if tmp, ok := rawArgs["name"]; ok { - var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["name"] = arg0 - return args, nil + return args, err } -func field___Type_fields_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, nil + return args, err } -func field___Type_enumValues_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, nil + return args, err } @@ -262,7 +262,6 @@ func (ec *executionContext) _Like_reaction(ctx context.Context, field graphql.Co defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Like", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -289,7 +288,6 @@ func (ec *executionContext) _Like_sent(ctx context.Context, field graphql.Collec defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Like", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -316,7 +314,6 @@ func (ec *executionContext) _Like_selection(ctx context.Context, field graphql.C defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Like", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -349,7 +346,6 @@ func (ec *executionContext) _Like_collected(ctx context.Context, field graphql.C defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Like", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -421,7 +417,6 @@ func (ec *executionContext) _Post_message(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Post", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -448,7 +443,6 @@ func (ec *executionContext) _Post_sent(ctx context.Context, field graphql.Collec defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Post", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -475,7 +469,6 @@ func (ec *executionContext) _Post_selection(ctx context.Context, field graphql.C defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Post", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -508,7 +501,6 @@ func (ec *executionContext) _Post_collected(ctx context.Context, field graphql.C defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Post", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -581,7 +573,6 @@ func (ec *executionContext) _Query_events(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -636,18 +627,18 @@ func (ec *executionContext) _Query_events(ctx context.Context, field graphql.Col func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query___type_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query___type_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -673,7 +664,6 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -744,7 +734,6 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -771,7 +760,6 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -795,7 +783,6 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -831,7 +818,6 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -930,7 +916,6 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -957,7 +942,6 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -981,7 +965,6 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1008,7 +991,6 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1085,7 +1067,6 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1112,7 +1093,6 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1136,7 +1116,6 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1196,7 +1175,6 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1231,7 +1209,6 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1258,7 +1235,6 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1325,7 +1301,6 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1352,7 +1327,6 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1376,7 +1350,6 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1411,7 +1384,6 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1483,7 +1455,6 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1543,7 +1514,6 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1578,7 +1548,6 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1607,7 +1576,6 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1636,7 +1604,6 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1742,7 +1709,6 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1769,7 +1735,6 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1797,7 +1762,6 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1819,18 +1783,18 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field___Type_fields_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "__Type", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_fields_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -1884,7 +1848,6 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1941,7 +1904,6 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1996,18 +1958,18 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field___Type_enumValues_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "__Type", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2061,7 +2023,6 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2118,7 +2079,6 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) diff --git a/example/starwars/generated.go b/example/starwars/generated.go index a58a5750e6b..c6a6cdd9979 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -141,11 +141,11 @@ type StarshipResolver interface { Length(ctx context.Context, obj *Starship, unit *LengthUnit) (float64, error) } -func field_Droid_friendsConnection_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Droid_friendsConnection_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 *int if tmp, ok := rawArgs["first"]; ok { - var err error var ptr1 int if tmp != nil { ptr1, err = graphql.UnmarshalInt(tmp) @@ -159,7 +159,6 @@ func field_Droid_friendsConnection_args(rawArgs map[string]interface{}) (map[str args["first"] = arg0 var arg1 *string if tmp, ok := rawArgs["after"]; ok { - var err error var ptr1 string if tmp != nil { ptr1, err = graphql.UnmarshalID(tmp) @@ -171,30 +170,30 @@ func field_Droid_friendsConnection_args(rawArgs map[string]interface{}) (map[str } } args["after"] = arg1 - return args, nil + return args, err } -func field_Human_height_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Human_height_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 LengthUnit if tmp, ok := rawArgs["unit"]; ok { - var err error err = (&arg0).UnmarshalGQL(tmp) if err != nil { return nil, err } } args["unit"] = arg0 - return args, nil + return args, err } -func field_Human_friendsConnection_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Human_friendsConnection_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 *int if tmp, ok := rawArgs["first"]; ok { - var err error var ptr1 int if tmp != nil { ptr1, err = graphql.UnmarshalInt(tmp) @@ -208,7 +207,6 @@ func field_Human_friendsConnection_args(rawArgs map[string]interface{}) (map[str args["first"] = arg0 var arg1 *string if tmp, ok := rawArgs["after"]; ok { - var err error var ptr1 string if tmp != nil { ptr1, err = graphql.UnmarshalID(tmp) @@ -220,15 +218,15 @@ func field_Human_friendsConnection_args(rawArgs map[string]interface{}) (map[str } } args["after"] = arg1 - return args, nil + return args, err } -func field_Mutation_createReview_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Mutation_createReview_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 Episode if tmp, ok := rawArgs["episode"]; ok { - var err error err = (&arg0).UnmarshalGQL(tmp) if err != nil { return nil, err @@ -237,22 +235,29 @@ func field_Mutation_createReview_args(rawArgs map[string]interface{}) (map[strin args["episode"] = arg0 var arg1 Review if tmp, ok := rawArgs["review"]; ok { - var err error + arg1, err = UnmarshalReviewInput(tmp) if err != nil { return nil, err } + + mTmp1, err := e.ReviewInputMiddleware(ctx, &arg1) + if err != nil { + return nil, err + } + arg1 = *mTmp1 + } args["review"] = arg1 - return args, nil + return args, err } -func field_Query_hero_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query_hero_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 *Episode if tmp, ok := rawArgs["episode"]; ok { - var err error var ptr1 Episode if tmp != nil { err = (&ptr1).UnmarshalGQL(tmp) @@ -264,15 +269,15 @@ func field_Query_hero_args(rawArgs map[string]interface{}) (map[string]interface } } args["episode"] = arg0 - return args, nil + return args, err } -func field_Query_reviews_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query_reviews_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 Episode if tmp, ok := rawArgs["episode"]; ok { - var err error err = (&arg0).UnmarshalGQL(tmp) if err != nil { return nil, err @@ -281,7 +286,6 @@ func field_Query_reviews_args(rawArgs map[string]interface{}) (map[string]interf args["episode"] = arg0 var arg1 *time.Time if tmp, ok := rawArgs["since"]; ok { - var err error var ptr1 time.Time if tmp != nil { ptr1, err = graphql.UnmarshalTime(tmp) @@ -293,105 +297,105 @@ func field_Query_reviews_args(rawArgs map[string]interface{}) (map[string]interf } } args["since"] = arg1 - return args, nil + return args, err } -func field_Query_search_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query_search_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 string if tmp, ok := rawArgs["text"]; ok { - var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["text"] = arg0 - return args, nil + return args, err } -func field_Query_character_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query_character_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 string if tmp, ok := rawArgs["id"]; ok { - var err error arg0, err = graphql.UnmarshalID(tmp) if err != nil { return nil, err } } args["id"] = arg0 - return args, nil + return args, err } -func field_Query_droid_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query_droid_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 string if tmp, ok := rawArgs["id"]; ok { - var err error arg0, err = graphql.UnmarshalID(tmp) if err != nil { return nil, err } } args["id"] = arg0 - return args, nil + return args, err } -func field_Query_human_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query_human_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 string if tmp, ok := rawArgs["id"]; ok { - var err error arg0, err = graphql.UnmarshalID(tmp) if err != nil { return nil, err } } args["id"] = arg0 - return args, nil + return args, err } -func field_Query_starship_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query_starship_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 string if tmp, ok := rawArgs["id"]; ok { - var err error arg0, err = graphql.UnmarshalID(tmp) if err != nil { return nil, err } } args["id"] = arg0 - return args, nil + return args, err } -func field_Query___type_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 string if tmp, ok := rawArgs["name"]; ok { - var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["name"] = arg0 - return args, nil + return args, err } -func field_Starship_length_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Starship_length_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 *LengthUnit if tmp, ok := rawArgs["unit"]; ok { - var err error var ptr1 LengthUnit if tmp != nil { err = (&ptr1).UnmarshalGQL(tmp) @@ -403,37 +407,37 @@ func field_Starship_length_args(rawArgs map[string]interface{}) (map[string]inte } } args["unit"] = arg0 - return args, nil + return args, err } -func field___Type_fields_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, nil + return args, err } -func field___Type_enumValues_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, nil + return args, err } @@ -476,7 +480,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Droid_friendsConnection_args(rawArgs) + args, err := e.field_Droid_friendsConnection_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -558,7 +562,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Human_height_args(rawArgs) + args, err := e.field_Human_height_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -584,7 +588,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Human_friendsConnection_args(rawArgs) + args, err := e.field_Human_friendsConnection_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -610,7 +614,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Mutation_createReview_args(rawArgs) + args, err := e.field_Mutation_createReview_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -643,7 +647,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Query_hero_args(rawArgs) + args, err := e.field_Query_hero_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -655,7 +659,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Query_reviews_args(rawArgs) + args, err := e.field_Query_reviews_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -667,7 +671,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Query_search_args(rawArgs) + args, err := e.field_Query_search_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -679,7 +683,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Query_character_args(rawArgs) + args, err := e.field_Query_character_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -691,7 +695,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Query_droid_args(rawArgs) + args, err := e.field_Query_droid_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -703,7 +707,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Query_human_args(rawArgs) + args, err := e.field_Query_human_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -715,7 +719,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Query_starship_args(rawArgs) + args, err := e.field_Query_starship_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -762,7 +766,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Starship_length_args(rawArgs) + args, err := e.field_Starship_length_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -886,7 +890,6 @@ func (ec *executionContext) _Droid_id(ctx context.Context, field graphql.Collect defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Droid", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -913,7 +916,6 @@ func (ec *executionContext) _Droid_name(ctx context.Context, field graphql.Colle defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Droid", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -940,7 +942,6 @@ func (ec *executionContext) _Droid_friends(ctx context.Context, field graphql.Co defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Droid", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -995,18 +996,18 @@ func (ec *executionContext) _Droid_friends(ctx context.Context, field graphql.Co func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Droid_friendsConnection_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Droid", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Droid_friendsConnection_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -1031,7 +1032,6 @@ func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql. defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Droid", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1067,7 +1067,6 @@ func (ec *executionContext) _Droid_primaryFunction(ctx context.Context, field gr defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Droid", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1139,7 +1138,6 @@ func (ec *executionContext) _FriendsConnection_totalCount(ctx context.Context, f defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "FriendsConnection", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1166,7 +1164,6 @@ func (ec *executionContext) _FriendsConnection_edges(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "FriendsConnection", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1223,7 +1220,6 @@ func (ec *executionContext) _FriendsConnection_friends(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "FriendsConnection", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1280,7 +1276,6 @@ func (ec *executionContext) _FriendsConnection_pageInfo(ctx context.Context, fie defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "FriendsConnection", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1340,7 +1335,6 @@ func (ec *executionContext) _FriendsEdge_cursor(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "FriendsEdge", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1367,7 +1361,6 @@ func (ec *executionContext) _FriendsEdge_node(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "FriendsEdge", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1461,7 +1454,6 @@ func (ec *executionContext) _Human_id(ctx context.Context, field graphql.Collect defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Human", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1488,7 +1480,6 @@ func (ec *executionContext) _Human_name(ctx context.Context, field graphql.Colle defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Human", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1513,18 +1504,18 @@ func (ec *executionContext) _Human_name(ctx context.Context, field graphql.Colle func (ec *executionContext) _Human_height(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Human_height_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Human", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Human_height_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -1548,7 +1539,6 @@ func (ec *executionContext) _Human_mass(ctx context.Context, field graphql.Colle defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Human", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1572,7 +1562,6 @@ func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.Co defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Human", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1627,18 +1616,18 @@ func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.Co func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Human_friendsConnection_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Human", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Human_friendsConnection_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -1663,7 +1652,6 @@ func (ec *executionContext) _Human_appearsIn(ctx context.Context, field graphql. defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Human", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1699,7 +1687,6 @@ func (ec *executionContext) _Human_starships(ctx context.Context, field graphql. defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Human", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1785,18 +1772,18 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) func (ec *executionContext) _Mutation_createReview(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Mutation_createReview_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Mutation", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_createReview_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -1862,7 +1849,6 @@ func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field gra defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "PageInfo", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1889,7 +1875,6 @@ func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "PageInfo", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1916,7 +1901,6 @@ func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field gra defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "PageInfo", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2023,18 +2007,18 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr func (ec *executionContext) _Query_hero(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query_hero_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_hero_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2054,18 +2038,18 @@ func (ec *executionContext) _Query_hero(ctx context.Context, field graphql.Colle func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query_reviews_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_reviews_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2120,18 +2104,18 @@ func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.Co func (ec *executionContext) _Query_search(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query_search_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_search_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2186,18 +2170,18 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col func (ec *executionContext) _Query_character(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query_character_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_character_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2217,18 +2201,18 @@ func (ec *executionContext) _Query_character(ctx context.Context, field graphql. func (ec *executionContext) _Query_droid(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query_droid_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_droid_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2252,18 +2236,18 @@ func (ec *executionContext) _Query_droid(ctx context.Context, field graphql.Coll func (ec *executionContext) _Query_human(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query_human_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_human_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2287,18 +2271,18 @@ func (ec *executionContext) _Query_human(ctx context.Context, field graphql.Coll func (ec *executionContext) _Query_starship(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query_starship_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_starship_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2322,18 +2306,18 @@ func (ec *executionContext) _Query_starship(ctx context.Context, field graphql.C func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query___type_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query___type_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2359,7 +2343,6 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2422,7 +2405,6 @@ func (ec *executionContext) _Review_stars(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Review", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2449,7 +2431,6 @@ func (ec *executionContext) _Review_commentary(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Review", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2477,7 +2458,6 @@ func (ec *executionContext) _Review_time(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Review", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2551,7 +2531,6 @@ func (ec *executionContext) _Starship_id(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Starship", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2578,7 +2557,6 @@ func (ec *executionContext) _Starship_name(ctx context.Context, field graphql.Co defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Starship", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2603,18 +2581,18 @@ func (ec *executionContext) _Starship_name(ctx context.Context, field graphql.Co func (ec *executionContext) _Starship_length(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Starship_length_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Starship", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Starship_length_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2638,7 +2616,6 @@ func (ec *executionContext) _Starship_history(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Starship", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2725,7 +2702,6 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2752,7 +2728,6 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2776,7 +2751,6 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2812,7 +2786,6 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2911,7 +2884,6 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2938,7 +2910,6 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2962,7 +2933,6 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2989,7 +2959,6 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3066,7 +3035,6 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3093,7 +3061,6 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3117,7 +3084,6 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3177,7 +3143,6 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3212,7 +3177,6 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3239,7 +3203,6 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3306,7 +3269,6 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3333,7 +3295,6 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3357,7 +3318,6 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3392,7 +3352,6 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3464,7 +3423,6 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3524,7 +3482,6 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3559,7 +3516,6 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3588,7 +3544,6 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3617,7 +3572,6 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3723,7 +3677,6 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3750,7 +3703,6 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3778,7 +3730,6 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3800,18 +3751,18 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field___Type_fields_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "__Type", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_fields_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -3865,7 +3816,6 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3922,7 +3872,6 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -3977,18 +3926,18 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field___Type_enumValues_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "__Type", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -4042,7 +3991,6 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -4099,7 +4047,6 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -4195,6 +4142,12 @@ func UnmarshalReviewInput(v interface{}) (Review, error) { return it, nil } +func (e *executableSchema) ReviewInputMiddleware(ctx context.Context, obj *Review) (*Review, error) { + var err error + + return obj, err +} + func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { defer func() { if r := recover(); r != nil { diff --git a/example/starwars/starwars_test.go b/example/starwars/starwars_test.go index d22e9b3209f..8468c82254a 100644 --- a/example/starwars/starwars_test.go +++ b/example/starwars/starwars_test.go @@ -215,7 +215,7 @@ func TestStarwars(t *testing.T) { } }`, &resp, client.Var("episode", "INVALID")) - require.EqualError(t, err, `[{"message":"INVALID is not a valid Episode"}]`) + require.EqualError(t, err, `[{"message":"INVALID is not a valid Episode","path":["createReview"]}]`) }) t.Run("introspection", func(t *testing.T) { diff --git a/example/todo/generated.go b/example/todo/generated.go index 2fbe0d159e9..a4a035c7060 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -68,26 +68,34 @@ type MyQueryResolver interface { Todos(ctx context.Context) ([]Todo, error) } -func field_MyMutation_createTodo_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 TodoInput if tmp, ok := rawArgs["todo"]; ok { - var err error + arg0, err = UnmarshalTodoInput(tmp) if err != nil { return nil, err } + + mTmp1, err := e.TodoInputMiddleware(ctx, &arg0) + if err != nil { + return nil, err + } + arg0 = *mTmp1 + } args["todo"] = arg0 - return args, nil + return args, err } -func field_MyMutation_updateTodo_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_MyMutation_updateTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 int if tmp, ok := rawArgs["id"]; ok { - var err error arg0, err = graphql.UnmarshalInt(tmp) if err != nil { return nil, err @@ -96,89 +104,88 @@ func field_MyMutation_updateTodo_args(rawArgs map[string]interface{}) (map[strin args["id"] = arg0 var arg1 map[string]interface{} if tmp, ok := rawArgs["changes"]; ok { - var err error arg1 = tmp.(map[string]interface{}) if err != nil { return nil, err } } args["changes"] = arg1 - return args, nil + return args, err } -func field_MyQuery_todo_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_MyQuery_todo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 int if tmp, ok := rawArgs["id"]; ok { - var err error arg0, err = graphql.UnmarshalInt(tmp) if err != nil { return nil, err } } args["id"] = arg0 - return args, nil + return args, err } -func field_MyQuery___type_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_MyQuery___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 string if tmp, ok := rawArgs["name"]; ok { - var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["name"] = arg0 - return args, nil + return args, err } -func field___Type_fields_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, nil + return args, err } -func field___Type_enumValues_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, nil + return args, err } -func dir_hasRole_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) dir_hasRole_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 Role if tmp, ok := rawArgs["role"]; ok { - var err error err = (&arg0).UnmarshalGQL(tmp) if err != nil { return nil, err } } args["role"] = arg0 - return args, nil + return args, err } @@ -200,7 +207,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_MyMutation_createTodo_args(rawArgs) + args, err := e.field_MyMutation_createTodo_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -212,7 +219,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_MyMutation_updateTodo_args(rawArgs) + args, err := e.field_MyMutation_updateTodo_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -224,7 +231,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_MyQuery_todo_args(rawArgs) + args, err := e.field_MyQuery_todo_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -352,18 +359,18 @@ func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSe func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_MyMutation_createTodo_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "MyMutation", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_MyMutation_createTodo_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -386,18 +393,18 @@ func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field gr func (ec *executionContext) _MyMutation_updateTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_MyMutation_updateTodo_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "MyMutation", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_MyMutation_updateTodo_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -476,18 +483,18 @@ func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_MyQuery_todo_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "MyQuery", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_MyQuery_todo_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -513,7 +520,6 @@ func (ec *executionContext) _MyQuery_lastTodo(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "MyQuery", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -542,7 +548,6 @@ func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.Co defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "MyQuery", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -600,18 +605,18 @@ func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.Co func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_MyQuery___type_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "MyQuery", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_MyQuery___type_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -637,7 +642,6 @@ func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "MyQuery", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -706,7 +710,6 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Todo", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -733,7 +736,6 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Todo", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -760,7 +762,6 @@ func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.Collec defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Todo", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -829,7 +830,6 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -856,7 +856,6 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -880,7 +879,6 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -916,7 +914,6 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1015,7 +1012,6 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1042,7 +1038,6 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1066,7 +1061,6 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1093,7 +1087,6 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1170,7 +1163,6 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1197,7 +1189,6 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1221,7 +1212,6 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1281,7 +1271,6 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1316,7 +1305,6 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1343,7 +1331,6 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1410,7 +1397,6 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1437,7 +1423,6 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1461,7 +1446,6 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1496,7 +1480,6 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1568,7 +1551,6 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1628,7 +1610,6 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1663,7 +1644,6 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1692,7 +1672,6 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1721,7 +1700,6 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1827,7 +1805,6 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1854,7 +1831,6 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1882,7 +1858,6 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1904,18 +1879,18 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field___Type_fields_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "__Type", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_fields_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -1969,7 +1944,6 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2026,7 +2000,6 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2081,18 +2054,18 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field___Type_enumValues_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "__Type", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2146,7 +2119,6 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2203,7 +2175,6 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2255,6 +2226,12 @@ func UnmarshalTodoInput(v interface{}) (TodoInput, error) { return it, nil } +func (e *executableSchema) TodoInputMiddleware(ctx context.Context, obj *TodoInput) (*TodoInput, error) { + var err error + + return obj, err +} + func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { defer func() { if r := recover(); r != nil { @@ -2268,7 +2245,7 @@ func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{} case "hasRole": if ec.directives.HasRole != nil { rawArgs := d.ArgumentMap(ec.Variables) - args, err := dir_hasRole_args(rawArgs) + args, err := ec.dir_hasRole_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return nil diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index 065da51a593..8c3920730a3 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -78,78 +78,86 @@ type MyQueryResolver interface { Todo(ctx context.Context, id string) (*Todo, error) } -func field_MyMutation_createTodo_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 TodoInput if tmp, ok := rawArgs["todo"]; ok { - var err error + arg0, err = UnmarshalTodoInput(tmp) if err != nil { return nil, err } + + mTmp1, err := e.TodoInputMiddleware(ctx, &arg0) + if err != nil { + return nil, err + } + arg0 = *mTmp1 + } args["todo"] = arg0 - return args, nil + return args, err } -func field_MyQuery_todo_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_MyQuery_todo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 string if tmp, ok := rawArgs["id"]; ok { - var err error arg0, err = graphql.UnmarshalID(tmp) if err != nil { return nil, err } } args["id"] = arg0 - return args, nil + return args, err } -func field_MyQuery___type_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_MyQuery___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 string if tmp, ok := rawArgs["name"]; ok { - var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["name"] = arg0 - return args, nil + return args, err } -func field___Type_fields_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, nil + return args, err } -func field___Type_enumValues_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, nil + return args, err } @@ -171,7 +179,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_MyMutation_createTodo_args(rawArgs) + args, err := e.field_MyMutation_createTodo_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -190,7 +198,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_MyQuery_todo_args(rawArgs) + args, err := e.field_MyQuery_todo_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -309,18 +317,18 @@ func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSe func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_MyMutation_createTodo_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "MyMutation", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_MyMutation_createTodo_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -394,7 +402,6 @@ func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.Co defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "MyQuery", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -452,18 +459,18 @@ func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.Co func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_MyQuery_todo_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "MyQuery", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_MyQuery_todo_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -487,18 +494,18 @@ func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.Col func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_MyQuery___type_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "MyQuery", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_MyQuery___type_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -524,7 +531,6 @@ func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "MyQuery", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -598,7 +604,6 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Todo", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -625,7 +630,6 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Todo", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -652,7 +656,6 @@ func (ec *executionContext) _Todo_state(ctx context.Context, field graphql.Colle defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Todo", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -679,7 +682,6 @@ func (ec *executionContext) _Todo_verified(ctx context.Context, field graphql.Co defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Todo", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -748,7 +750,6 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -775,7 +776,6 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -799,7 +799,6 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -835,7 +834,6 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -934,7 +932,6 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -961,7 +958,6 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -985,7 +981,6 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1012,7 +1007,6 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1089,7 +1083,6 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1116,7 +1109,6 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1140,7 +1132,6 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1200,7 +1191,6 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1235,7 +1225,6 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1262,7 +1251,6 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1329,7 +1317,6 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1356,7 +1343,6 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1380,7 +1366,6 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1415,7 +1400,6 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1487,7 +1471,6 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1547,7 +1530,6 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1582,7 +1564,6 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1611,7 +1592,6 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1640,7 +1620,6 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1746,7 +1725,6 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1773,7 +1751,6 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1801,7 +1778,6 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1823,18 +1799,18 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field___Type_fields_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "__Type", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_fields_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -1888,7 +1864,6 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1945,7 +1920,6 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2000,18 +1974,18 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field___Type_enumValues_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "__Type", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2065,7 +2039,6 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2122,7 +2095,6 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2189,6 +2161,29 @@ func UnmarshalTodoInput(v interface{}) (TodoInput, error) { return it, nil } +func (e *executableSchema) TodoInputMiddleware(ctx context.Context, obj *TodoInput) (*TodoInput, error) { + var err error + + cObj, err := graphql.ChainFieldMiddleware( + []graphql.FieldMiddleware{ + func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { + return e.directives.InputLogging(ctx, obj, n) + }, + }..., + )(ctx, func(ctx context.Context) (interface{}, error) { + return obj, nil + }) + if err != nil || cObj == nil { + return nil, err + } + obj, ok := cObj.(*TodoInput) + if !ok { + return nil, errors.New("expect TodoInput") + } + + return obj, err +} + func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { defer func() { if r := recover(); r != nil { diff --git a/integration/generated.go b/integration/generated.go index 008cf1959ab..310c3c6322f 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -83,26 +83,34 @@ type UserResolver interface { Likes(ctx context.Context, obj *remote_api.User) ([]string, error) } -func field_Query_date_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query_date_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 models.DateFilter if tmp, ok := rawArgs["filter"]; ok { - var err error + arg0, err = UnmarshalDateFilter(tmp) if err != nil { return nil, err } + + mTmp1, err := e.DateFilterMiddleware(ctx, &arg0) + if err != nil { + return nil, err + } + arg0 = *mTmp1 + } args["filter"] = arg0 - return args, nil + return args, err } -func field_Query_error_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query_error_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 *models.ErrorType if tmp, ok := rawArgs["type"]; ok { - var err error var ptr1 models.ErrorType if tmp != nil { err = (&ptr1).UnmarshalGQL(tmp) @@ -114,60 +122,60 @@ func field_Query_error_args(rawArgs map[string]interface{}) (map[string]interfac } } args["type"] = arg0 - return args, nil + return args, err } -func field_Query___type_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 string if tmp, ok := rawArgs["name"]; ok { - var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["name"] = arg0 - return args, nil + return args, err } -func field___Type_fields_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, nil + return args, err } -func field___Type_enumValues_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, nil + return args, err } -func dir_magic_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) dir_magic_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} + var err error var arg0 *int if tmp, ok := rawArgs["kind"]; ok { - var err error var ptr1 int if tmp != nil { ptr1, err = graphql.UnmarshalInt(tmp) @@ -179,7 +187,7 @@ func dir_magic_args(rawArgs map[string]interface{}) (map[string]interface{}, err } } args["kind"] = arg0 - return args, nil + return args, err } @@ -229,7 +237,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Query_date_args(rawArgs) + args, err := e.field_Query_date_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -255,7 +263,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := field_Query_error_args(rawArgs) + args, err := e.field_Query_error_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -372,7 +380,6 @@ func (ec *executionContext) _Element_child(ctx context.Context, field graphql.Co defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Element", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -400,7 +407,6 @@ func (ec *executionContext) _Element_error(ctx context.Context, field graphql.Co defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Element", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -427,7 +433,6 @@ func (ec *executionContext) _Element_mismatched(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Element", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -533,7 +538,6 @@ func (ec *executionContext) _Query_path(ctx context.Context, field graphql.Colle defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -592,18 +596,18 @@ func (ec *executionContext) _Query_path(ctx context.Context, field graphql.Colle func (ec *executionContext) _Query_date(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query_date_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_date_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -627,7 +631,6 @@ func (ec *executionContext) _Query_viewer(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -656,7 +659,6 @@ func (ec *executionContext) _Query_jsonEncoding(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -681,18 +683,18 @@ func (ec *executionContext) _Query_jsonEncoding(ctx context.Context, field graph func (ec *executionContext) _Query_error(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query_error_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_error_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -714,18 +716,18 @@ func (ec *executionContext) _Query_error(ctx context.Context, field graphql.Coll func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query___type_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "Query", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query___type_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -751,7 +753,6 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -820,7 +821,6 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "User", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -847,7 +847,6 @@ func (ec *executionContext) _User_likes(ctx context.Context, field graphql.Colle defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "User", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -910,7 +909,6 @@ func (ec *executionContext) _Viewer_user(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Viewer", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -981,7 +979,6 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1008,7 +1005,6 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1032,7 +1028,6 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1068,7 +1063,6 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1167,7 +1161,6 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1194,7 +1187,6 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1218,7 +1210,6 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1245,7 +1236,6 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1322,7 +1312,6 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1349,7 +1338,6 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1373,7 +1361,6 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1433,7 +1420,6 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1468,7 +1454,6 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1495,7 +1480,6 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1562,7 +1546,6 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1589,7 +1572,6 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1613,7 +1595,6 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1648,7 +1629,6 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1720,7 +1700,6 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1780,7 +1759,6 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1815,7 +1793,6 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1844,7 +1821,6 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1873,7 +1849,6 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -1979,7 +1954,6 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2006,7 +1980,6 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2034,7 +2007,6 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2056,18 +2028,18 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field___Type_fields_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "__Type", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_fields_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2121,7 +2093,6 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2178,7 +2149,6 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2233,18 +2203,18 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rawArgs := field.ArgumentMap(ec.Variables) - args, err := field___Type_enumValues_args(rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } rctx := &graphql.ResolverContext{ Object: "__Type", - Args: args, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children @@ -2298,7 +2268,6 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2355,7 +2324,6 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", - Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) @@ -2425,6 +2393,12 @@ func UnmarshalDateFilter(v interface{}) (models.DateFilter, error) { return it, nil } +func (e *executableSchema) DateFilterMiddleware(ctx context.Context, obj *models.DateFilter) (*models.DateFilter, error) { + var err error + + return obj, err +} + func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { defer func() { if r := recover(); r != nil { @@ -2438,7 +2412,7 @@ func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{} case "magic": if ec.directives.Magic != nil { rawArgs := d.ArgumentMap(ec.Variables) - args, err := dir_magic_args(rawArgs) + args, err := ec.dir_magic_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return nil From a13b31e9b40aa9098fcf90fb947b9d854b53dbe1 Mon Sep 17 00:00:00 2001 From: asamusev Date: Sat, 1 Dec 2018 23:49:58 +0300 Subject: [PATCH 006/147] metalinter --- codegen/templates/args.gotpl | 5 +- codegen/templates/data.go | 4 +- codegen/templates/input.gotpl | 3 +- codegen/testserver/generated.go | 79 ++++++++++++++-------- example/chat/generated.go | 26 +++---- example/config/generated.go | 19 +++--- example/dataloader/generated.go | 20 +++--- example/scalars/generated.go | 23 +++---- example/selection/generated.go | 12 ++-- example/starwars/generated.go | 67 +++++++++--------- example/todo/generated.go | 32 ++++----- example/type-system-extension/generated.go | 23 +++---- graphql/context.go | 2 +- integration/generated.go | 27 ++++---- 14 files changed, 181 insertions(+), 161 deletions(-) diff --git a/codegen/templates/args.gotpl b/codegen/templates/args.gotpl index b4f11857af5..e2d19e22006 100644 --- a/codegen/templates/args.gotpl +++ b/codegen/templates/args.gotpl @@ -1,5 +1,4 @@ args := map[string]interface{}{} - var err error {{- range $i, $arg := . }} var arg{{$i}} {{$arg.Signature }} if tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok { @@ -30,6 +29,7 @@ return nil, errors.New("expect {{$arg.Signature }}") } {{ else }} + var err error {{$arg.Unmarshal (print "arg" $i) "tmp" }} if err != nil { return nil, err @@ -41,6 +41,7 @@ {{- end }} {{ else }} + var err error {{$arg.Unmarshal (print "arg" $i) "tmp" }} if err != nil { return nil, err @@ -49,4 +50,4 @@ } args[{{$arg.GQLName|quote}}] = arg{{$i}} {{- end }} - return args, err + return args, nil diff --git a/codegen/templates/data.go b/codegen/templates/data.go index 55edc71f467..de9f4e89c78 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -1,10 +1,10 @@ package templates var data = map[string]string{ - "args.gotpl": "\targs := map[string]interface{}{}\n\tvar err error\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\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := graphql.ChainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $dArg.IsPtr $dArg.Value }}{{ $dArg.GoVarName }} := {{ $dArg.Value }}{{ end -}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){\n\t\t\t\t\t{{$arg.Unmarshal (print \"args\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t {{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, err\n", + "args.gotpl": "\targs := map[string]interface{}{}\n\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\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := graphql.ChainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $dArg.IsPtr $dArg.Value }}{{ $dArg.GoVarName }} := {{ $dArg.Value }}{{ end -}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){\n\t\t\t\t\t{{$arg.Unmarshal (print \"args\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t {{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\tvar err error\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\n\t\tresults, err := ec.resolvers.{{ $field.ShortInvocation }}\n\t\tif err != nil {\n\t\t\tec.Error(ctx, err)\n\t\t\treturn nil\n\t\t}\n\t\treturn func() graphql.Marshaler {\n\t\t\tres, ok := <-results\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tvar out graphql.OrderedMap\n\t\t\tout.Add(field.Alias, func() graphql.Marshaler { {{ $field.WriteJson }} }())\n\t\t\treturn &out\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tField: field,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\tvar err error\n\t\t{{ if .Directives }}\n\t\tcObj, err := graphql.ChainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t{{ $resolveName := \"\" }}\n\t\t{{ if $field.IsPtr }}\n\t\t\t{{ $resolveName := \"*\" }}\n\t\t{{ end }}\n\t\t\tc{{$field.GoFieldName}}, err := graphql.ChainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print $resolveName \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{$resolveName}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, err\n\t}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\n\t\t{{ if .Directives }}\n\t\tcObj, err := graphql.ChainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t{{ $resolveName := \"\" }}\n\t\t{{ if $field.IsPtr }}\n\t\t\t{{ $resolveName := \"*\" }}\n\t\t{{ end }}\n\t\t\tc{{$field.GoFieldName}}, err := graphql.ChainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print $resolveName \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{$resolveName}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{ range $model := .Models }}\n\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .IsInterface }}\n\t\ttype {{.GoType}} interface {\n\t\t\tIs{{.GoType}}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.GoType}} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\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\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.GoType}}) Is{{$iface.GoType}}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.GoType}} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- 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\n\t{{if $object.IsConcurrent}} var wg sync.WaitGroup {{end}}\n\tout := graphql.NewOrderedMap(len(fields))\n\tinvalid := false\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\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t{{- 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\tif invalid { return graphql.Null }\n\treturn out\n}\n{{- end }}\n", diff --git a/codegen/templates/input.gotpl b/codegen/templates/input.gotpl index 9197da12892..432f72c6d59 100644 --- a/codegen/templates/input.gotpl +++ b/codegen/templates/input.gotpl @@ -28,7 +28,6 @@ {{- end }} func (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) { - var err error {{ if .Directives }} cObj, err := graphql.ChainFieldMiddleware( []graphql.FieldMiddleware{ @@ -109,5 +108,5 @@ {{ $field.Middleware (print "obj." $field.GoFieldName ) (print "obj." $field.GoFieldName ) }} {{- end }} {{- end }} - return obj, err + return obj, nil } diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index f4071db5d79..e36f2121d92 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -154,10 +154,10 @@ type UserResolver interface { func (e *executableSchema) field_Query_mapInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 *map[string]interface{} if tmp, ok := rawArgs["input"]; ok { + var err error var ptr1 map[string]interface{} if tmp != nil { ptr1 = tmp.(map[string]interface{}) @@ -170,16 +170,16 @@ func (e *executableSchema) field_Query_mapInput_args(ctx context.Context, rawArg } args["input"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_Query_recursive_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 *RecursiveInputSlice if tmp, ok := rawArgs["input"]; ok { + var err error var ptr1 RecursiveInputSlice if tmp != nil { ptr1, err = UnmarshalRecursiveInputSlice(tmp) @@ -197,16 +197,16 @@ func (e *executableSchema) field_Query_recursive_args(ctx context.Context, rawAr } args["input"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_Query_nestedInputs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 [][]*OuterInput if tmp, ok := rawArgs["input"]; ok { + var err error var rawIf1 []interface{} if tmp != nil { if tmp1, ok := tmp.([]interface{}); ok { @@ -250,16 +250,16 @@ func (e *executableSchema) field_Query_nestedInputs_args(ctx context.Context, ra } args["input"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_Query_keywords_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 *Keywords if tmp, ok := rawArgs["input"]; ok { + var err error var ptr1 Keywords if tmp != nil { ptr1, err = UnmarshalKeywords(tmp) @@ -277,30 +277,30 @@ func (e *executableSchema) field_Query_keywords_args(ctx context.Context, rawArg } args["input"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 int if tmp, ok := rawArgs["id"]; ok { + var err error arg0, err = graphql.UnmarshalInt(tmp) if err != nil { return nil, err } } args["id"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_Query_nullableArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 *int if tmp, ok := rawArgs["arg"]; ok { + var err error var ptr1 int if tmp != nil { ptr1, err = graphql.UnmarshalInt(tmp) @@ -312,15 +312,15 @@ func (e *executableSchema) field_Query_nullableArg_args(ctx context.Context, raw } } args["arg"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 string if tmp, ok := rawArgs["break"]; ok { + var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -329,6 +329,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["break"] = arg0 var arg1 string if tmp, ok := rawArgs["default"]; ok { + var err error arg1, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -337,6 +338,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["default"] = arg1 var arg2 string if tmp, ok := rawArgs["func"]; ok { + var err error arg2, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -345,6 +347,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["func"] = arg2 var arg3 string if tmp, ok := rawArgs["interface"]; ok { + var err error arg3, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -353,6 +356,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["interface"] = arg3 var arg4 string if tmp, ok := rawArgs["select"]; ok { + var err error arg4, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -361,6 +365,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["select"] = arg4 var arg5 string if tmp, ok := rawArgs["case"]; ok { + var err error arg5, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -369,6 +374,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["case"] = arg5 var arg6 string if tmp, ok := rawArgs["defer"]; ok { + var err error arg6, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -377,6 +383,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["defer"] = arg6 var arg7 string if tmp, ok := rawArgs["go"]; ok { + var err error arg7, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -385,6 +392,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["go"] = arg7 var arg8 string if tmp, ok := rawArgs["map"]; ok { + var err error arg8, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -393,6 +401,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["map"] = arg8 var arg9 string if tmp, ok := rawArgs["struct"]; ok { + var err error arg9, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -401,6 +410,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["struct"] = arg9 var arg10 string if tmp, ok := rawArgs["chan"]; ok { + var err error arg10, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -409,6 +419,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["chan"] = arg10 var arg11 string if tmp, ok := rawArgs["else"]; ok { + var err error arg11, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -417,6 +428,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["else"] = arg11 var arg12 string if tmp, ok := rawArgs["goto"]; ok { + var err error arg12, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -425,6 +437,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["goto"] = arg12 var arg13 string if tmp, ok := rawArgs["package"]; ok { + var err error arg13, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -433,6 +446,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["package"] = arg13 var arg14 string if tmp, ok := rawArgs["switch"]; ok { + var err error arg14, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -441,6 +455,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["switch"] = arg14 var arg15 string if tmp, ok := rawArgs["const"]; ok { + var err error arg15, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -449,6 +464,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["const"] = arg15 var arg16 string if tmp, ok := rawArgs["fallthrough"]; ok { + var err error arg16, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -457,6 +473,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["fallthrough"] = arg16 var arg17 string if tmp, ok := rawArgs["if"]; ok { + var err error arg17, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -465,6 +482,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["if"] = arg17 var arg18 string if tmp, ok := rawArgs["range"]; ok { + var err error arg18, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -473,6 +491,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["range"] = arg18 var arg19 string if tmp, ok := rawArgs["type"]; ok { + var err error arg19, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -481,6 +500,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["type"] = arg19 var arg20 string if tmp, ok := rawArgs["continue"]; ok { + var err error arg20, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -489,6 +509,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["continue"] = arg20 var arg21 string if tmp, ok := rawArgs["for"]; ok { + var err error arg21, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -497,6 +518,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["for"] = arg21 var arg22 string if tmp, ok := rawArgs["import"]; ok { + var err error arg22, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -505,6 +527,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["import"] = arg22 var arg23 string if tmp, ok := rawArgs["return"]; ok { + var err error arg23, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -513,58 +536,59 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["return"] = arg23 var arg24 string if tmp, ok := rawArgs["var"]; ok { + var err error arg24, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["var"] = arg24 - return args, err + return args, nil } func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 string if tmp, ok := rawArgs["name"]; ok { + var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["name"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, err + return args, nil } @@ -4103,9 +4127,8 @@ func (ec *executionContext) _ShapeUnion(ctx context.Context, sel ast.SelectionSe } func (e *executableSchema) ChangesMiddleware(ctx context.Context, obj *map[string]interface{}) (*map[string]interface{}, error) { - var err error - return obj, err + return obj, nil } func UnmarshalInnerInput(v interface{}) (InnerInput, error) { @@ -4127,9 +4150,8 @@ func UnmarshalInnerInput(v interface{}) (InnerInput, error) { } func (e *executableSchema) InnerInputMiddleware(ctx context.Context, obj *InnerInput) (*InnerInput, error) { - var err error - return obj, err + return obj, nil } func UnmarshalKeywords(v interface{}) (Keywords, error) { @@ -4295,9 +4317,8 @@ func UnmarshalKeywords(v interface{}) (Keywords, error) { } func (e *executableSchema) KeywordsMiddleware(ctx context.Context, obj *Keywords) (*Keywords, error) { - var err error - return obj, err + return obj, nil } func UnmarshalOuterInput(v interface{}) (OuterInput, error) { @@ -4319,14 +4340,13 @@ func UnmarshalOuterInput(v interface{}) (OuterInput, error) { } func (e *executableSchema) OuterInputMiddleware(ctx context.Context, obj *OuterInput) (*OuterInput, error) { - var err error mTmp1, err := e.InnerInputMiddleware(ctx, &obj.Inner) if err != nil { return nil, err } obj.Inner = *mTmp1 - return obj, err + return obj, nil } func UnmarshalRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { @@ -4359,7 +4379,6 @@ func UnmarshalRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { } func (e *executableSchema) RecursiveInputSliceMiddleware(ctx context.Context, obj *RecursiveInputSlice) (*RecursiveInputSlice, error) { - var err error for idx1 := range obj.Self { @@ -4369,7 +4388,7 @@ func (e *executableSchema) RecursiveInputSliceMiddleware(ctx context.Context, ob } obj.Self[idx1] = *mTmp2 } - return obj, err + return obj, nil } func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { diff --git a/example/chat/generated.go b/example/chat/generated.go index 6c3dea5a050..d612795015f 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -78,9 +78,9 @@ type SubscriptionResolver interface { func (e *executableSchema) field_Mutation_post_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 string if tmp, ok := rawArgs["text"]; ok { + var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -89,6 +89,7 @@ func (e *executableSchema) field_Mutation_post_args(ctx context.Context, rawArgs args["text"] = arg0 var arg1 string if tmp, ok := rawArgs["username"]; ok { + var err error arg1, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err @@ -97,88 +98,89 @@ func (e *executableSchema) field_Mutation_post_args(ctx context.Context, rawArgs args["username"] = arg1 var arg2 string if tmp, ok := rawArgs["roomName"]; ok { + var err error arg2, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["roomName"] = arg2 - return args, err + return args, nil } func (e *executableSchema) field_Query_room_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 string if tmp, ok := rawArgs["name"]; ok { + var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["name"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 string if tmp, ok := rawArgs["name"]; ok { + var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["name"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_Subscription_messageAdded_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 string if tmp, ok := rawArgs["roomName"]; ok { + var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["roomName"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, err + return args, nil } diff --git a/example/config/generated.go b/example/config/generated.go index c29b0bc22ff..e807413377f 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -74,10 +74,10 @@ type TodoResolver interface { func (e *executableSchema) field_Mutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 NewTodo if tmp, ok := rawArgs["input"]; ok { + var err error arg0, err = UnmarshalNewTodo(tmp) if err != nil { return nil, err @@ -91,52 +91,52 @@ func (e *executableSchema) field_Mutation_createTodo_args(ctx context.Context, r } args["input"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 string if tmp, ok := rawArgs["name"]; ok { + var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["name"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, err + return args, nil } @@ -2213,9 +2213,8 @@ func UnmarshalNewTodo(v interface{}) (NewTodo, error) { } func (e *executableSchema) NewTodoMiddleware(ctx context.Context, obj *NewTodo) (*NewTodo, error) { - var err error - return obj, err + return obj, nil } func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index e215b431d24..aa91b9fe462 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -87,9 +87,9 @@ type QueryResolver interface { func (e *executableSchema) field_Query_torture1d_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 []int if tmp, ok := rawArgs["customerIds"]; ok { + var err error var rawIf1 []interface{} if tmp != nil { if tmp1, ok := tmp.([]interface{}); ok { @@ -107,15 +107,15 @@ func (e *executableSchema) field_Query_torture1d_args(ctx context.Context, rawAr } } args["customerIds"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_Query_torture2d_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 [][]int if tmp, ok := rawArgs["customerIds"]; ok { + var err error var rawIf1 []interface{} if tmp != nil { if tmp1, ok := tmp.([]interface{}); ok { @@ -144,52 +144,52 @@ func (e *executableSchema) field_Query_torture2d_args(ctx context.Context, rawAr } } args["customerIds"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 string if tmp, ok := rawArgs["name"]; ok { + var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["name"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, err + return args, nil } diff --git a/example/scalars/generated.go b/example/scalars/generated.go index 0c4a65ee03f..0c6a82110f8 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -75,25 +75,25 @@ type UserResolver interface { func (e *executableSchema) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 external.ObjectID if tmp, ok := rawArgs["id"]; ok { + var err error arg0, err = model.UnmarshalID(tmp) if err != nil { return nil, err } } args["id"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_Query_search_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 *model.SearchArgs if tmp, ok := rawArgs["input"]; ok { + var err error var ptr1 model.SearchArgs if tmp != nil { ptr1, err = UnmarshalSearchArgs(tmp) @@ -111,52 +111,52 @@ func (e *executableSchema) field_Query_search_args(ctx context.Context, rawArgs } args["input"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 string if tmp, ok := rawArgs["name"]; ok { + var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["name"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, err + return args, nil } @@ -2322,9 +2322,8 @@ func UnmarshalSearchArgs(v interface{}) (model.SearchArgs, error) { } func (e *executableSchema) SearchArgsMiddleware(ctx context.Context, obj *model.SearchArgs) (*model.SearchArgs, error) { - var err error - return obj, err + return obj, nil } func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { diff --git a/example/selection/generated.go b/example/selection/generated.go index 91134534ba9..52fb1cc0a7e 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -65,46 +65,46 @@ type QueryResolver interface { func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 string if tmp, ok := rawArgs["name"]; ok { + var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["name"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, err + return args, nil } diff --git a/example/starwars/generated.go b/example/starwars/generated.go index c6a6cdd9979..a591a364509 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -143,9 +143,9 @@ type StarshipResolver interface { func (e *executableSchema) field_Droid_friendsConnection_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 *int if tmp, ok := rawArgs["first"]; ok { + var err error var ptr1 int if tmp != nil { ptr1, err = graphql.UnmarshalInt(tmp) @@ -159,6 +159,7 @@ func (e *executableSchema) field_Droid_friendsConnection_args(ctx context.Contex args["first"] = arg0 var arg1 *string if tmp, ok := rawArgs["after"]; ok { + var err error var ptr1 string if tmp != nil { ptr1, err = graphql.UnmarshalID(tmp) @@ -170,30 +171,30 @@ func (e *executableSchema) field_Droid_friendsConnection_args(ctx context.Contex } } args["after"] = arg1 - return args, err + return args, nil } func (e *executableSchema) field_Human_height_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 LengthUnit if tmp, ok := rawArgs["unit"]; ok { + var err error err = (&arg0).UnmarshalGQL(tmp) if err != nil { return nil, err } } args["unit"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_Human_friendsConnection_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 *int if tmp, ok := rawArgs["first"]; ok { + var err error var ptr1 int if tmp != nil { ptr1, err = graphql.UnmarshalInt(tmp) @@ -207,6 +208,7 @@ func (e *executableSchema) field_Human_friendsConnection_args(ctx context.Contex args["first"] = arg0 var arg1 *string if tmp, ok := rawArgs["after"]; ok { + var err error var ptr1 string if tmp != nil { ptr1, err = graphql.UnmarshalID(tmp) @@ -218,15 +220,15 @@ func (e *executableSchema) field_Human_friendsConnection_args(ctx context.Contex } } args["after"] = arg1 - return args, err + return args, nil } func (e *executableSchema) field_Mutation_createReview_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 Episode if tmp, ok := rawArgs["episode"]; ok { + var err error err = (&arg0).UnmarshalGQL(tmp) if err != nil { return nil, err @@ -236,6 +238,7 @@ func (e *executableSchema) field_Mutation_createReview_args(ctx context.Context, var arg1 Review if tmp, ok := rawArgs["review"]; ok { + var err error arg1, err = UnmarshalReviewInput(tmp) if err != nil { return nil, err @@ -249,15 +252,15 @@ func (e *executableSchema) field_Mutation_createReview_args(ctx context.Context, } args["review"] = arg1 - return args, err + return args, nil } func (e *executableSchema) field_Query_hero_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 *Episode if tmp, ok := rawArgs["episode"]; ok { + var err error var ptr1 Episode if tmp != nil { err = (&ptr1).UnmarshalGQL(tmp) @@ -269,15 +272,15 @@ func (e *executableSchema) field_Query_hero_args(ctx context.Context, rawArgs ma } } args["episode"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_Query_reviews_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 Episode if tmp, ok := rawArgs["episode"]; ok { + var err error err = (&arg0).UnmarshalGQL(tmp) if err != nil { return nil, err @@ -286,6 +289,7 @@ func (e *executableSchema) field_Query_reviews_args(ctx context.Context, rawArgs args["episode"] = arg0 var arg1 *time.Time if tmp, ok := rawArgs["since"]; ok { + var err error var ptr1 time.Time if tmp != nil { ptr1, err = graphql.UnmarshalTime(tmp) @@ -297,105 +301,105 @@ func (e *executableSchema) field_Query_reviews_args(ctx context.Context, rawArgs } } args["since"] = arg1 - return args, err + return args, nil } func (e *executableSchema) field_Query_search_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 string if tmp, ok := rawArgs["text"]; ok { + var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["text"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_Query_character_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 string if tmp, ok := rawArgs["id"]; ok { + var err error arg0, err = graphql.UnmarshalID(tmp) if err != nil { return nil, err } } args["id"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_Query_droid_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 string if tmp, ok := rawArgs["id"]; ok { + var err error arg0, err = graphql.UnmarshalID(tmp) if err != nil { return nil, err } } args["id"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_Query_human_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 string if tmp, ok := rawArgs["id"]; ok { + var err error arg0, err = graphql.UnmarshalID(tmp) if err != nil { return nil, err } } args["id"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_Query_starship_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 string if tmp, ok := rawArgs["id"]; ok { + var err error arg0, err = graphql.UnmarshalID(tmp) if err != nil { return nil, err } } args["id"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 string if tmp, ok := rawArgs["name"]; ok { + var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["name"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_Starship_length_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 *LengthUnit if tmp, ok := rawArgs["unit"]; ok { + var err error var ptr1 LengthUnit if tmp != nil { err = (&ptr1).UnmarshalGQL(tmp) @@ -407,37 +411,37 @@ func (e *executableSchema) field_Starship_length_args(ctx context.Context, rawAr } } args["unit"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, err + return args, nil } @@ -4143,9 +4147,8 @@ func UnmarshalReviewInput(v interface{}) (Review, error) { } func (e *executableSchema) ReviewInputMiddleware(ctx context.Context, obj *Review) (*Review, error) { - var err error - return obj, err + return obj, nil } func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { diff --git a/example/todo/generated.go b/example/todo/generated.go index a4a035c7060..efe87e438a8 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -70,10 +70,10 @@ type MyQueryResolver interface { func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 TodoInput if tmp, ok := rawArgs["todo"]; ok { + var err error arg0, err = UnmarshalTodoInput(tmp) if err != nil { return nil, err @@ -87,15 +87,15 @@ func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, } args["todo"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_MyMutation_updateTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 int if tmp, ok := rawArgs["id"]; ok { + var err error arg0, err = graphql.UnmarshalInt(tmp) if err != nil { return nil, err @@ -104,88 +104,89 @@ func (e *executableSchema) field_MyMutation_updateTodo_args(ctx context.Context, args["id"] = arg0 var arg1 map[string]interface{} if tmp, ok := rawArgs["changes"]; ok { + var err error arg1 = tmp.(map[string]interface{}) if err != nil { return nil, err } } args["changes"] = arg1 - return args, err + return args, nil } func (e *executableSchema) field_MyQuery_todo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 int if tmp, ok := rawArgs["id"]; ok { + var err error arg0, err = graphql.UnmarshalInt(tmp) if err != nil { return nil, err } } args["id"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_MyQuery___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 string if tmp, ok := rawArgs["name"]; ok { + var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["name"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, err + return args, nil } func (e *executableSchema) dir_hasRole_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 Role if tmp, ok := rawArgs["role"]; ok { + var err error err = (&arg0).UnmarshalGQL(tmp) if err != nil { return nil, err } } args["role"] = arg0 - return args, err + return args, nil } @@ -2227,9 +2228,8 @@ func UnmarshalTodoInput(v interface{}) (TodoInput, error) { } func (e *executableSchema) TodoInputMiddleware(ctx context.Context, obj *TodoInput) (*TodoInput, error) { - var err error - return obj, err + return obj, nil } func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index 8c3920730a3..d7010d59cd9 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -80,10 +80,10 @@ type MyQueryResolver interface { func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 TodoInput if tmp, ok := rawArgs["todo"]; ok { + var err error arg0, err = UnmarshalTodoInput(tmp) if err != nil { return nil, err @@ -97,67 +97,67 @@ func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, } args["todo"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_MyQuery_todo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 string if tmp, ok := rawArgs["id"]; ok { + var err error arg0, err = graphql.UnmarshalID(tmp) if err != nil { return nil, err } } args["id"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_MyQuery___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 string if tmp, ok := rawArgs["name"]; ok { + var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["name"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, err + return args, nil } @@ -2162,7 +2162,6 @@ func UnmarshalTodoInput(v interface{}) (TodoInput, error) { } func (e *executableSchema) TodoInputMiddleware(ctx context.Context, obj *TodoInput) (*TodoInput, error) { - var err error cObj, err := graphql.ChainFieldMiddleware( []graphql.FieldMiddleware{ @@ -2181,7 +2180,7 @@ func (e *executableSchema) TodoInputMiddleware(ctx context.Context, obj *TodoInp return nil, errors.New("expect TodoInput") } - return obj, err + return obj, nil } func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { diff --git a/graphql/context.go b/graphql/context.go index 0cbd40b9780..39393cb27fc 100644 --- a/graphql/context.go +++ b/graphql/context.go @@ -236,7 +236,7 @@ func ChainFieldMiddleware(handleFunc ...FieldMiddleware) FieldMiddleware { curI++ res, err := handleFunc[curI](currentCtx, chainHandler) curI-- - return res,err + return res, err } return handleFunc[0](ctx, chainHandler) diff --git a/integration/generated.go b/integration/generated.go index 310c3c6322f..fc6714fac15 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -85,10 +85,10 @@ type UserResolver interface { func (e *executableSchema) field_Query_date_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 models.DateFilter if tmp, ok := rawArgs["filter"]; ok { + var err error arg0, err = UnmarshalDateFilter(tmp) if err != nil { return nil, err @@ -102,15 +102,15 @@ func (e *executableSchema) field_Query_date_args(ctx context.Context, rawArgs ma } args["filter"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_Query_error_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 *models.ErrorType if tmp, ok := rawArgs["type"]; ok { + var err error var ptr1 models.ErrorType if tmp != nil { err = (&ptr1).UnmarshalGQL(tmp) @@ -122,60 +122,60 @@ func (e *executableSchema) field_Query_error_args(ctx context.Context, rawArgs m } } args["type"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 string if tmp, ok := rawArgs["name"]; ok { + var err error arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } } args["name"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, err + return args, nil } func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error arg0, err = graphql.UnmarshalBoolean(tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 - return args, err + return args, nil } func (e *executableSchema) dir_magic_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} - var err error var arg0 *int if tmp, ok := rawArgs["kind"]; ok { + var err error var ptr1 int if tmp != nil { ptr1, err = graphql.UnmarshalInt(tmp) @@ -187,7 +187,7 @@ func (e *executableSchema) dir_magic_args(ctx context.Context, rawArgs map[strin } } args["kind"] = arg0 - return args, err + return args, nil } @@ -2394,9 +2394,8 @@ func UnmarshalDateFilter(v interface{}) (models.DateFilter, error) { } func (e *executableSchema) DateFilterMiddleware(ctx context.Context, obj *models.DateFilter) (*models.DateFilter, error) { - var err error - return obj, err + return obj, nil } func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { From 047f2ebcaebd043aed4a38cba282b2f5b5602521 Mon Sep 17 00:00:00 2001 From: asamusev Date: Sun, 2 Dec 2018 12:19:44 +0300 Subject: [PATCH 007/147] update inline template --- codegen/templates/data.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codegen/templates/data.go b/codegen/templates/data.go index de9f4e89c78..4e84394a6c4 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -1,10 +1,10 @@ package templates var data = map[string]string{ - "args.gotpl": "\targs := map[string]interface{}{}\n\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\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := graphql.ChainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $dArg.IsPtr $dArg.Value }}{{ $dArg.GoVarName }} := {{ $dArg.Value }}{{ end -}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){\n\t\t\t\t\t{{$arg.Unmarshal (print \"args\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t {{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\tvar err error\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", + "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := graphql.ChainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $dArg.IsPtr $dArg.Value }}{{ $dArg.GoVarName }} := {{ $dArg.Value }}{{ end -}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){\n\t\t\t\t\t{{$arg.Unmarshal (print \"args\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t {{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\tvar err error\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\n\t\tresults, err := ec.resolvers.{{ $field.ShortInvocation }}\n\t\tif err != nil {\n\t\t\tec.Error(ctx, err)\n\t\t\treturn nil\n\t\t}\n\t\treturn func() graphql.Marshaler {\n\t\t\tres, ok := <-results\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tvar out graphql.OrderedMap\n\t\t\tout.Add(field.Alias, func() graphql.Marshaler { {{ $field.WriteJson }} }())\n\t\t\treturn &out\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tField: field,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\n\t\t{{ if .Directives }}\n\t\tcObj, err := graphql.ChainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t{{ $resolveName := \"\" }}\n\t\t{{ if $field.IsPtr }}\n\t\t\t{{ $resolveName := \"*\" }}\n\t\t{{ end }}\n\t\t\tc{{$field.GoFieldName}}, err := graphql.ChainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print $resolveName \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{$resolveName}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\t{{ if .Directives }}\n\t\tcObj, err := graphql.ChainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t{{ $resolveName := \"\" }}\n\t\t{{ if $field.IsPtr }}\n\t\t\t{{ $resolveName := \"*\" }}\n\t\t{{ end }}\n\t\t\tc{{$field.GoFieldName}}, err := graphql.ChainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print $resolveName \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{$resolveName}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{ range $model := .Models }}\n\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .IsInterface }}\n\t\ttype {{.GoType}} interface {\n\t\t\tIs{{.GoType}}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.GoType}} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\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\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.GoType}}) Is{{$iface.GoType}}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.GoType}} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- 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\n\t{{if $object.IsConcurrent}} var wg sync.WaitGroup {{end}}\n\tout := graphql.NewOrderedMap(len(fields))\n\tinvalid := false\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\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t{{- 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\tif invalid { return graphql.Null }\n\treturn out\n}\n{{- end }}\n", From 6b0050940400bc02da4ccb6827e6ce1237f7b221 Mon Sep 17 00:00:00 2001 From: asamusev Date: Sun, 2 Dec 2018 13:37:21 +0300 Subject: [PATCH 008/147] add test directives generate --- codegen/templates/data.go | 2 +- codegen/templates/input.gotpl | 2 +- codegen/testserver/generated.go | 484 +++++++++++++++++++++++++-- codegen/testserver/generated_test.go | 125 +++++++ codegen/testserver/models-gen.go | 10 + codegen/testserver/resolver.go | 9 + codegen/testserver/schema.graphql | 15 + codegen/type.go | 2 + example/scalars/generated.go | 8 +- 9 files changed, 629 insertions(+), 28 deletions(-) diff --git a/codegen/templates/data.go b/codegen/templates/data.go index 4e84394a6c4..93a4d1b050f 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -4,7 +4,7 @@ var data = map[string]string{ "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := graphql.ChainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $dArg.IsPtr $dArg.Value }}{{ $dArg.GoVarName }} := {{ $dArg.Value }}{{ end -}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){\n\t\t\t\t\t{{$arg.Unmarshal (print \"args\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t {{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\tvar err error\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\n\t\tresults, err := ec.resolvers.{{ $field.ShortInvocation }}\n\t\tif err != nil {\n\t\t\tec.Error(ctx, err)\n\t\t\treturn nil\n\t\t}\n\t\treturn func() graphql.Marshaler {\n\t\t\tres, ok := <-results\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tvar out graphql.OrderedMap\n\t\t\tout.Add(field.Alias, func() graphql.Marshaler { {{ $field.WriteJson }} }())\n\t\t\treturn &out\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tField: field,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\t{{ if .Directives }}\n\t\tcObj, err := graphql.ChainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t{{ $resolveName := \"\" }}\n\t\t{{ if $field.IsPtr }}\n\t\t\t{{ $resolveName := \"*\" }}\n\t\t{{ end }}\n\t\t\tc{{$field.GoFieldName}}, err := graphql.ChainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print $resolveName \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{$resolveName}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := graphql.ChainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t{{ $resolveName := \"\" }}\n\t\t{{ if $field.IsPtr }}\n\t\t\t{{ $resolveName := \"*\" }}\n\t\t{{ end }}\n\t\t\tc{{$field.GoFieldName}}, err := graphql.ChainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print $resolveName \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{$resolveName}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{ range $model := .Models }}\n\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .IsInterface }}\n\t\ttype {{.GoType}} interface {\n\t\t\tIs{{.GoType}}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.GoType}} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\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\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.GoType}}) Is{{$iface.GoType}}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.GoType}} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- 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\n\t{{if $object.IsConcurrent}} var wg sync.WaitGroup {{end}}\n\tout := graphql.NewOrderedMap(len(fields))\n\tinvalid := false\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\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t{{- 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\tif invalid { return graphql.Null }\n\treturn out\n}\n{{- end }}\n", diff --git a/codegen/templates/input.gotpl b/codegen/templates/input.gotpl index 432f72c6d59..4a7b779c42b 100644 --- a/codegen/templates/input.gotpl +++ b/codegen/templates/input.gotpl @@ -28,7 +28,7 @@ {{- end }} func (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) { - {{ if .Directives }} + {{ if .Directives }} cObj, err := graphql.ChainFieldMiddleware( []graphql.FieldMiddleware{ {{- range $directive := .Directives }} diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index e36f2121d92..c34fdf55755 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -42,6 +42,7 @@ type ResolverRoot interface { } type DirectiveRoot struct { + Length func(ctx context.Context, obj interface{}, next graphql.Resolver, min int, max *int, message string) (res interface{}, err error) } type ComplexityRoot struct { @@ -89,20 +90,23 @@ type ComplexityRoot struct { } Query struct { - InvalidIdentifier func(childComplexity int) int - Collision func(childComplexity int) int - MapInput func(childComplexity int, input *map[string]interface{}) int - Recursive func(childComplexity int, input *RecursiveInputSlice) int - NestedInputs func(childComplexity int, input [][]*OuterInput) int - NestedOutputs func(childComplexity int) int - Keywords func(childComplexity int, input *Keywords) int - Shapes func(childComplexity int) int - ErrorBubble func(childComplexity int) int - ModelMethods func(childComplexity int) int - Valid func(childComplexity int) int - User func(childComplexity int, id int) int - NullableArg func(childComplexity int, arg *int) int - KeywordArgs func(childComplexity int, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) int + InvalidIdentifier func(childComplexity int) int + Collision func(childComplexity int) int + MapInput func(childComplexity int, input *map[string]interface{}) int + Recursive func(childComplexity int, input *RecursiveInputSlice) int + NestedInputs func(childComplexity int, input [][]*OuterInput) int + NestedOutputs func(childComplexity int) int + Keywords func(childComplexity int, input *Keywords) int + Shapes func(childComplexity int) int + ErrorBubble func(childComplexity int) int + ModelMethods func(childComplexity int) int + Valid func(childComplexity int) int + User func(childComplexity int, id int) int + NullableArg func(childComplexity int, arg *int) int + DirectiveArg func(childComplexity int, arg string) int + DirectiveInputNullable func(childComplexity int, arg *InputDirectives) int + DirectiveInput func(childComplexity int, arg InputDirectives) int + KeywordArgs func(childComplexity int, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) int } Rectangle struct { @@ -142,6 +146,9 @@ type QueryResolver interface { Valid(ctx context.Context) (string, error) User(ctx context.Context, id int) (User, error) NullableArg(ctx context.Context, arg *int) (*string, error) + DirectiveArg(ctx context.Context, arg string) (*string, error) + DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) + DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) } type SubscriptionResolver interface { @@ -190,9 +197,11 @@ func (e *executableSchema) field_Query_recursive_args(ctx context.Context, rawAr return nil, err } - arg0, err = e.RecursiveInputSliceMiddleware(ctx, arg0) - if err != nil { - return nil, err + if arg0 != nil { + arg0, err = e.RecursiveInputSliceMiddleware(ctx, arg0) + if err != nil { + return nil, err + } } } @@ -241,9 +250,11 @@ func (e *executableSchema) field_Query_nestedInputs_args(ctx context.Context, ra for idx1 := range arg0 { for idx2 := range arg0[idx1] { - arg0[idx1][idx2], err = e.OuterInputMiddleware(ctx, arg0[idx1][idx2]) - if err != nil { - return nil, err + if arg0[idx1][idx2] != nil { + arg0[idx1][idx2], err = e.OuterInputMiddleware(ctx, arg0[idx1][idx2]) + if err != nil { + return nil, err + } } } } @@ -270,9 +281,11 @@ func (e *executableSchema) field_Query_keywords_args(ctx context.Context, rawArg return nil, err } - arg0, err = e.KeywordsMiddleware(ctx, arg0) - if err != nil { - return nil, err + if arg0 != nil { + arg0, err = e.KeywordsMiddleware(ctx, arg0) + if err != nil { + return nil, err + } } } @@ -316,6 +329,90 @@ func (e *executableSchema) field_Query_nullableArg_args(ctx context.Context, raw } +func (e *executableSchema) field_Query_directiveArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["arg"]; ok { + + argm0, err := graphql.ChainFieldMiddleware([]graphql.FieldMiddleware{ + func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { + max := 255 + return e.directives.Length(ctx, tmp, n, 1, &max, "invalid length") + }, + }...)(ctx, func(ctx2 context.Context) (args0 interface{}, err error) { + args0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + return + }) + if err != nil { + return nil, err + } + if data, ok := argm0.(string); ok { + arg0 = data + } else { + return nil, errors.New("expect string") + } + + } + args["arg"] = arg0 + return args, nil + +} + +func (e *executableSchema) field_Query_directiveInputNullable_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *InputDirectives + if tmp, ok := rawArgs["arg"]; ok { + + var err error + var ptr1 InputDirectives + if tmp != nil { + ptr1, err = UnmarshalInputDirectives(tmp) + arg0 = &ptr1 + } + + if err != nil { + return nil, err + } + + if arg0 != nil { + arg0, err = e.InputDirectivesMiddleware(ctx, arg0) + if err != nil { + return nil, err + } + } + + } + args["arg"] = arg0 + return args, nil + +} + +func (e *executableSchema) field_Query_directiveInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 InputDirectives + if tmp, ok := rawArgs["arg"]; ok { + + var err error + arg0, err = UnmarshalInputDirectives(tmp) + if err != nil { + return nil, err + } + + mTmp1, err := e.InputDirectivesMiddleware(ctx, &arg0) + if err != nil { + return nil, err + } + arg0 = *mTmp1 + + } + args["arg"] = arg0 + return args, nil + +} + func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} var arg0 string @@ -592,6 +689,44 @@ func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, raw } +func (e *executableSchema) dir_length_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 int + if tmp, ok := rawArgs["min"]; ok { + var err error + arg0, err = graphql.UnmarshalInt(tmp) + if err != nil { + return nil, err + } + } + args["min"] = arg0 + var arg1 *int + if tmp, ok := rawArgs["max"]; ok { + var err error + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + arg1 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["max"] = arg1 + var arg2 string + if tmp, ok := rawArgs["message"]; ok { + var err error + arg2, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["message"] = arg2 + return args, nil + +} + type executableSchema struct { resolvers ResolverRoot directives DirectiveRoot @@ -838,6 +973,42 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.NullableArg(childComplexity, args["arg"].(*int)), true + case "Query.directiveArg": + if e.complexity.Query.DirectiveArg == nil { + break + } + + args, err := e.field_Query_directiveArg_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.DirectiveArg(childComplexity, args["arg"].(string)), true + + case "Query.directiveInputNullable": + if e.complexity.Query.DirectiveInputNullable == nil { + break + } + + args, err := e.field_Query_directiveInputNullable_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.DirectiveInputNullable(childComplexity, args["arg"].(*InputDirectives)), true + + case "Query.directiveInput": + if e.complexity.Query.DirectiveInput == nil { + break + } + + args, err := e.field_Query_directiveInput_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.DirectiveInput(childComplexity, args["arg"].(InputDirectives)), true + case "Query.keywordArgs": if e.complexity.Query.KeywordArgs == nil { break @@ -1779,6 +1950,24 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr out.Values[i] = ec._Query_nullableArg(ctx, field) wg.Done() }(i, field) + case "directiveArg": + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_directiveArg(ctx, field) + wg.Done() + }(i, field) + case "directiveInputNullable": + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_directiveInputNullable(ctx, field) + wg.Done() + }(i, field) + case "directiveInput": + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_directiveInput(ctx, field) + wg.Done() + }(i, field) case "keywordArgs": wg.Add(1) go func(i int, field graphql.CollectedField) { @@ -2295,6 +2484,108 @@ func (ec *executionContext) _Query_nullableArg(ctx context.Context, field graphq return graphql.MarshalString(*res) } +// nolint: vetshadow +func (ec *executionContext) _Query_directiveArg(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_directiveArg_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().DirectiveArg(rctx, args["arg"].(string)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) +} + +// nolint: vetshadow +func (ec *executionContext) _Query_directiveInputNullable(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_directiveInputNullable_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().DirectiveInputNullable(rctx, args["arg"].(*InputDirectives)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) +} + +// nolint: vetshadow +func (ec *executionContext) _Query_directiveInput(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_directiveInput_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().DirectiveInput(rctx, args["arg"].(InputDirectives)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) +} + // nolint: vetshadow func (ec *executionContext) _Query_keywordArgs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) @@ -4131,6 +4422,48 @@ func (e *executableSchema) ChangesMiddleware(ctx context.Context, obj *map[strin return obj, nil } +func UnmarshalInnerDirectives(v interface{}) (InnerDirectives, error) { + var it InnerDirectives + var asMap = v.(map[string]interface{}) + + for k, v := range asMap { + switch k { + case "message": + var err error + it.Message, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + } + } + + return it, nil +} + +func (e *executableSchema) InnerDirectivesMiddleware(ctx context.Context, obj *InnerDirectives) (*InnerDirectives, error) { + + cMessage, err := graphql.ChainFieldMiddleware( + []graphql.FieldMiddleware{ + func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { + return e.directives.Length(ctx, obj.Message, n, 1, nil, "not valid") + }, + }..., + )(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Message, nil + }) + if err != nil { + return obj, err + } + + if data, ok := cMessage.(string); ok { + obj.Message = data + } else { + return obj, errors.New("Message expect string") + } + + return obj, nil +} + func UnmarshalInnerInput(v interface{}) (InnerInput, error) { var it InnerInput var asMap = v.(map[string]interface{}) @@ -4154,6 +4487,78 @@ func (e *executableSchema) InnerInputMiddleware(ctx context.Context, obj *InnerI return obj, nil } +func UnmarshalInputDirectives(v interface{}) (InputDirectives, error) { + var it InputDirectives + var asMap = v.(map[string]interface{}) + + for k, v := range asMap { + switch k { + case "text": + var err error + it.Text, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "inner": + var err error + it.Inner, err = UnmarshalInnerDirectives(v) + if err != nil { + return it, err + } + case "innerNullable": + var err error + var ptr1 InnerDirectives + if v != nil { + ptr1, err = UnmarshalInnerDirectives(v) + it.InnerNullable = &ptr1 + } + + if err != nil { + return it, err + } + } + } + + return it, nil +} + +func (e *executableSchema) InputDirectivesMiddleware(ctx context.Context, obj *InputDirectives) (*InputDirectives, error) { + + cText, err := graphql.ChainFieldMiddleware( + []graphql.FieldMiddleware{ + func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { + max := 7 + return e.directives.Length(ctx, obj.Text, n, 0, &max, "not valid") + }, + }..., + )(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Text, nil + }) + if err != nil { + return obj, err + } + + if data, ok := cText.(string); ok { + obj.Text = data + } else { + return obj, errors.New("Text expect string") + } + + mTmp1, err := e.InnerDirectivesMiddleware(ctx, &obj.Inner) + if err != nil { + return nil, err + } + obj.Inner = *mTmp1 + + if obj.InnerNullable != nil { + obj.InnerNullable, err = e.InnerDirectivesMiddleware(ctx, obj.InnerNullable) + if err != nil { + return nil, err + } + } + return obj, nil +} + func UnmarshalKeywords(v interface{}) (Keywords, error) { var it Keywords var asMap = v.(map[string]interface{}) @@ -4398,6 +4803,24 @@ func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{} ret = nil } }() + rctx := graphql.GetResolverContext(ctx) + for _, d := range rctx.Field.Definition.Directives { + switch d.Name { + case "length": + if ec.directives.Length != nil { + rawArgs := d.ArgumentMap(ec.Variables) + args, err := ec.dir_length_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return nil + } + n := next + next = func(ctx context.Context) (interface{}, error) { + return ec.directives.Length(ctx, obj, n, args["min"].(int), args["max"].(*int), args["message"].(string)) + } + } + } + } res, err := ec.ResolverMiddleware(ctx, next) if err != nil { ec.Error(ctx, err) @@ -4435,6 +4858,9 @@ var parsedSchema = gqlparser.MustLoadSchema( valid: String! user(id: Int!): User! nullableArg(arg: Int = 123): String + directiveArg(arg: String! @length(min:1, max: 255, message: "invalid length")): String + directiveInputNullable(arg: InputDirectives): String + directiveInput(arg: InputDirectives!): String } type Subscription { @@ -4485,6 +4911,16 @@ input OuterInput { inner: InnerInput! } +input InputDirectives { + text: String! @length(min: 0, max: 7, message: "not valid") + inner: InnerDirectives! + innerNullable: InnerDirectives +} + +input InnerDirectives { + message: String! @length(min: 1, message: "not valid") +} + type OuterObject { inner: InnerObject! } @@ -4573,5 +5009,7 @@ type EmbeddedPointer { ID: String Title: String } + +directive @length(min: Int!, max: Int, message: String!) on ARGUMENT_DEFINITION `}, ) diff --git a/codegen/testserver/generated_test.go b/codegen/testserver/generated_test.go index 704869a0813..fddcb0e8098 100644 --- a/codegen/testserver/generated_test.go +++ b/codegen/testserver/generated_test.go @@ -6,6 +6,7 @@ package testserver import ( "context" "fmt" + "github.com/pkg/errors" "net/http" "net/http/httptest" "reflect" @@ -190,6 +191,115 @@ func TestGeneratedServer(t *testing.T) { }) } +func TestDirectives(t *testing.T) { + resolvers := &testResolver{tick: make(chan string, 1)} + + srv := httptest.NewServer( + handler.GraphQL( + NewExecutableSchema(Config{ + Resolvers: resolvers, + Directives: DirectiveRoot{ + Length: func(ctx context.Context, obj interface{}, next graphql.Resolver, min int, max *int, message string) (res interface{}, err error) { + if d, ok := obj.(string); ok { + if len(d) < min { + return nil, errors.New(message) + } + if max != nil && len(d) > *max { + return nil, errors.New(message) + } + return next(ctx) + } + return nil, errors.New(message) + }, + }, + }), + handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + path, _ := ctx.Value("path").([]int) + return next(context.WithValue(ctx, "path", append(path, 1))) + }), + handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + path, _ := ctx.Value("path").([]int) + return next(context.WithValue(ctx, "path", append(path, 2))) + }), + )) + c := client.New(srv.URL) + + t.Run("arg directives", func(t *testing.T) { + t.Run("when function errors on directives", func(t *testing.T) { + var resp struct { + DirectiveArg *string + } + + err := c.Post(`query { directiveArg(arg: "") }`, &resp) + + require.EqualError(t, err, `[{"message":"invalid length","path":["directiveArg"]}]`) + require.Nil(t, resp.DirectiveArg) + }) + t.Run("when function success", func(t *testing.T) { + var resp struct { + DirectiveArg *string + } + + err := c.Post(`query { directiveArg(arg: "test") }`, &resp) + + require.Nil(t, err) + require.Equal(t, "Ok", *resp.DirectiveArg) + }) + }) + t.Run("input field directives", func(t *testing.T) { + t.Run("when function errors on directives", func(t *testing.T) { + var resp struct { + DirectiveInputNullable *string + } + + err := c.Post(`query { directiveInputNullable(arg: {text:"invalid text",inner:{message:"123"}}) }`, &resp) + + require.EqualError(t, err, `[{"message":"not valid","path":["directiveInputNullable"]}]`) + require.Nil(t, resp.DirectiveInputNullable) + }) + t.Run("when function errors on inner directives", func(t *testing.T) { + var resp struct { + DirectiveInputNullable *string + } + + err := c.Post(`query { directiveInputNullable(arg: {text:"2",inner:{message:""}}) }`, &resp) + + require.EqualError(t, err, `[{"message":"not valid","path":["directiveInputNullable"]}]`) + require.Nil(t, resp.DirectiveInputNullable) + }) + t.Run("when function errors on nullable inner directives", func(t *testing.T) { + var resp struct { + DirectiveInputNullable *string + } + + err := c.Post(`query { directiveInputNullable(arg: {text:"success",inner:{message:"1"},innerNullable:{message:""}}) }`, &resp) + + require.EqualError(t, err, `[{"message":"not valid","path":["directiveInputNullable"]}]`) + require.Nil(t, resp.DirectiveInputNullable) + }) + t.Run("when function success", func(t *testing.T) { + var resp struct { + DirectiveInputNullable *string + } + + err := c.Post(`query { directiveInputNullable(arg: {text:"23",inner:{message:"1"}}) }`, &resp) + + require.Nil(t, err) + require.Equal(t, "Ok", *resp.DirectiveInputNullable) + }) + t.Run("when function inner nullable success", func(t *testing.T) { + var resp struct { + DirectiveInputNullable *string + } + + err := c.Post(`query { directiveInputNullable(arg: {text:"23",inner:{message:"1"},innerNullable:{message:"success"}}) }`, &resp) + + require.Nil(t, err) + require.Equal(t, "Ok", *resp.DirectiveInputNullable) + }) + }) +} + func TestIntrospection(t *testing.T) { t.Run("disabled", func(t *testing.T) { resolvers := &testResolver{tick: make(chan string, 1)} @@ -702,6 +812,21 @@ func (r *testQueryResolver) NullableArg(ctx context.Context, arg *int) (*string, return &s, nil } +func (r *testQueryResolver) DirectiveArg(ctx context.Context, arg string) (*string, error) { + s := "Ok" + return &s, nil +} + +func (r *testQueryResolver) DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) { + s := "Ok" + return &s, nil +} + +func (r *testQueryResolver) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) { + s := "Ok" + return &s, nil +} + func (r *testQueryResolver) ModelMethods(ctx context.Context) (*ModelMethods, error) { return &ModelMethods{}, nil } diff --git a/codegen/testserver/models-gen.go b/codegen/testserver/models-gen.go index ea2208bbd41..7f4354ccdc9 100644 --- a/codegen/testserver/models-gen.go +++ b/codegen/testserver/models-gen.go @@ -2,6 +2,10 @@ package testserver +type InnerDirectives struct { + Message string `json:"message"` +} + type InnerInput struct { ID int `json:"id"` } @@ -10,6 +14,12 @@ type InnerObject struct { ID int `json:"id"` } +type InputDirectives struct { + Text string `json:"text"` + Inner InnerDirectives `json:"inner"` + InnerNullable *InnerDirectives `json:"innerNullable"` +} + type Keywords struct { Break string `json:"break"` Default string `json:"default"` diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index f7d04e16cb4..702e64ed066 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -78,6 +78,15 @@ func (r *queryResolver) User(ctx context.Context, id int) (User, error) { func (r *queryResolver) NullableArg(ctx context.Context, arg *int) (*string, error) { panic("not implemented") } +func (r *queryResolver) DirectiveArg(ctx context.Context, arg string) (*string, error) { + panic("not implemented") +} +func (r *queryResolver) DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) { + panic("not implemented") +} +func (r *queryResolver) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) { + panic("not implemented") +} func (r *queryResolver) KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) { panic("not implemented") } diff --git a/codegen/testserver/schema.graphql b/codegen/testserver/schema.graphql index 276e7130be2..a75b9720b60 100644 --- a/codegen/testserver/schema.graphql +++ b/codegen/testserver/schema.graphql @@ -12,6 +12,9 @@ type Query { valid: String! user(id: Int!): User! nullableArg(arg: Int = 123): String + directiveArg(arg: String! @length(min:1, max: 255, message: "invalid length")): String + directiveInputNullable(arg: InputDirectives): String + directiveInput(arg: InputDirectives!): String } type Subscription { @@ -62,6 +65,16 @@ input OuterInput { inner: InnerInput! } +input InputDirectives { + text: String! @length(min: 0, max: 7, message: "not valid") + inner: InnerDirectives! + innerNullable: InnerDirectives +} + +input InnerDirectives { + message: String! @length(min: 1, message: "not valid") +} + type OuterObject { inner: InnerObject! } @@ -150,3 +163,5 @@ type EmbeddedPointer { ID: String Title: String } + +directive @length(min: Int!, max: Int, message: String!) on ARGUMENT_DEFINITION diff --git a/codegen/type.go b/codegen/type.go index ecf52fd5beb..6390ddaa048 100644 --- a/codegen/type.go +++ b/codegen/type.go @@ -168,10 +168,12 @@ func (t Type) Middleware(result, raw string) string { func (t Type) middleware(result, raw string, remainingMods []string, depth int) string { if len(remainingMods) == 1 && remainingMods[0] == modPtr { return tpl(`{{- if .t.Marshaler }} + if {{.raw}} != nil { {{.result}}, err = e.{{ .t.GQLType }}Middleware(ctx, {{.raw}}) if err != nil { return nil, err } + } {{- end }}`, map[string]interface{}{ "result": result, "raw": raw, diff --git a/example/scalars/generated.go b/example/scalars/generated.go index 0c6a82110f8..b4e2de2ab7d 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -104,9 +104,11 @@ func (e *executableSchema) field_Query_search_args(ctx context.Context, rawArgs return nil, err } - arg0, err = e.SearchArgsMiddleware(ctx, arg0) - if err != nil { - return nil, err + if arg0 != nil { + arg0, err = e.SearchArgsMiddleware(ctx, arg0) + if err != nil { + return nil, err + } } } From be51904c52bfec461626a7765b0c8ef2f063ffe6 Mon Sep 17 00:00:00 2001 From: asamusev Date: Mon, 3 Dec 2018 09:30:23 +0300 Subject: [PATCH 009/147] check nullable arguments --- codegen/templates/args.gotpl | 2 +- codegen/templates/data.go | 2 +- codegen/testserver/generated.go | 179 +++++++++++++++++++-- codegen/testserver/generated_test.go | 73 +++++++++ codegen/testserver/resolver.go | 3 + codegen/testserver/schema.graphql | 4 +- codegen/type.go | 3 +- example/config/generated.go | 4 +- example/scalars/generated.go | 1 + example/starwars/generated.go | 4 +- example/todo/generated.go | 4 +- example/type-system-extension/generated.go | 4 +- integration/generated.go | 4 +- 13 files changed, 264 insertions(+), 23 deletions(-) diff --git a/codegen/templates/args.gotpl b/codegen/templates/args.gotpl index e2d19e22006..b38bb09622d 100644 --- a/codegen/templates/args.gotpl +++ b/codegen/templates/args.gotpl @@ -8,7 +8,7 @@ {{- range $directive := $arg.Directives }} func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { {{- range $dArg := $directive.Args }} - {{- if and $dArg.IsPtr $dArg.Value }}{{ $dArg.GoVarName }} := {{ $dArg.Value }}{{ end -}} + {{- if and $dArg.IsPtr (not (eq ($dArg.Value|dump) "nil")) }}{{ $dArg.GoVarName }} := {{ $dArg.Value|dump }}{{ end -}} {{- end }} return e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs "tmp" "n" }}) }, diff --git a/codegen/templates/data.go b/codegen/templates/data.go index 93a4d1b050f..8637f8bc3af 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -1,7 +1,7 @@ package templates var data = map[string]string{ - "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := graphql.ChainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $dArg.IsPtr $dArg.Value }}{{ $dArg.GoVarName }} := {{ $dArg.Value }}{{ end -}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){\n\t\t\t\t\t{{$arg.Unmarshal (print \"args\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t {{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\tvar err error\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", + "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := graphql.ChainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $dArg.IsPtr (not (eq ($dArg.Value|dump) \"nil\")) }}{{ $dArg.GoVarName }} := {{ $dArg.Value|dump }}{{ end -}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){\n\t\t\t\t\t{{$arg.Unmarshal (print \"args\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t {{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\tvar err error\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\n\t\tresults, err := ec.resolvers.{{ $field.ShortInvocation }}\n\t\tif err != nil {\n\t\t\tec.Error(ctx, err)\n\t\t\treturn nil\n\t\t}\n\t\treturn func() graphql.Marshaler {\n\t\t\tres, ok := <-results\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tvar out graphql.OrderedMap\n\t\t\tout.Add(field.Alias, func() graphql.Marshaler { {{ $field.WriteJson }} }())\n\t\t\treturn &out\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tField: field,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := graphql.ChainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t{{ $resolveName := \"\" }}\n\t\t{{ if $field.IsPtr }}\n\t\t\t{{ $resolveName := \"*\" }}\n\t\t{{ end }}\n\t\t\tc{{$field.GoFieldName}}, err := graphql.ChainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print $resolveName \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{$resolveName}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\n", diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index c34fdf55755..657b5cf4897 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -43,6 +43,8 @@ type ResolverRoot interface { type DirectiveRoot struct { Length func(ctx context.Context, obj interface{}, next graphql.Resolver, min int, max *int, message string) (res interface{}, err error) + + Range func(ctx context.Context, obj interface{}, next graphql.Resolver, min *int, max *int, message *string) (res interface{}, err error) } type ComplexityRoot struct { @@ -104,6 +106,7 @@ type ComplexityRoot struct { User func(childComplexity int, id int) int NullableArg func(childComplexity int, arg *int) int DirectiveArg func(childComplexity int, arg string) int + DirectiveNullableArg func(childComplexity int, arg *int) int DirectiveInputNullable func(childComplexity int, arg *InputDirectives) int DirectiveInput func(childComplexity int, arg InputDirectives) int KeywordArgs func(childComplexity int, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) int @@ -147,6 +150,7 @@ type QueryResolver interface { User(ctx context.Context, id int) (User, error) NullableArg(ctx context.Context, arg *int) (*string, error) DirectiveArg(ctx context.Context, arg string) (*string, error) + DirectiveNullableArg(ctx context.Context, arg *int) (*string, error) DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) @@ -198,6 +202,7 @@ func (e *executableSchema) field_Query_recursive_args(ctx context.Context, rawAr } if arg0 != nil { + var err error arg0, err = e.RecursiveInputSliceMiddleware(ctx, arg0) if err != nil { return nil, err @@ -251,6 +256,7 @@ func (e *executableSchema) field_Query_nestedInputs_args(ctx context.Context, ra for idx2 := range arg0[idx1] { if arg0[idx1][idx2] != nil { + var err error arg0[idx1][idx2], err = e.OuterInputMiddleware(ctx, arg0[idx1][idx2]) if err != nil { return nil, err @@ -282,6 +288,7 @@ func (e *executableSchema) field_Query_keywords_args(ctx context.Context, rawArg } if arg0 != nil { + var err error arg0, err = e.KeywordsMiddleware(ctx, arg0) if err != nil { return nil, err @@ -361,6 +368,43 @@ func (e *executableSchema) field_Query_directiveArg_args(ctx context.Context, ra } +func (e *executableSchema) field_Query_directiveNullableArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *int + if tmp, ok := rawArgs["arg"]; ok { + + argm0, err := graphql.ChainFieldMiddleware([]graphql.FieldMiddleware{ + func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { + min := 0 + return e.directives.Range(ctx, tmp, n, &min, nil, nil) + }, + }...)(ctx, func(ctx2 context.Context) (args0 interface{}, err error) { + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + args0 = &ptr1 + } + + if err != nil { + return nil, err + } + return + }) + if err != nil { + return nil, err + } + if data, ok := argm0.(*int); ok { + arg0 = data + } else { + return nil, errors.New("expect *int") + } + + } + args["arg"] = arg0 + return args, nil + +} + func (e *executableSchema) field_Query_directiveInputNullable_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} var arg0 *InputDirectives @@ -378,6 +422,7 @@ func (e *executableSchema) field_Query_directiveInputNullable_args(ctx context.C } if arg0 != nil { + var err error arg0, err = e.InputDirectivesMiddleware(ctx, arg0) if err != nil { return nil, err @@ -401,11 +446,11 @@ func (e *executableSchema) field_Query_directiveInput_args(ctx context.Context, return nil, err } - mTmp1, err := e.InputDirectivesMiddleware(ctx, &arg0) + mInputDirectives1, err := e.InputDirectivesMiddleware(ctx, &arg0) if err != nil { return nil, err } - arg0 = *mTmp1 + arg0 = *mInputDirectives1 } args["arg"] = arg0 @@ -727,6 +772,54 @@ func (e *executableSchema) dir_length_args(ctx context.Context, rawArgs map[stri } +func (e *executableSchema) dir_range_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *int + if tmp, ok := rawArgs["min"]; ok { + var err error + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + arg0 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["min"] = arg0 + var arg1 *int + if tmp, ok := rawArgs["max"]; ok { + var err error + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + arg1 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["max"] = arg1 + var arg2 *string + if tmp, ok := rawArgs["message"]; ok { + var err error + var ptr1 string + if tmp != nil { + ptr1, err = graphql.UnmarshalString(tmp) + arg2 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["message"] = arg2 + return args, nil + +} + type executableSchema struct { resolvers ResolverRoot directives DirectiveRoot @@ -985,6 +1078,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.DirectiveArg(childComplexity, args["arg"].(string)), true + case "Query.directiveNullableArg": + if e.complexity.Query.DirectiveNullableArg == nil { + break + } + + args, err := e.field_Query_directiveNullableArg_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.DirectiveNullableArg(childComplexity, args["arg"].(*int)), true + case "Query.directiveInputNullable": if e.complexity.Query.DirectiveInputNullable == nil { break @@ -1956,6 +2061,12 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr out.Values[i] = ec._Query_directiveArg(ctx, field) wg.Done() }(i, field) + case "directiveNullableArg": + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_directiveNullableArg(ctx, field) + wg.Done() + }(i, field) case "directiveInputNullable": wg.Add(1) go func(i int, field graphql.CollectedField) { @@ -2518,6 +2629,40 @@ func (ec *executionContext) _Query_directiveArg(ctx context.Context, field graph return graphql.MarshalString(*res) } +// nolint: vetshadow +func (ec *executionContext) _Query_directiveNullableArg(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_directiveNullableArg_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().DirectiveNullableArg(rctx, args["arg"].(*int)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) +} + // nolint: vetshadow func (ec *executionContext) _Query_directiveInputNullable(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) @@ -4544,13 +4689,14 @@ func (e *executableSchema) InputDirectivesMiddleware(ctx context.Context, obj *I return obj, errors.New("Text expect string") } - mTmp1, err := e.InnerDirectivesMiddleware(ctx, &obj.Inner) + mInnerDirectives1, err := e.InnerDirectivesMiddleware(ctx, &obj.Inner) if err != nil { return nil, err } - obj.Inner = *mTmp1 + obj.Inner = *mInnerDirectives1 if obj.InnerNullable != nil { + var err error obj.InnerNullable, err = e.InnerDirectivesMiddleware(ctx, obj.InnerNullable) if err != nil { return nil, err @@ -4746,11 +4892,11 @@ func UnmarshalOuterInput(v interface{}) (OuterInput, error) { func (e *executableSchema) OuterInputMiddleware(ctx context.Context, obj *OuterInput) (*OuterInput, error) { - mTmp1, err := e.InnerInputMiddleware(ctx, &obj.Inner) + mInnerInput1, err := e.InnerInputMiddleware(ctx, &obj.Inner) if err != nil { return nil, err } - obj.Inner = *mTmp1 + obj.Inner = *mInnerInput1 return obj, nil } @@ -4787,11 +4933,11 @@ func (e *executableSchema) RecursiveInputSliceMiddleware(ctx context.Context, ob for idx1 := range obj.Self { - mTmp2, err := e.RecursiveInputSliceMiddleware(ctx, &obj.Self[idx1]) + mRecursiveInputSlice2, err := e.RecursiveInputSliceMiddleware(ctx, &obj.Self[idx1]) if err != nil { return nil, err } - obj.Self[idx1] = *mTmp2 + obj.Self[idx1] = *mRecursiveInputSlice2 } return obj, nil } @@ -4819,6 +4965,19 @@ func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{} return ec.directives.Length(ctx, obj, n, args["min"].(int), args["max"].(*int), args["message"].(string)) } } + case "range": + if ec.directives.Range != nil { + rawArgs := d.ArgumentMap(ec.Variables) + args, err := ec.dir_range_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return nil + } + n := next + next = func(ctx context.Context) (interface{}, error) { + return ec.directives.Range(ctx, obj, n, args["min"].(*int), args["max"].(*int), args["message"].(*string)) + } + } } } res, err := ec.ResolverMiddleware(ctx, next) @@ -4859,6 +5018,7 @@ var parsedSchema = gqlparser.MustLoadSchema( user(id: Int!): User! nullableArg(arg: Int = 123): String directiveArg(arg: String! @length(min:1, max: 255, message: "invalid length")): String + directiveNullableArg(arg: Int @range(min:0)): String directiveInputNullable(arg: InputDirectives): String directiveInput(arg: InputDirectives!): String } @@ -5010,6 +5170,7 @@ type EmbeddedPointer { Title: String } -directive @length(min: Int!, max: Int, message: String!) on ARGUMENT_DEFINITION +directive @length(min: Int!, max: Int, message: String!) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION +directive @range(min: Int, max: Int, message: String) on ARGUMENT_DEFINITION `}, ) diff --git a/codegen/testserver/generated_test.go b/codegen/testserver/generated_test.go index fddcb0e8098..18acca12e09 100644 --- a/codegen/testserver/generated_test.go +++ b/codegen/testserver/generated_test.go @@ -211,6 +211,44 @@ func TestDirectives(t *testing.T) { } return nil, errors.New(message) }, + Range: func(ctx context.Context, obj interface{}, next graphql.Resolver, min *int, max *int, message *string) (res interface{}, err error) { + if obj == nil { + return next(ctx) + } + if message == nil { + err = errors.New("range invalid") + }else{ + err = errors.New(*message) + } + if d, ok := obj.(int); ok { + if min != nil && d < *min { + return nil, err + } + if max != nil && d > *max { + return nil, err + } + return next(ctx) + } + if d, ok := obj.(int64); ok { + if min != nil && int(d) < *min { + return nil, err + } + if max != nil && int(d) > *max { + return nil, err + } + return next(ctx) + } + if d, ok := obj.(*int); ok { + if min != nil && *d < *min { + return nil, err + } + if max != nil && *d > *max { + return nil, err + } + return next(ctx) + } + return nil, err + }, }, }), handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { @@ -235,6 +273,36 @@ func TestDirectives(t *testing.T) { require.EqualError(t, err, `[{"message":"invalid length","path":["directiveArg"]}]`) require.Nil(t, resp.DirectiveArg) }) + t.Run("when function errors on nullable arg directives", func(t *testing.T) { + var resp struct { + DirectiveNullableArg *string + } + + err := c.Post(`query { directiveNullableArg(arg: -100) }`, &resp) + + require.EqualError(t, err, `[{"message":"range invalid","path":["directiveNullableArg"]}]`) + require.Nil(t, resp.DirectiveNullableArg) + }) + t.Run("when function success on nullable arg directives", func(t *testing.T) { + var resp struct { + DirectiveNullableArg *string + } + + err := c.Post(`query { directiveNullableArg }`, &resp) + + require.Nil(t, err) + require.Equal(t, "Ok", *resp.DirectiveNullableArg) + }) + t.Run("when function success on valid nullable arg directives", func(t *testing.T) { + var resp struct { + DirectiveNullableArg *string + } + + err := c.Post(`query { directiveNullableArg(arg: 1) }`, &resp) + + require.Nil(t, err) + require.Equal(t, "Ok", *resp.DirectiveNullableArg) + }) t.Run("when function success", func(t *testing.T) { var resp struct { DirectiveArg *string @@ -817,6 +885,11 @@ func (r *testQueryResolver) DirectiveArg(ctx context.Context, arg string) (*stri return &s, nil } +func (r *testQueryResolver) DirectiveNullableArg(ctx context.Context, arg *int) (*string, error) { + s := "Ok" + return &s, nil +} + func (r *testQueryResolver) DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) { s := "Ok" return &s, nil diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index 702e64ed066..ac7308b1480 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -81,6 +81,9 @@ func (r *queryResolver) NullableArg(ctx context.Context, arg *int) (*string, err func (r *queryResolver) DirectiveArg(ctx context.Context, arg string) (*string, error) { panic("not implemented") } +func (r *queryResolver) DirectiveNullableArg(ctx context.Context, arg *int) (*string, error) { + panic("not implemented") +} func (r *queryResolver) DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) { panic("not implemented") } diff --git a/codegen/testserver/schema.graphql b/codegen/testserver/schema.graphql index a75b9720b60..0d949f3550a 100644 --- a/codegen/testserver/schema.graphql +++ b/codegen/testserver/schema.graphql @@ -13,6 +13,7 @@ type Query { user(id: Int!): User! nullableArg(arg: Int = 123): String directiveArg(arg: String! @length(min:1, max: 255, message: "invalid length")): String + directiveNullableArg(arg: Int @range(min:0)): String directiveInputNullable(arg: InputDirectives): String directiveInput(arg: InputDirectives!): String } @@ -164,4 +165,5 @@ type EmbeddedPointer { Title: String } -directive @length(min: Int!, max: Int, message: String!) on ARGUMENT_DEFINITION +directive @length(min: Int!, max: Int, message: String!) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION +directive @range(min: Int, max: Int, message: String) on ARGUMENT_DEFINITION diff --git a/codegen/type.go b/codegen/type.go index 6390ddaa048..5309c1fbe1f 100644 --- a/codegen/type.go +++ b/codegen/type.go @@ -169,6 +169,7 @@ func (t Type) middleware(result, raw string, remainingMods []string, depth int) if len(remainingMods) == 1 && remainingMods[0] == modPtr { return tpl(`{{- if .t.Marshaler }} if {{.raw}} != nil { + var err error {{.result}}, err = e.{{ .t.GQLType }}Middleware(ctx, {{.raw}}) if err != nil { return nil, err @@ -206,7 +207,7 @@ func (t Type) middleware(result, raw string, remainingMods []string, depth int) }) } - ptr := "mTmp" + strconv.Itoa(depth) + ptr := "m" + t.GQLType + strconv.Itoa(depth) return tpl(`{{- if .t.Marshaler }} {{.ptr}}, err := e.{{ .t.GQLType }}Middleware(ctx, &{{.raw}}) if err != nil { diff --git a/example/config/generated.go b/example/config/generated.go index e807413377f..b83f99200fa 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -83,11 +83,11 @@ func (e *executableSchema) field_Mutation_createTodo_args(ctx context.Context, r return nil, err } - mTmp1, err := e.NewTodoMiddleware(ctx, &arg0) + mNewTodo1, err := e.NewTodoMiddleware(ctx, &arg0) if err != nil { return nil, err } - arg0 = *mTmp1 + arg0 = *mNewTodo1 } args["input"] = arg0 diff --git a/example/scalars/generated.go b/example/scalars/generated.go index b4e2de2ab7d..632d056cfc0 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -105,6 +105,7 @@ func (e *executableSchema) field_Query_search_args(ctx context.Context, rawArgs } if arg0 != nil { + var err error arg0, err = e.SearchArgsMiddleware(ctx, arg0) if err != nil { return nil, err diff --git a/example/starwars/generated.go b/example/starwars/generated.go index a591a364509..ced883bf3d5 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -244,11 +244,11 @@ func (e *executableSchema) field_Mutation_createReview_args(ctx context.Context, return nil, err } - mTmp1, err := e.ReviewInputMiddleware(ctx, &arg1) + mReviewInput1, err := e.ReviewInputMiddleware(ctx, &arg1) if err != nil { return nil, err } - arg1 = *mTmp1 + arg1 = *mReviewInput1 } args["review"] = arg1 diff --git a/example/todo/generated.go b/example/todo/generated.go index efe87e438a8..0026f9ffed5 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -79,11 +79,11 @@ func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, return nil, err } - mTmp1, err := e.TodoInputMiddleware(ctx, &arg0) + mTodoInput1, err := e.TodoInputMiddleware(ctx, &arg0) if err != nil { return nil, err } - arg0 = *mTmp1 + arg0 = *mTodoInput1 } args["todo"] = arg0 diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index d7010d59cd9..b8d9d78f4f1 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -89,11 +89,11 @@ func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, return nil, err } - mTmp1, err := e.TodoInputMiddleware(ctx, &arg0) + mTodoInput1, err := e.TodoInputMiddleware(ctx, &arg0) if err != nil { return nil, err } - arg0 = *mTmp1 + arg0 = *mTodoInput1 } args["todo"] = arg0 diff --git a/integration/generated.go b/integration/generated.go index fc6714fac15..bd2dfa8c26c 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -94,11 +94,11 @@ func (e *executableSchema) field_Query_date_args(ctx context.Context, rawArgs ma return nil, err } - mTmp1, err := e.DateFilterMiddleware(ctx, &arg0) + mDateFilter1, err := e.DateFilterMiddleware(ctx, &arg0) if err != nil { return nil, err } - arg0 = *mTmp1 + arg0 = *mDateFilter1 } args["filter"] = arg0 From 740960331927b0d7af1e80fca0f3bc4825fa74de Mon Sep 17 00:00:00 2001 From: asamusev Date: Mon, 3 Dec 2018 09:39:28 +0300 Subject: [PATCH 010/147] move chainFieldMiddleware to generate code for BC --- codegen/templates/args.gotpl | 2 +- codegen/templates/data.go | 6 ++-- codegen/templates/generated.gotpl | 36 +++++++++++++++++++ codegen/templates/input.gotpl | 4 +-- codegen/testserver/generated.go | 42 +++++++++++++++++++--- example/chat/generated.go | 34 ++++++++++++++++++ example/config/generated.go | 34 ++++++++++++++++++ example/dataloader/generated.go | 34 ++++++++++++++++++ example/scalars/generated.go | 34 ++++++++++++++++++ example/selection/generated.go | 34 ++++++++++++++++++ example/starwars/generated.go | 34 ++++++++++++++++++ example/todo/generated.go | 34 ++++++++++++++++++ example/type-system-extension/generated.go | 36 ++++++++++++++++++- integration/generated.go | 34 ++++++++++++++++++ 14 files changed, 387 insertions(+), 11 deletions(-) diff --git a/codegen/templates/args.gotpl b/codegen/templates/args.gotpl index b38bb09622d..16c8684ec2c 100644 --- a/codegen/templates/args.gotpl +++ b/codegen/templates/args.gotpl @@ -4,7 +4,7 @@ if tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok { {{- if or $arg.Directives $arg.IsInput }} {{ if $arg.Directives }} - argm{{$i}}, err := graphql.ChainFieldMiddleware([]graphql.FieldMiddleware{ + argm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{ {{- range $directive := $arg.Directives }} func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { {{- range $dArg := $directive.Args }} diff --git a/codegen/templates/data.go b/codegen/templates/data.go index 8637f8bc3af..34dfbbb30f9 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -1,10 +1,10 @@ package templates var data = map[string]string{ - "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := graphql.ChainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $dArg.IsPtr (not (eq ($dArg.Value|dump) \"nil\")) }}{{ $dArg.GoVarName }} := {{ $dArg.Value|dump }}{{ end -}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){\n\t\t\t\t\t{{$arg.Unmarshal (print \"args\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t {{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\tvar err error\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", + "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $dArg.IsPtr (not (eq ($dArg.Value|dump) \"nil\")) }}{{ $dArg.GoVarName }} := {{ $dArg.Value|dump }}{{ end -}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){\n\t\t\t\t\t{{$arg.Unmarshal (print \"args\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t {{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\tvar err error\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\n\t\tresults, err := ec.resolvers.{{ $field.ShortInvocation }}\n\t\tif err != nil {\n\t\t\tec.Error(ctx, err)\n\t\t\treturn nil\n\t\t}\n\t\treturn func() graphql.Marshaler {\n\t\t\tres, ok := <-results\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tvar out graphql.OrderedMap\n\t\t\tout.Add(field.Alias, func() graphql.Marshaler { {{ $field.WriteJson }} }())\n\t\t\treturn &out\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tField: field,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := graphql.ChainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t{{ $resolveName := \"\" }}\n\t\t{{ if $field.IsPtr }}\n\t\t\t{{ $resolveName := \"*\" }}\n\t\t{{ end }}\n\t\t\tc{{$field.GoFieldName}}, err := graphql.ChainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print $resolveName \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{$resolveName}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\n", + "generated.gotpl": "// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.\n\npackage {{ .PackageName }}\n\nimport (\n\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\n)\n\n\n\n// ChainFieldMiddleware add chain by FieldMiddleware\nfunc chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware {\n\tn := len(handleFunc)\n\n\tif n > 1 {\n\t\tlastI := n - 1\n\t\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\t\tvar (\n\t\t\t\tchainHandler graphql.Resolver\n\t\t\t\tcurI int\n\t\t\t)\n\t\t\tchainHandler = func(currentCtx context.Context) (interface{}, error) {\n\t\t\t\tif curI == lastI {\n\t\t\t\t\treturn next(currentCtx)\n\t\t\t\t}\n\t\t\t\tcurI++\n\t\t\t\tres, err := handleFunc[curI](currentCtx, chainHandler)\n\t\t\t\tcurI--\n\t\t\t\treturn res, err\n\n\t\t\t}\n\t\t\treturn handleFunc[0](ctx, chainHandler)\n\t\t}\n\t}\n\n\tif n == 1 {\n\t\treturn handleFunc[0]\n\t}\n\n\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\treturn next(ctx)\n\t}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := chainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t{{ $resolveName := \"\" }}\n\t\t{{ if $field.IsPtr }}\n\t\t\t{{ $resolveName := \"*\" }}\n\t\t{{ end }}\n\t\t\tc{{$field.GoFieldName}}, err := chainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print $resolveName \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{$resolveName}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{ range $model := .Models }}\n\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .IsInterface }}\n\t\ttype {{.GoType}} interface {\n\t\t\tIs{{.GoType}}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.GoType}} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\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\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.GoType}}) Is{{$iface.GoType}}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.GoType}} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- 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\n\t{{if $object.IsConcurrent}} var wg sync.WaitGroup {{end}}\n\tout := graphql.NewOrderedMap(len(fields))\n\tinvalid := false\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\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t{{- 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\tif invalid { return graphql.Null }\n\treturn out\n}\n{{- end }}\n", diff --git a/codegen/templates/generated.gotpl b/codegen/templates/generated.gotpl index 9776f1bcb62..b99dfd77490 100644 --- a/codegen/templates/generated.gotpl +++ b/codegen/templates/generated.gotpl @@ -283,3 +283,39 @@ var parsedSchema = gqlparser.MustLoadSchema( &ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}}, {{- end }} ) + + + +// ChainFieldMiddleware add chain by FieldMiddleware +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + + } + return handleFunc[0](ctx, chainHandler) + } + } + + if n == 1 { + return handleFunc[0] + } + + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) + } +} diff --git a/codegen/templates/input.gotpl b/codegen/templates/input.gotpl index 4a7b779c42b..f7beaaba1f1 100644 --- a/codegen/templates/input.gotpl +++ b/codegen/templates/input.gotpl @@ -29,7 +29,7 @@ func (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) { {{ if .Directives }} - cObj, err := graphql.ChainFieldMiddleware( + cObj, err := chainFieldMiddleware( []graphql.FieldMiddleware{ {{- range $directive := .Directives }} func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { @@ -64,7 +64,7 @@ {{ if $field.IsPtr }} {{ $resolveName := "*" }} {{ end }} - c{{$field.GoFieldName}}, err := graphql.ChainFieldMiddleware( + c{{$field.GoFieldName}}, err := chainFieldMiddleware( []graphql.FieldMiddleware{ {{- range $directive := $field.Directives }} func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 657b5cf4897..ccf44448f66 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -341,7 +341,7 @@ func (e *executableSchema) field_Query_directiveArg_args(ctx context.Context, ra var arg0 string if tmp, ok := rawArgs["arg"]; ok { - argm0, err := graphql.ChainFieldMiddleware([]graphql.FieldMiddleware{ + argm0, err := chainFieldMiddleware([]graphql.FieldMiddleware{ func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { max := 255 return e.directives.Length(ctx, tmp, n, 1, &max, "invalid length") @@ -373,7 +373,7 @@ func (e *executableSchema) field_Query_directiveNullableArg_args(ctx context.Con var arg0 *int if tmp, ok := rawArgs["arg"]; ok { - argm0, err := graphql.ChainFieldMiddleware([]graphql.FieldMiddleware{ + argm0, err := chainFieldMiddleware([]graphql.FieldMiddleware{ func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { min := 0 return e.directives.Range(ctx, tmp, n, &min, nil, nil) @@ -4587,7 +4587,7 @@ func UnmarshalInnerDirectives(v interface{}) (InnerDirectives, error) { func (e *executableSchema) InnerDirectivesMiddleware(ctx context.Context, obj *InnerDirectives) (*InnerDirectives, error) { - cMessage, err := graphql.ChainFieldMiddleware( + cMessage, err := chainFieldMiddleware( []graphql.FieldMiddleware{ func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { return e.directives.Length(ctx, obj.Message, n, 1, nil, "not valid") @@ -4669,7 +4669,7 @@ func UnmarshalInputDirectives(v interface{}) (InputDirectives, error) { func (e *executableSchema) InputDirectivesMiddleware(ctx context.Context, obj *InputDirectives) (*InputDirectives, error) { - cText, err := graphql.ChainFieldMiddleware( + cText, err := chainFieldMiddleware( []graphql.FieldMiddleware{ func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { max := 7 @@ -5174,3 +5174,37 @@ directive @length(min: Int!, max: Int, message: String!) on ARGUMENT_DEFINITION directive @range(min: Int, max: Int, message: String) on ARGUMENT_DEFINITION `}, ) + +// ChainFieldMiddleware add chain by FieldMiddleware +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + + } + return handleFunc[0](ctx, chainHandler) + } + } + + if n == 1 { + return handleFunc[0] + } + + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) + } +} diff --git a/example/chat/generated.go b/example/chat/generated.go index d612795015f..1007289da1f 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -2349,3 +2349,37 @@ type Subscription { scalar Time `}, ) + +// ChainFieldMiddleware add chain by FieldMiddleware +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + + } + return handleFunc[0](ctx, chainHandler) + } + } + + if n == 1 { + return handleFunc[0] + } + + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) + } +} diff --git a/example/config/generated.go b/example/config/generated.go index b83f99200fa..5a0441ae5af 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -2275,3 +2275,37 @@ input NewTodo { } `}, ) + +// ChainFieldMiddleware add chain by FieldMiddleware +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + + } + return handleFunc[0](ctx, chainHandler) + } + } + + if n == 1 { + return handleFunc[0] + } + + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) + } +} diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index aa91b9fe462..e12bf05cec4 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -2700,3 +2700,37 @@ type Item { scalar Time `}, ) + +// ChainFieldMiddleware add chain by FieldMiddleware +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + + } + return handleFunc[0](ctx, chainHandler) + } + } + + if n == 1 { + return handleFunc[0] + } + + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) + } +} diff --git a/example/scalars/generated.go b/example/scalars/generated.go index 632d056cfc0..0520ac9eab9 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -2396,3 +2396,37 @@ scalar Timestamp scalar Point `}, ) + +// ChainFieldMiddleware add chain by FieldMiddleware +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + + } + return handleFunc[0](ctx, chainHandler) + } + } + + if n == 1 { + return handleFunc[0] + } + + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) + } +} diff --git a/example/selection/generated.go b/example/selection/generated.go index 52fb1cc0a7e..1e0022dc45d 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -2174,3 +2174,37 @@ type Query { scalar Time `}, ) + +// ChainFieldMiddleware add chain by FieldMiddleware +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + + } + return handleFunc[0](ctx, chainHandler) + } + } + + if n == 1 { + return handleFunc[0] + } + + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) + } +} diff --git a/example/starwars/generated.go b/example/starwars/generated.go index ced883bf3d5..c2812d77ae1 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -4314,3 +4314,37 @@ union SearchResult = Human | Droid | Starship scalar Time `}, ) + +// ChainFieldMiddleware add chain by FieldMiddleware +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + + } + return handleFunc[0](ctx, chainHandler) + } + } + + if n == 1 { + return handleFunc[0] + } + + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) + } +} diff --git a/example/todo/generated.go b/example/todo/generated.go index 0026f9ffed5..014affba9dc 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -2321,3 +2321,37 @@ enum Role { } `}, ) + +// ChainFieldMiddleware add chain by FieldMiddleware +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + + } + return handleFunc[0](ctx, chainHandler) + } + } + + if n == 1 { + return handleFunc[0] + } + + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) + } +} diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index b8d9d78f4f1..ff4ac1577af 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -2163,7 +2163,7 @@ func UnmarshalTodoInput(v interface{}) (TodoInput, error) { func (e *executableSchema) TodoInputMiddleware(ctx context.Context, obj *TodoInput) (*TodoInput, error) { - cObj, err := graphql.ChainFieldMiddleware( + cObj, err := chainFieldMiddleware( []graphql.FieldMiddleware{ func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { return e.directives.InputLogging(ctx, obj, n) @@ -2343,3 +2343,37 @@ extend type Todo { extend union Data @unionLogging `}, ) + +// ChainFieldMiddleware add chain by FieldMiddleware +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + + } + return handleFunc[0](ctx, chainHandler) + } + } + + if n == 1 { + return handleFunc[0] + } + + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) + } +} diff --git a/integration/generated.go b/integration/generated.go index bd2dfa8c26c..b8dbc0fa3ac 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -2498,3 +2498,37 @@ enum ErrorType { } `}, ) + +// ChainFieldMiddleware add chain by FieldMiddleware +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + + } + return handleFunc[0](ctx, chainHandler) + } + } + + if n == 1 { + return handleFunc[0] + } + + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) + } +} From 428c6300f3f6ddbde7182e56a096307447686109 Mon Sep 17 00:00:00 2001 From: asamusev Date: Mon, 3 Dec 2018 10:19:09 +0300 Subject: [PATCH 011/147] add nullable argument to directives --- codegen/templates/args.gotpl | 10 +++++++++- codegen/templates/data.go | 4 ++-- codegen/templates/input.gotpl | 24 ++++++++++++++++-------- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/codegen/templates/args.gotpl b/codegen/templates/args.gotpl index 16c8684ec2c..73703931a53 100644 --- a/codegen/templates/args.gotpl +++ b/codegen/templates/args.gotpl @@ -8,7 +8,15 @@ {{- range $directive := $arg.Directives }} func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { {{- range $dArg := $directive.Args }} - {{- if and $dArg.IsPtr (not (eq ($dArg.Value|dump) "nil")) }}{{ $dArg.GoVarName }} := {{ $dArg.Value|dump }}{{ end -}} + {{- if $dArg.IsPtr }} + {{- $argValue := $dArg.Value | dump -}} + {{- $argDefault := $dArg.Default | dump -}} + {{- if not (eq $argValue "nil") }} + {{ $dArg.GoVarName }} := {{ $argValue }} + {{- else if not (eq $argDefault "nil") }} + {{ $dArg.GoVarName }} := {{ $argDefault }} + {{- end }} + {{- end }} {{- end }} return e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs "tmp" "n" }}) }, diff --git a/codegen/templates/data.go b/codegen/templates/data.go index 34dfbbb30f9..63fb2242977 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -1,10 +1,10 @@ package templates var data = map[string]string{ - "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $dArg.IsPtr (not (eq ($dArg.Value|dump) \"nil\")) }}{{ $dArg.GoVarName }} := {{ $dArg.Value|dump }}{{ end -}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){\n\t\t\t\t\t{{$arg.Unmarshal (print \"args\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t {{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\tvar err error\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", + "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if $dArg.IsPtr }}\n\t\t\t\t\t\t\t\t{{- $argValue := $dArg.Value | dump -}}\n\t\t\t\t\t\t\t\t{{- $argDefault := $dArg.Default | dump -}}\n\t\t\t\t\t\t\t\t{{- if not (eq $argValue \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $argValue }}\n\t\t\t\t\t\t\t\t{{- else if not (eq $argDefault \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $argDefault }}\n\t\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){\n\t\t\t\t\t{{$arg.Unmarshal (print \"args\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t {{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\tvar err error\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\n\t\tresults, err := ec.resolvers.{{ $field.ShortInvocation }}\n\t\tif err != nil {\n\t\t\tec.Error(ctx, err)\n\t\t\treturn nil\n\t\t}\n\t\treturn func() graphql.Marshaler {\n\t\t\tres, ok := <-results\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tvar out graphql.OrderedMap\n\t\t\tout.Add(field.Alias, func() graphql.Marshaler { {{ $field.WriteJson }} }())\n\t\t\treturn &out\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tField: field,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\n)\n\n\n\n// ChainFieldMiddleware add chain by FieldMiddleware\nfunc chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware {\n\tn := len(handleFunc)\n\n\tif n > 1 {\n\t\tlastI := n - 1\n\t\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\t\tvar (\n\t\t\t\tchainHandler graphql.Resolver\n\t\t\t\tcurI int\n\t\t\t)\n\t\t\tchainHandler = func(currentCtx context.Context) (interface{}, error) {\n\t\t\t\tif curI == lastI {\n\t\t\t\t\treturn next(currentCtx)\n\t\t\t\t}\n\t\t\t\tcurI++\n\t\t\t\tres, err := handleFunc[curI](currentCtx, chainHandler)\n\t\t\t\tcurI--\n\t\t\t\treturn res, err\n\n\t\t\t}\n\t\t\treturn handleFunc[0](ctx, chainHandler)\n\t\t}\n\t}\n\n\tif n == 1 {\n\t\treturn handleFunc[0]\n\t}\n\n\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\treturn next(ctx)\n\t}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := chainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t{{ $resolveName := \"\" }}\n\t\t{{ if $field.IsPtr }}\n\t\t\t{{ $resolveName := \"*\" }}\n\t\t{{ end }}\n\t\t\tc{{$field.GoFieldName}}, err := chainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr $arg.Value }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Value | dump}}\n\t\t\t\t\t\t\t{{ else if and $arg.IsPtr $arg.Default }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}}:={{ $arg.Default | dump}}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print $resolveName \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{$resolveName}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := chainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if $arg.IsPtr }}\n\t\t\t\t\t\t\t{{- $argValue := $arg.Value | dump -}}\n\t\t\t\t\t\t\t{{- $argDefault := $arg.Default | dump -}}\n\t\t\t\t\t\t\t{{- if not (eq $argValue \"nil\") }}\n\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $argValue }}\n\t\t\t\t\t\t\t{{ else if not (eq $argDefault \"nil\") }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}} := {{ $argDefault }}\n\t\t\t\t\t\t\t{{ end -}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t{{ $resolveName := \"\" }}\n\t\t{{ if $field.IsPtr }}\n\t\t\t{{ $resolveName := \"*\" }}\n\t\t{{ end }}\n\t\t\tc{{$field.GoFieldName}}, err := chainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if $arg.IsPtr }}\n\t\t\t\t\t\t\t\t{{- $argValue := $arg.Value | dump -}}\n\t\t\t\t\t\t\t\t{{- $argDefault := $arg.Default | dump -}}\n\t\t\t\t\t\t\t\t{{- if not (eq $argValue \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $argValue }}\n\t\t\t\t\t\t\t\t{{ else if not (eq $argDefault \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $argDefault }}\n\t\t\t\t\t\t\t\t{{ end -}}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print $resolveName \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{$resolveName}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{ range $model := .Models }}\n\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .IsInterface }}\n\t\ttype {{.GoType}} interface {\n\t\t\tIs{{.GoType}}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.GoType}} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\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\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.GoType}}) Is{{$iface.GoType}}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.GoType}} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- 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\n\t{{if $object.IsConcurrent}} var wg sync.WaitGroup {{end}}\n\tout := graphql.NewOrderedMap(len(fields))\n\tinvalid := false\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\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t{{- 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\tif invalid { return graphql.Null }\n\treturn out\n}\n{{- end }}\n", diff --git a/codegen/templates/input.gotpl b/codegen/templates/input.gotpl index f7beaaba1f1..5f2ffbbe830 100644 --- a/codegen/templates/input.gotpl +++ b/codegen/templates/input.gotpl @@ -35,10 +35,14 @@ func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { {{- if $directive.Args }} {{- range $arg := $directive.Args }} - {{- if and $arg.IsPtr $arg.Value }} - {{$arg.GoVarName}}:={{ $arg.Value | dump}} - {{ else if and $arg.IsPtr $arg.Default }} - {{$arg.GoVarName}}:={{ $arg.Default | dump}} + {{- if $arg.IsPtr }} + {{- $argValue := $arg.Value | dump -}} + {{- $argDefault := $arg.Default | dump -}} + {{- if not (eq $argValue "nil") }} + {{ $arg.GoVarName }} := {{ $argValue }} + {{ else if not (eq $argDefault "nil") }} + {{$arg.GoVarName}} := {{ $argDefault }} + {{ end -}} {{- end }} {{- end }} {{- end -}} @@ -70,10 +74,14 @@ func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { {{- if $directive.Args }} {{- range $arg := $directive.Args }} - {{- if and $arg.IsPtr $arg.Value }} - {{$arg.GoVarName}}:={{ $arg.Value | dump}} - {{ else if and $arg.IsPtr $arg.Default }} - {{$arg.GoVarName}}:={{ $arg.Default | dump}} + {{- if $arg.IsPtr }} + {{- $argValue := $arg.Value | dump -}} + {{- $argDefault := $arg.Default | dump -}} + {{- if not (eq $argValue "nil") }} + {{ $arg.GoVarName }} := {{ $argValue }} + {{ else if not (eq $argDefault "nil") }} + {{ $arg.GoVarName }} := {{ $argDefault }} + {{ end -}} {{- end }} {{- end }} {{- end -}} From 139ed9fb048a34598cc153f3e8ef3b6b6fa8b220 Mon Sep 17 00:00:00 2001 From: asamusev Date: Mon, 3 Dec 2018 15:20:13 +0300 Subject: [PATCH 012/147] fix go10 assign exist variable by eq --- codegen/templates/data.go | 2 +- codegen/templates/input.gotpl | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/codegen/templates/data.go b/codegen/templates/data.go index 63fb2242977..c2c416a1258 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -4,7 +4,7 @@ var data = map[string]string{ "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if $dArg.IsPtr }}\n\t\t\t\t\t\t\t\t{{- $argValue := $dArg.Value | dump -}}\n\t\t\t\t\t\t\t\t{{- $argDefault := $dArg.Default | dump -}}\n\t\t\t\t\t\t\t\t{{- if not (eq $argValue \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $argValue }}\n\t\t\t\t\t\t\t\t{{- else if not (eq $argDefault \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $argDefault }}\n\t\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){\n\t\t\t\t\t{{$arg.Unmarshal (print \"args\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t {{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\tvar err error\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\n\t\tresults, err := ec.resolvers.{{ $field.ShortInvocation }}\n\t\tif err != nil {\n\t\t\tec.Error(ctx, err)\n\t\t\treturn nil\n\t\t}\n\t\treturn func() graphql.Marshaler {\n\t\t\tres, ok := <-results\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tvar out graphql.OrderedMap\n\t\t\tout.Add(field.Alias, func() graphql.Marshaler { {{ $field.WriteJson }} }())\n\t\t\treturn &out\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tField: field,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\n)\n\n\n\n// ChainFieldMiddleware add chain by FieldMiddleware\nfunc chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware {\n\tn := len(handleFunc)\n\n\tif n > 1 {\n\t\tlastI := n - 1\n\t\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\t\tvar (\n\t\t\t\tchainHandler graphql.Resolver\n\t\t\t\tcurI int\n\t\t\t)\n\t\t\tchainHandler = func(currentCtx context.Context) (interface{}, error) {\n\t\t\t\tif curI == lastI {\n\t\t\t\t\treturn next(currentCtx)\n\t\t\t\t}\n\t\t\t\tcurI++\n\t\t\t\tres, err := handleFunc[curI](currentCtx, chainHandler)\n\t\t\t\tcurI--\n\t\t\t\treturn res, err\n\n\t\t\t}\n\t\t\treturn handleFunc[0](ctx, chainHandler)\n\t\t}\n\t}\n\n\tif n == 1 {\n\t\treturn handleFunc[0]\n\t}\n\n\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\treturn next(ctx)\n\t}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := chainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if $arg.IsPtr }}\n\t\t\t\t\t\t\t{{- $argValue := $arg.Value | dump -}}\n\t\t\t\t\t\t\t{{- $argDefault := $arg.Default | dump -}}\n\t\t\t\t\t\t\t{{- if not (eq $argValue \"nil\") }}\n\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $argValue }}\n\t\t\t\t\t\t\t{{ else if not (eq $argDefault \"nil\") }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}} := {{ $argDefault }}\n\t\t\t\t\t\t\t{{ end -}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t{{ $resolveName := \"\" }}\n\t\t{{ if $field.IsPtr }}\n\t\t\t{{ $resolveName := \"*\" }}\n\t\t{{ end }}\n\t\t\tc{{$field.GoFieldName}}, err := chainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if $arg.IsPtr }}\n\t\t\t\t\t\t\t\t{{- $argValue := $arg.Value | dump -}}\n\t\t\t\t\t\t\t\t{{- $argDefault := $arg.Default | dump -}}\n\t\t\t\t\t\t\t\t{{- if not (eq $argValue \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $argValue }}\n\t\t\t\t\t\t\t\t{{ else if not (eq $argDefault \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $argDefault }}\n\t\t\t\t\t\t\t\t{{ end -}}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print $resolveName \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{$resolveName}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := chainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if $arg.IsPtr }}\n\t\t\t\t\t\t\t{{- $argValue := $arg.Value | dump -}}\n\t\t\t\t\t\t\t{{- $argDefault := $arg.Default | dump -}}\n\t\t\t\t\t\t\t{{- if not (eq $argValue \"nil\") }}\n\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $argValue }}\n\t\t\t\t\t\t\t{{ else if not (eq $argDefault \"nil\") }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}} := {{ $argDefault }}\n\t\t\t\t\t\t\t{{ end -}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t\tc{{$field.GoFieldName}}, err := chainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if $arg.IsPtr }}\n\t\t\t\t\t\t\t\t{{- $argValue := $arg.Value | dump -}}\n\t\t\t\t\t\t\t\t{{- $argDefault := $arg.Default | dump -}}\n\t\t\t\t\t\t\t\t{{- if not (eq $argValue \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $argValue }}\n\t\t\t\t\t\t\t\t{{ else if not (eq $argDefault \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $argDefault }}\n\t\t\t\t\t\t\t\t{{ end -}}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\t\t{{ if $field.IsPtr }}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"*obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{ else }}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{ if $field.IsPtr }}*{{end}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{ range $model := .Models }}\n\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .IsInterface }}\n\t\ttype {{.GoType}} interface {\n\t\t\tIs{{.GoType}}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.GoType}} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\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\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.GoType}}) Is{{$iface.GoType}}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.GoType}} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- 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\n\t{{if $object.IsConcurrent}} var wg sync.WaitGroup {{end}}\n\tout := graphql.NewOrderedMap(len(fields))\n\tinvalid := false\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\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t{{- 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\tif invalid { return graphql.Null }\n\treturn out\n}\n{{- end }}\n", diff --git a/codegen/templates/input.gotpl b/codegen/templates/input.gotpl index 5f2ffbbe830..a73f3be0521 100644 --- a/codegen/templates/input.gotpl +++ b/codegen/templates/input.gotpl @@ -64,10 +64,6 @@ {{- range $field := .Fields }} {{ if $field.HasDirectives }} - {{ $resolveName := "" }} - {{ if $field.IsPtr }} - {{ $resolveName := "*" }} - {{ end }} c{{$field.GoFieldName}}, err := chainFieldMiddleware( []graphql.FieldMiddleware{ {{- range $directive := $field.Directives }} @@ -85,12 +81,16 @@ {{- end }} {{- end }} {{- end -}} - return e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print $resolveName "obj." $field.GoFieldName ) "n"}}) + {{ if $field.IsPtr }} + return e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print "*obj." $field.GoFieldName ) "n"}}) + {{ else }} + return e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print "obj." $field.GoFieldName ) "n"}}) + {{ end }} }, {{ end }} }... )(ctx, func(ctx context.Context)(interface{}, error){ - return {{$resolveName}}obj.{{$field.GoFieldName}}, nil + return {{ if $field.IsPtr }}*{{end}}obj.{{$field.GoFieldName}}, nil }) if err != nil { return obj ,err From 6fa6364004f9140e62b2b873f0fb5bf344dd68f7 Mon Sep 17 00:00:00 2001 From: asamusev Date: Mon, 3 Dec 2018 15:24:39 +0300 Subject: [PATCH 013/147] remove empty line in generated files --- codegen/templates/data.go | 2 +- codegen/templates/input.gotpl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/codegen/templates/data.go b/codegen/templates/data.go index c2c416a1258..9bc53ec1957 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -4,7 +4,7 @@ var data = map[string]string{ "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if $dArg.IsPtr }}\n\t\t\t\t\t\t\t\t{{- $argValue := $dArg.Value | dump -}}\n\t\t\t\t\t\t\t\t{{- $argDefault := $dArg.Default | dump -}}\n\t\t\t\t\t\t\t\t{{- if not (eq $argValue \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $argValue }}\n\t\t\t\t\t\t\t\t{{- else if not (eq $argDefault \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $argDefault }}\n\t\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){\n\t\t\t\t\t{{$arg.Unmarshal (print \"args\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t {{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\tvar err error\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\n\t\tresults, err := ec.resolvers.{{ $field.ShortInvocation }}\n\t\tif err != nil {\n\t\t\tec.Error(ctx, err)\n\t\t\treturn nil\n\t\t}\n\t\treturn func() graphql.Marshaler {\n\t\t\tres, ok := <-results\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tvar out graphql.OrderedMap\n\t\t\tout.Add(field.Alias, func() graphql.Marshaler { {{ $field.WriteJson }} }())\n\t\t\treturn &out\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tField: field,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\n)\n\n\n\n// ChainFieldMiddleware add chain by FieldMiddleware\nfunc chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware {\n\tn := len(handleFunc)\n\n\tif n > 1 {\n\t\tlastI := n - 1\n\t\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\t\tvar (\n\t\t\t\tchainHandler graphql.Resolver\n\t\t\t\tcurI int\n\t\t\t)\n\t\t\tchainHandler = func(currentCtx context.Context) (interface{}, error) {\n\t\t\t\tif curI == lastI {\n\t\t\t\t\treturn next(currentCtx)\n\t\t\t\t}\n\t\t\t\tcurI++\n\t\t\t\tres, err := handleFunc[curI](currentCtx, chainHandler)\n\t\t\t\tcurI--\n\t\t\t\treturn res, err\n\n\t\t\t}\n\t\t\treturn handleFunc[0](ctx, chainHandler)\n\t\t}\n\t}\n\n\tif n == 1 {\n\t\treturn handleFunc[0]\n\t}\n\n\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\treturn next(ctx)\n\t}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := chainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if $arg.IsPtr }}\n\t\t\t\t\t\t\t{{- $argValue := $arg.Value | dump -}}\n\t\t\t\t\t\t\t{{- $argDefault := $arg.Default | dump -}}\n\t\t\t\t\t\t\t{{- if not (eq $argValue \"nil\") }}\n\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $argValue }}\n\t\t\t\t\t\t\t{{ else if not (eq $argDefault \"nil\") }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}} := {{ $argDefault }}\n\t\t\t\t\t\t\t{{ end -}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t\tc{{$field.GoFieldName}}, err := chainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if $arg.IsPtr }}\n\t\t\t\t\t\t\t\t{{- $argValue := $arg.Value | dump -}}\n\t\t\t\t\t\t\t\t{{- $argDefault := $arg.Default | dump -}}\n\t\t\t\t\t\t\t\t{{- if not (eq $argValue \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $argValue }}\n\t\t\t\t\t\t\t\t{{ else if not (eq $argDefault \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $argDefault }}\n\t\t\t\t\t\t\t\t{{ end -}}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\t\t{{ if $field.IsPtr }}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"*obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{ else }}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{ if $field.IsPtr }}*{{end}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := chainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if $arg.IsPtr }}\n\t\t\t\t\t\t\t{{- $argValue := $arg.Value | dump -}}\n\t\t\t\t\t\t\t{{- $argDefault := $arg.Default | dump -}}\n\t\t\t\t\t\t\t{{- if not (eq $argValue \"nil\") }}\n\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $argValue }}\n\t\t\t\t\t\t\t{{ else if not (eq $argDefault \"nil\") }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}} := {{ $argDefault }}\n\t\t\t\t\t\t\t{{ end -}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t\tc{{$field.GoFieldName}}, err := chainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if $arg.IsPtr }}\n\t\t\t\t\t\t\t\t{{- $argValue := $arg.Value | dump -}}\n\t\t\t\t\t\t\t\t{{- $argDefault := $arg.Default | dump -}}\n\t\t\t\t\t\t\t\t{{- if not (eq $argValue \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $argValue }}\n\t\t\t\t\t\t\t\t{{ else if not (eq $argDefault \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $argDefault }}\n\t\t\t\t\t\t\t\t{{ end -}}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\t\t{{ if $field.IsPtr -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"*obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- else -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{ if $field.IsPtr }}*{{end}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{ range $model := .Models }}\n\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .IsInterface }}\n\t\ttype {{.GoType}} interface {\n\t\t\tIs{{.GoType}}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.GoType}} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\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\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.GoType}}) Is{{$iface.GoType}}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.GoType}} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- 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\n\t{{if $object.IsConcurrent}} var wg sync.WaitGroup {{end}}\n\tout := graphql.NewOrderedMap(len(fields))\n\tinvalid := false\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\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t{{- 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\tif invalid { return graphql.Null }\n\treturn out\n}\n{{- end }}\n", diff --git a/codegen/templates/input.gotpl b/codegen/templates/input.gotpl index a73f3be0521..957d5af3990 100644 --- a/codegen/templates/input.gotpl +++ b/codegen/templates/input.gotpl @@ -81,11 +81,11 @@ {{- end }} {{- end }} {{- end -}} - {{ if $field.IsPtr }} + {{ if $field.IsPtr -}} return e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print "*obj." $field.GoFieldName ) "n"}}) - {{ else }} + {{- else -}} return e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print "obj." $field.GoFieldName ) "n"}}) - {{ end }} + {{- end }} }, {{ end }} }... From e201bcb5540ecae0c9c9d96868cfce1ba2f79227 Mon Sep 17 00:00:00 2001 From: asamusev Date: Mon, 3 Dec 2018 15:44:16 +0300 Subject: [PATCH 014/147] set default nil arg to ResolverContext --- codegen/templates/data.go | 2 +- codegen/templates/field.gotpl | 2 + codegen/testserver/generated.go | 75 ++++++++++++++++++++++ example/chat/generated.go | 43 +++++++++++++ example/config/generated.go | 43 +++++++++++++ example/dataloader/generated.go | 49 ++++++++++++++ example/scalars/generated.go | 46 +++++++++++++ example/selection/generated.go | 43 +++++++++++++ example/starwars/generated.go | 72 +++++++++++++++++++++ example/todo/generated.go | 42 ++++++++++++ example/type-system-extension/generated.go | 41 ++++++++++++ integration/generated.go | 45 +++++++++++++ 12 files changed, 502 insertions(+), 1 deletion(-) diff --git a/codegen/templates/data.go b/codegen/templates/data.go index 9bc53ec1957..da6f3aec901 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -2,7 +2,7 @@ package templates var data = map[string]string{ "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if $dArg.IsPtr }}\n\t\t\t\t\t\t\t\t{{- $argValue := $dArg.Value | dump -}}\n\t\t\t\t\t\t\t\t{{- $argDefault := $dArg.Default | dump -}}\n\t\t\t\t\t\t\t\t{{- if not (eq $argValue \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $argValue }}\n\t\t\t\t\t\t\t\t{{- else if not (eq $argDefault \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $argDefault }}\n\t\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){\n\t\t\t\t\t{{$arg.Unmarshal (print \"args\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t {{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\tvar err error\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", - "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\n\t\tresults, err := ec.resolvers.{{ $field.ShortInvocation }}\n\t\tif err != nil {\n\t\t\tec.Error(ctx, err)\n\t\t\treturn nil\n\t\t}\n\t\treturn func() graphql.Marshaler {\n\t\t\tres, ok := <-results\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tvar out graphql.OrderedMap\n\t\t\tout.Add(field.Alias, func() graphql.Marshaler { {{ $field.WriteJson }} }())\n\t\t\treturn &out\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tField: field,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\n\t\t{{ $field.WriteJson }}\n\t}\n{{ end }}\n", + "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\n\t\tresults, err := ec.resolvers.{{ $field.ShortInvocation }}\n\t\tif err != nil {\n\t\t\tec.Error(ctx, err)\n\t\t\treturn nil\n\t\t}\n\t\treturn func() graphql.Marshaler {\n\t\t\tres, ok := <-results\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tvar out graphql.OrderedMap\n\t\t\tout.Add(field.Alias, func() graphql.Marshaler { {{ $field.WriteJson }} }())\n\t\t\treturn &out\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\n)\n\n\n\n// ChainFieldMiddleware add chain by FieldMiddleware\nfunc chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware {\n\tn := len(handleFunc)\n\n\tif n > 1 {\n\t\tlastI := n - 1\n\t\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\t\tvar (\n\t\t\t\tchainHandler graphql.Resolver\n\t\t\t\tcurI int\n\t\t\t)\n\t\t\tchainHandler = func(currentCtx context.Context) (interface{}, error) {\n\t\t\t\tif curI == lastI {\n\t\t\t\t\treturn next(currentCtx)\n\t\t\t\t}\n\t\t\t\tcurI++\n\t\t\t\tres, err := handleFunc[curI](currentCtx, chainHandler)\n\t\t\t\tcurI--\n\t\t\t\treturn res, err\n\n\t\t\t}\n\t\t\treturn handleFunc[0](ctx, chainHandler)\n\t\t}\n\t}\n\n\tif n == 1 {\n\t\treturn handleFunc[0]\n\t}\n\n\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\treturn next(ctx)\n\t}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := chainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if $arg.IsPtr }}\n\t\t\t\t\t\t\t{{- $argValue := $arg.Value | dump -}}\n\t\t\t\t\t\t\t{{- $argDefault := $arg.Default | dump -}}\n\t\t\t\t\t\t\t{{- if not (eq $argValue \"nil\") }}\n\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $argValue }}\n\t\t\t\t\t\t\t{{ else if not (eq $argDefault \"nil\") }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}} := {{ $argDefault }}\n\t\t\t\t\t\t\t{{ end -}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t\tc{{$field.GoFieldName}}, err := chainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if $arg.IsPtr }}\n\t\t\t\t\t\t\t\t{{- $argValue := $arg.Value | dump -}}\n\t\t\t\t\t\t\t\t{{- $argDefault := $arg.Default | dump -}}\n\t\t\t\t\t\t\t\t{{- if not (eq $argValue \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $argValue }}\n\t\t\t\t\t\t\t\t{{ else if not (eq $argDefault \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $argDefault }}\n\t\t\t\t\t\t\t\t{{ end -}}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\t\t{{ if $field.IsPtr -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"*obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- else -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{ if $field.IsPtr }}*{{end}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\n", "interface.gotpl": "{{- $interface := . }}\n\nfunc (ec *executionContext) _{{$interface.GQLType}}(ctx context.Context, sel ast.SelectionSet, obj *{{$interface.FullName}}) graphql.Marshaler {\n\tswitch obj := (*obj).(type) {\n\tcase nil:\n\t\treturn graphql.Null\n\t{{- range $implementor := $interface.Implementors }}\n\t\t{{- if $implementor.ValueReceiver }}\n\t\t\tcase {{$implementor.FullName}}:\n\t\t\t\treturn ec._{{$implementor.GQLType}}(ctx, sel, &obj)\n\t\t{{- end}}\n\t\tcase *{{$implementor.FullName}}:\n\t\t\treturn ec._{{$implementor.GQLType}}(ctx, sel, obj)\n\t{{- end }}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"unexpected type %T\", obj))\n\t}\n}\n", diff --git a/codegen/templates/field.gotpl b/codegen/templates/field.gotpl index 63920f883b7..e347e78c27e 100644 --- a/codegen/templates/field.gotpl +++ b/codegen/templates/field.gotpl @@ -5,6 +5,7 @@ func (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Field: field, + Args: nil, }) {{- if $field.Args }} rawArgs := field.ArgumentMap(ec.Variables) @@ -40,6 +41,7 @@ rctx := &graphql.ResolverContext{ Object: {{$object.GQLType|quote}}, Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) {{- if $field.Args }} diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index ccf44448f66..b2554b1951e 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -1273,6 +1273,7 @@ func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "Circle", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1296,6 +1297,7 @@ func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "Circle", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1348,6 +1350,7 @@ func (ec *executionContext) _EmbeddedPointer_ID(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "EmbeddedPointer", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1371,6 +1374,7 @@ func (ec *executionContext) _EmbeddedPointer_Title(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "EmbeddedPointer", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1436,6 +1440,7 @@ func (ec *executionContext) _Error_id(ctx context.Context, field graphql.Collect rctx := &graphql.ResolverContext{ Object: "Error", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1462,6 +1467,7 @@ func (ec *executionContext) _Error_errorOnNonRequiredField(ctx context.Context, rctx := &graphql.ResolverContext{ Object: "Error", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1485,6 +1491,7 @@ func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, fie rctx := &graphql.ResolverContext{ Object: "Error", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1511,6 +1518,7 @@ func (ec *executionContext) _Error_nilOnRequiredField(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "Error", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1576,6 +1584,7 @@ func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field gra rctx := &graphql.ResolverContext{ Object: "ForcedResolver", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1634,6 +1643,7 @@ func (ec *executionContext) _InnerObject_id(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "InnerObject", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1690,6 +1700,7 @@ func (ec *executionContext) _InvalidIdentifier_id(ctx context.Context, field gra rctx := &graphql.ResolverContext{ Object: "InvalidIdentifier", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1746,6 +1757,7 @@ func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedF rctx := &graphql.ResolverContext{ Object: "It", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1821,6 +1833,7 @@ func (ec *executionContext) _ModelMethods_resolverField(ctx context.Context, fie rctx := &graphql.ResolverContext{ Object: "ModelMethods", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1847,6 +1860,7 @@ func (ec *executionContext) _ModelMethods_noContext(ctx context.Context, field g rctx := &graphql.ResolverContext{ Object: "ModelMethods", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1873,6 +1887,7 @@ func (ec *executionContext) _ModelMethods_withContext(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "ModelMethods", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1929,6 +1944,7 @@ func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "OuterObject", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2110,6 +2126,7 @@ func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2138,6 +2155,7 @@ func (ec *executionContext) _Query_collision(ctx context.Context, field graphql. rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2166,6 +2184,7 @@ func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2200,6 +2219,7 @@ func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql. rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2234,6 +2254,7 @@ func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2268,6 +2289,7 @@ func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field grap rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2359,6 +2381,7 @@ func (ec *executionContext) _Query_keywords(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2392,6 +2415,7 @@ func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2452,6 +2476,7 @@ func (ec *executionContext) _Query_errorBubble(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2480,6 +2505,7 @@ func (ec *executionContext) _Query_modelMethods(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2508,6 +2534,7 @@ func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2534,6 +2561,7 @@ func (ec *executionContext) _Query_user(ctx context.Context, field graphql.Colle rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2568,6 +2596,7 @@ func (ec *executionContext) _Query_nullableArg(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2602,6 +2631,7 @@ func (ec *executionContext) _Query_directiveArg(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2636,6 +2666,7 @@ func (ec *executionContext) _Query_directiveNullableArg(ctx context.Context, fie rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2670,6 +2701,7 @@ func (ec *executionContext) _Query_directiveInputNullable(ctx context.Context, f rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2704,6 +2736,7 @@ func (ec *executionContext) _Query_directiveInput(ctx context.Context, field gra rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2738,6 +2771,7 @@ func (ec *executionContext) _Query_keywordArgs(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2771,6 +2805,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2806,6 +2841,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2865,6 +2901,7 @@ func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "Rectangle", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2888,6 +2925,7 @@ func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql. rctx := &graphql.ResolverContext{ Object: "Rectangle", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2911,6 +2949,7 @@ func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "Rectangle", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2953,6 +2992,7 @@ func (ec *executionContext) _Subscription(ctx context.Context, sel ast.Selection func (ec *executionContext) _Subscription_updated(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Field: field, + Args: nil, }) // FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259 // and Tracer stack @@ -2976,6 +3016,7 @@ func (ec *executionContext) _Subscription_updated(ctx context.Context, field gra func (ec *executionContext) _Subscription_initPayload(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Field: field, + Args: nil, }) // FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259 // and Tracer stack @@ -3043,6 +3084,7 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte rctx := &graphql.ResolverContext{ Object: "User", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3069,6 +3111,7 @@ func (ec *executionContext) _User_friends(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "User", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3170,6 +3213,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3196,6 +3240,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3219,6 +3264,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3254,6 +3300,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3352,6 +3399,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3378,6 +3426,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3401,6 +3450,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3427,6 +3477,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3503,6 +3554,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3529,6 +3581,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3552,6 +3605,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3611,6 +3665,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3645,6 +3700,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3671,6 +3727,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3737,6 +3794,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3763,6 +3821,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3786,6 +3845,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3820,6 +3880,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3891,6 +3952,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3950,6 +4012,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3984,6 +4047,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4012,6 +4076,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4040,6 +4105,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4145,6 +4211,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4171,6 +4238,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4198,6 +4266,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4221,6 +4290,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -4284,6 +4354,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4340,6 +4411,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4396,6 +4468,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -4459,6 +4532,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4515,6 +4589,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) diff --git a/example/chat/generated.go b/example/chat/generated.go index 1007289da1f..836c4e13765 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -392,6 +392,7 @@ func (ec *executionContext) _Chatroom_name(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "Chatroom", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -418,6 +419,7 @@ func (ec *executionContext) _Chatroom_messages(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "Chatroom", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -522,6 +524,7 @@ func (ec *executionContext) _Message_id(ctx context.Context, field graphql.Colle rctx := &graphql.ResolverContext{ Object: "Message", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -548,6 +551,7 @@ func (ec *executionContext) _Message_text(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "Message", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -574,6 +578,7 @@ func (ec *executionContext) _Message_createdBy(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "Message", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -600,6 +605,7 @@ func (ec *executionContext) _Message_createdAt(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "Message", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -660,6 +666,7 @@ func (ec *executionContext) _Mutation_post(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "Mutation", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -734,6 +741,7 @@ func (ec *executionContext) _Query_room(ctx context.Context, field graphql.Colle rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -769,6 +777,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -804,6 +813,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -849,6 +859,7 @@ func (ec *executionContext) _Subscription(ctx context.Context, sel ast.Selection func (ec *executionContext) _Subscription_messageAdded(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Field: field, + Args: nil, }) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Subscription_messageAdded_args(ctx, rawArgs) @@ -926,6 +937,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -952,6 +964,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -975,6 +988,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1010,6 +1024,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1108,6 +1123,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1134,6 +1150,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1157,6 +1174,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1183,6 +1201,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1259,6 +1278,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1285,6 +1305,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1308,6 +1329,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1367,6 +1389,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1401,6 +1424,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1427,6 +1451,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1493,6 +1518,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1519,6 +1545,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1542,6 +1569,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1576,6 +1604,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1647,6 +1676,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1706,6 +1736,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1740,6 +1771,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1768,6 +1800,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1796,6 +1829,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1901,6 +1935,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1927,6 +1962,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1954,6 +1990,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1977,6 +2014,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2040,6 +2078,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2096,6 +2135,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2152,6 +2192,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2215,6 +2256,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2271,6 +2313,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) diff --git a/example/config/generated.go b/example/config/generated.go index 5a0441ae5af..f7d8c69d333 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -308,6 +308,7 @@ func (ec *executionContext) _Mutation_createTodo(ctx context.Context, field grap rctx := &graphql.ResolverContext{ Object: "Mutation", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -385,6 +386,7 @@ func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -444,6 +446,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -479,6 +482,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -562,6 +566,7 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte rctx := &graphql.ResolverContext{ Object: "Todo", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -588,6 +593,7 @@ func (ec *executionContext) _Todo_databaseId(ctx context.Context, field graphql. rctx := &graphql.ResolverContext{ Object: "Todo", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -614,6 +620,7 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec rctx := &graphql.ResolverContext{ Object: "Todo", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -640,6 +647,7 @@ func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.Collec rctx := &graphql.ResolverContext{ Object: "Todo", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -666,6 +674,7 @@ func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.Collec rctx := &graphql.ResolverContext{ Object: "Todo", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -728,6 +737,7 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte rctx := &graphql.ResolverContext{ Object: "User", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -754,6 +764,7 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec rctx := &graphql.ResolverContext{ Object: "User", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -822,6 +833,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -848,6 +860,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -871,6 +884,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -906,6 +920,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1004,6 +1019,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1030,6 +1046,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1053,6 +1070,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1079,6 +1097,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1155,6 +1174,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1181,6 +1201,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1204,6 +1225,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1263,6 +1285,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1297,6 +1320,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1323,6 +1347,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1389,6 +1414,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1415,6 +1441,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1438,6 +1465,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1472,6 +1500,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1543,6 +1572,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1602,6 +1632,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1636,6 +1667,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1664,6 +1696,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1692,6 +1725,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1797,6 +1831,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1823,6 +1858,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1850,6 +1886,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1873,6 +1910,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1936,6 +1974,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1992,6 +2031,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2048,6 +2088,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2111,6 +2152,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2167,6 +2209,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index e12bf05cec4..c150e182440 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -401,6 +401,7 @@ func (ec *executionContext) _Address_id(ctx context.Context, field graphql.Colle rctx := &graphql.ResolverContext{ Object: "Address", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -427,6 +428,7 @@ func (ec *executionContext) _Address_street(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "Address", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -453,6 +455,7 @@ func (ec *executionContext) _Address_country(ctx context.Context, field graphql. rctx := &graphql.ResolverContext{ Object: "Address", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -527,6 +530,7 @@ func (ec *executionContext) _Customer_id(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "Customer", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -553,6 +557,7 @@ func (ec *executionContext) _Customer_name(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "Customer", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -579,6 +584,7 @@ func (ec *executionContext) _Customer_address(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "Customer", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -607,6 +613,7 @@ func (ec *executionContext) _Customer_orders(ctx context.Context, field graphql. rctx := &graphql.ResolverContext{ Object: "Customer", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -693,6 +700,7 @@ func (ec *executionContext) _Item_name(ctx context.Context, field graphql.Collec rctx := &graphql.ResolverContext{ Object: "Item", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -766,6 +774,7 @@ func (ec *executionContext) _Order_id(ctx context.Context, field graphql.Collect rctx := &graphql.ResolverContext{ Object: "Order", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -792,6 +801,7 @@ func (ec *executionContext) _Order_date(ctx context.Context, field graphql.Colle rctx := &graphql.ResolverContext{ Object: "Order", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -818,6 +828,7 @@ func (ec *executionContext) _Order_amount(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "Order", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -844,6 +855,7 @@ func (ec *executionContext) _Order_items(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "Order", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -952,6 +964,7 @@ func (ec *executionContext) _Query_customers(ctx context.Context, field graphql. rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1008,6 +1021,7 @@ func (ec *executionContext) _Query_torture1d(ctx context.Context, field graphql. rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1071,6 +1085,7 @@ func (ec *executionContext) _Query_torture2d(ctx context.Context, field graphql. rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1165,6 +1180,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1200,6 +1216,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1270,6 +1287,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1296,6 +1314,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1319,6 +1338,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1354,6 +1374,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1452,6 +1473,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1478,6 +1500,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1501,6 +1524,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1527,6 +1551,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1603,6 +1628,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1629,6 +1655,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1652,6 +1679,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1711,6 +1739,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1745,6 +1774,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1771,6 +1801,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1837,6 +1868,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1863,6 +1895,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1886,6 +1919,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1920,6 +1954,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1991,6 +2026,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2050,6 +2086,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2084,6 +2121,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2112,6 +2150,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2140,6 +2179,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2245,6 +2285,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2271,6 +2312,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2298,6 +2340,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2321,6 +2364,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2384,6 +2428,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2440,6 +2485,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2496,6 +2542,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2559,6 +2606,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2615,6 +2663,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) diff --git a/example/scalars/generated.go b/example/scalars/generated.go index 0520ac9eab9..a6a40231da1 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -342,6 +342,7 @@ func (ec *executionContext) _Address_id(ctx context.Context, field graphql.Colle rctx := &graphql.ResolverContext{ Object: "Address", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -368,6 +369,7 @@ func (ec *executionContext) _Address_location(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "Address", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -444,6 +446,7 @@ func (ec *executionContext) _Query_user(ctx context.Context, field graphql.Colle rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -479,6 +482,7 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -545,6 +549,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -580,6 +585,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -673,6 +679,7 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte rctx := &graphql.ResolverContext{ Object: "User", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -699,6 +706,7 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec rctx := &graphql.ResolverContext{ Object: "User", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -725,6 +733,7 @@ func (ec *executionContext) _User_created(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "User", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -748,6 +757,7 @@ func (ec *executionContext) _User_isBanned(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "User", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -774,6 +784,7 @@ func (ec *executionContext) _User_primitiveResolver(ctx context.Context, field g rctx := &graphql.ResolverContext{ Object: "User", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -800,6 +811,7 @@ func (ec *executionContext) _User_customResolver(ctx context.Context, field grap rctx := &graphql.ResolverContext{ Object: "User", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -826,6 +838,7 @@ func (ec *executionContext) _User_address(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "User", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -850,6 +863,7 @@ func (ec *executionContext) _User_tier(ctx context.Context, field graphql.Collec rctx := &graphql.ResolverContext{ Object: "User", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -915,6 +929,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -941,6 +956,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -964,6 +980,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -999,6 +1016,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1097,6 +1115,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1123,6 +1142,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1146,6 +1166,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1172,6 +1193,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1248,6 +1270,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1274,6 +1297,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1297,6 +1321,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1356,6 +1381,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1390,6 +1416,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1416,6 +1443,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1482,6 +1510,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1508,6 +1537,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1531,6 +1561,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1565,6 +1596,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1636,6 +1668,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1695,6 +1728,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1729,6 +1763,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1757,6 +1792,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1785,6 +1821,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1890,6 +1927,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1916,6 +1954,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1943,6 +1982,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1966,6 +2006,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2029,6 +2070,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2085,6 +2127,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2141,6 +2184,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2204,6 +2248,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2260,6 +2305,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) diff --git a/example/selection/generated.go b/example/selection/generated.go index 1e0022dc45d..519e86b63da 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -263,6 +263,7 @@ func (ec *executionContext) _Like_reaction(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "Like", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -289,6 +290,7 @@ func (ec *executionContext) _Like_sent(ctx context.Context, field graphql.Collec rctx := &graphql.ResolverContext{ Object: "Like", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -315,6 +317,7 @@ func (ec *executionContext) _Like_selection(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "Like", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -347,6 +350,7 @@ func (ec *executionContext) _Like_collected(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "Like", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -418,6 +422,7 @@ func (ec *executionContext) _Post_message(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "Post", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -444,6 +449,7 @@ func (ec *executionContext) _Post_sent(ctx context.Context, field graphql.Collec rctx := &graphql.ResolverContext{ Object: "Post", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -470,6 +476,7 @@ func (ec *executionContext) _Post_selection(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "Post", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -502,6 +509,7 @@ func (ec *executionContext) _Post_collected(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "Post", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -574,6 +582,7 @@ func (ec *executionContext) _Query_events(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -630,6 +639,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -665,6 +675,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -735,6 +746,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -761,6 +773,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -784,6 +797,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -819,6 +833,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -917,6 +932,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -943,6 +959,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -966,6 +983,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -992,6 +1010,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1068,6 +1087,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1094,6 +1114,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1117,6 +1138,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1176,6 +1198,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1210,6 +1233,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1236,6 +1260,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1302,6 +1327,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1328,6 +1354,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1351,6 +1378,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1385,6 +1413,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1456,6 +1485,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1515,6 +1545,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1549,6 +1580,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1577,6 +1609,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1605,6 +1638,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1710,6 +1744,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1736,6 +1771,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1763,6 +1799,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1786,6 +1823,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1849,6 +1887,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1905,6 +1944,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1961,6 +2001,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2024,6 +2065,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2080,6 +2122,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) diff --git a/example/starwars/generated.go b/example/starwars/generated.go index c2812d77ae1..c2ffc186676 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -895,6 +895,7 @@ func (ec *executionContext) _Droid_id(ctx context.Context, field graphql.Collect rctx := &graphql.ResolverContext{ Object: "Droid", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -921,6 +922,7 @@ func (ec *executionContext) _Droid_name(ctx context.Context, field graphql.Colle rctx := &graphql.ResolverContext{ Object: "Droid", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -947,6 +949,7 @@ func (ec *executionContext) _Droid_friends(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "Droid", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1003,6 +1006,7 @@ func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "Droid", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1037,6 +1041,7 @@ func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql. rctx := &graphql.ResolverContext{ Object: "Droid", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1072,6 +1077,7 @@ func (ec *executionContext) _Droid_primaryFunction(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "Droid", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1143,6 +1149,7 @@ func (ec *executionContext) _FriendsConnection_totalCount(ctx context.Context, f rctx := &graphql.ResolverContext{ Object: "FriendsConnection", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1169,6 +1176,7 @@ func (ec *executionContext) _FriendsConnection_edges(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "FriendsConnection", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1225,6 +1233,7 @@ func (ec *executionContext) _FriendsConnection_friends(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "FriendsConnection", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1281,6 +1290,7 @@ func (ec *executionContext) _FriendsConnection_pageInfo(ctx context.Context, fie rctx := &graphql.ResolverContext{ Object: "FriendsConnection", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1340,6 +1350,7 @@ func (ec *executionContext) _FriendsEdge_cursor(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "FriendsEdge", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1366,6 +1377,7 @@ func (ec *executionContext) _FriendsEdge_node(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "FriendsEdge", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1459,6 +1471,7 @@ func (ec *executionContext) _Human_id(ctx context.Context, field graphql.Collect rctx := &graphql.ResolverContext{ Object: "Human", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1485,6 +1498,7 @@ func (ec *executionContext) _Human_name(ctx context.Context, field graphql.Colle rctx := &graphql.ResolverContext{ Object: "Human", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1511,6 +1525,7 @@ func (ec *executionContext) _Human_height(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "Human", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1544,6 +1559,7 @@ func (ec *executionContext) _Human_mass(ctx context.Context, field graphql.Colle rctx := &graphql.ResolverContext{ Object: "Human", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1567,6 +1583,7 @@ func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "Human", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1623,6 +1640,7 @@ func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "Human", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1657,6 +1675,7 @@ func (ec *executionContext) _Human_appearsIn(ctx context.Context, field graphql. rctx := &graphql.ResolverContext{ Object: "Human", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1692,6 +1711,7 @@ func (ec *executionContext) _Human_starships(ctx context.Context, field graphql. rctx := &graphql.ResolverContext{ Object: "Human", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1779,6 +1799,7 @@ func (ec *executionContext) _Mutation_createReview(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "Mutation", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1854,6 +1875,7 @@ func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field gra rctx := &graphql.ResolverContext{ Object: "PageInfo", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1880,6 +1902,7 @@ func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "PageInfo", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1906,6 +1929,7 @@ func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field gra rctx := &graphql.ResolverContext{ Object: "PageInfo", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2014,6 +2038,7 @@ func (ec *executionContext) _Query_hero(ctx context.Context, field graphql.Colle rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2045,6 +2070,7 @@ func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2111,6 +2137,7 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2177,6 +2204,7 @@ func (ec *executionContext) _Query_character(ctx context.Context, field graphql. rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2208,6 +2236,7 @@ func (ec *executionContext) _Query_droid(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2243,6 +2272,7 @@ func (ec *executionContext) _Query_human(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2278,6 +2308,7 @@ func (ec *executionContext) _Query_starship(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2313,6 +2344,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2348,6 +2380,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2410,6 +2443,7 @@ func (ec *executionContext) _Review_stars(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "Review", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2436,6 +2470,7 @@ func (ec *executionContext) _Review_commentary(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "Review", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2463,6 +2498,7 @@ func (ec *executionContext) _Review_time(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "Review", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2536,6 +2572,7 @@ func (ec *executionContext) _Starship_id(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "Starship", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2562,6 +2599,7 @@ func (ec *executionContext) _Starship_name(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "Starship", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2588,6 +2626,7 @@ func (ec *executionContext) _Starship_length(ctx context.Context, field graphql. rctx := &graphql.ResolverContext{ Object: "Starship", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2621,6 +2660,7 @@ func (ec *executionContext) _Starship_history(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "Starship", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2707,6 +2747,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2733,6 +2774,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2756,6 +2798,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2791,6 +2834,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2889,6 +2933,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2915,6 +2960,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2938,6 +2984,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2964,6 +3011,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3040,6 +3088,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3066,6 +3115,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3089,6 +3139,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3148,6 +3199,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3182,6 +3234,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3208,6 +3261,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3274,6 +3328,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3300,6 +3355,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3323,6 +3379,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3357,6 +3414,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3428,6 +3486,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3487,6 +3546,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3521,6 +3581,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3549,6 +3610,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3577,6 +3639,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3682,6 +3745,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3708,6 +3772,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3735,6 +3800,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3758,6 +3824,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -3821,6 +3888,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3877,6 +3945,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3933,6 +4002,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -3996,6 +4066,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4052,6 +4123,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) diff --git a/example/todo/generated.go b/example/todo/generated.go index 014affba9dc..851aeb63e15 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -363,6 +363,7 @@ func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "MyMutation", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -397,6 +398,7 @@ func (ec *executionContext) _MyMutation_updateTodo(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "MyMutation", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -487,6 +489,7 @@ func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "MyQuery", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -522,6 +525,7 @@ func (ec *executionContext) _MyQuery_lastTodo(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "MyQuery", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -550,6 +554,7 @@ func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "MyQuery", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -609,6 +614,7 @@ func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "MyQuery", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -644,6 +650,7 @@ func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "MyQuery", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -712,6 +719,7 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte rctx := &graphql.ResolverContext{ Object: "Todo", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -738,6 +746,7 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec rctx := &graphql.ResolverContext{ Object: "Todo", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -764,6 +773,7 @@ func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.Collec rctx := &graphql.ResolverContext{ Object: "Todo", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -832,6 +842,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -858,6 +869,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -881,6 +893,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -916,6 +929,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1014,6 +1028,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1040,6 +1055,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1063,6 +1079,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1089,6 +1106,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1165,6 +1183,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1191,6 +1210,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1214,6 +1234,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1273,6 +1294,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1307,6 +1329,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1333,6 +1356,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1399,6 +1423,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1425,6 +1450,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1448,6 +1474,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1482,6 +1509,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1553,6 +1581,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1612,6 +1641,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1646,6 +1676,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1674,6 +1705,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1702,6 +1734,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1807,6 +1840,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1833,6 +1867,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1860,6 +1895,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1883,6 +1919,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1946,6 +1983,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2002,6 +2040,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2058,6 +2097,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2121,6 +2161,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2177,6 +2218,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index ff4ac1577af..3bc7b94ab73 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -320,6 +320,7 @@ func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "MyMutation", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -403,6 +404,7 @@ func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "MyQuery", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -462,6 +464,7 @@ func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "MyQuery", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -497,6 +500,7 @@ func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "MyQuery", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -532,6 +536,7 @@ func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "MyQuery", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -605,6 +610,7 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte rctx := &graphql.ResolverContext{ Object: "Todo", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -631,6 +637,7 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec rctx := &graphql.ResolverContext{ Object: "Todo", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -657,6 +664,7 @@ func (ec *executionContext) _Todo_state(ctx context.Context, field graphql.Colle rctx := &graphql.ResolverContext{ Object: "Todo", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -683,6 +691,7 @@ func (ec *executionContext) _Todo_verified(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "Todo", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -751,6 +760,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -777,6 +787,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -800,6 +811,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -835,6 +847,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -933,6 +946,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -959,6 +973,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -982,6 +997,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1008,6 +1024,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1084,6 +1101,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1110,6 +1128,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1133,6 +1152,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1192,6 +1212,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1226,6 +1247,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1252,6 +1274,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1318,6 +1341,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1344,6 +1368,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1367,6 +1392,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1401,6 +1427,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1472,6 +1499,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1531,6 +1559,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1565,6 +1594,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1593,6 +1623,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1621,6 +1652,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1726,6 +1758,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1752,6 +1785,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1779,6 +1813,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1802,6 +1837,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1865,6 +1901,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1921,6 +1958,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1977,6 +2015,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2040,6 +2079,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2096,6 +2136,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) diff --git a/integration/generated.go b/integration/generated.go index b8dbc0fa3ac..4418dc9e912 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -381,6 +381,7 @@ func (ec *executionContext) _Element_child(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "Element", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -408,6 +409,7 @@ func (ec *executionContext) _Element_error(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "Element", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -434,6 +436,7 @@ func (ec *executionContext) _Element_mismatched(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "Element", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -539,6 +542,7 @@ func (ec *executionContext) _Query_path(ctx context.Context, field graphql.Colle rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -599,6 +603,7 @@ func (ec *executionContext) _Query_date(ctx context.Context, field graphql.Colle rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -632,6 +637,7 @@ func (ec *executionContext) _Query_viewer(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -660,6 +666,7 @@ func (ec *executionContext) _Query_jsonEncoding(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -686,6 +693,7 @@ func (ec *executionContext) _Query_error(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -719,6 +727,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -754,6 +763,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "Query", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -822,6 +832,7 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec rctx := &graphql.ResolverContext{ Object: "User", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -848,6 +859,7 @@ func (ec *executionContext) _User_likes(ctx context.Context, field graphql.Colle rctx := &graphql.ResolverContext{ Object: "User", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -910,6 +922,7 @@ func (ec *executionContext) _Viewer_user(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "Viewer", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -980,6 +993,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1006,6 +1020,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1029,6 +1044,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1064,6 +1080,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1162,6 +1179,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1188,6 +1206,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1211,6 +1230,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1237,6 +1257,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1313,6 +1334,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1339,6 +1361,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1362,6 +1385,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1421,6 +1445,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1455,6 +1480,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1481,6 +1507,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1547,6 +1574,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1573,6 +1601,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1596,6 +1625,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1630,6 +1660,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1701,6 +1732,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1760,6 +1792,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1794,6 +1827,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1822,6 +1856,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1850,6 +1885,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1955,6 +1991,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1981,6 +2018,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2008,6 +2046,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2031,6 +2070,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2094,6 +2134,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2150,6 +2191,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2206,6 +2248,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2269,6 +2312,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2325,6 +2369,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) From d586bb61f1b4da0a9a916118809cb6dc0c996bbd Mon Sep 17 00:00:00 2001 From: asamusev Date: Tue, 4 Dec 2018 16:43:56 +0300 Subject: [PATCH 015/147] use arg value for the ResolveArgs --- codegen/templates/args.gotpl | 3 -- codegen/templates/data.go | 4 +-- codegen/templates/input.gotpl | 6 ---- codegen/testserver/generated.go | 43 ++++++++++++++++++++++++---- codegen/testserver/generated_test.go | 2 +- codegen/testserver/resolver.go | 2 +- codegen/testserver/schema.graphql | 4 +-- 7 files changed, 43 insertions(+), 21 deletions(-) diff --git a/codegen/templates/args.gotpl b/codegen/templates/args.gotpl index 73703931a53..f069813452c 100644 --- a/codegen/templates/args.gotpl +++ b/codegen/templates/args.gotpl @@ -10,11 +10,8 @@ {{- range $dArg := $directive.Args }} {{- if $dArg.IsPtr }} {{- $argValue := $dArg.Value | dump -}} - {{- $argDefault := $dArg.Default | dump -}} {{- if not (eq $argValue "nil") }} {{ $dArg.GoVarName }} := {{ $argValue }} - {{- else if not (eq $argDefault "nil") }} - {{ $dArg.GoVarName }} := {{ $argDefault }} {{- end }} {{- end }} {{- end }} diff --git a/codegen/templates/data.go b/codegen/templates/data.go index da6f3aec901..c240f6e56f1 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -1,10 +1,10 @@ package templates var data = map[string]string{ - "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if $dArg.IsPtr }}\n\t\t\t\t\t\t\t\t{{- $argValue := $dArg.Value | dump -}}\n\t\t\t\t\t\t\t\t{{- $argDefault := $dArg.Default | dump -}}\n\t\t\t\t\t\t\t\t{{- if not (eq $argValue \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $argValue }}\n\t\t\t\t\t\t\t\t{{- else if not (eq $argDefault \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $argDefault }}\n\t\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){\n\t\t\t\t\t{{$arg.Unmarshal (print \"args\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t {{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\tvar err error\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", + "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if $dArg.IsPtr }}\n\t\t\t\t\t\t\t\t{{- $argValue := $dArg.Value | dump -}}\n\t\t\t\t\t\t\t\t{{- if not (eq $argValue \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $argValue }}\n\t\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){\n\t\t\t\t\t{{$arg.Unmarshal (print \"args\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t {{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\tvar err error\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\n\t\tresults, err := ec.resolvers.{{ $field.ShortInvocation }}\n\t\tif err != nil {\n\t\t\tec.Error(ctx, err)\n\t\t\treturn nil\n\t\t}\n\t\treturn func() graphql.Marshaler {\n\t\t\tres, ok := <-results\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tvar out graphql.OrderedMap\n\t\t\tout.Add(field.Alias, func() graphql.Marshaler { {{ $field.WriteJson }} }())\n\t\t\treturn &out\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\n)\n\n\n\n// ChainFieldMiddleware add chain by FieldMiddleware\nfunc chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware {\n\tn := len(handleFunc)\n\n\tif n > 1 {\n\t\tlastI := n - 1\n\t\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\t\tvar (\n\t\t\t\tchainHandler graphql.Resolver\n\t\t\t\tcurI int\n\t\t\t)\n\t\t\tchainHandler = func(currentCtx context.Context) (interface{}, error) {\n\t\t\t\tif curI == lastI {\n\t\t\t\t\treturn next(currentCtx)\n\t\t\t\t}\n\t\t\t\tcurI++\n\t\t\t\tres, err := handleFunc[curI](currentCtx, chainHandler)\n\t\t\t\tcurI--\n\t\t\t\treturn res, err\n\n\t\t\t}\n\t\t\treturn handleFunc[0](ctx, chainHandler)\n\t\t}\n\t}\n\n\tif n == 1 {\n\t\treturn handleFunc[0]\n\t}\n\n\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\treturn next(ctx)\n\t}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := chainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if $arg.IsPtr }}\n\t\t\t\t\t\t\t{{- $argValue := $arg.Value | dump -}}\n\t\t\t\t\t\t\t{{- $argDefault := $arg.Default | dump -}}\n\t\t\t\t\t\t\t{{- if not (eq $argValue \"nil\") }}\n\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $argValue }}\n\t\t\t\t\t\t\t{{ else if not (eq $argDefault \"nil\") }}\n\t\t\t\t\t\t\t\t{{$arg.GoVarName}} := {{ $argDefault }}\n\t\t\t\t\t\t\t{{ end -}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t\tc{{$field.GoFieldName}}, err := chainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if $arg.IsPtr }}\n\t\t\t\t\t\t\t\t{{- $argValue := $arg.Value | dump -}}\n\t\t\t\t\t\t\t\t{{- $argDefault := $arg.Default | dump -}}\n\t\t\t\t\t\t\t\t{{- if not (eq $argValue \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $argValue }}\n\t\t\t\t\t\t\t\t{{ else if not (eq $argDefault \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $argDefault }}\n\t\t\t\t\t\t\t\t{{ end -}}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\t\t{{ if $field.IsPtr -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"*obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- else -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{ if $field.IsPtr }}*{{end}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := chainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if $arg.IsPtr }}\n\t\t\t\t\t\t\t{{- $argValue := $arg.Value | dump -}}\n\t\t\t\t\t\t\t{{- if not (eq $argValue \"nil\") }}\n\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $argValue }}\n\t\t\t\t\t\t\t{{ end -}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t\tc{{$field.GoFieldName}}, err := chainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if $arg.IsPtr }}\n\t\t\t\t\t\t\t\t{{- $argValue := $arg.Value | dump -}}\n\t\t\t\t\t\t\t\t{{- if not (eq $argValue \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $argValue }}\n\t\t\t\t\t\t\t\t{{ end -}}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\t\t{{ if $field.IsPtr -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"*obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- else -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{ if $field.IsPtr }}*{{end}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{ range $model := .Models }}\n\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .IsInterface }}\n\t\ttype {{.GoType}} interface {\n\t\t\tIs{{.GoType}}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.GoType}} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\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\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.GoType}}) Is{{$iface.GoType}}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.GoType}} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- 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\n\t{{if $object.IsConcurrent}} var wg sync.WaitGroup {{end}}\n\tout := graphql.NewOrderedMap(len(fields))\n\tinvalid := false\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\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t{{- 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\tif invalid { return graphql.Null }\n\treturn out\n}\n{{- end }}\n", diff --git a/codegen/templates/input.gotpl b/codegen/templates/input.gotpl index 957d5af3990..d76214bb34a 100644 --- a/codegen/templates/input.gotpl +++ b/codegen/templates/input.gotpl @@ -37,11 +37,8 @@ {{- range $arg := $directive.Args }} {{- if $arg.IsPtr }} {{- $argValue := $arg.Value | dump -}} - {{- $argDefault := $arg.Default | dump -}} {{- if not (eq $argValue "nil") }} {{ $arg.GoVarName }} := {{ $argValue }} - {{ else if not (eq $argDefault "nil") }} - {{$arg.GoVarName}} := {{ $argDefault }} {{ end -}} {{- end }} {{- end }} @@ -72,11 +69,8 @@ {{- range $arg := $directive.Args }} {{- if $arg.IsPtr }} {{- $argValue := $arg.Value | dump -}} - {{- $argDefault := $arg.Default | dump -}} {{- if not (eq $argValue "nil") }} {{ $arg.GoVarName }} := {{ $argValue }} - {{ else if not (eq $argDefault "nil") }} - {{ $arg.GoVarName }} := {{ $argDefault }} {{ end -}} {{- end }} {{- end }} diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index b2554b1951e..648a0a8feef 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -106,7 +106,7 @@ type ComplexityRoot struct { User func(childComplexity int, id int) int NullableArg func(childComplexity int, arg *int) int DirectiveArg func(childComplexity int, arg string) int - DirectiveNullableArg func(childComplexity int, arg *int) int + DirectiveNullableArg func(childComplexity int, arg *int, arg2 *int) int DirectiveInputNullable func(childComplexity int, arg *InputDirectives) int DirectiveInput func(childComplexity int, arg InputDirectives) int KeywordArgs func(childComplexity int, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) int @@ -150,7 +150,7 @@ type QueryResolver interface { User(ctx context.Context, id int) (User, error) NullableArg(ctx context.Context, arg *int) (*string, error) DirectiveArg(ctx context.Context, arg string) (*string, error) - DirectiveNullableArg(ctx context.Context, arg *int) (*string, error) + DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int) (*string, error) DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) @@ -401,6 +401,37 @@ func (e *executableSchema) field_Query_directiveNullableArg_args(ctx context.Con } args["arg"] = arg0 + var arg1 *int + if tmp, ok := rawArgs["arg2"]; ok { + + argm1, err := chainFieldMiddleware([]graphql.FieldMiddleware{ + func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { + min := 0 + return e.directives.Range(ctx, tmp, n, &min, nil, nil) + }, + }...)(ctx, func(ctx2 context.Context) (args1 interface{}, err error) { + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + args1 = &ptr1 + } + + if err != nil { + return nil, err + } + return + }) + if err != nil { + return nil, err + } + if data, ok := argm1.(*int); ok { + arg1 = data + } else { + return nil, errors.New("expect *int") + } + + } + args["arg2"] = arg1 return args, nil } @@ -1088,7 +1119,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Query.DirectiveNullableArg(childComplexity, args["arg"].(*int)), true + return e.complexity.Query.DirectiveNullableArg(childComplexity, args["arg"].(*int), args["arg2"].(*int)), true case "Query.directiveInputNullable": if e.complexity.Query.DirectiveInputNullable == nil { @@ -2679,7 +2710,7 @@ func (ec *executionContext) _Query_directiveNullableArg(ctx context.Context, fie ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().DirectiveNullableArg(rctx, args["arg"].(*int)) + return ec.resolvers.Query().DirectiveNullableArg(rctx, args["arg"].(*int), args["arg2"].(*int)) }) if resTmp == nil { return graphql.Null @@ -5093,7 +5124,7 @@ var parsedSchema = gqlparser.MustLoadSchema( user(id: Int!): User! nullableArg(arg: Int = 123): String directiveArg(arg: String! @length(min:1, max: 255, message: "invalid length")): String - directiveNullableArg(arg: Int @range(min:0)): String + directiveNullableArg(arg: Int @range(min:0), arg2: Int @range): String directiveInputNullable(arg: InputDirectives): String directiveInput(arg: InputDirectives!): String } @@ -5246,7 +5277,7 @@ type EmbeddedPointer { } directive @length(min: Int!, max: Int, message: String!) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION -directive @range(min: Int, max: Int, message: String) on ARGUMENT_DEFINITION +directive @range(min: Int = 0, max: Int, message: String) on ARGUMENT_DEFINITION `}, ) diff --git a/codegen/testserver/generated_test.go b/codegen/testserver/generated_test.go index 18acca12e09..774b7baf24c 100644 --- a/codegen/testserver/generated_test.go +++ b/codegen/testserver/generated_test.go @@ -885,7 +885,7 @@ func (r *testQueryResolver) DirectiveArg(ctx context.Context, arg string) (*stri return &s, nil } -func (r *testQueryResolver) DirectiveNullableArg(ctx context.Context, arg *int) (*string, error) { +func (r *testQueryResolver) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int) (*string, error) { s := "Ok" return &s, nil } diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index ac7308b1480..e48a0354ac3 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -81,7 +81,7 @@ func (r *queryResolver) NullableArg(ctx context.Context, arg *int) (*string, err func (r *queryResolver) DirectiveArg(ctx context.Context, arg string) (*string, error) { panic("not implemented") } -func (r *queryResolver) DirectiveNullableArg(ctx context.Context, arg *int) (*string, error) { +func (r *queryResolver) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int) (*string, error) { panic("not implemented") } func (r *queryResolver) DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) { diff --git a/codegen/testserver/schema.graphql b/codegen/testserver/schema.graphql index 0d949f3550a..812d93b2372 100644 --- a/codegen/testserver/schema.graphql +++ b/codegen/testserver/schema.graphql @@ -13,7 +13,7 @@ type Query { user(id: Int!): User! nullableArg(arg: Int = 123): String directiveArg(arg: String! @length(min:1, max: 255, message: "invalid length")): String - directiveNullableArg(arg: Int @range(min:0)): String + directiveNullableArg(arg: Int @range(min:0), arg2: Int @range): String directiveInputNullable(arg: InputDirectives): String directiveInput(arg: InputDirectives!): String } @@ -166,4 +166,4 @@ type EmbeddedPointer { } directive @length(min: Int!, max: Int, message: String!) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION -directive @range(min: Int, max: Int, message: String) on ARGUMENT_DEFINITION +directive @range(min: Int = 0, max: Int, message: String) on ARGUMENT_DEFINITION From b32ebe1480704a34bc941553c689e0c4d746bcd5 Mon Sep 17 00:00:00 2001 From: asamusev Date: Wed, 5 Dec 2018 10:45:06 +0300 Subject: [PATCH 016/147] check nullable value for go1.10 --- codegen/templates/args.gotpl | 7 ++----- codegen/templates/data.go | 4 ++-- codegen/templates/input.gotpl | 16 +++++----------- codegen/templates/templates.go | 15 +++++++++++++++ 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/codegen/templates/args.gotpl b/codegen/templates/args.gotpl index f069813452c..5b6e0f33c54 100644 --- a/codegen/templates/args.gotpl +++ b/codegen/templates/args.gotpl @@ -8,11 +8,8 @@ {{- range $directive := $arg.Directives }} func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { {{- range $dArg := $directive.Args }} - {{- if $dArg.IsPtr }} - {{- $argValue := $dArg.Value | dump -}} - {{- if not (eq $argValue "nil") }} - {{ $dArg.GoVarName }} := {{ $argValue }} - {{- end }} + {{- if and $dArg.IsPtr ( notNil "Value" $dArg ) }} + {{ $dArg.GoVarName }} := {{ $dArg.Value | dump }} {{- end }} {{- end }} return e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs "tmp" "n" }}) diff --git a/codegen/templates/data.go b/codegen/templates/data.go index c240f6e56f1..f7904504654 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -1,10 +1,10 @@ package templates var data = map[string]string{ - "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if $dArg.IsPtr }}\n\t\t\t\t\t\t\t\t{{- $argValue := $dArg.Value | dump -}}\n\t\t\t\t\t\t\t\t{{- if not (eq $argValue \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $argValue }}\n\t\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){\n\t\t\t\t\t{{$arg.Unmarshal (print \"args\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t {{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\tvar err error\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", + "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $dArg.IsPtr ( notNil \"Value\" $dArg ) }}\n\t\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $dArg.Value | dump }}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){\n\t\t\t\t\t{{$arg.Unmarshal (print \"args\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t {{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\tvar err error\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\n\t\tresults, err := ec.resolvers.{{ $field.ShortInvocation }}\n\t\tif err != nil {\n\t\t\tec.Error(ctx, err)\n\t\t\treturn nil\n\t\t}\n\t\treturn func() graphql.Marshaler {\n\t\t\tres, ok := <-results\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tvar out graphql.OrderedMap\n\t\t\tout.Add(field.Alias, func() graphql.Marshaler { {{ $field.WriteJson }} }())\n\t\t\treturn &out\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\n)\n\n\n\n// ChainFieldMiddleware add chain by FieldMiddleware\nfunc chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware {\n\tn := len(handleFunc)\n\n\tif n > 1 {\n\t\tlastI := n - 1\n\t\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\t\tvar (\n\t\t\t\tchainHandler graphql.Resolver\n\t\t\t\tcurI int\n\t\t\t)\n\t\t\tchainHandler = func(currentCtx context.Context) (interface{}, error) {\n\t\t\t\tif curI == lastI {\n\t\t\t\t\treturn next(currentCtx)\n\t\t\t\t}\n\t\t\t\tcurI++\n\t\t\t\tres, err := handleFunc[curI](currentCtx, chainHandler)\n\t\t\t\tcurI--\n\t\t\t\treturn res, err\n\n\t\t\t}\n\t\t\treturn handleFunc[0](ctx, chainHandler)\n\t\t}\n\t}\n\n\tif n == 1 {\n\t\treturn handleFunc[0]\n\t}\n\n\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\treturn next(ctx)\n\t}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := chainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if $arg.IsPtr }}\n\t\t\t\t\t\t\t{{- $argValue := $arg.Value | dump -}}\n\t\t\t\t\t\t\t{{- if not (eq $argValue \"nil\") }}\n\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $argValue }}\n\t\t\t\t\t\t\t{{ end -}}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t\tc{{$field.GoFieldName}}, err := chainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if $arg.IsPtr }}\n\t\t\t\t\t\t\t\t{{- $argValue := $arg.Value | dump -}}\n\t\t\t\t\t\t\t\t{{- if not (eq $argValue \"nil\") }}\n\t\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $argValue }}\n\t\t\t\t\t\t\t\t{{ end -}}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\t\t{{ if $field.IsPtr -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"*obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- else -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{ if $field.IsPtr }}*{{end}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := chainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t\tc{{$field.GoFieldName}}, err := chainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\t{{ if $field.IsPtr -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"*obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- else -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{ if $field.IsPtr }}*{{end}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{ range $model := .Models }}\n\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .IsInterface }}\n\t\ttype {{.GoType}} interface {\n\t\t\tIs{{.GoType}}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.GoType}} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\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\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.GoType}}) Is{{$iface.GoType}}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.GoType}} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- 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\n\t{{if $object.IsConcurrent}} var wg sync.WaitGroup {{end}}\n\tout := graphql.NewOrderedMap(len(fields))\n\tinvalid := false\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\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t{{- 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\tif invalid { return graphql.Null }\n\treturn out\n}\n{{- end }}\n", diff --git a/codegen/templates/input.gotpl b/codegen/templates/input.gotpl index d76214bb34a..c6224d2af17 100644 --- a/codegen/templates/input.gotpl +++ b/codegen/templates/input.gotpl @@ -35,11 +35,8 @@ func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { {{- if $directive.Args }} {{- range $arg := $directive.Args }} - {{- if $arg.IsPtr }} - {{- $argValue := $arg.Value | dump -}} - {{- if not (eq $argValue "nil") }} - {{ $arg.GoVarName }} := {{ $argValue }} - {{ end -}} + {{- if and $arg.IsPtr ( notNil "Value" $arg ) }} + {{ $arg.GoVarName }} := {{ $arg.Value | dump }} {{- end }} {{- end }} {{- end -}} @@ -67,14 +64,11 @@ func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { {{- if $directive.Args }} {{- range $arg := $directive.Args }} - {{- if $arg.IsPtr }} - {{- $argValue := $arg.Value | dump -}} - {{- if not (eq $argValue "nil") }} - {{ $arg.GoVarName }} := {{ $argValue }} - {{ end -}} + {{- if and $arg.IsPtr ( notNil "Value" $arg ) }} + {{ $arg.GoVarName }} := {{ $arg.Value | dump }} {{- end }} {{- end }} - {{- end -}} + {{- end }} {{ if $field.IsPtr -}} return e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print "*obj." $field.GoFieldName ) "n"}}) {{- else -}} diff --git a/codegen/templates/templates.go b/codegen/templates/templates.go index 0e6915eacf1..1bc7cf93c5b 100644 --- a/codegen/templates/templates.go +++ b/codegen/templates/templates.go @@ -8,6 +8,7 @@ import ( "io/ioutil" "os" "path/filepath" + "reflect" "sort" "strconv" "strings" @@ -31,6 +32,7 @@ func Run(name string, tpldata interface{}) (*bytes.Buffer, error) { "toCamel": ToCamel, "dump": Dump, "prefixLines": prefixLines, + "notNil": notNil, "reserveImport": CurrentImports.Reserve, "lookupImport": CurrentImports.Lookup, }) @@ -104,6 +106,19 @@ func rawQuote(s string) string { return "`" + strings.Replace(s, "`", "`+\"`\"+`", -1) + "`" } +func notNil(field string, data interface{}) bool { + v := reflect.ValueOf(data) + + if v.Kind() == reflect.Ptr { + v = v.Elem() + } + if v.Kind() != reflect.Struct { + return false + } + val := v.FieldByName(field) + return val.IsValid() && !val.IsNil() +} + func Dump(val interface{}) string { switch val := val.(type) { case int: From 5e0456febd0b1c61fa09fe16f1dbd1d8a56c5b84 Mon Sep 17 00:00:00 2001 From: asamusev Date: Thu, 6 Dec 2018 10:32:26 +0300 Subject: [PATCH 017/147] fix fmt anf metalint generated code --- codegen/templates/data.go | 2 +- codegen/templates/generated.gotpl | 1 + codegen/templates/templates.go | 3 ++- codegen/testserver/generated.go | 1 + codegen/testserver/generated_test.go | 2 +- example/chat/generated.go | 1 + example/config/generated.go | 1 + example/dataloader/generated.go | 1 + example/scalars/generated.go | 1 + example/selection/generated.go | 1 + example/starwars/generated.go | 1 + example/todo/generated.go | 1 + example/type-system-extension/generated.go | 1 + integration/generated.go | 1 + 14 files changed, 15 insertions(+), 3 deletions(-) diff --git a/codegen/templates/data.go b/codegen/templates/data.go index f7904504654..2928ed29d7e 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -3,7 +3,7 @@ package templates var data = map[string]string{ "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $dArg.IsPtr ( notNil \"Value\" $dArg ) }}\n\t\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $dArg.Value | dump }}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){\n\t\t\t\t\t{{$arg.Unmarshal (print \"args\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t {{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\tvar err error\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\n\t\tresults, err := ec.resolvers.{{ $field.ShortInvocation }}\n\t\tif err != nil {\n\t\t\tec.Error(ctx, err)\n\t\t\treturn nil\n\t\t}\n\t\treturn func() graphql.Marshaler {\n\t\t\tres, ok := <-results\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tvar out graphql.OrderedMap\n\t\t\tout.Add(field.Alias, func() graphql.Marshaler { {{ $field.WriteJson }} }())\n\t\t\treturn &out\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\n)\n\n\n\n// ChainFieldMiddleware add chain by FieldMiddleware\nfunc chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware {\n\tn := len(handleFunc)\n\n\tif n > 1 {\n\t\tlastI := n - 1\n\t\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\t\tvar (\n\t\t\t\tchainHandler graphql.Resolver\n\t\t\t\tcurI int\n\t\t\t)\n\t\t\tchainHandler = func(currentCtx context.Context) (interface{}, error) {\n\t\t\t\tif curI == lastI {\n\t\t\t\t\treturn next(currentCtx)\n\t\t\t\t}\n\t\t\t\tcurI++\n\t\t\t\tres, err := handleFunc[curI](currentCtx, chainHandler)\n\t\t\t\tcurI--\n\t\t\t\treturn res, err\n\n\t\t\t}\n\t\t\treturn handleFunc[0](ctx, chainHandler)\n\t\t}\n\t}\n\n\tif n == 1 {\n\t\treturn handleFunc[0]\n\t}\n\n\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\treturn next(ctx)\n\t}\n}\n", + "generated.gotpl": "// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.\n\npackage {{ .PackageName }}\n\nimport (\n\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\n)\n\n\n\n// ChainFieldMiddleware add chain by FieldMiddleware\n// nolint: deadcode\nfunc chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware {\n\tn := len(handleFunc)\n\n\tif n > 1 {\n\t\tlastI := n - 1\n\t\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\t\tvar (\n\t\t\t\tchainHandler graphql.Resolver\n\t\t\t\tcurI int\n\t\t\t)\n\t\t\tchainHandler = func(currentCtx context.Context) (interface{}, error) {\n\t\t\t\tif curI == lastI {\n\t\t\t\t\treturn next(currentCtx)\n\t\t\t\t}\n\t\t\t\tcurI++\n\t\t\t\tres, err := handleFunc[curI](currentCtx, chainHandler)\n\t\t\t\tcurI--\n\t\t\t\treturn res, err\n\n\t\t\t}\n\t\t\treturn handleFunc[0](ctx, chainHandler)\n\t\t}\n\t}\n\n\tif n == 1 {\n\t\treturn handleFunc[0]\n\t}\n\n\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\treturn next(ctx)\n\t}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := chainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t\tc{{$field.GoFieldName}}, err := chainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\t{{ if $field.IsPtr -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"*obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- else -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{ if $field.IsPtr }}*{{end}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{ range $model := .Models }}\n\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .IsInterface }}\n\t\ttype {{.GoType}} interface {\n\t\t\tIs{{.GoType}}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.GoType}} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\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\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.GoType}}) Is{{$iface.GoType}}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.GoType}} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- end}}\n\t\t{{$enum.GoType}}{{ .Name|toCamel }} {{$enum.GoType}} = {{.Name|quote}}\n\t{{- end }}\n\t)\n\n\tfunc (e {{.GoType}}) IsValid() bool {\n\t\tswitch e {\n\t\tcase {{ range $index, $element := .Values}}{{if $index}},{{end}}{{ $enum.GoType }}{{ $element.Name|toCamel }}{{end}}:\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tfunc (e {{.GoType}}) String() string {\n\t\treturn string(e)\n\t}\n\n\tfunc (e *{{.GoType}}) UnmarshalGQL(v interface{}) error {\n\t\tstr, ok := v.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"enums must be strings\")\n\t\t}\n\n\t\t*e = {{.GoType}}(str)\n\t\tif !e.IsValid() {\n\t\t\treturn fmt.Errorf(\"%s is not a valid {{.GQLType}}\", str)\n\t\t}\n\t\treturn nil\n\t}\n\n\tfunc (e {{.GoType}}) MarshalGQL(w io.Writer) {\n\t\tfmt.Fprint(w, strconv.Quote(e.String()))\n\t}\n\n{{- end }}\n", diff --git a/codegen/templates/generated.gotpl b/codegen/templates/generated.gotpl index b99dfd77490..eade2d59d5f 100644 --- a/codegen/templates/generated.gotpl +++ b/codegen/templates/generated.gotpl @@ -287,6 +287,7 @@ var parsedSchema = gqlparser.MustLoadSchema( // ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { n := len(handleFunc) diff --git a/codegen/templates/templates.go b/codegen/templates/templates.go index 1bc7cf93c5b..a2684ebb4ee 100644 --- a/codegen/templates/templates.go +++ b/codegen/templates/templates.go @@ -32,7 +32,7 @@ func Run(name string, tpldata interface{}) (*bytes.Buffer, error) { "toCamel": ToCamel, "dump": Dump, "prefixLines": prefixLines, - "notNil": notNil, + "notNil": notNil, "reserveImport": CurrentImports.Reserve, "lookupImport": CurrentImports.Lookup, }) @@ -116,6 +116,7 @@ func notNil(field string, data interface{}) bool { return false } val := v.FieldByName(field) + return val.IsValid() && !val.IsNil() } diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 648a0a8feef..dacbb2becf3 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -5282,6 +5282,7 @@ directive @range(min: Int = 0, max: Int, message: String) on ARGUMENT_DEFINITION ) // ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { n := len(handleFunc) diff --git a/codegen/testserver/generated_test.go b/codegen/testserver/generated_test.go index 774b7baf24c..50f62a60b91 100644 --- a/codegen/testserver/generated_test.go +++ b/codegen/testserver/generated_test.go @@ -217,7 +217,7 @@ func TestDirectives(t *testing.T) { } if message == nil { err = errors.New("range invalid") - }else{ + } else { err = errors.New(*message) } if d, ok := obj.(int); ok { diff --git a/example/chat/generated.go b/example/chat/generated.go index 836c4e13765..52afecbebf3 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -2394,6 +2394,7 @@ scalar Time ) // ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { n := len(handleFunc) diff --git a/example/config/generated.go b/example/config/generated.go index f7d8c69d333..cf96fb821f4 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -2320,6 +2320,7 @@ input NewTodo { ) // ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { n := len(handleFunc) diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index c150e182440..c9fe13ff5cf 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -2751,6 +2751,7 @@ scalar Time ) // ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { n := len(handleFunc) diff --git a/example/scalars/generated.go b/example/scalars/generated.go index a6a40231da1..5b5f9913917 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -2444,6 +2444,7 @@ scalar Point ) // ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { n := len(handleFunc) diff --git a/example/selection/generated.go b/example/selection/generated.go index 519e86b63da..00a8314fd45 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -2219,6 +2219,7 @@ scalar Time ) // ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { n := len(handleFunc) diff --git a/example/starwars/generated.go b/example/starwars/generated.go index c2ffc186676..c169e796328 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -4388,6 +4388,7 @@ scalar Time ) // ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { n := len(handleFunc) diff --git a/example/todo/generated.go b/example/todo/generated.go index 851aeb63e15..3d6714c8484 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -2365,6 +2365,7 @@ enum Role { ) // ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { n := len(handleFunc) diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index 3bc7b94ab73..ef1c78fd84f 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -2386,6 +2386,7 @@ extend union Data @unionLogging ) // ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { n := len(handleFunc) diff --git a/integration/generated.go b/integration/generated.go index 4418dc9e912..a1ba7ebfd30 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -2545,6 +2545,7 @@ enum ErrorType { ) // ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { n := len(handleFunc) From 2cf5a5b8049198e130ccdcd8068cfe321b82e17e Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Tue, 27 Nov 2018 19:26:02 +1100 Subject: [PATCH 018/147] Add a benchmark go test -benchtime=5s -bench=. -benchmem goos: linux goarch: amd64 pkg: github.com/99designs/gqlgen/example/starwars BenchmarkSimpleQueryNoArgs-8 200000 32680 ns/op 6357 B/op 126 allocs/op PASS ok github.com/99designs/gqlgen/example/starwars 9.901s --- .gitignore | 2 ++ example/starwars/benchmarks_test.go | 30 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 example/starwars/benchmarks_test.go diff --git a/.gitignore b/.gitignore index a9712beb0bc..c0ff0ef28b9 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ /codegen/gen .idea/ +*.test +*.out diff --git a/example/starwars/benchmarks_test.go b/example/starwars/benchmarks_test.go new file mode 100644 index 00000000000..8386b7963f0 --- /dev/null +++ b/example/starwars/benchmarks_test.go @@ -0,0 +1,30 @@ +package starwars + +import ( + "net/http/httptest" + "strings" + "testing" + + "github.com/99designs/gqlgen/handler" +) + +func BenchmarkSimpleQueryNoArgs(b *testing.B) { + server := handler.GraphQL(NewExecutableSchema(NewResolver())) + + q := `{"query":"{ search(text:\"Luke\") { ... on Human { starships { name } } } }"}` + + var body strings.Reader + r := httptest.NewRequest("POST", "/graphql", &body) + + b.ResetTimer() + rec := httptest.NewRecorder() + for i := 0; i < b.N; i++ { + body.Reset(q) + rec.Body.Reset() + server.ServeHTTP(rec, r) + if rec.Body.String() != `{"data":{"search":[{"starships":[{"name":"X-Wing"},{"name":"Imperial shuttle"}]}]}}` { + b.Fatalf("Unexpected response") + } + + } +} From b0ffa22a8a06fb912b5ef36260b2025bf66e1356 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Tue, 27 Nov 2018 19:27:19 +1100 Subject: [PATCH 019/147] Remove strconv.Quote call in hot path to avoid some allocs go test -benchtime=5s -bench=. -benchmem goos: linux goarch: amd64 pkg: github.com/99designs/gqlgen/example/starwars BenchmarkSimpleQueryNoArgs-8 200000 32125 ns/op 6277 B/op 118 allocs/op PASS ok github.com/99designs/gqlgen/example/starwars 9.768s --- graphql/jsonw.go | 3 +-- graphql/string.go | 59 +++++++++++++++++++++++++---------------------- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/graphql/jsonw.go b/graphql/jsonw.go index c112444a7e6..c087f63bd0d 100644 --- a/graphql/jsonw.go +++ b/graphql/jsonw.go @@ -2,7 +2,6 @@ package graphql import ( "io" - "strconv" ) var nullLit = []byte(`null`) @@ -56,7 +55,7 @@ func (m *OrderedMap) MarshalGQL(writer io.Writer) { if i != 0 { writer.Write(comma) } - io.WriteString(writer, strconv.Quote(key)) + writeQuotedString(writer, key) writer.Write(colon) m.Values[i].MarshalGQL(writer) } diff --git a/graphql/string.go b/graphql/string.go index d5fb32947dc..7c1b7d95775 100644 --- a/graphql/string.go +++ b/graphql/string.go @@ -10,37 +10,42 @@ const encodeHex = "0123456789ABCDEF" func MarshalString(s string) Marshaler { return WriterFunc(func(w io.Writer) { - start := 0 - io.WriteString(w, `"`) - - for i, c := range s { - if c < 0x20 || c == '\\' || c == '"' { - io.WriteString(w, s[start:i]) - - switch c { - case '\t': - io.WriteString(w, `\t`) - case '\r': - io.WriteString(w, `\r`) - case '\n': - io.WriteString(w, `\n`) - case '\\': - io.WriteString(w, `\\`) - case '"': - io.WriteString(w, `\"`) - default: - io.WriteString(w, `\u00`) - w.Write([]byte{encodeHex[c>>4], encodeHex[c&0xf]}) - } - - start = i + 1 + writeQuotedString(w, s) + }) +} + +func writeQuotedString(w io.Writer, s string) { + start := 0 + io.WriteString(w, `"`) + + for i, c := range s { + if c < 0x20 || c == '\\' || c == '"' { + io.WriteString(w, s[start:i]) + + switch c { + case '\t': + io.WriteString(w, `\t`) + case '\r': + io.WriteString(w, `\r`) + case '\n': + io.WriteString(w, `\n`) + case '\\': + io.WriteString(w, `\\`) + case '"': + io.WriteString(w, `\"`) + default: + io.WriteString(w, `\u00`) + w.Write([]byte{encodeHex[c>>4], encodeHex[c&0xf]}) } + + start = i + 1 } + } - io.WriteString(w, s[start:]) - io.WriteString(w, `"`) - }) + io.WriteString(w, s[start:]) + io.WriteString(w, `"`) } + func UnmarshalString(v interface{}) (string, error) { switch v := v.(type) { case string: From 5c8b1e24546c78ddc00a05e2605f894d66f2911f Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Sat, 8 Dec 2018 13:11:32 +1100 Subject: [PATCH 020/147] Avoid unnessicary goroutines goos: linux goarch: amd64 pkg: github.com/99designs/gqlgen/example/starwars BenchmarkSimpleQueryNoArgs-8 300000 25093 ns/op 6453 B/op 114 allocs/op PASS ok github.com/99designs/gqlgen/example/starwars 10.807s --- codegen/templates/data.go | 4 +- codegen/templates/field.gotpl | 12 +- codegen/templates/object.gotpl | 24 +- codegen/testserver/generated.go | 331 ++++++++++----------- example/chat/generated.go | 87 +++--- example/config/generated.go | 86 ++---- example/dataloader/generated.go | 129 ++++---- example/scalars/generated.go | 102 +++---- example/selection/generated.go | 65 ++-- example/starwars/generated.go | 255 +++++++--------- example/todo/generated.go | 87 +++--- example/type-system-extension/generated.go | 77 ++--- graphql/fieldset.go | 63 ++++ graphql/jsonw.go | 30 -- graphql/jsonw_test.go | 30 +- integration/generated.go | 165 +++++----- 16 files changed, 687 insertions(+), 860 deletions(-) create mode 100644 graphql/fieldset.go diff --git a/codegen/templates/data.go b/codegen/templates/data.go index d3098aaae14..7eb66cb5932 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -2,12 +2,12 @@ package templates var data = map[string]string{ "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\tvar err error\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", - "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := {{ $field.ArgsFunc }}(rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t})\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\n\t\tresults, err := ec.resolvers.{{ $field.ShortInvocation }}\n\t\tif err != nil {\n\t\t\tec.Error(ctx, err)\n\t\t\treturn nil\n\t\t}\n\t\treturn func() graphql.Marshaler {\n\t\t\tres, ok := <-results\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tvar out graphql.OrderedMap\n\t\t\tout.Add(field.Alias, func() graphql.Marshaler { {{ $field.WriteJson }} }())\n\t\t\treturn &out\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := {{ $field.ArgsFunc }}(rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t{{- end }}\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tArgs: {{if $field.Args }}args{{else}}nil{{end}},\n\t\t\tField: field,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\n\t\t{{ $field.WriteJson }}\n\t}\n{{ end }}\n", + "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := {{ $field.ArgsFunc }}(rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t})\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\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\treturn graphql.WriterFunc(func(w io.Writer) {\n\t\t\t\tw.Write([]byte{'{'})\n\t\t\t\tgraphql.MarshalString(field.Alias).MarshalGQL(w)\n\t\t\t\tw.Write([]byte{':'})\n\t\t\t\tfunc() graphql.Marshaler {\n\t\t\t\t\t{{ $field.WriteJson }}\n\t\t\t\t}().MarshalGQL(w)\n\t\t\t\tw.Write([]byte{'}'})\n\t\t\t})\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := {{ $field.ArgsFunc }}(rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t{{- end }}\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tArgs: {{if $field.Args }}args{{else}}nil{{end}},\n\t\t\tField: field,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc {{ $field.ArgsFunc }}(rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc {{ $directive.ArgsFunc }}(rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := {{ $field.ArgsFunc }}(rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := {{ $directive.ArgsFunc }}(rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{ range $model := .Models }}\n\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .IsInterface }}\n\t\ttype {{.GoType}} interface {\n\t\t\tIs{{.GoType}}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.GoType}} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\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\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.GoType}}) Is{{$iface.GoType}}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.GoType}} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- 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\n\t{{if $object.IsConcurrent}} var wg sync.WaitGroup {{end}}\n\tout := graphql.NewOrderedMap(len(fields))\n\tinvalid := false\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\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t{{- 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\tif invalid { return graphql.Null }\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\tout := graphql.NewFieldSet(fields)\n\tinvalid := false\n\tfor i, field := range fields {\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\tfield := field\n\t\t\t\tout.Concurrently(i, func() (res graphql.Marshaler) {\n\t\t\t\t\tres = ec._{{$object.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\t\tif res == graphql.Null {\n\t\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t\t}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\treturn res\n\t\t\t\t})\n\t\t\t{{- else }}\n\t\t\t\tout.Values[i] = ec._{{$object.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\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\tout.Dispatch()\n\tif invalid { return graphql.Null }\n\treturn out\n}\n{{- end }}\n", "resolver.gotpl": "package {{ .PackageName }}\n\nimport (\n\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/99designs/gqlgen/handler\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"log\" }}\n\t{{ reserveImport \"net/http\" }}\n\t{{ reserveImport \"os\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/handler\" }}\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({{ lookupImport .ExecPackageName }}.NewExecutableSchema({{ lookupImport .ExecPackageName}}.Config{Resolvers: &{{ lookupImport .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 3df847fa980..0d2c07368cc 100644 --- a/codegen/templates/field.gotpl +++ b/codegen/templates/field.gotpl @@ -27,9 +27,15 @@ if !ok { return nil } - var out graphql.OrderedMap - out.Add(field.Alias, func() graphql.Marshaler { {{ $field.WriteJson }} }()) - return &out + return graphql.WriterFunc(func(w io.Writer) { + w.Write([]byte{'{'}) + graphql.MarshalString(field.Alias).MarshalGQL(w) + w.Write([]byte{':'}) + func() graphql.Marshaler { + {{ $field.WriteJson }} + }().MarshalGQL(w) + w.Write([]byte{'}'}) + }) } } {{ else }} diff --git a/codegen/templates/object.gotpl b/codegen/templates/object.gotpl index e98cbe1ee55..135f4f21f31 100644 --- a/codegen/templates/object.gotpl +++ b/codegen/templates/object.gotpl @@ -32,37 +32,39 @@ func (ec *executionContext) _{{$object.GQLType}}(ctx context.Context, sel ast.Se }) {{end}} - {{if $object.IsConcurrent}} var wg sync.WaitGroup {{end}} - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString({{$object.GQLType|quote}}) {{- range $field := $object.Fields }} case "{{$field.GQLName}}": {{- if $field.IsConcurrent }} - wg.Add(1) - go func(i int, field graphql.CollectedField) { - {{- end }} + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._{{$object.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}}) + {{- if $field.ASTType.NonNull }} + if res == graphql.Null { + invalid = true + } + {{- end }} + return res + }) + {{- else }} out.Values[i] = ec._{{$object.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}}) {{- if $field.ASTType.NonNull }} if out.Values[i] == graphql.Null { invalid = true } {{- end }} - {{- if $field.IsConcurrent }} - wg.Done() - }(i, field) {{- end }} {{- end }} default: panic("unknown field " + strconv.Quote(field.Name)) } } - {{if $object.IsConcurrent}} wg.Wait() {{end}} + out.Dispatch() if invalid { return graphql.Null } return out } diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 3f97c620b14..b0f5764ff80 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -7,6 +7,7 @@ import ( "context" "errors" "fmt" + "io" "strconv" "sync" @@ -939,11 +940,9 @@ var circleImplementors = []string{"Circle", "Shape"} func (ec *executionContext) _Circle(ctx context.Context, sel ast.SelectionSet, obj *Circle) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, circleImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Circle") @@ -955,7 +954,7 @@ func (ec *executionContext) _Circle(ctx context.Context, sel ast.SelectionSet, o panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1016,11 +1015,9 @@ var embeddedPointerImplementors = []string{"EmbeddedPointer"} func (ec *executionContext) _EmbeddedPointer(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedPointerModel) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, embeddedPointerImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("EmbeddedPointer") @@ -1032,7 +1029,7 @@ func (ec *executionContext) _EmbeddedPointer(ctx context.Context, sel ast.Select panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1093,11 +1090,9 @@ var errorImplementors = []string{"Error"} func (ec *executionContext) _Error(ctx context.Context, sel ast.SelectionSet, obj *Error) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, errorImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Error") @@ -1122,7 +1117,7 @@ func (ec *executionContext) _Error(ctx context.Context, sel ast.SelectionSet, ob panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1247,26 +1242,23 @@ 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)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("ForcedResolver") case "field": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._ForcedResolver_field(ctx, field, obj) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._ForcedResolver_field(ctx, field, obj) + return res + }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - wg.Wait() + out.Dispatch() if invalid { return graphql.Null } @@ -1308,11 +1300,9 @@ var innerObjectImplementors = []string{"InnerObject"} func (ec *executionContext) _InnerObject(ctx context.Context, sel ast.SelectionSet, obj *InnerObject) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, innerObjectImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("InnerObject") @@ -1325,7 +1315,7 @@ func (ec *executionContext) _InnerObject(ctx context.Context, sel ast.SelectionS panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1365,11 +1355,9 @@ var invalidIdentifierImplementors = []string{"InvalidIdentifier"} func (ec *executionContext) _InvalidIdentifier(ctx context.Context, sel ast.SelectionSet, obj *invalid_packagename.InvalidIdentifier) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, invalidIdentifierImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("InvalidIdentifier") @@ -1382,7 +1370,7 @@ func (ec *executionContext) _InvalidIdentifier(ctx context.Context, sel ast.Sele panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1422,11 +1410,9 @@ var itImplementors = []string{"It"} func (ec *executionContext) _It(ctx context.Context, sel ast.SelectionSet, obj *introspection1.It) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, itImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("It") @@ -1439,7 +1425,7 @@ func (ec *executionContext) _It(ctx context.Context, sel ast.SelectionSet, obj * panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1479,43 +1465,40 @@ var modelMethodsImplementors = []string{"ModelMethods"} func (ec *executionContext) _ModelMethods(ctx context.Context, sel ast.SelectionSet, obj *ModelMethods) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, modelMethodsImplementors) - var wg sync.WaitGroup - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("ModelMethods") case "resolverField": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._ModelMethods_resolverField(ctx, field, obj) - if out.Values[i] == graphql.Null { + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._ModelMethods_resolverField(ctx, field, obj) + if res == graphql.Null { invalid = true } - wg.Done() - }(i, field) + return res + }) case "noContext": out.Values[i] = ec._ModelMethods_noContext(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } case "withContext": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._ModelMethods_withContext(ctx, field, obj) - if out.Values[i] == graphql.Null { + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._ModelMethods_withContext(ctx, field, obj) + if res == graphql.Null { invalid = true } - wg.Done() - }(i, field) + return res + }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - wg.Wait() + out.Dispatch() if invalid { return graphql.Null } @@ -1609,11 +1592,9 @@ var outerObjectImplementors = []string{"OuterObject"} func (ec *executionContext) _OuterObject(ctx context.Context, sel ast.SelectionSet, obj *OuterObject) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, outerObjectImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("OuterObject") @@ -1626,7 +1607,7 @@ func (ec *executionContext) _OuterObject(ctx context.Context, sel ast.SelectionS panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1671,111 +1652,108 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr Object: "Query", }) - var wg sync.WaitGroup - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "invalidIdentifier": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_invalidIdentifier(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_invalidIdentifier(ctx, field) + return res + }) case "collision": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_collision(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_collision(ctx, field) + return res + }) case "mapInput": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_mapInput(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_mapInput(ctx, field) + return res + }) case "recursive": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_recursive(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_recursive(ctx, field) + return res + }) case "nestedInputs": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_nestedInputs(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_nestedInputs(ctx, field) + return res + }) case "nestedOutputs": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_nestedOutputs(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_nestedOutputs(ctx, field) + return res + }) case "keywords": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_keywords(ctx, field) - if out.Values[i] == graphql.Null { + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_keywords(ctx, field) + if res == graphql.Null { invalid = true } - wg.Done() - }(i, field) + return res + }) case "shapes": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_shapes(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_shapes(ctx, field) + return res + }) case "errorBubble": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_errorBubble(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_errorBubble(ctx, field) + return res + }) case "modelMethods": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_modelMethods(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_modelMethods(ctx, field) + return res + }) case "valid": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_valid(ctx, field) - if out.Values[i] == graphql.Null { + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_valid(ctx, field) + if res == graphql.Null { invalid = true } - wg.Done() - }(i, field) + return res + }) case "user": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_user(ctx, field) - if out.Values[i] == graphql.Null { + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_user(ctx, field) + if res == graphql.Null { invalid = true } - wg.Done() - }(i, field) + return res + }) case "nullableArg": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_nullableArg(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_nullableArg(ctx, field) + return res + }) case "keywordArgs": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_keywordArgs(ctx, field) - if out.Values[i] == graphql.Null { + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_keywordArgs(ctx, field) + if res == graphql.Null { invalid = true } - wg.Done() - }(i, field) + return res + }) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": @@ -1784,7 +1762,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr panic("unknown field " + strconv.Quote(field.Name)) } } - wg.Wait() + out.Dispatch() if invalid { return graphql.Null } @@ -2393,11 +2371,9 @@ var rectangleImplementors = []string{"Rectangle", "Shape"} func (ec *executionContext) _Rectangle(ctx context.Context, sel ast.SelectionSet, obj *Rectangle) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, rectangleImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Rectangle") @@ -2411,7 +2387,7 @@ func (ec *executionContext) _Rectangle(ctx context.Context, sel ast.SelectionSet panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -2530,9 +2506,15 @@ func (ec *executionContext) _Subscription_updated(ctx context.Context, field gra if !ok { return nil } - var out graphql.OrderedMap - out.Add(field.Alias, func() graphql.Marshaler { return graphql.MarshalString(res) }()) - return &out + return graphql.WriterFunc(func(w io.Writer) { + w.Write([]byte{'{'}) + graphql.MarshalString(field.Alias).MarshalGQL(w) + w.Write([]byte{':'}) + func() graphql.Marshaler { + return graphql.MarshalString(res) + }().MarshalGQL(w) + w.Write([]byte{'}'}) + }) } } @@ -2553,9 +2535,15 @@ func (ec *executionContext) _Subscription_initPayload(ctx context.Context, field if !ok { return nil } - var out graphql.OrderedMap - out.Add(field.Alias, func() graphql.Marshaler { return graphql.MarshalString(res) }()) - return &out + return graphql.WriterFunc(func(w io.Writer) { + w.Write([]byte{'{'}) + graphql.MarshalString(field.Alias).MarshalGQL(w) + w.Write([]byte{':'}) + func() graphql.Marshaler { + return graphql.MarshalString(res) + }().MarshalGQL(w) + w.Write([]byte{'}'}) + }) } } @@ -2565,12 +2553,9 @@ var userImplementors = []string{"User"} func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *User) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, userImplementors) - var wg sync.WaitGroup - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("User") @@ -2580,19 +2565,19 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj invalid = true } case "friends": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._User_friends(ctx, field, obj) - if out.Values[i] == graphql.Null { + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._User_friends(ctx, field, obj) + if res == graphql.Null { invalid = true } - wg.Done() - }(i, field) + return res + }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - wg.Wait() + out.Dispatch() if invalid { return graphql.Null } @@ -2692,11 +2677,9 @@ var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") @@ -2721,7 +2704,7 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -2881,11 +2864,9 @@ var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__EnumValue") @@ -2907,7 +2888,7 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -3026,11 +3007,9 @@ var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __FieldImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Field") @@ -3062,7 +3041,7 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -3276,11 +3255,9 @@ var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__InputValue") @@ -3302,7 +3279,7 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -3429,11 +3406,9 @@ var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Schema") @@ -3460,7 +3435,7 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -3686,11 +3661,9 @@ var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __TypeImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Type") @@ -3719,7 +3692,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } diff --git a/example/chat/generated.go b/example/chat/generated.go index d1bb62f7d3d..4f4682c0e3b 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -6,6 +6,7 @@ import ( "bytes" "context" "errors" + "io" "strconv" "sync" "time" @@ -356,11 +357,9 @@ var chatroomImplementors = []string{"Chatroom"} func (ec *executionContext) _Chatroom(ctx context.Context, sel ast.SelectionSet, obj *Chatroom) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, chatroomImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Chatroom") @@ -378,7 +377,7 @@ func (ec *executionContext) _Chatroom(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -478,11 +477,9 @@ var messageImplementors = []string{"Message"} func (ec *executionContext) _Message(ctx context.Context, sel ast.SelectionSet, obj *Message) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, messageImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Message") @@ -510,7 +507,7 @@ func (ec *executionContext) _Message(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -635,11 +632,9 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) Object: "Mutation", }) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Mutation") @@ -652,7 +647,7 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -703,21 +698,18 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr Object: "Query", }) - var wg sync.WaitGroup - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "room": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_room(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_room(ctx, field) + return res + }) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": @@ -726,7 +718,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr panic("unknown field " + strconv.Quote(field.Name)) } } - wg.Wait() + out.Dispatch() if invalid { return graphql.Null } @@ -876,11 +868,16 @@ func (ec *executionContext) _Subscription_messageAdded(ctx context.Context, fiel if !ok { return nil } - var out graphql.OrderedMap - out.Add(field.Alias, func() graphql.Marshaler { - return ec._Message(ctx, field.Selections, &res) - }()) - return &out + return graphql.WriterFunc(func(w io.Writer) { + w.Write([]byte{'{'}) + graphql.MarshalString(field.Alias).MarshalGQL(w) + w.Write([]byte{':'}) + func() graphql.Marshaler { + + return ec._Message(ctx, field.Selections, &res) + }().MarshalGQL(w) + w.Write([]byte{'}'}) + }) } } @@ -890,11 +887,9 @@ var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") @@ -919,7 +914,7 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1079,11 +1074,9 @@ var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__EnumValue") @@ -1105,7 +1098,7 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1224,11 +1217,9 @@ var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __FieldImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Field") @@ -1260,7 +1251,7 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1474,11 +1465,9 @@ var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__InputValue") @@ -1500,7 +1489,7 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1627,11 +1616,9 @@ var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Schema") @@ -1658,7 +1645,7 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1884,11 +1871,9 @@ var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __TypeImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Type") @@ -1917,7 +1902,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } diff --git a/example/config/generated.go b/example/config/generated.go index f408b8e5fa3..c9e36cd03a3 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -269,11 +269,9 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) Object: "Mutation", }) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Mutation") @@ -286,7 +284,7 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -337,24 +335,21 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr Object: "Query", }) - var wg sync.WaitGroup - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "todos": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_todos(ctx, field) - if out.Values[i] == graphql.Null { + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_todos(ctx, field) + if res == graphql.Null { invalid = true } - wg.Done() - }(i, field) + return res + }) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": @@ -363,7 +358,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr panic("unknown field " + strconv.Quote(field.Name)) } } - wg.Wait() + out.Dispatch() if invalid { return graphql.Null } @@ -500,24 +495,21 @@ 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)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Todo") case "id": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Todo_id(ctx, field, obj) - if out.Values[i] == graphql.Null { + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Todo_id(ctx, field, obj) + if res == graphql.Null { invalid = true } - wg.Done() - }(i, field) + return res + }) case "databaseId": out.Values[i] = ec._Todo_databaseId(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -542,7 +534,7 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj panic("unknown field " + strconv.Quote(field.Name)) } } - wg.Wait() + out.Dispatch() if invalid { return graphql.Null } @@ -691,11 +683,9 @@ var userImplementors = []string{"User"} func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *User) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, userImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("User") @@ -713,7 +703,7 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -780,11 +770,9 @@ var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") @@ -809,7 +797,7 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -969,11 +957,9 @@ var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__EnumValue") @@ -995,7 +981,7 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1114,11 +1100,9 @@ var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __FieldImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Field") @@ -1150,7 +1134,7 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1364,11 +1348,9 @@ var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__InputValue") @@ -1390,7 +1372,7 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1517,11 +1499,9 @@ var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Schema") @@ -1548,7 +1528,7 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1774,11 +1754,9 @@ var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __TypeImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Type") @@ -1807,7 +1785,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index a3d4f0ffdb2..ba3a3d6e45a 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -360,11 +360,9 @@ var addressImplementors = []string{"Address"} func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, obj *Address) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, addressImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Address") @@ -387,7 +385,7 @@ func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -481,12 +479,9 @@ 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)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Customer") @@ -501,22 +496,22 @@ func (ec *executionContext) _Customer(ctx context.Context, sel ast.SelectionSet, invalid = true } case "address": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Customer_address(ctx, field, obj) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Customer_address(ctx, field, obj) + return res + }) case "orders": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Customer_orders(ctx, field, obj) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Customer_orders(ctx, field, obj) + return res + }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - wg.Wait() + out.Dispatch() if invalid { return graphql.Null } @@ -669,11 +664,9 @@ var itemImplementors = []string{"Item"} func (ec *executionContext) _Item(ctx context.Context, sel ast.SelectionSet, obj *Item) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, itemImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Item") @@ -686,7 +679,7 @@ func (ec *executionContext) _Item(ctx context.Context, sel ast.SelectionSet, obj panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -726,12 +719,9 @@ 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)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Order") @@ -751,16 +741,16 @@ func (ec *executionContext) _Order(ctx context.Context, sel ast.SelectionSet, ob invalid = true } case "items": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Order_items(ctx, field, obj) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Order_items(ctx, field, obj) + return res + }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - wg.Wait() + out.Dispatch() if invalid { return graphql.Null } @@ -915,33 +905,30 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr Object: "Query", }) - var wg sync.WaitGroup - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "customers": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_customers(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_customers(ctx, field) + return res + }) case "torture1d": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_torture1d(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_torture1d(ctx, field) + return res + }) case "torture2d": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_torture2d(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_torture2d(ctx, field) + return res + }) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": @@ -950,7 +937,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr panic("unknown field " + strconv.Quote(field.Name)) } } - wg.Wait() + out.Dispatch() if invalid { return graphql.Null } @@ -1241,11 +1228,9 @@ var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") @@ -1270,7 +1255,7 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1430,11 +1415,9 @@ var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__EnumValue") @@ -1456,7 +1439,7 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1575,11 +1558,9 @@ var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __FieldImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Field") @@ -1611,7 +1592,7 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1825,11 +1806,9 @@ var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__InputValue") @@ -1851,7 +1830,7 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1978,11 +1957,9 @@ var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Schema") @@ -2009,7 +1986,7 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -2235,11 +2212,9 @@ var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __TypeImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Type") @@ -2268,7 +2243,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } diff --git a/example/scalars/generated.go b/example/scalars/generated.go index af67c2b40dd..c05d47525c4 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -299,11 +299,9 @@ var addressImplementors = []string{"Address"} func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, obj *model.Address) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, addressImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Address") @@ -318,7 +316,7 @@ func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -390,30 +388,27 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr Object: "Query", }) - var wg sync.WaitGroup - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "user": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_user(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_user(ctx, field) + return res + }) case "search": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_search(ctx, field) - if out.Values[i] == graphql.Null { + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_search(ctx, field) + if res == graphql.Null { invalid = true } - wg.Done() - }(i, field) + return res + }) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": @@ -422,7 +417,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr panic("unknown field " + strconv.Quote(field.Name)) } } - wg.Wait() + out.Dispatch() if invalid { return graphql.Null } @@ -600,12 +595,9 @@ 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)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("User") @@ -627,23 +619,23 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj invalid = true } case "primitiveResolver": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._User_primitiveResolver(ctx, field, obj) - if out.Values[i] == graphql.Null { + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._User_primitiveResolver(ctx, field, obj) + if res == graphql.Null { invalid = true } - wg.Done() - }(i, field) + return res + }) case "customResolver": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._User_customResolver(ctx, field, obj) - if out.Values[i] == graphql.Null { + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._User_customResolver(ctx, field, obj) + if res == graphql.Null { invalid = true } - wg.Done() - }(i, field) + return res + }) case "address": out.Values[i] = ec._User_address(ctx, field, obj) case "tier": @@ -652,7 +644,7 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj panic("unknown field " + strconv.Quote(field.Name)) } } - wg.Wait() + out.Dispatch() if invalid { return graphql.Null } @@ -873,11 +865,9 @@ var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") @@ -902,7 +892,7 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1062,11 +1052,9 @@ var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__EnumValue") @@ -1088,7 +1076,7 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1207,11 +1195,9 @@ var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __FieldImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Field") @@ -1243,7 +1229,7 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1457,11 +1443,9 @@ var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__InputValue") @@ -1483,7 +1467,7 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1610,11 +1594,9 @@ var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Schema") @@ -1641,7 +1623,7 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1867,11 +1849,9 @@ var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __TypeImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Type") @@ -1900,7 +1880,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } diff --git a/example/selection/generated.go b/example/selection/generated.go index b8f99c7e32c..5e6f8c53bd3 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -223,11 +223,9 @@ var likeImplementors = []string{"Like", "Event"} func (ec *executionContext) _Like(ctx context.Context, sel ast.SelectionSet, obj *Like) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, likeImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Like") @@ -249,7 +247,7 @@ func (ec *executionContext) _Like(ctx context.Context, sel ast.SelectionSet, obj panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -382,11 +380,9 @@ var postImplementors = []string{"Post", "Event"} func (ec *executionContext) _Post(ctx context.Context, sel ast.SelectionSet, obj *Post) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, postImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Post") @@ -408,7 +404,7 @@ func (ec *executionContext) _Post(ctx context.Context, sel ast.SelectionSet, obj panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -545,21 +541,18 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr Object: "Query", }) - var wg sync.WaitGroup - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "events": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_events(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_events(ctx, field) + return res + }) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": @@ -568,7 +561,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr panic("unknown field " + strconv.Quote(field.Name)) } } - wg.Wait() + out.Dispatch() if invalid { return graphql.Null } @@ -702,11 +695,9 @@ var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") @@ -731,7 +722,7 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -891,11 +882,9 @@ var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__EnumValue") @@ -917,7 +906,7 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1036,11 +1025,9 @@ var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __FieldImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Field") @@ -1072,7 +1059,7 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1286,11 +1273,9 @@ var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__InputValue") @@ -1312,7 +1297,7 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1439,11 +1424,9 @@ var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Schema") @@ -1470,7 +1453,7 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1696,11 +1679,9 @@ var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __TypeImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Type") @@ -1729,7 +1710,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } diff --git a/example/starwars/generated.go b/example/starwars/generated.go index a58a5750e6b..9c38be96a51 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -828,12 +828,9 @@ 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)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Droid") @@ -848,20 +845,20 @@ func (ec *executionContext) _Droid(ctx context.Context, sel ast.SelectionSet, ob invalid = true } case "friends": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Droid_friends(ctx, field, obj) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Droid_friends(ctx, field, obj) + return res + }) case "friendsConnection": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Droid_friendsConnection(ctx, field, obj) - if out.Values[i] == graphql.Null { + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Droid_friendsConnection(ctx, field, obj) + if res == graphql.Null { invalid = true } - wg.Done() - }(i, field) + return res + }) case "appearsIn": out.Values[i] = ec._Droid_appearsIn(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -873,7 +870,7 @@ func (ec *executionContext) _Droid(ctx context.Context, sel ast.SelectionSet, ob panic("unknown field " + strconv.Quote(field.Name)) } } - wg.Wait() + out.Dispatch() if invalid { return graphql.Null } @@ -1091,12 +1088,9 @@ 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)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("FriendsConnection") @@ -1106,17 +1100,17 @@ func (ec *executionContext) _FriendsConnection(ctx context.Context, sel ast.Sele invalid = true } case "edges": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._FriendsConnection_edges(ctx, field, obj) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._FriendsConnection_edges(ctx, field, obj) + return res + }) case "friends": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._FriendsConnection_friends(ctx, field, obj) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._FriendsConnection_friends(ctx, field, obj) + return res + }) case "pageInfo": out.Values[i] = ec._FriendsConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -1126,7 +1120,7 @@ func (ec *executionContext) _FriendsConnection(ctx context.Context, sel ast.Sele panic("unknown field " + strconv.Quote(field.Name)) } } - wg.Wait() + out.Dispatch() if invalid { return graphql.Null } @@ -1308,11 +1302,9 @@ var friendsEdgeImplementors = []string{"FriendsEdge"} func (ec *executionContext) _FriendsEdge(ctx context.Context, sel ast.SelectionSet, obj *FriendsEdge) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, friendsEdgeImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("FriendsEdge") @@ -1327,7 +1319,7 @@ func (ec *executionContext) _FriendsEdge(ctx context.Context, sel ast.SelectionS panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1392,12 +1384,9 @@ 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)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Human") @@ -1419,36 +1408,36 @@ func (ec *executionContext) _Human(ctx context.Context, sel ast.SelectionSet, ob case "mass": out.Values[i] = ec._Human_mass(ctx, field, obj) case "friends": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Human_friends(ctx, field, obj) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Human_friends(ctx, field, obj) + return res + }) case "friendsConnection": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Human_friendsConnection(ctx, field, obj) - if out.Values[i] == graphql.Null { + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Human_friendsConnection(ctx, field, obj) + if res == graphql.Null { invalid = true } - wg.Done() - }(i, field) + return res + }) case "appearsIn": out.Values[i] = ec._Human_appearsIn(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } case "starships": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Human_starships(ctx, field, obj) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Human_starships(ctx, field, obj) + return res + }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - wg.Wait() + out.Dispatch() if invalid { return graphql.Null } @@ -1760,11 +1749,9 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) Object: "Mutation", }) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Mutation") @@ -1774,7 +1761,7 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1822,11 +1809,9 @@ var pageInfoImplementors = []string{"PageInfo"} func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *PageInfo) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, pageInfoImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("PageInfo") @@ -1849,7 +1834,7 @@ func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1947,63 +1932,60 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr Object: "Query", }) - var wg sync.WaitGroup - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "hero": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_hero(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_hero(ctx, field) + return res + }) case "reviews": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_reviews(ctx, field) - if out.Values[i] == graphql.Null { + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_reviews(ctx, field) + if res == graphql.Null { invalid = true } - wg.Done() - }(i, field) + return res + }) case "search": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_search(ctx, field) - if out.Values[i] == graphql.Null { + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_search(ctx, field) + if res == graphql.Null { invalid = true } - wg.Done() - }(i, field) + return res + }) case "character": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_character(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_character(ctx, field) + return res + }) case "droid": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_droid(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_droid(ctx, field) + return res + }) case "human": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_human(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_human(ctx, field) + return res + }) case "starship": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_starship(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_starship(ctx, field) + return res + }) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": @@ -2012,7 +1994,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr panic("unknown field " + strconv.Quote(field.Name)) } } - wg.Wait() + out.Dispatch() if invalid { return graphql.Null } @@ -2388,11 +2370,9 @@ var reviewImplementors = []string{"Review"} func (ec *executionContext) _Review(ctx context.Context, sel ast.SelectionSet, obj *Review) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, reviewImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Review") @@ -2409,7 +2389,7 @@ func (ec *executionContext) _Review(ctx context.Context, sel ast.SelectionSet, o panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -2501,12 +2481,9 @@ 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)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Starship") @@ -2521,14 +2498,14 @@ func (ec *executionContext) _Starship(ctx context.Context, sel ast.SelectionSet, invalid = true } case "length": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Starship_length(ctx, field, obj) - if out.Values[i] == graphql.Null { + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Starship_length(ctx, field, obj) + if res == graphql.Null { invalid = true } - wg.Done() - }(i, field) + return res + }) case "history": out.Values[i] = ec._Starship_history(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -2538,7 +2515,7 @@ func (ec *executionContext) _Starship(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - wg.Wait() + out.Dispatch() if invalid { return graphql.Null } @@ -2683,11 +2660,9 @@ var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") @@ -2712,7 +2687,7 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -2872,11 +2847,9 @@ var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__EnumValue") @@ -2898,7 +2871,7 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -3017,11 +2990,9 @@ var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __FieldImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Field") @@ -3053,7 +3024,7 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -3267,11 +3238,9 @@ var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__InputValue") @@ -3293,7 +3262,7 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -3420,11 +3389,9 @@ var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Schema") @@ -3451,7 +3418,7 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -3677,11 +3644,9 @@ var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __TypeImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Type") @@ -3710,7 +3675,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } diff --git a/example/todo/generated.go b/example/todo/generated.go index 2fbe0d159e9..4e70d88ac18 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -322,11 +322,9 @@ func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSe Object: "MyMutation", }) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("MyMutation") @@ -341,7 +339,7 @@ func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSe panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -427,36 +425,33 @@ func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) Object: "MyQuery", }) - var wg sync.WaitGroup - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("MyQuery") case "todo": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._MyQuery_todo(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._MyQuery_todo(ctx, field) + return res + }) case "lastTodo": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._MyQuery_lastTodo(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._MyQuery_lastTodo(ctx, field) + return res + }) case "todos": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._MyQuery_todos(ctx, field) - if out.Values[i] == graphql.Null { + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._MyQuery_todos(ctx, field) + if res == graphql.Null { invalid = true } - wg.Done() - }(i, field) + return res + }) case "__type": out.Values[i] = ec._MyQuery___type(ctx, field) case "__schema": @@ -465,7 +460,7 @@ func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) panic("unknown field " + strconv.Quote(field.Name)) } } - wg.Wait() + out.Dispatch() if invalid { return graphql.Null } @@ -666,11 +661,9 @@ var todoImplementors = []string{"Todo"} func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, todoImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Todo") @@ -693,7 +686,7 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -787,11 +780,9 @@ var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") @@ -816,7 +807,7 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -976,11 +967,9 @@ var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__EnumValue") @@ -1002,7 +991,7 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1121,11 +1110,9 @@ var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __FieldImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Field") @@ -1157,7 +1144,7 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1371,11 +1358,9 @@ var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__InputValue") @@ -1397,7 +1382,7 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1524,11 +1509,9 @@ var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Schema") @@ -1555,7 +1538,7 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1781,11 +1764,9 @@ var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __TypeImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Type") @@ -1814,7 +1795,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index 065da51a593..1372ad097fe 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -281,11 +281,9 @@ func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSe Object: "MyMutation", }) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("MyMutation") @@ -298,7 +296,7 @@ func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSe panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -349,30 +347,27 @@ func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) Object: "MyQuery", }) - var wg sync.WaitGroup - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("MyQuery") case "todos": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._MyQuery_todos(ctx, field) - if out.Values[i] == graphql.Null { + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._MyQuery_todos(ctx, field) + if res == graphql.Null { invalid = true } - wg.Done() - }(i, field) + return res + }) case "todo": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._MyQuery_todo(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._MyQuery_todo(ctx, field) + return res + }) case "__type": out.Values[i] = ec._MyQuery___type(ctx, field) case "__schema": @@ -381,7 +376,7 @@ func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) panic("unknown field " + strconv.Quote(field.Name)) } } - wg.Wait() + out.Dispatch() if invalid { return graphql.Null } @@ -553,11 +548,9 @@ var todoImplementors = []string{"Todo", "Node"} func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, todoImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Todo") @@ -585,7 +578,7 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -706,11 +699,9 @@ var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") @@ -735,7 +726,7 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -895,11 +886,9 @@ var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__EnumValue") @@ -921,7 +910,7 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1040,11 +1029,9 @@ var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __FieldImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Field") @@ -1076,7 +1063,7 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1290,11 +1277,9 @@ var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__InputValue") @@ -1316,7 +1301,7 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1443,11 +1428,9 @@ var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Schema") @@ -1474,7 +1457,7 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1700,11 +1683,9 @@ var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __TypeImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Type") @@ -1733,7 +1714,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } diff --git a/graphql/fieldset.go b/graphql/fieldset.go new file mode 100644 index 00000000000..351e266fdb3 --- /dev/null +++ b/graphql/fieldset.go @@ -0,0 +1,63 @@ +package graphql + +import ( + "io" + "sync" +) + +type FieldSet struct { + fields []CollectedField + Values []Marshaler + delayed []delayedResult +} + +type delayedResult struct { + i int + f func() Marshaler +} + +func NewFieldSet(fields []CollectedField) *FieldSet { + return &FieldSet{ + fields: fields, + Values: make([]Marshaler, len(fields)), + } +} + +func (m *FieldSet) Concurrently(i int, f func() Marshaler) { + m.delayed = append(m.delayed, delayedResult{i: i, f: f}) +} + +func (m *FieldSet) Dispatch() { + if len(m.delayed) == 1 { + // only one concurrent task, no need to spawn a goroutine or deal create waitgroups + d := m.delayed[0] + m.Values[d.i] = d.f() + } else if len(m.delayed) > 1 { + // more than one concurrent task, use the main goroutine to do one, only spawn goroutines for the others + + var wg sync.WaitGroup + for _, d := range m.delayed[1:] { + wg.Add(1) + go func(d delayedResult) { + m.Values[d.i] = d.f() + wg.Done() + }(d) + } + + m.Values[m.delayed[0].i] = m.delayed[0].f() + wg.Wait() + } +} + +func (m *FieldSet) MarshalGQL(writer io.Writer) { + writer.Write(openBrace) + for i, field := range m.fields { + if i != 0 { + writer.Write(comma) + } + writeQuotedString(writer, field.Alias) + writer.Write(colon) + m.Values[i].MarshalGQL(writer) + } + writer.Write(closeBrace) +} diff --git a/graphql/jsonw.go b/graphql/jsonw.go index c087f63bd0d..db95d8e4419 100644 --- a/graphql/jsonw.go +++ b/graphql/jsonw.go @@ -26,42 +26,12 @@ type Unmarshaler interface { UnmarshalGQL(v interface{}) error } -type OrderedMap struct { - Keys []string - Values []Marshaler -} - type WriterFunc func(writer io.Writer) func (f WriterFunc) MarshalGQL(w io.Writer) { f(w) } -func NewOrderedMap(len int) *OrderedMap { - return &OrderedMap{ - Keys: make([]string, len), - Values: make([]Marshaler, len), - } -} - -func (m *OrderedMap) Add(key string, value Marshaler) { - m.Keys = append(m.Keys, key) - m.Values = append(m.Values, value) -} - -func (m *OrderedMap) MarshalGQL(writer io.Writer) { - writer.Write(openBrace) - for i, key := range m.Keys { - if i != 0 { - writer.Write(comma) - } - writeQuotedString(writer, key) - writer.Write(colon) - m.Values[i].MarshalGQL(writer) - } - writer.Write(closeBrace) -} - type Array []Marshaler func (a Array) MarshalGQL(writer io.Writer) { diff --git a/graphql/jsonw_test.go b/graphql/jsonw_test.go index 00f01cf57b7..856f1b9cdde 100644 --- a/graphql/jsonw_test.go +++ b/graphql/jsonw_test.go @@ -5,13 +5,19 @@ import ( "testing" "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser/ast" ) func TestJsonWriter(t *testing.T) { - obj := &OrderedMap{} - obj.Add("test", MarshalInt(10)) + obj := NewFieldSet([]CollectedField{ + {Field: &ast.Field{Alias: "test"}}, + {Field: &ast.Field{Alias: "array"}}, + {Field: &ast.Field{Alias: "emptyArray"}}, + {Field: &ast.Field{Alias: "child"}}, + }) + obj.Values[0] = MarshalInt(10) - obj.Add("array", &Array{ + obj.Values[1] = &Array{ MarshalInt(1), MarshalString("2"), MarshalBoolean(true), @@ -19,17 +25,21 @@ func TestJsonWriter(t *testing.T) { Null, MarshalFloat(1.3), True, - }) + } - obj.Add("emptyArray", &Array{}) + obj.Values[2] = &Array{} - child2 := &OrderedMap{} - child2.Add("child", Null) + child2 := NewFieldSet([]CollectedField{ + {Field: &ast.Field{Alias: "child"}}, + }) + child2.Values[0] = Null - child1 := &OrderedMap{} - child1.Add("child", child2) + child1 := NewFieldSet([]CollectedField{ + {Field: &ast.Field{Alias: "child"}}, + }) + child1.Values[0] = child2 - obj.Add("child", child1) + obj.Values[3] = child1 b := &bytes.Buffer{} obj.MarshalGQL(b) diff --git a/integration/generated.go b/integration/generated.go index 008cf1959ab..83a4a42cc48 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -322,44 +322,41 @@ 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)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Element") case "child": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Element_child(ctx, field, obj) - if out.Values[i] == graphql.Null { + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Element_child(ctx, field, obj) + if res == graphql.Null { invalid = true } - wg.Done() - }(i, field) + return res + }) case "error": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Element_error(ctx, field, obj) - if out.Values[i] == graphql.Null { + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Element_error(ctx, field, obj) + if res == graphql.Null { invalid = true } - wg.Done() - }(i, field) + return res + }) case "mismatched": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Element_mismatched(ctx, field, obj) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Element_mismatched(ctx, field, obj) + return res + }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - wg.Wait() + out.Dispatch() if invalid { return graphql.Null } @@ -464,54 +461,51 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr Object: "Query", }) - var wg sync.WaitGroup - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "path": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_path(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_path(ctx, field) + return res + }) case "date": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_date(ctx, field) - if out.Values[i] == graphql.Null { + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_date(ctx, field) + if res == graphql.Null { invalid = true } - wg.Done() - }(i, field) + return res + }) case "viewer": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_viewer(ctx, field) - wg.Done() - }(i, field) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_viewer(ctx, field) + return res + }) case "jsonEncoding": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_jsonEncoding(ctx, field) - if out.Values[i] == graphql.Null { + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_jsonEncoding(ctx, field) + if res == graphql.Null { invalid = true } - wg.Done() - }(i, field) + return res + }) case "error": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_error(ctx, field) - if out.Values[i] == graphql.Null { + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_error(ctx, field) + if res == graphql.Null { invalid = true } - wg.Done() - }(i, field) + return res + }) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": @@ -520,7 +514,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr panic("unknown field " + strconv.Quote(field.Name)) } } - wg.Wait() + out.Dispatch() if invalid { return graphql.Null } @@ -780,12 +774,9 @@ 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)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("User") @@ -795,19 +786,19 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj invalid = true } case "likes": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._User_likes(ctx, field, obj) - if out.Values[i] == graphql.Null { + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._User_likes(ctx, field, obj) + if res == graphql.Null { invalid = true } - wg.Done() - }(i, field) + return res + }) default: panic("unknown field " + strconv.Quote(field.Name)) } } - wg.Wait() + out.Dispatch() if invalid { return graphql.Null } @@ -883,11 +874,9 @@ var viewerImplementors = []string{"Viewer"} func (ec *executionContext) _Viewer(ctx context.Context, sel ast.SelectionSet, obj *models.Viewer) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, viewerImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Viewer") @@ -897,7 +886,7 @@ func (ec *executionContext) _Viewer(ctx context.Context, sel ast.SelectionSet, o panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -939,11 +928,9 @@ var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") @@ -968,7 +955,7 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1128,11 +1115,9 @@ var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__EnumValue") @@ -1154,7 +1139,7 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1273,11 +1258,9 @@ var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __FieldImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Field") @@ -1309,7 +1292,7 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1523,11 +1506,9 @@ var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__InputValue") @@ -1549,7 +1530,7 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1676,11 +1657,9 @@ var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Schema") @@ -1707,7 +1686,7 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } @@ -1933,11 +1912,9 @@ var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __TypeImplementors) - out := graphql.NewOrderedMap(len(fields)) + out := graphql.NewFieldSet(fields) invalid := false for i, field := range fields { - out.Keys[i] = field.Alias - switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Type") @@ -1966,7 +1943,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o panic("unknown field " + strconv.Quote(field.Name)) } } - + out.Dispatch() if invalid { return graphql.Null } From f9ee6ce0a09fd587c5786e18d2f089df83a10b55 Mon Sep 17 00:00:00 2001 From: andrey1s <“andrey@4devs.pro”> Date: Sat, 8 Dec 2018 12:26:21 +0300 Subject: [PATCH 021/147] return arg in middleware --- codegen/templates/args.gotpl | 7 ++++--- codegen/templates/data.go | 2 +- codegen/testserver/generated.go | 21 ++++++++++++--------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/codegen/templates/args.gotpl b/codegen/templates/args.gotpl index 5b6e0f33c54..7d75e1e838a 100644 --- a/codegen/templates/args.gotpl +++ b/codegen/templates/args.gotpl @@ -15,12 +15,13 @@ return e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs "tmp" "n" }}) }, {{- end }} - }...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){ - {{$arg.Unmarshal (print "args" $i) "tmp" }} + }...)(ctx, func(ctx2 context.Context)(interface{}, error){ + var err error + {{$arg.Unmarshal (print "arg" $i) "tmp" }} if err != nil { return nil, err } - return + return arg{{ $i }}, nil }) if err != nil { return nil, err diff --git a/codegen/templates/data.go b/codegen/templates/data.go index 2928ed29d7e..495ba220432 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -1,7 +1,7 @@ package templates var data = map[string]string{ - "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $dArg.IsPtr ( notNil \"Value\" $dArg ) }}\n\t\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $dArg.Value | dump }}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(args{{$i}} interface{},err error){\n\t\t\t\t\t{{$arg.Unmarshal (print \"args\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t {{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\tvar err error\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", + "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $dArg.IsPtr ( notNil \"Value\" $dArg ) }}\n\t\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $dArg.Value | dump }}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(interface{}, error){\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn arg{{ $i }}, nil\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t {{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\tvar err error\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\n\t\tresults, err := ec.resolvers.{{ $field.ShortInvocation }}\n\t\tif err != nil {\n\t\t\tec.Error(ctx, err)\n\t\t\treturn nil\n\t\t}\n\t\treturn func() graphql.Marshaler {\n\t\t\tres, ok := <-results\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tvar out graphql.OrderedMap\n\t\t\tout.Add(field.Alias, func() graphql.Marshaler { {{ $field.WriteJson }} }())\n\t\t\treturn &out\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\n)\n\n\n\n// ChainFieldMiddleware add chain by FieldMiddleware\n// nolint: deadcode\nfunc chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware {\n\tn := len(handleFunc)\n\n\tif n > 1 {\n\t\tlastI := n - 1\n\t\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\t\tvar (\n\t\t\t\tchainHandler graphql.Resolver\n\t\t\t\tcurI int\n\t\t\t)\n\t\t\tchainHandler = func(currentCtx context.Context) (interface{}, error) {\n\t\t\t\tif curI == lastI {\n\t\t\t\t\treturn next(currentCtx)\n\t\t\t\t}\n\t\t\t\tcurI++\n\t\t\t\tres, err := handleFunc[curI](currentCtx, chainHandler)\n\t\t\t\tcurI--\n\t\t\t\treturn res, err\n\n\t\t\t}\n\t\t\treturn handleFunc[0](ctx, chainHandler)\n\t\t}\n\t}\n\n\tif n == 1 {\n\t\treturn handleFunc[0]\n\t}\n\n\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\treturn next(ctx)\n\t}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := chainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t\tc{{$field.GoFieldName}}, err := chainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\t{{ if $field.IsPtr -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"*obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- else -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{ if $field.IsPtr }}*{{end}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\n", diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index dacbb2becf3..a645a0b9612 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -346,12 +346,13 @@ func (e *executableSchema) field_Query_directiveArg_args(ctx context.Context, ra max := 255 return e.directives.Length(ctx, tmp, n, 1, &max, "invalid length") }, - }...)(ctx, func(ctx2 context.Context) (args0 interface{}, err error) { - args0, err = graphql.UnmarshalString(tmp) + }...)(ctx, func(ctx2 context.Context) (interface{}, error) { + var err error + arg0, err = graphql.UnmarshalString(tmp) if err != nil { return nil, err } - return + return arg0, nil }) if err != nil { return nil, err @@ -378,17 +379,18 @@ func (e *executableSchema) field_Query_directiveNullableArg_args(ctx context.Con min := 0 return e.directives.Range(ctx, tmp, n, &min, nil, nil) }, - }...)(ctx, func(ctx2 context.Context) (args0 interface{}, err error) { + }...)(ctx, func(ctx2 context.Context) (interface{}, error) { + var err error var ptr1 int if tmp != nil { ptr1, err = graphql.UnmarshalInt(tmp) - args0 = &ptr1 + arg0 = &ptr1 } if err != nil { return nil, err } - return + return arg0, nil }) if err != nil { return nil, err @@ -409,17 +411,18 @@ func (e *executableSchema) field_Query_directiveNullableArg_args(ctx context.Con min := 0 return e.directives.Range(ctx, tmp, n, &min, nil, nil) }, - }...)(ctx, func(ctx2 context.Context) (args1 interface{}, err error) { + }...)(ctx, func(ctx2 context.Context) (interface{}, error) { + var err error var ptr1 int if tmp != nil { ptr1, err = graphql.UnmarshalInt(tmp) - args1 = &ptr1 + arg1 = &ptr1 } if err != nil { return nil, err } - return + return arg1, nil }) if err != nil { return nil, err From 1e3e5e9b36587311b8b632668f83b53278d3f8eb Mon Sep 17 00:00:00 2001 From: Nico Vogelaar Date: Thu, 3 Jan 2019 21:11:25 +0000 Subject: [PATCH 022/147] add list of enums --- codegen/templates/data.go | 2 +- codegen/templates/models.gotpl | 6 ++++++ example/starwars/models_gen.go | 11 +++++++++++ example/todo/models_gen.go | 5 +++++ example/type-system-extension/models_gen.go | 5 +++++ integration/models-go/generated.go | 14 ++++++++++++++ 6 files changed, 42 insertions(+), 1 deletion(-) diff --git a/codegen/templates/data.go b/codegen/templates/data.go index 7eb66cb5932..1f2d9b1923d 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -6,7 +6,7 @@ var data = map[string]string{ "generated.gotpl": "// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.\n\npackage {{ .PackageName }}\n\nimport (\n\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc {{ $field.ArgsFunc }}(rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc {{ $directive.ArgsFunc }}(rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := {{ $field.ArgsFunc }}(rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := {{ $directive.ArgsFunc }}(rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{ range $model := .Models }}\n\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .IsInterface }}\n\t\ttype {{.GoType}} interface {\n\t\t\tIs{{.GoType}}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.GoType}} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\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\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.GoType}}) Is{{$iface.GoType}}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.GoType}} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- 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", + "models.gotpl": "// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.\n\npackage {{ .PackageName }}\n\nimport (\n\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{ range $model := .Models }}\n\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .IsInterface }}\n\t\ttype {{.GoType}} interface {\n\t\t\tIs{{.GoType}}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.GoType}} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\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\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.GoType}}) Is{{$iface.GoType}}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.GoType}} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- end}}\n\t\t{{$enum.GoType}}{{ .Name|toCamel }} {{$enum.GoType}} = {{.Name|quote}}\n\t{{- end }}\n\t)\n\n\tvar All{{.GoType}} = []{{.GoType}}{\n\t{{- range $value := .Values}}\n\t\t{{$enum.GoType}}{{ .Name|toCamel }},\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\n\tout := graphql.NewFieldSet(fields)\n\tinvalid := false\n\tfor i, field := range fields {\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\tfield := field\n\t\t\t\tout.Concurrently(i, func() (res graphql.Marshaler) {\n\t\t\t\t\tres = ec._{{$object.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\t\tif res == graphql.Null {\n\t\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t\t}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\treturn res\n\t\t\t\t})\n\t\t\t{{- else }}\n\t\t\t\tout.Values[i] = ec._{{$object.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\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\tout.Dispatch()\n\tif invalid { return graphql.Null }\n\treturn out\n}\n{{- end }}\n", "resolver.gotpl": "package {{ .PackageName }}\n\nimport (\n\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/99designs/gqlgen/handler\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"log\" }}\n\t{{ reserveImport \"net/http\" }}\n\t{{ reserveImport \"os\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/handler\" }}\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({{ lookupImport .ExecPackageName }}.NewExecutableSchema({{ lookupImport .ExecPackageName}}.Config{Resolvers: &{{ lookupImport .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/models.gotpl b/codegen/templates/models.gotpl index db63a996ba8..651aa793e5a 100644 --- a/codegen/templates/models.gotpl +++ b/codegen/templates/models.gotpl @@ -59,6 +59,12 @@ import ( {{- end }} ) + var All{{.GoType}} = []{{.GoType}}{ + {{- range $value := .Values}} + {{$enum.GoType}}{{ .Name|toCamel }}, + {{- end }} + } + func (e {{.GoType}}) IsValid() bool { switch e { case {{ range $index, $element := .Values}}{{if $index}},{{end}}{{ $enum.GoType }}{{ $element.Name|toCamel }}{{end}}: diff --git a/example/starwars/models_gen.go b/example/starwars/models_gen.go index 4c6809ee440..07e36ad6f7a 100644 --- a/example/starwars/models_gen.go +++ b/example/starwars/models_gen.go @@ -44,6 +44,12 @@ const ( EpisodeJedi Episode = "JEDI" ) +var AllEpisode = []Episode{ + EpisodeNewhope, + EpisodeEmpire, + EpisodeJedi, +} + func (e Episode) IsValid() bool { switch e { case EpisodeNewhope, EpisodeEmpire, EpisodeJedi: @@ -80,6 +86,11 @@ const ( LengthUnitFoot LengthUnit = "FOOT" ) +var AllLengthUnit = []LengthUnit{ + LengthUnitMeter, + LengthUnitFoot, +} + func (e LengthUnit) IsValid() bool { switch e { case LengthUnitMeter, LengthUnitFoot: diff --git a/example/todo/models_gen.go b/example/todo/models_gen.go index 2d7a219ac0f..6abc2273493 100644 --- a/example/todo/models_gen.go +++ b/example/todo/models_gen.go @@ -21,6 +21,11 @@ const ( RoleOwner Role = "OWNER" ) +var AllRole = []Role{ + RoleAdmin, + RoleOwner, +} + func (e Role) IsValid() bool { switch e { case RoleAdmin, RoleOwner: diff --git a/example/type-system-extension/models_gen.go b/example/type-system-extension/models_gen.go index f11cbc58eed..ece1b800b2e 100644 --- a/example/type-system-extension/models_gen.go +++ b/example/type-system-extension/models_gen.go @@ -37,6 +37,11 @@ const ( StateDone State = "DONE" ) +var AllState = []State{ + StateNotYet, + StateDone, +} + func (e State) IsValid() bool { switch e { case StateNotYet, StateDone: diff --git a/integration/models-go/generated.go b/integration/models-go/generated.go index f3d8f92172d..7d4b611e83e 100644 --- a/integration/models-go/generated.go +++ b/integration/models-go/generated.go @@ -25,6 +25,15 @@ const ( DateFilterOpLte DateFilterOp = "LTE" ) +var AllDateFilterOp = []DateFilterOp{ + DateFilterOpEq, + DateFilterOpNeq, + DateFilterOpGt, + DateFilterOpGte, + DateFilterOpLt, + DateFilterOpLte, +} + func (e DateFilterOp) IsValid() bool { switch e { case DateFilterOpEq, DateFilterOpNeq, DateFilterOpGt, DateFilterOpGte, DateFilterOpLt, DateFilterOpLte: @@ -61,6 +70,11 @@ const ( ErrorTypeNormal ErrorType = "NORMAL" ) +var AllErrorType = []ErrorType{ + ErrorTypeCustom, + ErrorTypeNormal, +} + func (e ErrorType) IsValid() bool { switch e { case ErrorTypeCustom, ErrorTypeNormal: From 1140dd85782572b148e8ec2c1d9526f87b763a1e Mon Sep 17 00:00:00 2001 From: Nico Vogelaar Date: Fri, 4 Jan 2019 19:43:38 +0000 Subject: [PATCH 023/147] add unit test for list of enums --- codegen/codegen_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/codegen/codegen_test.go b/codegen/codegen_test.go index ebe1bf16418..7135f996ac0 100644 --- a/codegen/codegen_test.go +++ b/codegen/codegen_test.go @@ -18,6 +18,10 @@ func TestGenerateServer(t *testing.T) { id: Int fist_name: String } + enum Status { + OK + ERROR + } ` serverFilename := "gen/" + name + "/server/server.go" cfg := Config{ @@ -42,4 +46,30 @@ func TestGenerateServer(t *testing.T) { _, err = conf.Load() require.NoError(t, err) + + t.Run("list of enums", func(t *testing.T) { + conf = loader.Config{} + conf.CreateFromFilenames("gen/"+name, "gen/"+name+"/model.go") + + program, err := conf.Load() + require.NoError(t, err) + + found := false + + for _, c := range program.Created { + for ident := range c.Defs { + if ident.Name == "AllStatus" { + found = true + break + } + } + if found { + break + } + } + + if !found { + t.Fail() + } + }) } From 34b878713c95839e085cef8e8fbe377cf7dae725 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Sat, 5 Jan 2019 13:34:49 +1100 Subject: [PATCH 024/147] Rename core types to have clearer meanings --- codegen/directive_build.go | 16 +++--- codegen/enum.go | 2 +- codegen/enum_build.go | 6 +-- codegen/input_build.go | 16 +++--- codegen/interface.go | 4 +- codegen/interface_build.go | 8 +-- codegen/model.go | 6 +-- codegen/models_build.go | 16 +++--- codegen/object.go | 12 ++--- codegen/object_build.go | 24 ++++----- codegen/type_build.go | 28 +++++----- codegen/type_definition.go | 43 +++++++++++++++ codegen/{type.go => type_reference.go} | 73 ++++++-------------------- codegen/util.go | 10 ++-- 14 files changed, 133 insertions(+), 131 deletions(-) create mode 100644 codegen/type_definition.go rename codegen/{type.go => type_reference.go} (74%) diff --git a/codegen/directive_build.go b/codegen/directive_build.go index 18ece308635..8124afb3207 100644 --- a/codegen/directive_build.go +++ b/codegen/directive_build.go @@ -19,12 +19,12 @@ func (cfg *Config) buildDirectives(types NamedTypes) (map[string]*Directive, err var args []FieldArgument for _, arg := range dir.Arguments { newArg := FieldArgument{ - GQLName: arg.Name, - Type: types.getType(arg.Type), - GoVarName: sanitizeArgName(arg.Name), + GQLName: arg.Name, + TypeReference: types.getType(arg.Type), + GoVarName: sanitizeArgName(arg.Name), } - if !newArg.Type.IsInput && !newArg.Type.IsScalar { + if !newArg.TypeReference.IsInput && !newArg.TypeReference.IsScalar { return nil, errors.Errorf("%s cannot be used as argument of directive %s(%s) only input and scalar types are allowed", arg.Type, dir.Name, arg.Name) } @@ -69,10 +69,10 @@ func (cfg *Config) getDirectives(list ast.DirectiveList) ([]*Directive, error) { value = argValue } args = append(args, FieldArgument{ - GQLName: a.GQLName, - Value: value, - GoVarName: a.GoVarName, - Type: a.Type, + GQLName: a.GQLName, + Value: value, + GoVarName: a.GoVarName, + TypeReference: a.TypeReference, }) } dirs[i] = &Directive{ diff --git a/codegen/enum.go b/codegen/enum.go index 7804971c02a..0fc497eea1f 100644 --- a/codegen/enum.go +++ b/codegen/enum.go @@ -1,7 +1,7 @@ package codegen type Enum struct { - *NamedType + *TypeDefinition Description string Values []EnumValue } diff --git a/codegen/enum_build.go b/codegen/enum_build.go index 457d923f22c..9c55e4f3433 100644 --- a/codegen/enum_build.go +++ b/codegen/enum_build.go @@ -23,9 +23,9 @@ func (cfg *Config) buildEnums(types NamedTypes) []Enum { } enum := Enum{ - NamedType: namedType, - Values: values, - Description: typ.Description, + TypeDefinition: namedType, + Values: values, + Description: typ.Description, } enum.GoType = templates.ToCamel(enum.GQLType) enums = append(enums, enum) diff --git a/codegen/input_build.go b/codegen/input_build.go index 5eac32e5dd3..c0ac31ee020 100644 --- a/codegen/input_build.go +++ b/codegen/input_build.go @@ -44,7 +44,7 @@ func (cfg *Config) buildInputs(namedTypes NamedTypes, prog *loader.Program) (Obj } func (cfg *Config) buildInput(types NamedTypes, typ *ast.Definition) (*Object, error) { - obj := &Object{NamedType: types[typ.Name]} + obj := &Object{TypeDefinition: types[typ.Name]} typeEntry, entryExists := cfg.Models[typ.Name] for _, field := range typ.Fields { @@ -53,10 +53,10 @@ func (cfg *Config) buildInput(types NamedTypes, typ *ast.Definition) (*Object, e return nil, err } newField := Field{ - GQLName: field.Name, - Type: types.getType(field.Type), - Object: obj, - Directives: dirs, + GQLName: field.Name, + TypeReference: types.getType(field.Type), + Object: obj, + Directives: dirs, } if entryExists { @@ -73,7 +73,7 @@ func (cfg *Config) buildInput(types NamedTypes, typ *ast.Definition) (*Object, e } } - if !newField.Type.IsInput && !newField.Type.IsScalar { + if !newField.TypeReference.IsInput && !newField.TypeReference.IsScalar { return nil, errors.Errorf("%s cannot be used as a field of %s. only input and scalar types are allowed", newField.GQLType, obj.GQLType) } @@ -91,7 +91,7 @@ func (cfg *Config) buildInput(types NamedTypes, typ *ast.Definition) (*Object, e // if user has implemented an UnmarshalGQL method on the input type manually, use it // otherwise we will generate one. -func buildInputMarshaler(typ *ast.Definition, def types.Object) *Ref { +func buildInputMarshaler(typ *ast.Definition, def types.Object) *TypeImplementation { switch def := def.(type) { case *types.TypeName: namedType := def.Type().(*types.Named) @@ -103,5 +103,5 @@ func buildInputMarshaler(typ *ast.Definition, def types.Object) *Ref { } } - return &Ref{GoType: typ.Name} + return &TypeImplementation{GoType: typ.Name} } diff --git a/codegen/interface.go b/codegen/interface.go index 2de0c88a9b3..e18e849d20a 100644 --- a/codegen/interface.go +++ b/codegen/interface.go @@ -1,7 +1,7 @@ package codegen type Interface struct { - *NamedType + *TypeDefinition Implementors []InterfaceImplementor } @@ -9,5 +9,5 @@ type Interface struct { type InterfaceImplementor struct { ValueReceiver bool - *NamedType + *TypeDefinition } diff --git a/codegen/interface_build.go b/codegen/interface_build.go index 92052ba6b99..47152d577c6 100644 --- a/codegen/interface_build.go +++ b/codegen/interface_build.go @@ -24,21 +24,21 @@ func (cfg *Config) buildInterfaces(types NamedTypes, prog *loader.Program) []*In } func (cfg *Config) buildInterface(types NamedTypes, typ *ast.Definition, prog *loader.Program) *Interface { - i := &Interface{NamedType: types[typ.Name]} + i := &Interface{TypeDefinition: types[typ.Name]} for _, implementor := range cfg.schema.GetPossibleTypes(typ) { t := types[implementor.Name] i.Implementors = append(i.Implementors, InterfaceImplementor{ - NamedType: t, - ValueReceiver: cfg.isValueReceiver(types[typ.Name], t, prog), + TypeDefinition: t, + ValueReceiver: cfg.isValueReceiver(types[typ.Name], t, prog), }) } return i } -func (cfg *Config) isValueReceiver(intf *NamedType, implementor *NamedType, prog *loader.Program) bool { +func (cfg *Config) isValueReceiver(intf *TypeDefinition, implementor *TypeDefinition, prog *loader.Program) bool { interfaceType, err := findGoInterface(prog, intf.Package, intf.GoType) if interfaceType == nil || err != nil { return true diff --git a/codegen/model.go b/codegen/model.go index bcdc8703a6c..8c3acba1986 100644 --- a/codegen/model.go +++ b/codegen/model.go @@ -1,14 +1,14 @@ package codegen type Model struct { - *NamedType + *TypeDefinition Description string Fields []ModelField - Implements []*NamedType + Implements []*TypeDefinition } type ModelField struct { - *Type + *TypeReference GQLName string GoFieldName string GoFKName string diff --git a/codegen/models_build.go b/codegen/models_build.go index 56d2ff1fae1..f718e590a77 100644 --- a/codegen/models_build.go +++ b/codegen/models_build.go @@ -54,17 +54,17 @@ func (cfg *Config) buildModels(types NamedTypes, prog *loader.Program) ([]Model, func (cfg *Config) obj2Model(obj *Object) Model { model := Model{ - NamedType: obj.NamedType, - Implements: obj.Implements, - Fields: []ModelField{}, + TypeDefinition: obj.TypeDefinition, + Implements: obj.Implements, + Fields: []ModelField{}, } model.GoType = ucFirst(obj.GQLType) - model.Marshaler = &Ref{GoType: obj.GoType} + model.Marshaler = &TypeImplementation{GoType: obj.GoType} for i := range obj.Fields { field := &obj.Fields[i] - mf := ModelField{Type: field.Type, GQLName: field.GQLName} + mf := ModelField{TypeReference: field.TypeReference, GQLName: field.GQLName} if field.GoFieldName != "" { mf.GoFieldName = field.GoFieldName @@ -80,12 +80,12 @@ func (cfg *Config) obj2Model(obj *Object) Model { func int2Model(obj *Interface) Model { model := Model{ - NamedType: obj.NamedType, - Fields: []ModelField{}, + TypeDefinition: obj.TypeDefinition, + Fields: []ModelField{}, } model.GoType = ucFirst(obj.GQLType) - model.Marshaler = &Ref{GoType: obj.GoType} + model.Marshaler = &TypeImplementation{GoType: obj.GoType} return model } diff --git a/codegen/object.go b/codegen/object.go index 484a49f918e..eb477680d57 100644 --- a/codegen/object.go +++ b/codegen/object.go @@ -20,12 +20,12 @@ const ( ) type Object struct { - *NamedType + *TypeDefinition Fields []Field Satisfies []string - Implements []*NamedType - ResolverInterface *Ref + Implements []*TypeDefinition + ResolverInterface *TypeImplementation Root bool DisableConcurrency bool Stream bool @@ -33,7 +33,7 @@ type Object struct { } type Field struct { - *Type + *TypeReference Description string // Description of a field GQLName string // The name of the field in graphql GoFieldType GoFieldType // The field type in go, if any @@ -49,7 +49,7 @@ type Field struct { } type FieldArgument struct { - *Type + *TypeReference GQLName string // The name of the argument in graphql GoVarName string // The name of the var in go @@ -248,7 +248,7 @@ func (f *Field) CallArgs() string { // should be in the template, but its recursive and has a bunch of args func (f *Field) WriteJson() string { - return f.doWriteJson("res", f.Type.Modifiers, f.ASTType, false, 1) + return f.doWriteJson("res", f.TypeReference.Modifiers, f.ASTType, false, 1) } func (f *Field) doWriteJson(val string, remainingMods []string, astType *ast.Type, isPtr bool, depth int) string { diff --git a/codegen/object_build.go b/codegen/object_build.go index c1ef9bad5e4..e3d067a3f1e 100644 --- a/codegen/object_build.go +++ b/codegen/object_build.go @@ -82,10 +82,10 @@ func sanitizeArgName(name string) string { } func (cfg *Config) buildObject(types NamedTypes, typ *ast.Definition) (*Object, error) { - obj := &Object{NamedType: types[typ.Name]} + obj := &Object{TypeDefinition: types[typ.Name]} typeEntry, entryExists := cfg.Models[typ.Name] - obj.ResolverInterface = &Ref{GoType: obj.GQLType + "Resolver"} + obj.ResolverInterface = &TypeImplementation{GoType: obj.GQLType + "Resolver"} if typ == cfg.schema.Query { obj.Root = true @@ -110,7 +110,7 @@ func (cfg *Config) buildObject(types NamedTypes, typ *ast.Definition) (*Object, for _, field := range typ.Fields { if typ == cfg.schema.Query && field.Name == "__type" { obj.Fields = append(obj.Fields, Field{ - Type: &Type{types["__Schema"], []string{modPtr}, ast.NamedType("__Schema", nil), nil}, + TypeReference: &TypeReference{types["__Schema"], []string{modPtr}, ast.NamedType("__Schema", nil), nil}, GQLName: "__schema", GoFieldType: GoFieldMethod, GoReceiverName: "ec", @@ -122,13 +122,13 @@ func (cfg *Config) buildObject(types NamedTypes, typ *ast.Definition) (*Object, } if typ == cfg.schema.Query && field.Name == "__schema" { obj.Fields = append(obj.Fields, Field{ - Type: &Type{types["__Type"], []string{modPtr}, ast.NamedType("__Schema", nil), nil}, + TypeReference: &TypeReference{types["__Type"], []string{modPtr}, ast.NamedType("__Schema", nil), nil}, GQLName: "__type", GoFieldType: GoFieldMethod, GoReceiverName: "ec", GoFieldName: "introspectType", Args: []FieldArgument{ - {GQLName: "name", Type: &Type{types["String"], []string{}, ast.NamedType("String", nil), nil}, Object: &Object{}}, + {GQLName: "name", TypeReference: &TypeReference{types["String"], []string{}, ast.NamedType("String", nil), nil}, Object: &Object{}}, }, Object: obj, }) @@ -151,14 +151,14 @@ func (cfg *Config) buildObject(types NamedTypes, typ *ast.Definition) (*Object, return nil, err } newArg := FieldArgument{ - GQLName: arg.Name, - Type: types.getType(arg.Type), - Object: obj, - GoVarName: sanitizeArgName(arg.Name), - Directives: dirs, + GQLName: arg.Name, + TypeReference: types.getType(arg.Type), + Object: obj, + GoVarName: sanitizeArgName(arg.Name), + Directives: dirs, } - if !newArg.Type.IsInput && !newArg.Type.IsScalar { + if !newArg.TypeReference.IsInput && !newArg.TypeReference.IsScalar { return nil, errors.Errorf("%s cannot be used as argument of %s.%s. only input and scalar types are allowed", arg.Type, obj.GQLType, field.Name) } @@ -174,7 +174,7 @@ func (cfg *Config) buildObject(types NamedTypes, typ *ast.Definition) (*Object, obj.Fields = append(obj.Fields, Field{ GQLName: field.Name, - Type: types.getType(field.Type), + TypeReference: types.getType(field.Type), Args: args, Object: obj, GoFieldName: goName, diff --git a/codegen/type_build.go b/codegen/type_build.go index 586b0db2386..096fc447d09 100644 --- a/codegen/type_build.go +++ b/codegen/type_build.go @@ -8,9 +8,9 @@ import ( "golang.org/x/tools/go/loader" ) -// namedTypeFromSchema objects for every graphql type, including scalars. There should only be one instance of Type for each thing +// namedTypeFromSchema objects for every graphql type, including scalars. There should only be one instance of TypeReference for each thing func (cfg *Config) buildNamedTypes() NamedTypes { - types := map[string]*NamedType{} + types := map[string]*TypeDefinition{} for _, schemaType := range cfg.schema.Types { t := namedTypeFromSchema(schemaType) @@ -37,7 +37,7 @@ func (cfg *Config) bindTypes(namedTypes NamedTypes, destDir string, prog *loader switch def := def.(type) { case *types.Func: sig := def.Type().(*types.Signature) - cpy := t.Ref + cpy := t.TypeImplementation t.Marshaler = &cpy t.Package, t.GoType = pkgAndType(sig.Params().At(0).Type().String()) @@ -47,20 +47,20 @@ func (cfg *Config) bindTypes(namedTypes NamedTypes, destDir string, prog *loader // namedTypeFromSchema objects for every graphql type, including primitives. // don't recurse into object fields or interfaces yet, lets make sure we have collected everything first. -func namedTypeFromSchema(schemaType *ast.Definition) *NamedType { +func namedTypeFromSchema(schemaType *ast.Definition) *TypeDefinition { switch schemaType.Kind { case ast.Scalar, ast.Enum: - return &NamedType{GQLType: schemaType.Name, IsScalar: true} + return &TypeDefinition{GQLType: schemaType.Name, IsScalar: true} case ast.Interface, ast.Union: - return &NamedType{GQLType: schemaType.Name, IsInterface: true} + return &TypeDefinition{GQLType: schemaType.Name, IsInterface: true} case ast.InputObject: - return &NamedType{GQLType: schemaType.Name, IsInput: true} + return &TypeDefinition{GQLType: schemaType.Name, IsInput: true} default: - return &NamedType{GQLType: schemaType.Name} + return &TypeDefinition{GQLType: schemaType.Name} } } -// take a string in the form github.com/package/blah.Type and split it into package and type +// take a string in the form github.com/package/blah.TypeReference and split it into package and type func pkgAndType(name string) (string, string) { parts := strings.Split(name, ".") if len(parts) == 1 { @@ -70,7 +70,7 @@ func pkgAndType(name string) (string, string) { return normalizeVendor(strings.Join(parts[:len(parts)-1], ".")), parts[len(parts)-1] } -func (n NamedTypes) getType(t *ast.Type) *Type { +func (n NamedTypes) getType(t *ast.Type) *TypeReference { orig := t var modifiers []string for { @@ -84,10 +84,10 @@ func (n NamedTypes) getType(t *ast.Type) *Type { if n[t.NamedType] == nil { panic("missing type " + t.NamedType) } - res := &Type{ - NamedType: n[t.NamedType], - Modifiers: modifiers, - ASTType: orig, + res := &TypeReference{ + TypeDefinition: n[t.NamedType], + Modifiers: modifiers, + ASTType: orig, } if res.IsInterface { diff --git a/codegen/type_definition.go b/codegen/type_definition.go new file mode 100644 index 00000000000..810cddcf33e --- /dev/null +++ b/codegen/type_definition.go @@ -0,0 +1,43 @@ +package codegen + +import "github.com/99designs/gqlgen/codegen/templates" + +type NamedTypes map[string]*TypeDefinition + +type TypeDefinition struct { + TypeImplementation + IsScalar bool + IsInterface bool + IsInput bool + GQLType string // Name of the graphql type + Marshaler *TypeImplementation // If this type has an external marshaler this will be set +} + +type TypeImplementation struct { + GoType string // Name of the go type + Package string // the package the go type lives in + IsUserDefined bool // does the type exist in the typemap +} + +const ( + modList = "[]" + modPtr = "*" +) + +func (t TypeImplementation) FullName() string { + return t.PkgDot() + t.GoType +} + +func (t TypeImplementation) PkgDot() string { + name := templates.CurrentImports.Lookup(t.Package) + if name == "" { + return "" + + } + + return name + "." +} + +func (t TypeDefinition) IsMarshaled() bool { + return t.Marshaler != nil +} diff --git a/codegen/type.go b/codegen/type_reference.go similarity index 74% rename from codegen/type.go rename to codegen/type_reference.go index 5309c1fbe1f..67b1d033b87 100644 --- a/codegen/type.go +++ b/codegen/type_reference.go @@ -4,63 +4,26 @@ import ( "strconv" "strings" - "github.com/99designs/gqlgen/codegen/templates" - "github.com/vektah/gqlparser/ast" ) -type NamedTypes map[string]*NamedType - -type NamedType struct { - Ref - IsScalar bool - IsInterface bool - IsInput bool - GQLType string // Name of the graphql type - Marshaler *Ref // If this type has an external marshaler this will be set -} - -type Ref struct { - GoType string // Name of the go type - Package string // the package the go type lives in - IsUserDefined bool // does the type exist in the typemap -} - -type Type struct { - *NamedType +// TypeReference represents the type of a field or arg, referencing an underlying TypeDefinition (type, input, scalar) +type TypeReference struct { + *TypeDefinition Modifiers []string ASTType *ast.Type - AliasedType *Ref + AliasedType *TypeImplementation } -const ( - modList = "[]" - modPtr = "*" -) - -func (t Ref) FullName() string { - return t.PkgDot() + t.GoType -} - -func (t Ref) PkgDot() string { - name := templates.CurrentImports.Lookup(t.Package) - if name == "" { - return "" - - } - - return name + "." -} - -func (t Type) Signature() string { +func (t TypeReference) Signature() string { if t.AliasedType != nil { return strings.Join(t.Modifiers, "") + t.AliasedType.FullName() } return strings.Join(t.Modifiers, "") + t.FullName() } -func (t Type) FullSignature() string { +func (t TypeReference) FullSignature() string { pkg := "" if t.Package != "" { pkg = t.Package + "." @@ -69,31 +32,27 @@ func (t Type) FullSignature() string { return strings.Join(t.Modifiers, "") + pkg + t.GoType } -func (t Type) IsPtr() bool { +func (t TypeReference) IsPtr() bool { return len(t.Modifiers) > 0 && t.Modifiers[0] == modPtr } -func (t *Type) StripPtr() { +func (t *TypeReference) StripPtr() { if !t.IsPtr() { return } t.Modifiers = t.Modifiers[0 : len(t.Modifiers)-1] } -func (t Type) IsSlice() bool { +func (t TypeReference) IsSlice() bool { return len(t.Modifiers) > 0 && t.Modifiers[0] == modList || len(t.Modifiers) > 1 && t.Modifiers[0] == modPtr && t.Modifiers[1] == modList } -func (t NamedType) IsMarshaled() bool { - return t.Marshaler != nil -} - -func (t Type) Unmarshal(result, raw string) string { +func (t TypeReference) Unmarshal(result, raw string) string { return t.unmarshal(result, raw, t.Modifiers, 1) } -func (t Type) unmarshal(result, raw string, remainingMods []string, depth int) string { +func (t TypeReference) unmarshal(result, raw string, remainingMods []string, depth int) string { switch { case len(remainingMods) > 0 && remainingMods[0] == modPtr: ptr := "ptr" + strconv.Itoa(depth) @@ -131,7 +90,7 @@ func (t Type) unmarshal(result, raw string, remainingMods []string, depth int) s "rawSlice": rawIf, "index": index, "result": result, - "type": strings.Join(remainingMods, "") + t.NamedType.FullName(), + "type": strings.Join(remainingMods, "") + t.TypeDefinition.FullName(), "next": t.unmarshal(result+"["+index+"]", rawIf+"["+index+"]", remainingMods[1:], depth+1), }) } @@ -161,11 +120,11 @@ func (t Type) unmarshal(result, raw string, remainingMods []string, depth int) s }) } -func (t Type) Middleware(result, raw string) string { +func (t TypeReference) Middleware(result, raw string) string { return t.middleware(result, raw, t.Modifiers, 1) } -func (t Type) middleware(result, raw string, remainingMods []string, depth int) string { +func (t TypeReference) middleware(result, raw string, remainingMods []string, depth int) string { if len(remainingMods) == 1 && remainingMods[0] == modPtr { return tpl(`{{- if .t.Marshaler }} if {{.raw}} != nil { @@ -202,7 +161,7 @@ func (t Type) middleware(result, raw string, remainingMods []string, depth int) "raw": raw, "index": index, "result": result, - "type": strings.Join(remainingMods, "") + t.NamedType.FullName(), + "type": strings.Join(remainingMods, "") + t.TypeDefinition.FullName(), "next": t.middleware(result+"["+index+"]", raw+"["+index+"]", remainingMods[1:], depth+1), }) } @@ -222,7 +181,7 @@ func (t Type) middleware(result, raw string, remainingMods []string, depth int) }) } -func (t Type) Marshal(val string) string { +func (t TypeReference) Marshal(val string) string { if t.AliasedType != nil { val = t.GoType + "(" + val + ")" } diff --git a/codegen/util.go b/codegen/util.go index cc6246fdb74..41cce5f8bff 100644 --- a/codegen/util.go +++ b/codegen/util.go @@ -320,7 +320,7 @@ nextArg: for _, oldArg := range field.Args { if strings.EqualFold(oldArg.GQLName, param.Name()) { if !field.ForceResolver { - oldArg.Type.Modifiers = modifiersFromGoType(param.Type()) + oldArg.TypeReference.Modifiers = modifiersFromGoType(param.Type()) } newArgs = append(newArgs, oldArg) continue nextArg @@ -334,20 +334,20 @@ nextArg: } func validateTypeBinding(field *Field, goType types.Type) error { - gqlType := normalizeVendor(field.Type.FullSignature()) + gqlType := normalizeVendor(field.TypeReference.FullSignature()) goTypeStr := normalizeVendor(goType.String()) if equalTypes(goTypeStr, gqlType) { - field.Type.Modifiers = modifiersFromGoType(goType) + field.TypeReference.Modifiers = modifiersFromGoType(goType) return nil } // deal with type aliases underlyingStr := normalizeVendor(goType.Underlying().String()) if equalTypes(underlyingStr, gqlType) { - field.Type.Modifiers = modifiersFromGoType(goType) + field.TypeReference.Modifiers = modifiersFromGoType(goType) pkg, typ := pkgAndType(goType.String()) - field.AliasedType = &Ref{GoType: typ, Package: pkg} + field.AliasedType = &TypeImplementation{GoType: typ, Package: pkg} return nil } From bec38c7e304c2bdc2e4ff32661e1d1972cdb1484 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Thu, 13 Dec 2018 16:17:04 +1100 Subject: [PATCH 025/147] Extract config into its own package --- cmd/gen.go | 35 ++--- cmd/init.go | 58 ++++---- codegen/build.go | 19 +-- codegen/codegen_test.go | 36 +++-- codegen/{ => config}/config.go | 130 ++++++++++++++---- codegen/{ => config}/config_test.go | 9 +- codegen/{ => config}/testdata/cfg/gqlgen.yml | 0 .../testdata/cfg/malformedconfig.yml | 0 .../testdata/cfg/otherdir/.gitkeep | 0 codegen/{ => config}/testdata/cfg/outer | 0 .../testdata/cfg/subdir/gqlgen.yaml | 0 .../{ => config}/testdata/cfg/subdir/inner | 0 .../{ => config}/testdata/cfg/unknownkeys.yml | 0 codegen/directive_build.go | 5 +- codegen/enum_build.go | 2 +- codegen/{codegen.go => generator.go} | 103 ++++---------- codegen/input_build.go | 4 +- codegen/input_test.go | 55 +++++--- codegen/interface_build.go | 6 +- codegen/models_build.go | 4 +- codegen/object_build.go | 4 +- codegen/type_build.go | 33 +---- codegen/type_definition.go | 38 ++++- internal/gopath/util.go | 25 ++++ 24 files changed, 324 insertions(+), 242 deletions(-) rename codegen/{ => config}/config.go (64%) rename codegen/{ => config}/config_test.go (90%) rename codegen/{ => config}/testdata/cfg/gqlgen.yml (100%) rename codegen/{ => config}/testdata/cfg/malformedconfig.yml (100%) rename codegen/{ => config}/testdata/cfg/otherdir/.gitkeep (100%) rename codegen/{ => config}/testdata/cfg/outer (100%) rename codegen/{ => config}/testdata/cfg/subdir/gqlgen.yaml (100%) rename codegen/{ => config}/testdata/cfg/subdir/inner (100%) rename codegen/{ => config}/testdata/cfg/unknownkeys.yml (100%) rename codegen/{codegen.go => generator.go} (51%) create mode 100644 internal/gopath/util.go diff --git a/cmd/gen.go b/cmd/gen.go index 3842f02b37d..7d328861e61 100644 --- a/cmd/gen.go +++ b/cmd/gen.go @@ -2,10 +2,10 @@ package cmd import ( "fmt" - "io/ioutil" "os" "github.com/99designs/gqlgen/codegen" + "github.com/99designs/gqlgen/codegen/config" "github.com/pkg/errors" "github.com/urfave/cli" ) @@ -18,43 +18,34 @@ var genCmd = cli.Command{ cli.StringFlag{Name: "config, c", Usage: "the config filename"}, }, Action: func(ctx *cli.Context) { - var config *codegen.Config + var cfg *config.Config var err error - if configFilename := ctx.String("config"); configFilename != "" { - config, err = codegen.LoadConfig(configFilename) + if configFilename := ctx.String("gen"); configFilename != "" { + cfg, err = config.LoadConfig(configFilename) if err != nil { fmt.Fprintln(os.Stderr, err.Error()) os.Exit(1) } } else { - config, err = codegen.LoadConfigFromDefaultLocations() + cfg, err = config.LoadConfigFromDefaultLocations() if os.IsNotExist(errors.Cause(err)) { - config = codegen.DefaultConfig() + cfg = config.DefaultConfig() } else if err != nil { fmt.Fprintln(os.Stderr, err.Error()) - os.Exit(1) - } - } - - for _, filename := range config.SchemaFilename { - var schemaRaw []byte - schemaRaw, err = ioutil.ReadFile(filename) - if err != nil { - fmt.Fprintln(os.Stderr, "unable to open schema: "+err.Error()) - os.Exit(1) + os.Exit(2) } - config.SchemaStr[filename] = string(schemaRaw) } - if err = config.Check(); err != nil { - fmt.Fprintln(os.Stderr, "invalid config format: "+err.Error()) - os.Exit(1) + gen, err := codegen.New(cfg) + if err != nil { + fmt.Fprintln(os.Stderr, err.Error()) + os.Exit(3) } - err = codegen.Generate(*config) + err = gen.Generate() if err != nil { fmt.Fprintln(os.Stderr, err.Error()) - os.Exit(2) + os.Exit(4) } }, } diff --git a/cmd/init.go b/cmd/init.go index 1e7c18b9327..cdb9e60ec8c 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -8,6 +8,7 @@ import ( "strings" "github.com/99designs/gqlgen/codegen" + "github.com/99designs/gqlgen/codegen/config" "github.com/pkg/errors" "github.com/urfave/cli" "gopkg.in/yaml.v2" @@ -68,27 +69,18 @@ var initCmd = cli.Command{ }, } -func GenerateGraphServer(config *codegen.Config, serverFilename string) { - for _, filename := range config.SchemaFilename { - schemaRaw, err := ioutil.ReadFile(filename) - if err != nil { - fmt.Fprintln(os.Stderr, "unable to open schema: "+err.Error()) - os.Exit(1) - } - config.SchemaStr[filename] = string(schemaRaw) - } - - if err := config.Check(); err != nil { - fmt.Fprintln(os.Stderr, "invalid config format: "+err.Error()) - os.Exit(1) +func GenerateGraphServer(cfg *config.Config, serverFilename string) { + gen, err := codegen.New(cfg) + if err != nil { + fmt.Fprintln(os.Stderr, err.Error()) } - if err := codegen.Generate(*config); err != nil { + if err := gen.Generate(); err != nil { fmt.Fprintln(os.Stderr, err.Error()) os.Exit(1) } - if err := codegen.GenerateServer(*config, serverFilename); err != nil { + if err := gen.GenerateServer(serverFilename); err != nil { fmt.Fprintln(os.Stderr, err.Error()) os.Exit(1) } @@ -96,18 +88,18 @@ func GenerateGraphServer(config *codegen.Config, serverFilename string) { fmt.Fprintf(os.Stdout, "Exec \"go run ./%s\" to start GraphQL server\n", serverFilename) } -func initConfig(ctx *cli.Context) *codegen.Config { - var config *codegen.Config +func initConfig(ctx *cli.Context) *config.Config { + var cfg *config.Config var err error - configFilename := ctx.String("config") + configFilename := ctx.String("cfg") if configFilename != "" { - config, err = codegen.LoadConfig(configFilename) + cfg, err = config.LoadConfig(configFilename) } else { - config, err = codegen.LoadConfigFromDefaultLocations() + cfg, err = config.LoadConfigFromDefaultLocations() } - if config != nil { - fmt.Fprintf(os.Stderr, "init failed: a configuration file already exists at %s\n", config.FilePath) + if cfg != nil { + fmt.Fprintf(os.Stderr, "init failed: a configuration file already exists\n") os.Exit(1) } @@ -119,9 +111,9 @@ func initConfig(ctx *cli.Context) *codegen.Config { if configFilename == "" { configFilename = "gqlgen.yml" } - config = codegen.DefaultConfig() + cfg = config.DefaultConfig() - config.Resolver = codegen.PackageConfig{ + cfg.Resolver = config.PackageConfig{ Filename: "resolver.go", Type: "Resolver", } @@ -129,23 +121,21 @@ func initConfig(ctx *cli.Context) *codegen.Config { var buf bytes.Buffer buf.WriteString(strings.TrimSpace(configComment)) buf.WriteString("\n\n") - { - var b []byte - b, err = yaml.Marshal(config) - if err != nil { - fmt.Fprintln(os.Stderr, "unable to marshal yaml: "+err.Error()) - os.Exit(1) - } - buf.Write(b) + var b []byte + b, err = yaml.Marshal(cfg) + if err != nil { + fmt.Fprintln(os.Stderr, "unable to marshal yaml: "+err.Error()) + os.Exit(1) } + buf.Write(b) err = ioutil.WriteFile(configFilename, buf.Bytes(), 0644) if err != nil { - fmt.Fprintln(os.Stderr, "unable to write config file: "+err.Error()) + fmt.Fprintln(os.Stderr, "unable to write cfg file: "+err.Error()) os.Exit(1) } - return config + return cfg } func initSchema(schemaFilename string) { diff --git a/codegen/build.go b/codegen/build.go index 71eb9c5e0c0..21db90e8ad8 100644 --- a/codegen/build.go +++ b/codegen/build.go @@ -6,6 +6,7 @@ import ( "go/types" "os" + "github.com/99designs/gqlgen/codegen/config" "github.com/pkg/errors" "golang.org/x/tools/go/loader" ) @@ -19,7 +20,7 @@ type Build struct { MutationRoot *Object SubscriptionRoot *Object SchemaRaw map[string]string - SchemaFilename SchemaFilenames + SchemaFilename config.SchemaFilenames Directives map[string]*Directive } @@ -43,7 +44,7 @@ type ServerBuild struct { } // Create a list of models that need to be generated -func (cfg *Config) models() (*ModelBuild, error) { +func (cfg *Generator) models() (*ModelBuild, error) { namedTypes := cfg.buildNamedTypes() progLoader := cfg.newLoaderWithoutErrors() @@ -67,7 +68,7 @@ func (cfg *Config) models() (*ModelBuild, error) { } // bind a schema together with some code to generate a Build -func (cfg *Config) resolver() (*ResolverBuild, error) { +func (cfg *Generator) resolver() (*ResolverBuild, error) { progLoader := cfg.newLoaderWithoutErrors() progLoader.Import(cfg.Resolver.ImportPath()) @@ -98,7 +99,7 @@ func (cfg *Config) resolver() (*ResolverBuild, error) { }, nil } -func (cfg *Config) server(destDir string) *ServerBuild { +func (cfg *Generator) server(destDir string) *ServerBuild { return &ServerBuild{ PackageName: cfg.Resolver.Package, ExecPackageName: cfg.Exec.ImportPath(), @@ -107,7 +108,7 @@ func (cfg *Config) server(destDir string) *ServerBuild { } // bind a schema together with some code to generate a Build -func (cfg *Config) bind() (*Build, error) { +func (cfg *Generator) bind() (*Build, error) { namedTypes := cfg.buildNamedTypes() progLoader := cfg.newLoaderWithoutErrors() @@ -158,22 +159,22 @@ func (cfg *Config) bind() (*Build, error) { return b, nil } -func (cfg *Config) validate() error { +func (cfg *Generator) validate() error { progLoader := cfg.newLoaderWithErrors() _, err := progLoader.Load() return err } -func (cfg *Config) newLoaderWithErrors() loader.Config { +func (cfg *Generator) newLoaderWithErrors() loader.Config { conf := loader.Config{} - for _, pkg := range cfg.Models.referencedPackages() { + for _, pkg := range cfg.Models.ReferencedPackages() { conf.Import(pkg) } return conf } -func (cfg *Config) newLoaderWithoutErrors() loader.Config { +func (cfg *Generator) newLoaderWithoutErrors() loader.Config { conf := cfg.newLoaderWithErrors() conf.AllowErrors = true conf.TypeChecker = types.Config{ diff --git a/codegen/codegen_test.go b/codegen/codegen_test.go index 7135f996ac0..abe0e39c259 100644 --- a/codegen/codegen_test.go +++ b/codegen/codegen_test.go @@ -4,7 +4,11 @@ import ( "syscall" "testing" + "github.com/99designs/gqlgen/codegen/config" "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser" + "github.com/vektah/gqlparser/ast" + "github.com/vektah/gqlparser/gqlerror" "golang.org/x/tools/go/loader" ) @@ -24,21 +28,35 @@ func TestGenerateServer(t *testing.T) { } ` serverFilename := "gen/" + name + "/server/server.go" - cfg := Config{ - SchemaFilename: SchemaFilenames{"schema.graphql"}, - SchemaStr: map[string]string{"schema.graphql": schema}, - Exec: PackageConfig{Filename: "gen/" + name + "/exec.go"}, - Model: PackageConfig{Filename: "gen/" + name + "/model.go"}, - Resolver: PackageConfig{Filename: "gen/" + name + "/resolver.go", Type: "Resolver"}, + gen := Generator{ + Config: &config.Config{ + SchemaFilename: config.SchemaFilenames{"schema.graphql"}, + Exec: config.PackageConfig{Filename: "gen/" + name + "/exec.go"}, + Model: config.PackageConfig{Filename: "gen/" + name + "/model.go"}, + Resolver: config.PackageConfig{Filename: "gen/" + name + "/resolver.go", Type: "Resolver"}, + }, + + SchemaStr: map[string]string{"schema.graphql": schema}, + } + + err := gen.Config.Check() + if err != nil { + panic(err) + } + + var gerr *gqlerror.Error + gen.schema, gerr = gqlparser.LoadSchema(&ast.Source{Name: "schema.graphql", Input: schema}) + if gerr != nil { + panic(gerr) } - _ = syscall.Unlink(cfg.Resolver.Filename) + _ = syscall.Unlink(gen.Resolver.Filename) _ = syscall.Unlink(serverFilename) - err := Generate(cfg) + err = gen.Generate() require.NoError(t, err) - err = GenerateServer(cfg, serverFilename) + err = gen.GenerateServer(serverFilename) require.NoError(t, err) conf := loader.Config{} diff --git a/codegen/config.go b/codegen/config/config.go similarity index 64% rename from codegen/config.go rename to codegen/config/config.go index 6d427a978f5..ec19bdc6012 100644 --- a/codegen/config.go +++ b/codegen/config/config.go @@ -1,4 +1,4 @@ -package codegen +package config import ( "fmt" @@ -6,22 +6,32 @@ import ( "io/ioutil" "os" "path/filepath" + "regexp" "sort" "strings" "github.com/99designs/gqlgen/internal/gopath" "github.com/pkg/errors" + "github.com/vektah/gqlparser" "github.com/vektah/gqlparser/ast" "gopkg.in/yaml.v2" ) +type Config struct { + SchemaFilename SchemaFilenames `yaml:"schema,omitempty"` + Exec PackageConfig `yaml:"exec"` + Model PackageConfig `yaml:"model"` + Resolver PackageConfig `yaml:"resolver,omitempty"` + Models TypeMap `yaml:"models,omitempty"` + StructTag string `yaml:"struct_tag,omitempty"` +} + var cfgFilenames = []string{".gqlgen.yml", "gqlgen.yml", "gqlgen.yaml"} // DefaultConfig creates a copy of the default config func DefaultConfig() *Config { return &Config{ SchemaFilename: SchemaFilenames{"schema.graphql"}, - SchemaStr: map[string]string{}, Model: PackageConfig{Filename: "models_gen.go"}, Exec: PackageConfig{Filename: "generated.go"}, } @@ -71,28 +81,9 @@ func LoadConfig(filename string) (*Config, error) { } } - config.FilePath = filename - config.SchemaStr = map[string]string{} - return config, nil } -type Config struct { - SchemaFilename SchemaFilenames `yaml:"schema,omitempty"` - SchemaStr map[string]string `yaml:"-"` - Exec PackageConfig `yaml:"exec"` - Model PackageConfig `yaml:"model"` - Resolver PackageConfig `yaml:"resolver,omitempty"` - Models TypeMap `yaml:"models,omitempty"` - StructTag string `yaml:"struct_tag,omitempty"` - - Directives map[string]*Directive `yaml:"-"` - - FilePath string `yaml:"-"` - - schema *ast.Schema `yaml:"-"` -} - type PackageConfig struct { Filename string `yaml:"filename,omitempty"` Package string `yaml:"package,omitempty"` @@ -173,7 +164,8 @@ func (c *PackageConfig) Check() error { if c.Filename != "" && !strings.HasSuffix(c.Filename, ".go") { return fmt.Errorf("filename should be path to a go source file") } - return nil + + return c.normalize() } func (c *PackageConfig) IsDefined() bool { @@ -190,10 +182,13 @@ func (cfg *Config) Check() error { if err := cfg.Model.Check(); err != nil { return errors.Wrap(err, "config.model") } - if err := cfg.Resolver.Check(); err != nil { - return errors.Wrap(err, "config.resolver") + if cfg.Resolver.IsDefined() { + if err := cfg.Resolver.Check(); err != nil { + return errors.Wrap(err, "config.resolver") + } } - return nil + + return cfg.normalize() } type TypeMap map[string]TypeMapEntry @@ -212,14 +207,14 @@ func (tm TypeMap) Check() error { return nil } -func (tm TypeMap) referencedPackages() []string { +func (tm TypeMap) ReferencedPackages() []string { var pkgs []string for _, typ := range tm { if typ.Model == "map[string]interface{}" { continue } - pkg, _ := pkgAndType(typ.Model) + pkg, _ := gopath.PkgAndType(typ.Model) if pkg == "" || inStrSlice(pkgs, pkg) { continue } @@ -273,3 +268,84 @@ func findCfgInDir(dir string) string { } return "" } + +func (cfg *Config) normalize() error { + if err := cfg.Model.normalize(); err != nil { + return errors.Wrap(err, "model") + } + + if err := cfg.Exec.normalize(); err != nil { + return errors.Wrap(err, "exec") + } + + if cfg.Resolver.IsDefined() { + if err := cfg.Resolver.normalize(); err != nil { + return errors.Wrap(err, "resolver") + } + } + + builtins := TypeMap{ + "__Directive": {Model: "github.com/99designs/gqlgen/graphql/introspection.Directive"}, + "__Type": {Model: "github.com/99designs/gqlgen/graphql/introspection.Type"}, + "__Field": {Model: "github.com/99designs/gqlgen/graphql/introspection.Field"}, + "__EnumValue": {Model: "github.com/99designs/gqlgen/graphql/introspection.EnumValue"}, + "__InputValue": {Model: "github.com/99designs/gqlgen/graphql/introspection.InputValue"}, + "__Schema": {Model: "github.com/99designs/gqlgen/graphql/introspection.Schema"}, + "Int": {Model: "github.com/99designs/gqlgen/graphql.Int"}, + "Float": {Model: "github.com/99designs/gqlgen/graphql.Float"}, + "String": {Model: "github.com/99designs/gqlgen/graphql.String"}, + "Boolean": {Model: "github.com/99designs/gqlgen/graphql.Boolean"}, + "ID": {Model: "github.com/99designs/gqlgen/graphql.ID"}, + "Time": {Model: "github.com/99designs/gqlgen/graphql.Time"}, + "Map": {Model: "github.com/99designs/gqlgen/graphql.Map"}, + } + + if cfg.Models == nil { + cfg.Models = TypeMap{} + } + for typeName, entry := range builtins { + if !cfg.Models.Exists(typeName) { + cfg.Models[typeName] = entry + } + } + + return nil +} + +func (c *Config) LoadSchema() (*ast.Schema, map[string]string, error) { + schemaStrings := map[string]string{} + + var sources []*ast.Source + + for _, filename := range c.SchemaFilename { + var err error + var schemaRaw []byte + schemaRaw, err = ioutil.ReadFile(filename) + if err != nil { + fmt.Fprintln(os.Stderr, "unable to open schema: "+err.Error()) + os.Exit(1) + } + schemaStrings[filename] = string(schemaRaw) + sources = append(sources, &ast.Source{Name: filename, Input: schemaStrings[filename]}) + } + + schema, err := gqlparser.LoadSchema(sources...) + if err != nil { + return nil, nil, err + } + return schema, schemaStrings, nil +} + +var invalidPackageNameChar = regexp.MustCompile(`[^\w]`) + +func sanitizePackageName(pkg string) string { + return invalidPackageNameChar.ReplaceAllLiteralString(filepath.Base(pkg), "_") +} + +func abs(path string) string { + absPath, err := filepath.Abs(path) + if err != nil { + panic(err) + } + return filepath.ToSlash(absPath) +} diff --git a/codegen/config_test.go b/codegen/config/config_test.go similarity index 90% rename from codegen/config_test.go rename to codegen/config/config_test.go index a97b9d20f56..2647a7fc600 100644 --- a/codegen/config_test.go +++ b/codegen/config/config_test.go @@ -1,4 +1,4 @@ -package codegen +package config import ( "os" @@ -6,7 +6,6 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) @@ -18,12 +17,12 @@ func TestLoadConfig(t *testing.T) { t.Run("malformed config", func(t *testing.T) { _, err := LoadConfig("testdata/cfg/malformedconfig.yml") - require.EqualError(t, err, "unable to parse config: yaml: unmarshal errors:\n line 1: cannot unmarshal !!str `asdf` into codegen.Config") + require.EqualError(t, err, "unable to parse config: yaml: unmarshal errors:\n line 1: cannot unmarshal !!str `asdf` into config.Config") }) t.Run("unknown keys", func(t *testing.T) { _, err := LoadConfig("testdata/cfg/unknownkeys.yml") - require.EqualError(t, err, "unable to parse config: yaml: unmarshal errors:\n line 2: field unknown not found in type codegen.Config") + require.EqualError(t, err, "unable to parse config: yaml: unmarshal errors:\n line 2: field unknown not found in type config.Config") }) } @@ -73,7 +72,7 @@ func TestReferencedPackages(t *testing.T) { }, } - pkgs := tm.referencedPackages() + pkgs := tm.ReferencedPackages() assert.Equal(t, []string{"github.com/test", "github.com/otherpkg"}, pkgs) }) diff --git a/codegen/testdata/cfg/gqlgen.yml b/codegen/config/testdata/cfg/gqlgen.yml similarity index 100% rename from codegen/testdata/cfg/gqlgen.yml rename to codegen/config/testdata/cfg/gqlgen.yml diff --git a/codegen/testdata/cfg/malformedconfig.yml b/codegen/config/testdata/cfg/malformedconfig.yml similarity index 100% rename from codegen/testdata/cfg/malformedconfig.yml rename to codegen/config/testdata/cfg/malformedconfig.yml diff --git a/codegen/testdata/cfg/otherdir/.gitkeep b/codegen/config/testdata/cfg/otherdir/.gitkeep similarity index 100% rename from codegen/testdata/cfg/otherdir/.gitkeep rename to codegen/config/testdata/cfg/otherdir/.gitkeep diff --git a/codegen/testdata/cfg/outer b/codegen/config/testdata/cfg/outer similarity index 100% rename from codegen/testdata/cfg/outer rename to codegen/config/testdata/cfg/outer diff --git a/codegen/testdata/cfg/subdir/gqlgen.yaml b/codegen/config/testdata/cfg/subdir/gqlgen.yaml similarity index 100% rename from codegen/testdata/cfg/subdir/gqlgen.yaml rename to codegen/config/testdata/cfg/subdir/gqlgen.yaml diff --git a/codegen/testdata/cfg/subdir/inner b/codegen/config/testdata/cfg/subdir/inner similarity index 100% rename from codegen/testdata/cfg/subdir/inner rename to codegen/config/testdata/cfg/subdir/inner diff --git a/codegen/testdata/cfg/unknownkeys.yml b/codegen/config/testdata/cfg/unknownkeys.yml similarity index 100% rename from codegen/testdata/cfg/unknownkeys.yml rename to codegen/config/testdata/cfg/unknownkeys.yml diff --git a/codegen/directive_build.go b/codegen/directive_build.go index 8124afb3207..0ebe9af37bb 100644 --- a/codegen/directive_build.go +++ b/codegen/directive_build.go @@ -5,7 +5,7 @@ import ( "github.com/vektah/gqlparser/ast" ) -func (cfg *Config) buildDirectives(types NamedTypes) (map[string]*Directive, error) { +func (cfg *Generator) buildDirectives(types NamedTypes) (map[string]*Directive, error) { directives := make(map[string]*Directive, len(cfg.schema.Directives)) for name, dir := range cfg.schema.Directives { @@ -18,6 +18,7 @@ func (cfg *Config) buildDirectives(types NamedTypes) (map[string]*Directive, err var args []FieldArgument for _, arg := range dir.Arguments { + newArg := FieldArgument{ GQLName: arg.Name, TypeReference: types.getType(arg.Type), @@ -47,7 +48,7 @@ func (cfg *Config) buildDirectives(types NamedTypes) (map[string]*Directive, err return directives, nil } -func (cfg *Config) getDirectives(list ast.DirectiveList) ([]*Directive, error) { +func (cfg *Generator) getDirectives(list ast.DirectiveList) ([]*Directive, error) { dirs := make([]*Directive, len(list)) for i, d := range list { diff --git a/codegen/enum_build.go b/codegen/enum_build.go index 9c55e4f3433..9ab34d206b9 100644 --- a/codegen/enum_build.go +++ b/codegen/enum_build.go @@ -8,7 +8,7 @@ import ( "github.com/vektah/gqlparser/ast" ) -func (cfg *Config) buildEnums(types NamedTypes) []Enum { +func (cfg *Generator) buildEnums(types NamedTypes) []Enum { var enums []Enum for _, typ := range cfg.schema.Types { diff --git a/codegen/codegen.go b/codegen/generator.go similarity index 51% rename from codegen/codegen.go rename to codegen/generator.go index 6b185dd1d38..a61ba84a0c2 100644 --- a/codegen/codegen.go +++ b/codegen/generator.go @@ -4,23 +4,42 @@ import ( "log" "os" "path/filepath" - "regexp" "syscall" + "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/codegen/templates" "github.com/pkg/errors" - "github.com/vektah/gqlparser" "github.com/vektah/gqlparser/ast" - "github.com/vektah/gqlparser/gqlerror" ) -func Generate(cfg Config) error { - if err := cfg.normalize(); err != nil { - return err +type Generator struct { + *config.Config + schema *ast.Schema `yaml:"-"` + SchemaStr map[string]string `yaml:"-"` + Directives map[string]*Directive +} + +func New(cfg *config.Config) (*Generator, error) { + g := &Generator{Config: cfg} + + var err error + g.schema, g.SchemaStr, err = cfg.LoadSchema() + if err != nil { + return nil, err } + err = cfg.Check() + if err != nil { + return nil, err + } + + return g, nil +} + +func (cfg *Generator) Generate() error { _ = syscall.Unlink(cfg.Exec.Filename) _ = syscall.Unlink(cfg.Model.Filename) + namedTypes := cfg.buildNamedTypes() directives, err := cfg.buildDirectives(namedTypes) @@ -61,7 +80,7 @@ func Generate(cfg Config) error { } if cfg.Resolver.IsDefined() { - if err := generateResolver(cfg); err != nil { + if err := cfg.GenerateResolver(); err != nil { return errors.Wrap(err, "generating resolver failed") } } @@ -73,14 +92,7 @@ func Generate(cfg Config) error { return nil } -func GenerateServer(cfg Config, filename string) error { - if err := cfg.Exec.normalize(); err != nil { - return errors.Wrap(err, "exec") - } - if err := cfg.Resolver.normalize(); err != nil { - return errors.Wrap(err, "resolver") - } - +func (cfg *Generator) GenerateServer(filename string) error { serverFilename := abs(filename) serverBuild := cfg.server(filepath.Dir(serverFilename)) @@ -95,7 +107,7 @@ func GenerateServer(cfg Config, filename string) error { return nil } -func generateResolver(cfg Config) error { +func (cfg *Generator) GenerateResolver() error { resolverBuild, err := cfg.resolver() if err != nil { return errors.Wrap(err, "resolver build failed") @@ -118,65 +130,6 @@ func generateResolver(cfg Config) error { return nil } -func (cfg *Config) normalize() error { - if err := cfg.Model.normalize(); err != nil { - return errors.Wrap(err, "model") - } - - if err := cfg.Exec.normalize(); err != nil { - return errors.Wrap(err, "exec") - } - - if cfg.Resolver.IsDefined() { - if err := cfg.Resolver.normalize(); err != nil { - return errors.Wrap(err, "resolver") - } - } - - builtins := TypeMap{ - "__Directive": {Model: "github.com/99designs/gqlgen/graphql/introspection.Directive"}, - "__Type": {Model: "github.com/99designs/gqlgen/graphql/introspection.Type"}, - "__Field": {Model: "github.com/99designs/gqlgen/graphql/introspection.Field"}, - "__EnumValue": {Model: "github.com/99designs/gqlgen/graphql/introspection.EnumValue"}, - "__InputValue": {Model: "github.com/99designs/gqlgen/graphql/introspection.InputValue"}, - "__Schema": {Model: "github.com/99designs/gqlgen/graphql/introspection.Schema"}, - "Int": {Model: "github.com/99designs/gqlgen/graphql.Int"}, - "Float": {Model: "github.com/99designs/gqlgen/graphql.Float"}, - "String": {Model: "github.com/99designs/gqlgen/graphql.String"}, - "Boolean": {Model: "github.com/99designs/gqlgen/graphql.Boolean"}, - "ID": {Model: "github.com/99designs/gqlgen/graphql.ID"}, - "Time": {Model: "github.com/99designs/gqlgen/graphql.Time"}, - "Map": {Model: "github.com/99designs/gqlgen/graphql.Map"}, - } - - if cfg.Models == nil { - cfg.Models = TypeMap{} - } - for typeName, entry := range builtins { - if !cfg.Models.Exists(typeName) { - cfg.Models[typeName] = entry - } - } - - var sources []*ast.Source - for _, filename := range cfg.SchemaFilename { - sources = append(sources, &ast.Source{Name: filename, Input: cfg.SchemaStr[filename]}) - } - - var err *gqlerror.Error - cfg.schema, err = gqlparser.LoadSchema(sources...) - if err != nil { - return err - } - return nil -} - -var invalidPackageNameChar = regexp.MustCompile(`[^\w]`) - -func sanitizePackageName(pkg string) string { - return invalidPackageNameChar.ReplaceAllLiteralString(filepath.Base(pkg), "_") -} - func abs(path string) string { absPath, err := filepath.Abs(path) if err != nil { diff --git a/codegen/input_build.go b/codegen/input_build.go index c0ac31ee020..581b2dc43f7 100644 --- a/codegen/input_build.go +++ b/codegen/input_build.go @@ -9,7 +9,7 @@ import ( "golang.org/x/tools/go/loader" ) -func (cfg *Config) buildInputs(namedTypes NamedTypes, prog *loader.Program) (Objects, error) { +func (cfg *Generator) buildInputs(namedTypes NamedTypes, prog *loader.Program) (Objects, error) { var inputs Objects for _, typ := range cfg.schema.Types { @@ -43,7 +43,7 @@ func (cfg *Config) buildInputs(namedTypes NamedTypes, prog *loader.Program) (Obj return inputs, nil } -func (cfg *Config) buildInput(types NamedTypes, typ *ast.Definition) (*Object, error) { +func (cfg *Generator) buildInput(types NamedTypes, typ *ast.Definition) (*Object, error) { obj := &Object{TypeDefinition: types[typ.Name]} typeEntry, entryExists := cfg.Models[typ.Name] diff --git a/codegen/input_test.go b/codegen/input_test.go index af2a7fc9286..d13847658cf 100644 --- a/codegen/input_test.go +++ b/codegen/input_test.go @@ -3,7 +3,13 @@ package codegen import ( "testing" + "github.com/vektah/gqlparser/gqlerror" + + "github.com/vektah/gqlparser/ast" + + "github.com/99designs/gqlgen/codegen/config" "github.com/stretchr/testify/require" + "github.com/vektah/gqlparser" "golang.org/x/tools/go/loader" ) @@ -33,26 +39,41 @@ func TestTypeInInput(t *testing.T) { require.EqualError(t, err, "model plan failed: Item cannot be used as a field of BookmarkableInput. only input and scalar types are allowed") } -func generate(name string, schema string, typemap ...TypeMap) error { - cfg := Config{ - SchemaFilename: SchemaFilenames{"schema.graphql"}, - SchemaStr: map[string]string{"schema.graphql": schema}, - Exec: PackageConfig{Filename: "gen/" + name + "/exec.go"}, - Model: PackageConfig{Filename: "gen/" + name + "/model.go"}, +func generate(name string, schema string, typemap ...config.TypeMap) error { + gen := Generator{ + Config: &config.Config{ + SchemaFilename: config.SchemaFilenames{"schema.graphql"}, + Exec: config.PackageConfig{Filename: "gen/" + name + "/exec.go"}, + Model: config.PackageConfig{Filename: "gen/" + name + "/model.go"}, + }, + + SchemaStr: map[string]string{"schema.graphql": schema}, + } + + err := gen.Config.Check() + if err != nil { + panic(err) + } + + var gerr *gqlerror.Error + gen.schema, gerr = gqlparser.LoadSchema(&ast.Source{Name: "schema.graphql", Input: schema}) + if gerr != nil { + panic(gerr) } if len(typemap) > 0 { - cfg.Models = typemap[0] + gen.Models = typemap[0] } - err := Generate(cfg) - if err == nil { - conf := loader.Config{} - conf.Import("github.com/99designs/gqlgen/codegen/testdata/gen/" + name) - - _, err = conf.Load() - if err != nil { - panic(err) - } + err = gen.Generate() + if err != nil { + return err + } + conf := loader.Config{} + conf.Import("github.com/99designs/gqlgen/codegen/testdata/gen/" + name) + + _, err = conf.Load() + if err != nil { + panic(err) } - return err + return nil } diff --git a/codegen/interface_build.go b/codegen/interface_build.go index 47152d577c6..d6eefd2c9a2 100644 --- a/codegen/interface_build.go +++ b/codegen/interface_build.go @@ -8,7 +8,7 @@ import ( "golang.org/x/tools/go/loader" ) -func (cfg *Config) buildInterfaces(types NamedTypes, prog *loader.Program) []*Interface { +func (cfg *Generator) buildInterfaces(types NamedTypes, prog *loader.Program) []*Interface { var interfaces []*Interface for _, typ := range cfg.schema.Types { if typ.Kind == ast.Union || typ.Kind == ast.Interface { @@ -23,7 +23,7 @@ func (cfg *Config) buildInterfaces(types NamedTypes, prog *loader.Program) []*In return interfaces } -func (cfg *Config) buildInterface(types NamedTypes, typ *ast.Definition, prog *loader.Program) *Interface { +func (cfg *Generator) buildInterface(types NamedTypes, typ *ast.Definition, prog *loader.Program) *Interface { i := &Interface{TypeDefinition: types[typ.Name]} for _, implementor := range cfg.schema.GetPossibleTypes(typ) { @@ -38,7 +38,7 @@ func (cfg *Config) buildInterface(types NamedTypes, typ *ast.Definition, prog *l return i } -func (cfg *Config) isValueReceiver(intf *TypeDefinition, implementor *TypeDefinition, prog *loader.Program) bool { +func (cfg *Generator) isValueReceiver(intf *TypeDefinition, implementor *TypeDefinition, prog *loader.Program) bool { interfaceType, err := findGoInterface(prog, intf.Package, intf.GoType) if interfaceType == nil || err != nil { return true diff --git a/codegen/models_build.go b/codegen/models_build.go index f718e590a77..a3a7d0bfc8a 100644 --- a/codegen/models_build.go +++ b/codegen/models_build.go @@ -7,7 +7,7 @@ import ( "golang.org/x/tools/go/loader" ) -func (cfg *Config) buildModels(types NamedTypes, prog *loader.Program) ([]Model, error) { +func (cfg *Generator) buildModels(types NamedTypes, prog *loader.Program) ([]Model, error) { var models []Model for _, typ := range cfg.schema.Types { @@ -52,7 +52,7 @@ func (cfg *Config) buildModels(types NamedTypes, prog *loader.Program) ([]Model, return models, nil } -func (cfg *Config) obj2Model(obj *Object) Model { +func (cfg *Generator) obj2Model(obj *Object) Model { model := Model{ TypeDefinition: obj.TypeDefinition, Implements: obj.Implements, diff --git a/codegen/object_build.go b/codegen/object_build.go index e3d067a3f1e..dc7e5813d46 100644 --- a/codegen/object_build.go +++ b/codegen/object_build.go @@ -9,7 +9,7 @@ import ( "golang.org/x/tools/go/loader" ) -func (cfg *Config) buildObjects(types NamedTypes, prog *loader.Program) (Objects, error) { +func (cfg *Generator) buildObjects(types NamedTypes, prog *loader.Program) (Objects, error) { var objects Objects for _, typ := range cfg.schema.Types { @@ -81,7 +81,7 @@ func sanitizeArgName(name string) string { return name } -func (cfg *Config) buildObject(types NamedTypes, typ *ast.Definition) (*Object, error) { +func (cfg *Generator) buildObject(types NamedTypes, typ *ast.Definition) (*Object, error) { obj := &Object{TypeDefinition: types[typ.Name]} typeEntry, entryExists := cfg.Models[typ.Name] diff --git a/codegen/type_build.go b/codegen/type_build.go index 096fc447d09..2b9687b7b5a 100644 --- a/codegen/type_build.go +++ b/codegen/type_build.go @@ -9,7 +9,7 @@ import ( ) // namedTypeFromSchema objects for every graphql type, including scalars. There should only be one instance of TypeReference for each thing -func (cfg *Config) buildNamedTypes() NamedTypes { +func (cfg *Generator) buildNamedTypes() NamedTypes { types := map[string]*TypeDefinition{} for _, schemaType := range cfg.schema.Types { t := namedTypeFromSchema(schemaType) @@ -27,7 +27,7 @@ func (cfg *Config) buildNamedTypes() NamedTypes { return types } -func (cfg *Config) bindTypes(namedTypes NamedTypes, destDir string, prog *loader.Program) { +func (cfg *Generator) bindTypes(namedTypes NamedTypes, destDir string, prog *loader.Program) { for _, t := range namedTypes { if t.Package == "" { continue @@ -69,32 +69,3 @@ func pkgAndType(name string) (string, string) { return normalizeVendor(strings.Join(parts[:len(parts)-1], ".")), parts[len(parts)-1] } - -func (n NamedTypes) getType(t *ast.Type) *TypeReference { - orig := t - var modifiers []string - for { - if t.Elem != nil { - modifiers = append(modifiers, modList) - t = t.Elem - } else { - if !t.NonNull { - modifiers = append(modifiers, modPtr) - } - if n[t.NamedType] == nil { - panic("missing type " + t.NamedType) - } - res := &TypeReference{ - TypeDefinition: n[t.NamedType], - Modifiers: modifiers, - ASTType: orig, - } - - if res.IsInterface { - res.StripPtr() - } - - return res - } - } -} diff --git a/codegen/type_definition.go b/codegen/type_definition.go index 810cddcf33e..f0ccafc4ddc 100644 --- a/codegen/type_definition.go +++ b/codegen/type_definition.go @@ -1,9 +1,14 @@ package codegen -import "github.com/99designs/gqlgen/codegen/templates" +import ( + "github.com/99designs/gqlgen/codegen/templates" + "github.com/vektah/gqlparser/ast" +) type NamedTypes map[string]*TypeDefinition +// TypeDefinition is the static reference to a graphql type. It can be referenced by many TypeReferences, +// and has one or more backing implementations in go. type TypeDefinition struct { TypeImplementation IsScalar bool @@ -13,6 +18,8 @@ type TypeDefinition struct { Marshaler *TypeImplementation // If this type has an external marshaler this will be set } +// TypeImplementation is a reference to exisiting golang code that either meets the graphql.Marshaler interface +// or points to the root of a pair of external Marshal[TYPE] and Unmarshal[TYPE] functions. type TypeImplementation struct { GoType string // Name of the go type Package string // the package the go type lives in @@ -41,3 +48,32 @@ func (t TypeImplementation) PkgDot() string { func (t TypeDefinition) IsMarshaled() bool { return t.Marshaler != nil } + +func (n NamedTypes) getType(t *ast.Type) *TypeReference { + orig := t + var modifiers []string + for { + if t.Elem != nil { + modifiers = append(modifiers, modList) + t = t.Elem + } else { + if !t.NonNull { + modifiers = append(modifiers, modPtr) + } + if n[t.NamedType] == nil { + panic("missing type " + t.NamedType) + } + res := &TypeReference{ + TypeDefinition: n[t.NamedType], + Modifiers: modifiers, + ASTType: orig, + } + + if res.IsInterface { + res.StripPtr() + } + + return res + } + } +} diff --git a/internal/gopath/util.go b/internal/gopath/util.go new file mode 100644 index 00000000000..5d0babe3f12 --- /dev/null +++ b/internal/gopath/util.go @@ -0,0 +1,25 @@ +package gopath + +import ( + "regexp" + "strings" +) + +// take a string in the form github.com/package/blah.Type and split it into package and type +func PkgAndType(name string) (string, string) { + parts := strings.Split(name, ".") + if len(parts) == 1 { + return "", name + } + + return NormalizeVendor(strings.Join(parts[:len(parts)-1], ".")), parts[len(parts)-1] +} + +var modsRegex = regexp.MustCompile(`^(\*|\[\])*`) + +func NormalizeVendor(pkg string) string { + modifiers := modsRegex.FindAllString(pkg, 1)[0] + pkg = strings.TrimPrefix(pkg, modifiers) + parts := strings.Split(pkg, "/vendor/") + return modifiers + parts[len(parts)-1] +} From 4138a3728d3dec69e509b09ff7f3fe7257f01cf2 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Sat, 5 Jan 2019 15:26:18 +1100 Subject: [PATCH 026/147] rename generator receiver --- codegen/build.go | 88 +++++++++++++++++++------------------- codegen/directive_build.go | 10 ++--- codegen/enum_build.go | 4 +- codegen/generator.go | 50 +++++++++++----------- codegen/input_build.go | 16 +++---- codegen/interface_build.go | 14 +++--- codegen/models_build.go | 16 +++---- codegen/object_build.go | 26 +++++------ codegen/type_build.go | 8 ++-- 9 files changed, 116 insertions(+), 116 deletions(-) diff --git a/codegen/build.go b/codegen/build.go index 21db90e8ad8..252cad19147 100644 --- a/codegen/build.go +++ b/codegen/build.go @@ -44,138 +44,138 @@ type ServerBuild struct { } // Create a list of models that need to be generated -func (cfg *Generator) models() (*ModelBuild, error) { - namedTypes := cfg.buildNamedTypes() +func (g *Generator) models() (*ModelBuild, error) { + namedTypes := g.buildNamedTypes() - progLoader := cfg.newLoaderWithoutErrors() + progLoader := g.newLoaderWithoutErrors() prog, err := progLoader.Load() if err != nil { return nil, errors.Wrap(err, "loading failed") } - cfg.bindTypes(namedTypes, cfg.Model.Dir(), prog) + g.bindTypes(namedTypes, g.Model.Dir(), prog) - models, err := cfg.buildModels(namedTypes, prog) + models, err := g.buildModels(namedTypes, prog) if err != nil { return nil, err } return &ModelBuild{ - PackageName: cfg.Model.Package, + PackageName: g.Model.Package, Models: models, - Enums: cfg.buildEnums(namedTypes), + Enums: g.buildEnums(namedTypes), }, nil } // bind a schema together with some code to generate a Build -func (cfg *Generator) resolver() (*ResolverBuild, error) { - progLoader := cfg.newLoaderWithoutErrors() - progLoader.Import(cfg.Resolver.ImportPath()) +func (g *Generator) resolver() (*ResolverBuild, error) { + progLoader := g.newLoaderWithoutErrors() + progLoader.Import(g.Resolver.ImportPath()) prog, err := progLoader.Load() if err != nil { return nil, err } - destDir := cfg.Resolver.Dir() + destDir := g.Resolver.Dir() - namedTypes := cfg.buildNamedTypes() + namedTypes := g.buildNamedTypes() - cfg.bindTypes(namedTypes, destDir, prog) + g.bindTypes(namedTypes, destDir, prog) - objects, err := cfg.buildObjects(namedTypes, prog) + objects, err := g.buildObjects(namedTypes, prog) if err != nil { return nil, err } - def, _ := findGoType(prog, cfg.Resolver.ImportPath(), cfg.Resolver.Type) + def, _ := findGoType(prog, g.Resolver.ImportPath(), g.Resolver.Type) resolverFound := def != nil return &ResolverBuild{ - PackageName: cfg.Resolver.Package, + PackageName: g.Resolver.Package, Objects: objects, - ResolverType: cfg.Resolver.Type, + ResolverType: g.Resolver.Type, ResolverFound: resolverFound, }, nil } -func (cfg *Generator) server(destDir string) *ServerBuild { +func (g *Generator) server(destDir string) *ServerBuild { return &ServerBuild{ - PackageName: cfg.Resolver.Package, - ExecPackageName: cfg.Exec.ImportPath(), - ResolverPackageName: cfg.Resolver.ImportPath(), + PackageName: g.Resolver.Package, + ExecPackageName: g.Exec.ImportPath(), + ResolverPackageName: g.Resolver.ImportPath(), } } // bind a schema together with some code to generate a Build -func (cfg *Generator) bind() (*Build, error) { - namedTypes := cfg.buildNamedTypes() +func (g *Generator) bind() (*Build, error) { + namedTypes := g.buildNamedTypes() - progLoader := cfg.newLoaderWithoutErrors() + progLoader := g.newLoaderWithoutErrors() prog, err := progLoader.Load() if err != nil { return nil, errors.Wrap(err, "loading failed") } - cfg.bindTypes(namedTypes, cfg.Exec.Dir(), prog) + g.bindTypes(namedTypes, g.Exec.Dir(), prog) - objects, err := cfg.buildObjects(namedTypes, prog) + objects, err := g.buildObjects(namedTypes, prog) if err != nil { return nil, err } - inputs, err := cfg.buildInputs(namedTypes, prog) + inputs, err := g.buildInputs(namedTypes, prog) if err != nil { return nil, err } - directives, err := cfg.buildDirectives(namedTypes) + directives, err := g.buildDirectives(namedTypes) if err != nil { return nil, err } b := &Build{ - PackageName: cfg.Exec.Package, + PackageName: g.Exec.Package, Objects: objects, - Interfaces: cfg.buildInterfaces(namedTypes, prog), + Interfaces: g.buildInterfaces(namedTypes, prog), Inputs: inputs, - SchemaRaw: cfg.SchemaStr, - SchemaFilename: cfg.SchemaFilename, + SchemaRaw: g.SchemaStr, + SchemaFilename: g.SchemaFilename, Directives: directives, } - if cfg.schema.Query != nil { - b.QueryRoot = b.Objects.ByName(cfg.schema.Query.Name) + if g.schema.Query != nil { + b.QueryRoot = b.Objects.ByName(g.schema.Query.Name) } else { return b, fmt.Errorf("query entry point missing") } - if cfg.schema.Mutation != nil { - b.MutationRoot = b.Objects.ByName(cfg.schema.Mutation.Name) + if g.schema.Mutation != nil { + b.MutationRoot = b.Objects.ByName(g.schema.Mutation.Name) } - if cfg.schema.Subscription != nil { - b.SubscriptionRoot = b.Objects.ByName(cfg.schema.Subscription.Name) + if g.schema.Subscription != nil { + b.SubscriptionRoot = b.Objects.ByName(g.schema.Subscription.Name) } return b, nil } -func (cfg *Generator) validate() error { - progLoader := cfg.newLoaderWithErrors() +func (g *Generator) validate() error { + progLoader := g.newLoaderWithErrors() _, err := progLoader.Load() return err } -func (cfg *Generator) newLoaderWithErrors() loader.Config { +func (g *Generator) newLoaderWithErrors() loader.Config { conf := loader.Config{} - for _, pkg := range cfg.Models.ReferencedPackages() { + for _, pkg := range g.Models.ReferencedPackages() { conf.Import(pkg) } return conf } -func (cfg *Generator) newLoaderWithoutErrors() loader.Config { - conf := cfg.newLoaderWithErrors() +func (g *Generator) newLoaderWithoutErrors() loader.Config { + conf := g.newLoaderWithErrors() conf.AllowErrors = true conf.TypeChecker = types.Config{ Error: func(e error) {}, diff --git a/codegen/directive_build.go b/codegen/directive_build.go index 0ebe9af37bb..f123b307abb 100644 --- a/codegen/directive_build.go +++ b/codegen/directive_build.go @@ -5,10 +5,10 @@ import ( "github.com/vektah/gqlparser/ast" ) -func (cfg *Generator) buildDirectives(types NamedTypes) (map[string]*Directive, error) { - directives := make(map[string]*Directive, len(cfg.schema.Directives)) +func (g *Generator) buildDirectives(types NamedTypes) (map[string]*Directive, error) { + directives := make(map[string]*Directive, len(g.schema.Directives)) - for name, dir := range cfg.schema.Directives { + for name, dir := range g.schema.Directives { if _, ok := directives[name]; ok { return nil, errors.Errorf("directive with name %s already exists", name) } @@ -48,7 +48,7 @@ func (cfg *Generator) buildDirectives(types NamedTypes) (map[string]*Directive, return directives, nil } -func (cfg *Generator) getDirectives(list ast.DirectiveList) ([]*Directive, error) { +func (g *Generator) getDirectives(list ast.DirectiveList) ([]*Directive, error) { dirs := make([]*Directive, len(list)) for i, d := range list { @@ -61,7 +61,7 @@ func (cfg *Generator) getDirectives(list ast.DirectiveList) ([]*Directive, error argValues[da.Name] = val } - if def, ok := cfg.Directives[d.Name]; ok { + if def, ok := g.Directives[d.Name]; ok { var args []FieldArgument for _, a := range def.Args { diff --git a/codegen/enum_build.go b/codegen/enum_build.go index 9ab34d206b9..052ddfd9696 100644 --- a/codegen/enum_build.go +++ b/codegen/enum_build.go @@ -8,10 +8,10 @@ import ( "github.com/vektah/gqlparser/ast" ) -func (cfg *Generator) buildEnums(types NamedTypes) []Enum { +func (g *Generator) buildEnums(types NamedTypes) []Enum { var enums []Enum - for _, typ := range cfg.schema.Types { + for _, typ := range g.schema.Types { namedType := types[typ.Name] if typ.Kind != ast.Enum || strings.HasPrefix(typ.Name, "__") || namedType.IsUserDefined { continue diff --git a/codegen/generator.go b/codegen/generator.go index a61ba84a0c2..0741f928117 100644 --- a/codegen/generator.go +++ b/codegen/generator.go @@ -36,65 +36,65 @@ func New(cfg *config.Config) (*Generator, error) { return g, nil } -func (cfg *Generator) Generate() error { - _ = syscall.Unlink(cfg.Exec.Filename) - _ = syscall.Unlink(cfg.Model.Filename) +func (g *Generator) Generate() error { + _ = syscall.Unlink(g.Exec.Filename) + _ = syscall.Unlink(g.Model.Filename) - namedTypes := cfg.buildNamedTypes() + namedTypes := g.buildNamedTypes() - directives, err := cfg.buildDirectives(namedTypes) + directives, err := g.buildDirectives(namedTypes) if err != nil { return err } - cfg.Directives = directives + g.Directives = directives - modelsBuild, err := cfg.models() + modelsBuild, err := g.models() if err != nil { return errors.Wrap(err, "model plan failed") } if len(modelsBuild.Models) > 0 || len(modelsBuild.Enums) > 0 { - if err = templates.RenderToFile("models.gotpl", cfg.Model.Filename, modelsBuild); err != nil { + if err = templates.RenderToFile("models.gotpl", g.Model.Filename, modelsBuild); err != nil { return err } for _, model := range modelsBuild.Models { - modelCfg := cfg.Models[model.GQLType] - modelCfg.Model = cfg.Model.ImportPath() + "." + model.GoType - cfg.Models[model.GQLType] = modelCfg + modelCfg := g.Models[model.GQLType] + modelCfg.Model = g.Model.ImportPath() + "." + model.GoType + g.Models[model.GQLType] = modelCfg } for _, enum := range modelsBuild.Enums { - modelCfg := cfg.Models[enum.GQLType] - modelCfg.Model = cfg.Model.ImportPath() + "." + enum.GoType - cfg.Models[enum.GQLType] = modelCfg + modelCfg := g.Models[enum.GQLType] + modelCfg.Model = g.Model.ImportPath() + "." + enum.GoType + g.Models[enum.GQLType] = modelCfg } } - build, err := cfg.bind() + build, err := g.bind() if err != nil { return errors.Wrap(err, "exec plan failed") } - if err := templates.RenderToFile("generated.gotpl", cfg.Exec.Filename, build); err != nil { + if err := templates.RenderToFile("generated.gotpl", g.Exec.Filename, build); err != nil { return err } - if cfg.Resolver.IsDefined() { - if err := cfg.GenerateResolver(); err != nil { + if g.Resolver.IsDefined() { + if err := g.GenerateResolver(); err != nil { return errors.Wrap(err, "generating resolver failed") } } - if err := cfg.validate(); err != nil { + if err := g.validate(); err != nil { return errors.Wrap(err, "validation failed") } return nil } -func (cfg *Generator) GenerateServer(filename string) error { +func (g *Generator) GenerateServer(filename string) error { serverFilename := abs(filename) - serverBuild := cfg.server(filepath.Dir(serverFilename)) + serverBuild := g.server(filepath.Dir(serverFilename)) if _, err := os.Stat(serverFilename); os.IsNotExist(errors.Cause(err)) { err = templates.RenderToFile("server.gotpl", serverFilename, serverBuild) @@ -107,15 +107,15 @@ func (cfg *Generator) GenerateServer(filename string) error { return nil } -func (cfg *Generator) GenerateResolver() error { - resolverBuild, err := cfg.resolver() +func (g *Generator) GenerateResolver() error { + resolverBuild, err := g.resolver() if err != nil { return errors.Wrap(err, "resolver build failed") } - filename := cfg.Resolver.Filename + filename := g.Resolver.Filename if resolverBuild.ResolverFound { - log.Printf("Skipped resolver: %s.%s already exists\n", cfg.Resolver.ImportPath(), cfg.Resolver.Type) + log.Printf("Skipped resolver: %s.%s already exists\n", g.Resolver.ImportPath(), g.Resolver.Type) return nil } diff --git a/codegen/input_build.go b/codegen/input_build.go index 581b2dc43f7..27f9b3fa825 100644 --- a/codegen/input_build.go +++ b/codegen/input_build.go @@ -9,13 +9,13 @@ import ( "golang.org/x/tools/go/loader" ) -func (cfg *Generator) buildInputs(namedTypes NamedTypes, prog *loader.Program) (Objects, error) { +func (g *Generator) buildInputs(namedTypes NamedTypes, prog *loader.Program) (Objects, error) { var inputs Objects - for _, typ := range cfg.schema.Types { + for _, typ := range g.schema.Types { switch typ.Kind { case ast.InputObject: - input, err := cfg.buildInput(namedTypes, typ) + input, err := g.buildInput(namedTypes, typ) if err != nil { return nil, err } @@ -26,7 +26,7 @@ func (cfg *Generator) buildInputs(namedTypes NamedTypes, prog *loader.Program) ( } if def != nil { input.Marshaler = buildInputMarshaler(typ, def) - bindErrs := bindObject(def.Type(), input, cfg.StructTag) + bindErrs := bindObject(def.Type(), input, g.StructTag) if len(bindErrs) > 0 { return nil, bindErrs } @@ -43,12 +43,12 @@ func (cfg *Generator) buildInputs(namedTypes NamedTypes, prog *loader.Program) ( return inputs, nil } -func (cfg *Generator) buildInput(types NamedTypes, typ *ast.Definition) (*Object, error) { +func (g *Generator) buildInput(types NamedTypes, typ *ast.Definition) (*Object, error) { obj := &Object{TypeDefinition: types[typ.Name]} - typeEntry, entryExists := cfg.Models[typ.Name] + typeEntry, entryExists := g.Models[typ.Name] for _, field := range typ.Fields { - dirs, err := cfg.getDirectives(field.Directives) + dirs, err := g.getDirectives(field.Directives) if err != nil { return nil, err } @@ -80,7 +80,7 @@ func (cfg *Generator) buildInput(types NamedTypes, typ *ast.Definition) (*Object obj.Fields = append(obj.Fields, newField) } - dirs, err := cfg.getDirectives(typ.Directives) + dirs, err := g.getDirectives(typ.Directives) if err != nil { return nil, err } diff --git a/codegen/interface_build.go b/codegen/interface_build.go index d6eefd2c9a2..0a9532d553d 100644 --- a/codegen/interface_build.go +++ b/codegen/interface_build.go @@ -8,11 +8,11 @@ import ( "golang.org/x/tools/go/loader" ) -func (cfg *Generator) buildInterfaces(types NamedTypes, prog *loader.Program) []*Interface { +func (g *Generator) buildInterfaces(types NamedTypes, prog *loader.Program) []*Interface { var interfaces []*Interface - for _, typ := range cfg.schema.Types { + for _, typ := range g.schema.Types { if typ.Kind == ast.Union || typ.Kind == ast.Interface { - interfaces = append(interfaces, cfg.buildInterface(types, typ, prog)) + interfaces = append(interfaces, g.buildInterface(types, typ, prog)) } } @@ -23,22 +23,22 @@ func (cfg *Generator) buildInterfaces(types NamedTypes, prog *loader.Program) [] return interfaces } -func (cfg *Generator) buildInterface(types NamedTypes, typ *ast.Definition, prog *loader.Program) *Interface { +func (g *Generator) buildInterface(types NamedTypes, typ *ast.Definition, prog *loader.Program) *Interface { i := &Interface{TypeDefinition: types[typ.Name]} - for _, implementor := range cfg.schema.GetPossibleTypes(typ) { + for _, implementor := range g.schema.GetPossibleTypes(typ) { t := types[implementor.Name] i.Implementors = append(i.Implementors, InterfaceImplementor{ TypeDefinition: t, - ValueReceiver: cfg.isValueReceiver(types[typ.Name], t, prog), + ValueReceiver: g.isValueReceiver(types[typ.Name], t, prog), }) } return i } -func (cfg *Generator) isValueReceiver(intf *TypeDefinition, implementor *TypeDefinition, prog *loader.Program) bool { +func (g *Generator) isValueReceiver(intf *TypeDefinition, implementor *TypeDefinition, prog *loader.Program) bool { interfaceType, err := findGoInterface(prog, intf.Package, intf.GoType) if interfaceType == nil || err != nil { return true diff --git a/codegen/models_build.go b/codegen/models_build.go index a3a7d0bfc8a..e21e6aa1fe7 100644 --- a/codegen/models_build.go +++ b/codegen/models_build.go @@ -7,32 +7,32 @@ import ( "golang.org/x/tools/go/loader" ) -func (cfg *Generator) buildModels(types NamedTypes, prog *loader.Program) ([]Model, error) { +func (g *Generator) buildModels(types NamedTypes, prog *loader.Program) ([]Model, error) { var models []Model - for _, typ := range cfg.schema.Types { + for _, typ := range g.schema.Types { var model Model switch typ.Kind { case ast.Object: - obj, err := cfg.buildObject(types, typ) + obj, err := g.buildObject(types, typ) if err != nil { return nil, err } if obj.Root || obj.IsUserDefined { continue } - model = cfg.obj2Model(obj) + model = g.obj2Model(obj) case ast.InputObject: - obj, err := cfg.buildInput(types, typ) + obj, err := g.buildInput(types, typ) if err != nil { return nil, err } if obj.IsUserDefined { continue } - model = cfg.obj2Model(obj) + model = g.obj2Model(obj) case ast.Interface, ast.Union: - intf := cfg.buildInterface(types, typ, prog) + intf := g.buildInterface(types, typ, prog) if intf.IsUserDefined { continue } @@ -52,7 +52,7 @@ func (cfg *Generator) buildModels(types NamedTypes, prog *loader.Program) ([]Mod return models, nil } -func (cfg *Generator) obj2Model(obj *Object) Model { +func (g *Generator) obj2Model(obj *Object) Model { model := Model{ TypeDefinition: obj.TypeDefinition, Implements: obj.Implements, diff --git a/codegen/object_build.go b/codegen/object_build.go index dc7e5813d46..a0edc0b2c21 100644 --- a/codegen/object_build.go +++ b/codegen/object_build.go @@ -9,15 +9,15 @@ import ( "golang.org/x/tools/go/loader" ) -func (cfg *Generator) buildObjects(types NamedTypes, prog *loader.Program) (Objects, error) { +func (g *Generator) buildObjects(types NamedTypes, prog *loader.Program) (Objects, error) { var objects Objects - for _, typ := range cfg.schema.Types { + for _, typ := range g.schema.Types { if typ.Kind != ast.Object { continue } - obj, err := cfg.buildObject(types, typ) + obj, err := g.buildObject(types, typ) if err != nil { return nil, err } @@ -27,7 +27,7 @@ func (cfg *Generator) buildObjects(types NamedTypes, prog *loader.Program) (Obje return nil, err } if def != nil { - for _, bindErr := range bindObject(def.Type(), obj, cfg.StructTag) { + for _, bindErr := range bindObject(def.Type(), obj, g.StructTag) { log.Println(bindErr.Error()) log.Println(" Adding resolver method") } @@ -81,34 +81,34 @@ func sanitizeArgName(name string) string { return name } -func (cfg *Generator) buildObject(types NamedTypes, typ *ast.Definition) (*Object, error) { +func (g *Generator) buildObject(types NamedTypes, typ *ast.Definition) (*Object, error) { obj := &Object{TypeDefinition: types[typ.Name]} - typeEntry, entryExists := cfg.Models[typ.Name] + typeEntry, entryExists := g.Models[typ.Name] obj.ResolverInterface = &TypeImplementation{GoType: obj.GQLType + "Resolver"} - if typ == cfg.schema.Query { + if typ == g.schema.Query { obj.Root = true } - if typ == cfg.schema.Mutation { + if typ == g.schema.Mutation { obj.Root = true obj.DisableConcurrency = true } - if typ == cfg.schema.Subscription { + if typ == g.schema.Subscription { obj.Root = true obj.Stream = true } obj.Satisfies = append(obj.Satisfies, typ.Interfaces...) - for _, intf := range cfg.schema.GetImplements(typ) { + for _, intf := range g.schema.GetImplements(typ) { obj.Implements = append(obj.Implements, types[intf.Name]) } for _, field := range typ.Fields { - if typ == cfg.schema.Query && field.Name == "__type" { + if typ == g.schema.Query && field.Name == "__type" { obj.Fields = append(obj.Fields, Field{ TypeReference: &TypeReference{types["__Schema"], []string{modPtr}, ast.NamedType("__Schema", nil), nil}, GQLName: "__schema", @@ -120,7 +120,7 @@ func (cfg *Generator) buildObject(types NamedTypes, typ *ast.Definition) (*Objec }) continue } - if typ == cfg.schema.Query && field.Name == "__schema" { + if typ == g.schema.Query && field.Name == "__schema" { obj.Fields = append(obj.Fields, Field{ TypeReference: &TypeReference{types["__Type"], []string{modPtr}, ast.NamedType("__Schema", nil), nil}, GQLName: "__type", @@ -146,7 +146,7 @@ func (cfg *Generator) buildObject(types NamedTypes, typ *ast.Definition) (*Objec var args []FieldArgument for _, arg := range field.Arguments { - dirs, err := cfg.getDirectives(arg.Directives) + dirs, err := g.getDirectives(arg.Directives) if err != nil { return nil, err } diff --git a/codegen/type_build.go b/codegen/type_build.go index 2b9687b7b5a..f69bd19aaaf 100644 --- a/codegen/type_build.go +++ b/codegen/type_build.go @@ -9,12 +9,12 @@ import ( ) // namedTypeFromSchema objects for every graphql type, including scalars. There should only be one instance of TypeReference for each thing -func (cfg *Generator) buildNamedTypes() NamedTypes { +func (g *Generator) buildNamedTypes() NamedTypes { types := map[string]*TypeDefinition{} - for _, schemaType := range cfg.schema.Types { + for _, schemaType := range g.schema.Types { t := namedTypeFromSchema(schemaType) - if userEntry, ok := cfg.Models[t.GQLType]; ok && userEntry.Model != "" { + if userEntry, ok := g.Models[t.GQLType]; ok && userEntry.Model != "" { t.IsUserDefined = true t.Package, t.GoType = pkgAndType(userEntry.Model) } else if t.IsScalar { @@ -27,7 +27,7 @@ func (cfg *Generator) buildNamedTypes() NamedTypes { return types } -func (cfg *Generator) bindTypes(namedTypes NamedTypes, destDir string, prog *loader.Program) { +func (g *Generator) bindTypes(namedTypes NamedTypes, destDir string, prog *loader.Program) { for _, t := range namedTypes { if t.Package == "" { continue From eb1011617b052446b44239ec2fb9b6f6ee9cfdde Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Mon, 7 Jan 2019 16:49:07 +1100 Subject: [PATCH 027/147] Remove aliased types, to be replaced by allowing multiple backing types --- codegen/object_build.go | 6 +++--- codegen/type_reference.go | 23 ++++------------------- codegen/util.go | 9 --------- example/scalars/.gqlgen.yml | 2 ++ example/scalars/generated.go | 12 +++++------- example/scalars/model/model.go | 26 +++++++++++++++++++++++--- example/scalars/schema.graphql | 5 +++-- 7 files changed, 40 insertions(+), 43 deletions(-) diff --git a/codegen/object_build.go b/codegen/object_build.go index a0edc0b2c21..b4ca783c275 100644 --- a/codegen/object_build.go +++ b/codegen/object_build.go @@ -110,7 +110,7 @@ func (g *Generator) buildObject(types NamedTypes, typ *ast.Definition) (*Object, for _, field := range typ.Fields { if typ == g.schema.Query && field.Name == "__type" { obj.Fields = append(obj.Fields, Field{ - TypeReference: &TypeReference{types["__Schema"], []string{modPtr}, ast.NamedType("__Schema", nil), nil}, + TypeReference: &TypeReference{types["__Schema"], []string{modPtr}, ast.NamedType("__Schema", nil)}, GQLName: "__schema", GoFieldType: GoFieldMethod, GoReceiverName: "ec", @@ -122,13 +122,13 @@ func (g *Generator) buildObject(types NamedTypes, typ *ast.Definition) (*Object, } if typ == g.schema.Query && field.Name == "__schema" { obj.Fields = append(obj.Fields, Field{ - TypeReference: &TypeReference{types["__Type"], []string{modPtr}, ast.NamedType("__Schema", nil), nil}, + TypeReference: &TypeReference{types["__Type"], []string{modPtr}, ast.NamedType("__Schema", nil)}, GQLName: "__type", GoFieldType: GoFieldMethod, GoReceiverName: "ec", GoFieldName: "introspectType", Args: []FieldArgument{ - {GQLName: "name", TypeReference: &TypeReference{types["String"], []string{}, ast.NamedType("String", nil), nil}, Object: &Object{}}, + {GQLName: "name", TypeReference: &TypeReference{types["String"], []string{}, ast.NamedType("String", nil)}, Object: &Object{}}, }, Object: obj, }) diff --git a/codegen/type_reference.go b/codegen/type_reference.go index 67b1d033b87..a50f5437651 100644 --- a/codegen/type_reference.go +++ b/codegen/type_reference.go @@ -11,15 +11,11 @@ import ( type TypeReference struct { *TypeDefinition - Modifiers []string - ASTType *ast.Type - AliasedType *TypeImplementation + Modifiers []string + ASTType *ast.Type } func (t TypeReference) Signature() string { - if t.AliasedType != nil { - return strings.Join(t.Modifiers, "") + t.AliasedType.FullName() - } return strings.Join(t.Modifiers, "") + t.FullName() } @@ -96,23 +92,15 @@ func (t TypeReference) unmarshal(result, raw string, remainingMods []string, dep } realResult := result - if t.AliasedType != nil { - result = "castTmp" - } - return tpl(`{{- if .t.AliasedType }} - var castTmp {{.t.FullName}} - {{ end }} + return tpl(` {{- if eq .t.GoType "map[string]interface{}" }} {{- .result }} = {{.raw}}.(map[string]interface{}) {{- else if .t.Marshaler }} {{- .result }}, err = {{ .t.Marshaler.PkgDot }}Unmarshal{{.t.Marshaler.GoType}}({{.raw}}) {{- else -}} err = (&{{.result}}).UnmarshalGQL({{.raw}}) - {{- end }} - {{- if .t.AliasedType }} - {{ .realResult }} = {{.t.AliasedType.FullName}}(castTmp) - {{- end }}`, map[string]interface{}{ + {{- end }}`, map[string]interface{}{ "realResult": realResult, "result": result, "raw": raw, @@ -182,9 +170,6 @@ func (t TypeReference) middleware(result, raw string, remainingMods []string, de } func (t TypeReference) Marshal(val string) string { - if t.AliasedType != nil { - val = t.GoType + "(" + val + ")" - } if t.Marshaler != nil { return "return " + t.Marshaler.PkgDot() + "Marshal" + t.Marshaler.GoType + "(" + val + ")" diff --git a/codegen/util.go b/codegen/util.go index 41cce5f8bff..076f2ab111c 100644 --- a/codegen/util.go +++ b/codegen/util.go @@ -342,15 +342,6 @@ func validateTypeBinding(field *Field, goType types.Type) error { return nil } - // deal with type aliases - underlyingStr := normalizeVendor(goType.Underlying().String()) - if equalTypes(underlyingStr, gqlType) { - field.TypeReference.Modifiers = modifiersFromGoType(goType) - pkg, typ := pkgAndType(goType.String()) - field.AliasedType = &TypeImplementation{GoType: typ, Package: pkg} - return nil - } - return fmt.Errorf("%s is not compatible with %s", gqlType, goTypeStr) } diff --git a/example/scalars/.gqlgen.yml b/example/scalars/.gqlgen.yml index c49b8f70eff..e92ce20865c 100644 --- a/example/scalars/.gqlgen.yml +++ b/example/scalars/.gqlgen.yml @@ -14,3 +14,5 @@ models: model: github.com/99designs/gqlgen/example/scalars/model.ID Tier: model: github.com/99designs/gqlgen/example/scalars/model.Tier + Banned: + model: github.com/99designs/gqlgen/example/scalars/model.Banned diff --git a/example/scalars/generated.go b/example/scalars/generated.go index a60a7178f73..1bff78859aa 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -766,7 +766,7 @@ func (ec *executionContext) _User_isBanned(ctx context.Context, field graphql.Co res := resTmp.(model.Banned) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(bool(res)) + return res } // nolint: vetshadow @@ -2337,10 +2337,7 @@ func UnmarshalSearchArgs(v interface{}) (model.SearchArgs, error) { } case "isBanned": var err error - - var castTmp bool - castTmp, err = graphql.UnmarshalBoolean(v) - it.IsBanned = model.Banned(castTmp) + err = (&it.IsBanned).UnmarshalGQL(v) if err != nil { return it, err } @@ -2394,7 +2391,7 @@ type User { id: ID! name: String! created: Timestamp - isBanned: Boolean! + isBanned: Banned! primitiveResolver: String! customResolver: Point! address: Address @@ -2409,7 +2406,7 @@ type Address { input SearchArgs { location: Point createdAfter: Timestamp - isBanned: Boolean + isBanned: Banned # TODO: This can be a Boolean again once multiple backing types are allowed } enum Tier { @@ -2420,6 +2417,7 @@ enum Tier { scalar Timestamp scalar Point +scalar Banned `}, ) diff --git a/example/scalars/model/model.go b/example/scalars/model/model.go index a98134f1977..e779efaddbf 100644 --- a/example/scalars/model/model.go +++ b/example/scalars/model/model.go @@ -2,24 +2,44 @@ package model import ( "errors" + "external" "fmt" "io" "strconv" "strings" "time" - "external" - "github.com/99designs/gqlgen/graphql" ) type Banned bool +func (b Banned) MarshalGQL(w io.Writer) { + if b { + w.Write([]byte("true")) + } else { + w.Write([]byte("false")) + } +} + +func (b *Banned) UnmarshalGQL(v interface{}) error { + switch v := v.(type) { + case string: + *b = "true" == strings.ToLower(v) + return nil + case bool: + *b = Banned(v) + return nil + default: + return fmt.Errorf("%T is not a bool", v) + } +} + type User struct { ID external.ObjectID Name string Created time.Time // direct binding to builtin types with external Marshal/Unmarshal methods - IsBanned Banned // aliased primitive + IsBanned Banned Address Address Tier Tier } diff --git a/example/scalars/schema.graphql b/example/scalars/schema.graphql index 032e3f3a991..2bf00540ff5 100644 --- a/example/scalars/schema.graphql +++ b/example/scalars/schema.graphql @@ -7,7 +7,7 @@ type User { id: ID! name: String! created: Timestamp - isBanned: Boolean! + isBanned: Banned! primitiveResolver: String! customResolver: Point! address: Address @@ -22,7 +22,7 @@ type Address { input SearchArgs { location: Point createdAfter: Timestamp - isBanned: Boolean + isBanned: Banned # TODO: This can be a Boolean again once multiple backing types are allowed } enum Tier { @@ -33,3 +33,4 @@ enum Tier { scalar Timestamp scalar Point +scalar Banned From 70c852eb59e98136ae6595b0e756ae94000d5a85 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Mon, 7 Jan 2019 17:12:35 +1100 Subject: [PATCH 028/147] Add lookup by go type to import collection --- codegen/templates/import.go | 8 ++++++++ codegen/templates/import_test.go | 12 ++++++++++++ codegen/templates/templates.go | 1 - 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/codegen/templates/import.go b/codegen/templates/import.go index c9db2d96bba..138843b4432 100644 --- a/codegen/templates/import.go +++ b/codegen/templates/import.go @@ -5,6 +5,8 @@ import ( "go/build" "strconv" + "go/types" + "github.com/99designs/gqlgen/internal/gopath" ) @@ -116,6 +118,12 @@ func (s *Imports) Lookup(path string) string { return imp.Alias } +func (s *Imports) LookupType(t types.Type) string { + return types.TypeString(t, func(i *types.Package) string { + return s.Lookup(i.Path()) + }) +} + func (s Imports) findByPath(importPath string) *Import { for _, imp := range s.imports { if imp.Path == importPath { diff --git a/codegen/templates/import_test.go b/codegen/templates/import_test.go index fb7931f9867..a8dd39d4bfc 100644 --- a/codegen/templates/import_test.go +++ b/codegen/templates/import_test.go @@ -4,6 +4,8 @@ import ( "os" "testing" + "go/types" + "github.com/stretchr/testify/require" ) @@ -22,6 +24,15 @@ func TestImports(t *testing.T) { require.Equal(t, "bar", a.Lookup(aBar)) }) + t.Run("lookup by type", func(t *testing.T) { + a := Imports{destDir: wd} + + pkg := types.NewPackage("github.com/99designs/gqlgen/codegen/templates/testdata/b/bar", "bar") + typ := types.NewNamed(types.NewTypeName(0, pkg, "Boolean", types.Typ[types.Bool]), types.Typ[types.Bool], nil) + + require.Equal(t, "bar.Boolean", a.LookupType(typ)) + }) + t.Run("duplicates are decollisioned", func(t *testing.T) { a := Imports{destDir: wd} @@ -83,4 +94,5 @@ bar1 "github.com/99designs/gqlgen/codegen/templates/testdata/b/bar" require.Equal(t, `abar "github.com/99designs/gqlgen/codegen/templates/testdata/a/bar" bbar "github.com/99designs/gqlgen/codegen/templates/testdata/b/bar"`, a.String()) }) + } diff --git a/codegen/templates/templates.go b/codegen/templates/templates.go index a2684ebb4ee..a4ef2e4531d 100644 --- a/codegen/templates/templates.go +++ b/codegen/templates/templates.go @@ -16,7 +16,6 @@ import ( "unicode" "github.com/99designs/gqlgen/internal/imports" - "github.com/pkg/errors" ) From 950ff42c2668399e50d749b8d56e2208e9155142 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Mon, 7 Jan 2019 21:41:32 +1100 Subject: [PATCH 029/147] Bind to types.Type directly to remove TypeImplementation --- codegen/build.go | 41 ++++++++---- codegen/config/config.go | 11 +++ codegen/enum_build.go | 11 +-- codegen/generator.go | 13 +--- codegen/input_build.go | 29 ++------ codegen/interface_build.go | 4 +- codegen/models_build.go | 17 ++--- codegen/object.go | 11 +-- codegen/object_build.go | 36 +++++----- codegen/templates/args.gotpl | 52 ++++++--------- codegen/templates/data.go | 14 ++-- codegen/templates/field.gotpl | 2 +- codegen/templates/import.go | 2 + codegen/templates/input.gotpl | 12 ++-- codegen/templates/interface.gotpl | 6 +- codegen/templates/models.gotpl | 34 +++++----- codegen/templates/object.gotpl | 2 +- codegen/templates/resolver.gotpl | 2 +- codegen/templates/templates.go | 33 ++++++++- codegen/testserver/generated.go | 25 ++----- codegen/type_build.go | 78 ++++++++++++++++------ codegen/type_definition.go | 37 +++------- codegen/type_reference.go | 38 +++++------ codegen/util.go | 27 ++++---- example/config/generated.go | 2 - example/scalars/generated.go | 2 - example/starwars/generated.go | 2 - example/todo/generated.go | 2 - example/type-system-extension/generated.go | 2 - integration/generated.go | 2 - 30 files changed, 276 insertions(+), 273 deletions(-) diff --git a/codegen/build.go b/codegen/build.go index 252cad19147..3bfddba7005 100644 --- a/codegen/build.go +++ b/codegen/build.go @@ -45,8 +45,6 @@ type ServerBuild struct { // Create a list of models that need to be generated func (g *Generator) models() (*ModelBuild, error) { - namedTypes := g.buildNamedTypes() - progLoader := g.newLoaderWithoutErrors() prog, err := progLoader.Load() @@ -54,7 +52,16 @@ func (g *Generator) models() (*ModelBuild, error) { return nil, errors.Wrap(err, "loading failed") } - g.bindTypes(namedTypes, g.Model.Dir(), prog) + namedTypes, err := g.buildNamedTypes(prog) + if err != nil { + return nil, errors.Wrap(err, "binding types failed") + } + + directives, err := g.buildDirectives(namedTypes) + if err != nil { + return nil, err + } + g.Directives = directives models, err := g.buildModels(namedTypes, prog) if err != nil { @@ -77,11 +84,16 @@ func (g *Generator) resolver() (*ResolverBuild, error) { return nil, err } - destDir := g.Resolver.Dir() - - namedTypes := g.buildNamedTypes() + namedTypes, err := g.buildNamedTypes(prog) + if err != nil { + return nil, errors.Wrap(err, "binding types failed") + } - g.bindTypes(namedTypes, destDir, prog) + directives, err := g.buildDirectives(namedTypes) + if err != nil { + return nil, err + } + g.Directives = directives objects, err := g.buildObjects(namedTypes, prog) if err != nil { @@ -109,26 +121,29 @@ func (g *Generator) server(destDir string) *ServerBuild { // bind a schema together with some code to generate a Build func (g *Generator) bind() (*Build, error) { - namedTypes := g.buildNamedTypes() - progLoader := g.newLoaderWithoutErrors() prog, err := progLoader.Load() if err != nil { return nil, errors.Wrap(err, "loading failed") } - g.bindTypes(namedTypes, g.Exec.Dir(), prog) + namedTypes, err := g.buildNamedTypes(prog) + if err != nil { + return nil, errors.Wrap(err, "binding types failed") + } - objects, err := g.buildObjects(namedTypes, prog) + directives, err := g.buildDirectives(namedTypes) if err != nil { return nil, err } + g.Directives = directives - inputs, err := g.buildInputs(namedTypes, prog) + objects, err := g.buildObjects(namedTypes, prog) if err != nil { return nil, err } - directives, err := g.buildDirectives(namedTypes) + + inputs, err := g.buildInputs(namedTypes, prog) if err != nil { return nil, err } diff --git a/codegen/config/config.go b/codegen/config/config.go index ec19bdc6012..14e28c11e5d 100644 --- a/codegen/config/config.go +++ b/codegen/config/config.go @@ -10,6 +10,8 @@ import ( "sort" "strings" + "go/types" + "github.com/99designs/gqlgen/internal/gopath" "github.com/pkg/errors" "github.com/vektah/gqlparser" @@ -168,6 +170,10 @@ func (c *PackageConfig) Check() error { return c.normalize() } +func (c *PackageConfig) Pkg() *types.Package { + return types.NewPackage(c.ImportPath(), c.Dir()) +} + func (c *PackageConfig) IsDefined() bool { return c.Filename != "" } @@ -198,6 +204,11 @@ func (tm TypeMap) Exists(typeName string) bool { return ok } +func (tm TypeMap) UserDefined(typeName string) bool { + m, ok := tm[typeName] + return ok && m.Model != "" +} + func (tm TypeMap) Check() error { for typeName, entry := range tm { if strings.LastIndex(entry.Model, ".") < strings.LastIndex(entry.Model, "/") { diff --git a/codegen/enum_build.go b/codegen/enum_build.go index 052ddfd9696..9519e687def 100644 --- a/codegen/enum_build.go +++ b/codegen/enum_build.go @@ -1,6 +1,7 @@ package codegen import ( + "go/types" "sort" "strings" @@ -8,12 +9,12 @@ import ( "github.com/vektah/gqlparser/ast" ) -func (g *Generator) buildEnums(types NamedTypes) []Enum { +func (g *Generator) buildEnums(ts NamedTypes) []Enum { var enums []Enum for _, typ := range g.schema.Types { - namedType := types[typ.Name] - if typ.Kind != ast.Enum || strings.HasPrefix(typ.Name, "__") || namedType.IsUserDefined { + namedType := ts[typ.Name] + if typ.Kind != ast.Enum || strings.HasPrefix(typ.Name, "__") || g.Models.UserDefined(typ.Name) { continue } @@ -27,7 +28,9 @@ func (g *Generator) buildEnums(types NamedTypes) []Enum { Values: values, Description: typ.Description, } - enum.GoType = templates.ToCamel(enum.GQLType) + + enum.GoType = types.NewNamed(types.NewTypeName(0, g.Config.Model.Pkg(), templates.ToCamel(enum.GQLType), nil), nil, nil) + enums = append(enums, enum) } diff --git a/codegen/generator.go b/codegen/generator.go index 0741f928117..1edb0358f4e 100644 --- a/codegen/generator.go +++ b/codegen/generator.go @@ -1,6 +1,7 @@ package codegen import ( + "go/types" "log" "os" "path/filepath" @@ -40,14 +41,6 @@ func (g *Generator) Generate() error { _ = syscall.Unlink(g.Exec.Filename) _ = syscall.Unlink(g.Model.Filename) - namedTypes := g.buildNamedTypes() - - directives, err := g.buildDirectives(namedTypes) - if err != nil { - return err - } - g.Directives = directives - modelsBuild, err := g.models() if err != nil { return errors.Wrap(err, "model plan failed") @@ -59,13 +52,13 @@ func (g *Generator) Generate() error { for _, model := range modelsBuild.Models { modelCfg := g.Models[model.GQLType] - modelCfg.Model = g.Model.ImportPath() + "." + model.GoType + modelCfg.Model = types.TypeString(model.GoType, nil) g.Models[model.GQLType] = modelCfg } for _, enum := range modelsBuild.Enums { modelCfg := g.Models[enum.GQLType] - modelCfg.Model = g.Model.ImportPath() + "." + enum.GoType + modelCfg.Model = types.TypeString(enum.GoType, nil) g.Models[enum.GQLType] = modelCfg } } diff --git a/codegen/input_build.go b/codegen/input_build.go index 27f9b3fa825..1c572389ce3 100644 --- a/codegen/input_build.go +++ b/codegen/input_build.go @@ -1,9 +1,10 @@ package codegen import ( - "go/types" "sort" + "go/types" + "github.com/pkg/errors" "github.com/vektah/gqlparser/ast" "golang.org/x/tools/go/loader" @@ -20,13 +21,8 @@ func (g *Generator) buildInputs(namedTypes NamedTypes, prog *loader.Program) (Ob return nil, err } - def, err := findGoType(prog, input.Package, input.GoType) - if err != nil { - return nil, errors.Wrap(err, "cannot find type") - } - if def != nil { - input.Marshaler = buildInputMarshaler(typ, def) - bindErrs := bindObject(def.Type(), input, g.StructTag) + if _, isMap := input.GoType.(*types.Map); !isMap { + bindErrs := bindObject(input, g.StructTag) if len(bindErrs) > 0 { return nil, bindErrs } @@ -88,20 +84,3 @@ func (g *Generator) buildInput(types NamedTypes, typ *ast.Definition) (*Object, return obj, nil } - -// if user has implemented an UnmarshalGQL method on the input type manually, use it -// otherwise we will generate one. -func buildInputMarshaler(typ *ast.Definition, def types.Object) *TypeImplementation { - switch def := def.(type) { - case *types.TypeName: - namedType := def.Type().(*types.Named) - for i := 0; i < namedType.NumMethods(); i++ { - method := namedType.Method(i) - if method.Name() == "UnmarshalGQL" { - return nil - } - } - } - - return &TypeImplementation{GoType: typ.Name} -} diff --git a/codegen/interface_build.go b/codegen/interface_build.go index 0a9532d553d..6d085b185d2 100644 --- a/codegen/interface_build.go +++ b/codegen/interface_build.go @@ -39,12 +39,12 @@ func (g *Generator) buildInterface(types NamedTypes, typ *ast.Definition, prog * } func (g *Generator) isValueReceiver(intf *TypeDefinition, implementor *TypeDefinition, prog *loader.Program) bool { - interfaceType, err := findGoInterface(prog, intf.Package, intf.GoType) + interfaceType, err := findGoInterface(intf.GoType) if interfaceType == nil || err != nil { return true } - implementorType, err := findGoNamedType(prog, implementor.Package, implementor.GoType) + implementorType, err := findGoNamedType(implementor.GoType) if implementorType == nil || err != nil { return true } diff --git a/codegen/models_build.go b/codegen/models_build.go index e21e6aa1fe7..865b57cf14b 100644 --- a/codegen/models_build.go +++ b/codegen/models_build.go @@ -12,13 +12,16 @@ func (g *Generator) buildModels(types NamedTypes, prog *loader.Program) ([]Model for _, typ := range g.schema.Types { var model Model + if g.Models.UserDefined(typ.Name) { + continue + } switch typ.Kind { case ast.Object: obj, err := g.buildObject(types, typ) if err != nil { return nil, err } - if obj.Root || obj.IsUserDefined { + if obj.Root { continue } model = g.obj2Model(obj) @@ -27,15 +30,9 @@ func (g *Generator) buildModels(types NamedTypes, prog *loader.Program) ([]Model if err != nil { return nil, err } - if obj.IsUserDefined { - continue - } model = g.obj2Model(obj) case ast.Interface, ast.Union: intf := g.buildInterface(types, typ, prog) - if intf.IsUserDefined { - continue - } model = int2Model(intf) default: continue @@ -59,9 +56,6 @@ func (g *Generator) obj2Model(obj *Object) Model { Fields: []ModelField{}, } - model.GoType = ucFirst(obj.GQLType) - model.Marshaler = &TypeImplementation{GoType: obj.GoType} - for i := range obj.Fields { field := &obj.Fields[i] mf := ModelField{TypeReference: field.TypeReference, GQLName: field.GQLName} @@ -84,8 +78,5 @@ func int2Model(obj *Interface) Model { Fields: []ModelField{}, } - model.GoType = ucFirst(obj.GQLType) - model.Marshaler = &TypeImplementation{GoType: obj.GoType} - return model } diff --git a/codegen/object.go b/codegen/object.go index eb477680d57..4f4d2d5e179 100644 --- a/codegen/object.go +++ b/codegen/object.go @@ -8,6 +8,9 @@ import ( "text/template" "unicode" + "go/types" + + "github.com/99designs/gqlgen/codegen/templates" "github.com/vektah/gqlparser/ast" ) @@ -25,7 +28,7 @@ type Object struct { Fields []Field Satisfies []string Implements []*TypeDefinition - ResolverInterface *TypeImplementation + ResolverInterface types.Type Root bool DisableConcurrency bool Stream bool @@ -169,7 +172,7 @@ func (f *Field) ShortResolverDeclaration() string { res := fmt.Sprintf("%s(ctx context.Context", f.GoNameExported()) if !f.Object.Root { - res += fmt.Sprintf(", obj *%s", f.Object.FullName()) + res += fmt.Sprintf(", obj *%s", templates.CurrentImports.LookupType(f.Object.GoType)) } for _, arg := range f.Args { res += fmt.Sprintf(", %s %s", arg.GoVarName, arg.Signature()) @@ -191,7 +194,7 @@ func (f *Field) ResolverDeclaration() string { res := fmt.Sprintf("%s_%s(ctx context.Context", f.Object.GQLType, f.GoNameUnexported()) if !f.Object.Root { - res += fmt.Sprintf(", obj *%s", f.Object.FullName()) + res += fmt.Sprintf(", obj *%s", templates.CurrentImports.LookupType(f.Object.GoType)) } for _, arg := range f.Args { res += fmt.Sprintf(", %s %s", arg.GoVarName, arg.Signature()) @@ -361,7 +364,7 @@ func (os Objects) ByName(name string) *Object { func tpl(tpl string, vars map[string]interface{}) string { b := &bytes.Buffer{} - err := template.Must(template.New("inline").Parse(tpl)).Execute(b, vars) + err := template.Must(template.New("inline").Funcs(templates.Funcs()).Parse(tpl)).Execute(b, vars) if err != nil { panic(err) } diff --git a/codegen/object_build.go b/codegen/object_build.go index b4ca783c275..498deae39e5 100644 --- a/codegen/object_build.go +++ b/codegen/object_build.go @@ -1,15 +1,18 @@ package codegen import ( - "log" "sort" + "go/types" + + "log" + "github.com/pkg/errors" "github.com/vektah/gqlparser/ast" "golang.org/x/tools/go/loader" ) -func (g *Generator) buildObjects(types NamedTypes, prog *loader.Program) (Objects, error) { +func (g *Generator) buildObjects(ts NamedTypes, prog *loader.Program) (Objects, error) { var objects Objects for _, typ := range g.schema.Types { @@ -17,17 +20,13 @@ func (g *Generator) buildObjects(types NamedTypes, prog *loader.Program) (Object continue } - obj, err := g.buildObject(types, typ) + obj, err := g.buildObject(ts, typ) if err != nil { return nil, err } - def, err := findGoType(prog, obj.Package, obj.GoType) - if err != nil { - return nil, err - } - if def != nil { - for _, bindErr := range bindObject(def.Type(), obj, g.StructTag) { + if _, isMap := obj.GoType.(*types.Map); !isMap { + for _, bindErr := range bindObject(obj, g.StructTag) { log.Println(bindErr.Error()) log.Println(" Adding resolver method") } @@ -81,11 +80,12 @@ func sanitizeArgName(name string) string { return name } -func (g *Generator) buildObject(types NamedTypes, typ *ast.Definition) (*Object, error) { - obj := &Object{TypeDefinition: types[typ.Name]} +func (g *Generator) buildObject(ts NamedTypes, typ *ast.Definition) (*Object, error) { + obj := &Object{TypeDefinition: ts[typ.Name]} typeEntry, entryExists := g.Models[typ.Name] - obj.ResolverInterface = &TypeImplementation{GoType: obj.GQLType + "Resolver"} + tt := types.NewTypeName(0, g.Config.Exec.Pkg(), obj.GQLType+"Resolver", nil) + obj.ResolverInterface = types.NewNamed(tt, nil, nil) if typ == g.schema.Query { obj.Root = true @@ -104,13 +104,13 @@ func (g *Generator) buildObject(types NamedTypes, typ *ast.Definition) (*Object, obj.Satisfies = append(obj.Satisfies, typ.Interfaces...) for _, intf := range g.schema.GetImplements(typ) { - obj.Implements = append(obj.Implements, types[intf.Name]) + obj.Implements = append(obj.Implements, ts[intf.Name]) } for _, field := range typ.Fields { if typ == g.schema.Query && field.Name == "__type" { obj.Fields = append(obj.Fields, Field{ - TypeReference: &TypeReference{types["__Schema"], []string{modPtr}, ast.NamedType("__Schema", nil)}, + TypeReference: &TypeReference{ts["__Schema"], []string{modPtr}, ast.NamedType("__Schema", nil)}, GQLName: "__schema", GoFieldType: GoFieldMethod, GoReceiverName: "ec", @@ -122,13 +122,13 @@ func (g *Generator) buildObject(types NamedTypes, typ *ast.Definition) (*Object, } if typ == g.schema.Query && field.Name == "__schema" { obj.Fields = append(obj.Fields, Field{ - TypeReference: &TypeReference{types["__Type"], []string{modPtr}, ast.NamedType("__Schema", nil)}, + TypeReference: &TypeReference{ts["__Type"], []string{modPtr}, ast.NamedType("__Schema", nil)}, GQLName: "__type", GoFieldType: GoFieldMethod, GoReceiverName: "ec", GoFieldName: "introspectType", Args: []FieldArgument{ - {GQLName: "name", TypeReference: &TypeReference{types["String"], []string{}, ast.NamedType("String", nil)}, Object: &Object{}}, + {GQLName: "name", TypeReference: &TypeReference{ts["String"], []string{}, ast.NamedType("String", nil)}, Object: &Object{}}, }, Object: obj, }) @@ -152,7 +152,7 @@ func (g *Generator) buildObject(types NamedTypes, typ *ast.Definition) (*Object, } newArg := FieldArgument{ GQLName: arg.Name, - TypeReference: types.getType(arg.Type), + TypeReference: ts.getType(arg.Type), Object: obj, GoVarName: sanitizeArgName(arg.Name), Directives: dirs, @@ -174,7 +174,7 @@ func (g *Generator) buildObject(types NamedTypes, typ *ast.Definition) (*Object, obj.Fields = append(obj.Fields, Field{ GQLName: field.Name, - TypeReference: types.getType(field.Type), + TypeReference: ts.getType(field.Type), Args: args, Object: obj, GoFieldName: goName, diff --git a/codegen/templates/args.gotpl b/codegen/templates/args.gotpl index 7d75e1e838a..bb894839285 100644 --- a/codegen/templates/args.gotpl +++ b/codegen/templates/args.gotpl @@ -2,20 +2,19 @@ {{- range $i, $arg := . }} var arg{{$i}} {{$arg.Signature }} if tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok { - {{- if or $arg.Directives $arg.IsInput }} - {{ if $arg.Directives }} - argm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{ - {{- range $directive := $arg.Directives }} - func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { - {{- range $dArg := $directive.Args }} - {{- if and $dArg.IsPtr ( notNil "Value" $dArg ) }} - {{ $dArg.GoVarName }} := {{ $dArg.Value | dump }} - {{- end }} + {{- if $arg.Directives }} + argm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{ + {{- range $directive := $arg.Directives }} + func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { + {{- range $dArg := $directive.Args }} + {{- if and $dArg.IsPtr ( notNil "Value" $dArg ) }} + {{ $dArg.GoVarName }} := {{ $dArg.Value | dump }} {{- end }} - return e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs "tmp" "n" }}) - }, {{- end }} - }...)(ctx, func(ctx2 context.Context)(interface{}, error){ + return e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs "tmp" "n" }}) + }, + {{- end }} + }...)(ctx, func(ctx2 context.Context) (interface{}, error) { var err error {{$arg.Unmarshal (print "arg" $i) "tmp" }} if err != nil { @@ -26,29 +25,20 @@ if err != nil { return nil, err } - if data, ok := argm{{$i}}.({{$arg.Signature }}); ok{ + if data, ok := argm{{$i}}.({{$arg.Signature }}); ok { arg{{$i}} = data } else { return nil, errors.New("expect {{$arg.Signature }}") } - {{ else }} - var err error - {{$arg.Unmarshal (print "arg" $i) "tmp" }} - if err != nil { - return nil, err - } - {{ end }} - - {{- if $arg.IsInput }} - {{ $arg.Middleware (print "arg" $i) (print "arg" $i) }} - {{- end }} - - {{ else }} - var err error - {{$arg.Unmarshal (print "arg" $i) "tmp" }} - if err != nil { - return nil, err - } + {{- else }} + var err error + {{ $arg.Unmarshal (print "arg" $i) "tmp" }} + if err != nil { + return nil, err + } + {{- end }} + {{- if $arg.IsInput }} + {{ $arg.Middleware (print "arg" $i) (print "arg" $i) }} {{- end }} } args[{{$arg.GQLName|quote}}] = arg{{$i}} diff --git a/codegen/templates/data.go b/codegen/templates/data.go index 8813aa12fe0..2a54e75d592 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -1,13 +1,13 @@ package templates var data = map[string]string{ - "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if or $arg.Directives $arg.IsInput }}\n\t\t\t\t{{ if $arg.Directives }}\n \targm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $dArg.IsPtr ( notNil \"Value\" $dArg ) }}\n\t\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $dArg.Value | dump }}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t\t},\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t}...)(ctx, func(ctx2 context.Context)(interface{}, error){\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn arg{{ $i }}, nil\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok{\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t\t{{ else }}\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t{{ end }}\n\n\t\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t\t {{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t\t{{- end }}\n\n\t\t\t{{ else }}\n\t\t\tvar err error\n\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", - "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\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\treturn graphql.WriterFunc(func(w io.Writer) {\n\t\t\t\tw.Write([]byte{'{'})\n\t\t\t\tgraphql.MarshalString(field.Alias).MarshalGQL(w)\n\t\t\t\tw.Write([]byte{':'})\n\t\t\t\tfunc() graphql.Marshaler {\n\t\t\t\t\t{{ $field.WriteJson }}\n\t\t\t\t}().MarshalGQL(w)\n\t\t\t\tw.Write([]byte{'}'})\n\t\t\t})\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\n\t\t{{ $field.WriteJson }}\n\t}\n{{ end }}\n", + "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if $arg.Directives }}\n\t\t\t\targm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $dArg.IsPtr ( notNil \"Value\" $dArg ) }}\n\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $dArg.Value | dump }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t},\n\t\t\t\t{{- end }}\n\t\t\t\t}...)(ctx, func(ctx2 context.Context) (interface{}, error) {\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn arg{{ $i }}, nil\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok {\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t{{- else }}\n\t\t\t\tvar err error\n\t\t\t\t{{ $arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t{{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", + "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\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\treturn graphql.WriterFunc(func(w io.Writer) {\n\t\t\t\tw.Write([]byte{'{'})\n\t\t\t\tgraphql.MarshalString(field.Alias).MarshalGQL(w)\n\t\t\t\tw.Write([]byte{':'})\n\t\t\t\tfunc() graphql.Marshaler {\n\t\t\t\t\t{{ $field.WriteJson }}\n\t\t\t\t}().MarshalGQL(w)\n\t\t\t\tw.Write([]byte{'}'})\n\t\t\t})\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.GoType | ref}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\n)\n\n\n\n// ChainFieldMiddleware add chain by FieldMiddleware\n// nolint: deadcode\nfunc chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware {\n\tn := len(handleFunc)\n\n\tif n > 1 {\n\t\tlastI := n - 1\n\t\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\t\tvar (\n\t\t\t\tchainHandler graphql.Resolver\n\t\t\t\tcurI int\n\t\t\t)\n\t\t\tchainHandler = func(currentCtx context.Context) (interface{}, error) {\n\t\t\t\tif curI == lastI {\n\t\t\t\t\treturn next(currentCtx)\n\t\t\t\t}\n\t\t\t\tcurI++\n\t\t\t\tres, err := handleFunc[curI](currentCtx, chainHandler)\n\t\t\t\tcurI--\n\t\t\t\treturn res, err\n\n\t\t\t}\n\t\t\treturn handleFunc[0](ctx, chainHandler)\n\t\t}\n\t}\n\n\tif n == 1 {\n\t\treturn handleFunc[0]\n\t}\n\n\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\treturn next(ctx)\n\t}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := chainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.FullName}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.FullName}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t\tc{{$field.GoFieldName}}, err := chainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\t{{ if $field.IsPtr -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"*obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- else -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{ if $field.IsPtr }}*{{end}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{ range $model := .Models }}\n\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .IsInterface }}\n\t\ttype {{.GoType}} interface {\n\t\t\tIs{{.GoType}}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.GoType}} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\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\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.GoType}}) Is{{$iface.GoType}}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.GoType}} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- end}}\n\t\t{{$enum.GoType}}{{ .Name|toCamel }} {{$enum.GoType}} = {{.Name|quote}}\n\t{{- end }}\n\t)\n\n\tvar All{{.GoType}} = []{{.GoType}}{\n\t{{- range $value := .Values}}\n\t\t{{$enum.GoType}}{{ .Name|toCamel }},\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\n\tout := graphql.NewFieldSet(fields)\n\tinvalid := false\n\tfor i, field := range fields {\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\tfield := field\n\t\t\t\tout.Concurrently(i, func() (res graphql.Marshaler) {\n\t\t\t\t\tres = ec._{{$object.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\t\tif res == graphql.Null {\n\t\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t\t}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\treturn res\n\t\t\t\t})\n\t\t\t{{- else }}\n\t\t\t\tout.Values[i] = ec._{{$object.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\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\tout.Dispatch()\n\tif invalid { return graphql.Null }\n\treturn out\n}\n{{- end }}\n", - "resolver.gotpl": "package {{ .PackageName }}\n\nimport (\n\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/99designs/gqlgen/handler\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\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", + "input.gotpl": "\t{{- if .IsMarshaled }}\n\tfunc Unmarshal{{ .GQLType }}(v interface{}) ({{.GoType | ref}}, error) {\n\t\tvar it {{.GoType | ref}}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.GoType | ref}}) (*{{.GoType | ref}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := chainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.GoType | ref}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.GoType | ref}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t\tc{{$field.GoFieldName}}, err := chainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\t{{ if $field.IsPtr -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"*obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- else -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{ if $field.IsPtr }}*{{end}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.GoType | ref }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\n", + "interface.gotpl": "{{- $interface := . }}\n\nfunc (ec *executionContext) _{{$interface.GQLType}}(ctx context.Context, sel ast.SelectionSet, obj *{{$interface.GoType | ref}}) 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.GoType | ref}}:\n\t\t\t\treturn ec._{{$implementor.GQLType}}(ctx, sel, &obj)\n\t\t{{- end}}\n\t\tcase *{{$implementor.GoType | ref}}:\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{ range $model := .Models }}\n\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .IsInterface }}\n\t\ttype {{.GoType | ref }} interface {\n\t\t\tIs{{.GoType | ref }}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.GoType | ref }} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\n\t\t\t\t{{ $field.GoFieldName }} {{$field.Signature}} `json:\"{{$field.GQLName}}\"`\n\t\t\t{{- end }}\n\t\t}\n\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.GoType | ref }}) Is{{$iface.GoType | ref }}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.GoType | ref }} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- end}}\n\t\t{{$enum.GoType | ref }}{{ .Name|toCamel }} {{$enum.GoType | ref }} = {{.Name|quote}}\n\t{{- end }}\n\t)\n\n\tvar All{{.GoType | ref }} = []{{.GoType | ref }}{\n\t{{- range $value := .Values}}\n\t\t{{$enum.GoType | ref }}{{ .Name|toCamel }},\n\t{{- end }}\n\t}\n\n\tfunc (e {{.GoType | ref }}) IsValid() bool {\n\t\tswitch e {\n\t\tcase {{ range $index, $element := .Values}}{{if $index}},{{end}}{{ $enum.GoType | ref }}{{ $element.Name|toCamel }}{{end}}:\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tfunc (e {{.GoType | ref }}) String() string {\n\t\treturn string(e)\n\t}\n\n\tfunc (e *{{.GoType | ref }}) 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 | ref }}(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 | ref }}) 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.GoType | ref }} {{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\tout := graphql.NewFieldSet(fields)\n\tinvalid := false\n\tfor i, field := range fields {\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\tfield := field\n\t\t\t\tout.Concurrently(i, func() (res graphql.Marshaler) {\n\t\t\t\t\tres = ec._{{$object.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\t\tif res == graphql.Null {\n\t\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t\t}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\treturn res\n\t\t\t\t})\n\t\t\t{{- else }}\n\t\t\t\tout.Values[i] = ec._{{$object.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\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\tout.Dispatch()\n\tif invalid { return graphql.Null }\n\treturn out\n}\n{{- end }}\n", + "resolver.gotpl": "package {{ .PackageName }}\n\nimport (\n\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/99designs/gqlgen/handler\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\ntype {{.ResolverType}} struct {}\n\n{{ range $object := .Objects -}}\n\t{{- if $object.HasResolvers -}}\n\t\tfunc (r *{{$.ResolverType}}) {{$object.GQLType}}() {{ $object.ResolverInterface | ref }} {\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"log\" }}\n\t{{ reserveImport \"net/http\" }}\n\t{{ reserveImport \"os\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/handler\" }}\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({{ lookupImport .ExecPackageName }}.NewExecutableSchema({{ lookupImport .ExecPackageName}}.Config{Resolvers: &{{ lookupImport .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 649f822d60a..6b5d86f05af 100644 --- a/codegen/templates/field.gotpl +++ b/codegen/templates/field.gotpl @@ -41,7 +41,7 @@ } {{ else }} // nolint: vetshadow - func (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.FullName}}{{end}}) graphql.Marshaler { + func (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.GoType | ref}}{{end}}) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func () { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ diff --git a/codegen/templates/import.go b/codegen/templates/import.go index 138843b4432..c83f5672e52 100644 --- a/codegen/templates/import.go +++ b/codegen/templates/import.go @@ -84,6 +84,8 @@ func (s *Imports) Lookup(path string) string { return "" } + path = gopath.NormalizeVendor(path) + // if we are referencing our own package we dont need an import if gopath.MustDir2Import(s.destDir) == path { return "" diff --git a/codegen/templates/input.gotpl b/codegen/templates/input.gotpl index c6224d2af17..7f1fd6d74e5 100644 --- a/codegen/templates/input.gotpl +++ b/codegen/templates/input.gotpl @@ -1,6 +1,6 @@ {{- if .IsMarshaled }} - func Unmarshal{{ .GQLType }}(v interface{}) ({{.FullName}}, error) { - var it {{.FullName}} + func Unmarshal{{ .GQLType }}(v interface{}) ({{.GoType | ref}}, error) { + var it {{.GoType | ref}} var asMap = v.(map[string]interface{}) {{ range $field := .Fields}} {{- if $field.Default}} @@ -27,7 +27,7 @@ } {{- end }} - func (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.FullName}}) (*{{.FullName}}, error) { + func (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.GoType | ref}}) (*{{.GoType | ref}}, error) { {{ if .Directives }} cObj, err := chainFieldMiddleware( []graphql.FieldMiddleware{ @@ -50,9 +50,9 @@ if err != nil || cObj == nil { return nil ,err } - obj, ok := cObj.(*{{.FullName}}) + obj, ok := cObj.(*{{.GoType | ref}}) if !ok { - return nil, errors.New("expect {{.FullName}}") + return nil, errors.New("expect {{.GoType | ref}}") } {{ end }} @@ -85,7 +85,7 @@ } {{ if $field.IsPtr }} - if data, ok := c{{$field.GoFieldName}}.({{ $field.FullName }}); ok { + if data, ok := c{{$field.GoFieldName}}.({{ $field.GoType | ref }}); ok { obj.{{$field.GoFieldName}} = &data } else { return obj, errors.New("expect {{ $field.Signature }}") diff --git a/codegen/templates/interface.gotpl b/codegen/templates/interface.gotpl index 84cbe5002c5..9620f450e8d 100644 --- a/codegen/templates/interface.gotpl +++ b/codegen/templates/interface.gotpl @@ -1,15 +1,15 @@ {{- $interface := . }} -func (ec *executionContext) _{{$interface.GQLType}}(ctx context.Context, sel ast.SelectionSet, obj *{{$interface.FullName}}) graphql.Marshaler { +func (ec *executionContext) _{{$interface.GQLType}}(ctx context.Context, sel ast.SelectionSet, obj *{{$interface.GoType | ref}}) graphql.Marshaler { switch obj := (*obj).(type) { case nil: return graphql.Null {{- range $implementor := $interface.Implementors }} {{- if $implementor.ValueReceiver }} - case {{$implementor.FullName}}: + case {{$implementor.GoType | ref}}: return ec._{{$implementor.GQLType}}(ctx, sel, &obj) {{- end}} - case *{{$implementor.FullName}}: + case *{{$implementor.GoType | ref}}: return ec._{{$implementor.GQLType}}(ctx, sel, obj) {{- end }} default: diff --git a/codegen/templates/models.gotpl b/codegen/templates/models.gotpl index 651aa793e5a..53e48e4cf6b 100644 --- a/codegen/templates/models.gotpl +++ b/codegen/templates/models.gotpl @@ -23,25 +23,21 @@ import ( {{ range $model := .Models }} {{with .Description}} {{.|prefixLines "// "}} {{end}} {{- if .IsInterface }} - type {{.GoType}} interface { - Is{{.GoType}}() + type {{.GoType | ref }} interface { + Is{{.GoType | ref }}() } {{- else }} - type {{.GoType}} struct { + type {{.GoType | ref }} struct { {{- range $field := .Fields }} {{- with .Description}} {{.|prefixLines "// "}} {{- end}} - {{- if $field.GoFieldName }} - {{ $field.GoFieldName }} {{$field.Signature}} `json:"{{$field.GQLName}}"` - {{- else }} - {{ $field.GoFKName }} {{$field.GoFKType}} - {{- end }} + {{ $field.GoFieldName }} {{$field.Signature}} `json:"{{$field.GQLName}}"` {{- end }} } {{- range $iface := .Implements }} - func ({{$model.GoType}}) Is{{$iface.GoType}}() {} + func ({{$model.GoType | ref }}) Is{{$iface.GoType | ref }}() {} {{- end }} {{- end }} @@ -49,48 +45,48 @@ import ( {{ range $enum := .Enums }} {{with .Description}}{{.|prefixLines "// "}} {{end}} - type {{.GoType}} string + type {{.GoType | ref }} string const ( {{- range $value := .Values}} {{- with .Description}} {{.|prefixLines "// "}} {{- end}} - {{$enum.GoType}}{{ .Name|toCamel }} {{$enum.GoType}} = {{.Name|quote}} + {{$enum.GoType | ref }}{{ .Name|toCamel }} {{$enum.GoType | ref }} = {{.Name|quote}} {{- end }} ) - var All{{.GoType}} = []{{.GoType}}{ + var All{{.GoType | ref }} = []{{.GoType | ref }}{ {{- range $value := .Values}} - {{$enum.GoType}}{{ .Name|toCamel }}, + {{$enum.GoType | ref }}{{ .Name|toCamel }}, {{- end }} } - func (e {{.GoType}}) IsValid() bool { + func (e {{.GoType | ref }}) IsValid() bool { switch e { - case {{ range $index, $element := .Values}}{{if $index}},{{end}}{{ $enum.GoType }}{{ $element.Name|toCamel }}{{end}}: + case {{ range $index, $element := .Values}}{{if $index}},{{end}}{{ $enum.GoType | ref }}{{ $element.Name|toCamel }}{{end}}: return true } return false } - func (e {{.GoType}}) String() string { + func (e {{.GoType | ref }}) String() string { return string(e) } - func (e *{{.GoType}}) UnmarshalGQL(v interface{}) error { + func (e *{{.GoType | ref }}) UnmarshalGQL(v interface{}) error { str, ok := v.(string) if !ok { return fmt.Errorf("enums must be strings") } - *e = {{.GoType}}(str) + *e = {{.GoType | ref }}(str) if !e.IsValid() { return fmt.Errorf("%s is not a valid {{.GQLType}}", str) } return nil } - func (e {{.GoType}}) MarshalGQL(w io.Writer) { + func (e {{.GoType | ref }}) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } diff --git a/codegen/templates/object.gotpl b/codegen/templates/object.gotpl index 135f4f21f31..9f39b6b6739 100644 --- a/codegen/templates/object.gotpl +++ b/codegen/templates/object.gotpl @@ -24,7 +24,7 @@ func (ec *executionContext) _{{$object.GQLType}}(ctx context.Context, sel ast.Se } } {{- else }} -func (ec *executionContext) _{{$object.GQLType}}(ctx context.Context, sel ast.SelectionSet{{if not $object.Root}}, obj *{{$object.FullName}} {{end}}) graphql.Marshaler { +func (ec *executionContext) _{{$object.GQLType}}(ctx context.Context, sel ast.SelectionSet{{if not $object.Root}}, obj *{{$object.GoType | ref }} {{end}}) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, {{$object.GQLType|lcFirst}}Implementors) {{if $object.Root}} ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ diff --git a/codegen/templates/resolver.gotpl b/codegen/templates/resolver.gotpl index 53ba8c43380..8919e329bef 100644 --- a/codegen/templates/resolver.gotpl +++ b/codegen/templates/resolver.gotpl @@ -23,7 +23,7 @@ type {{.ResolverType}} struct {} {{ range $object := .Objects -}} {{- if $object.HasResolvers -}} - func (r *{{$.ResolverType}}) {{$object.GQLType}}() {{ $object.ResolverInterface.FullName }} { + func (r *{{$.ResolverType}}) {{$object.GQLType}}() {{ $object.ResolverInterface | ref }} { return &{{lcFirst $object.GQLType}}Resolver{r} } {{ end -}} diff --git a/codegen/templates/templates.go b/codegen/templates/templates.go index a4ef2e4531d..44a3cc09d21 100644 --- a/codegen/templates/templates.go +++ b/codegen/templates/templates.go @@ -15,6 +15,8 @@ import ( "text/template" "unicode" + "go/types" + "github.com/99designs/gqlgen/internal/imports" "github.com/pkg/errors" ) @@ -22,19 +24,25 @@ import ( // this is done with a global because subtemplates currently get called in functions. Lets aim to remove this eventually. var CurrentImports *Imports -func Run(name string, tpldata interface{}) (*bytes.Buffer, error) { - t := template.New("").Funcs(template.FuncMap{ +func Funcs() template.FuncMap { + return template.FuncMap{ "ucFirst": ucFirst, "lcFirst": lcFirst, "quote": strconv.Quote, "rawQuote": rawQuote, "toCamel": ToCamel, "dump": Dump, + "ref": ref, + "call": Call, "prefixLines": prefixLines, "notNil": notNil, "reserveImport": CurrentImports.Reserve, "lookupImport": CurrentImports.Lookup, - }) + } +} + +func Run(name string, tpldata interface{}) (*bytes.Buffer, error) { + t := template.New("").Funcs(Funcs()) for filename, data := range data { _, err := t.New(filename).Parse(data) @@ -75,6 +83,25 @@ func isDelimiter(c rune) bool { return c == '-' || c == '_' || unicode.IsSpace(c) } +func ref(p types.Type) string { + return CurrentImports.LookupType(p) +} + +func Call(p *types.Func) string { + pkg := CurrentImports.Lookup(p.Pkg().Path()) + + if pkg != "" { + pkg += "." + } + + if p.Type() != nil { + // make sure the returned type is listed in our imports. + ref(p.Type().(*types.Signature).Results().At(0).Type()) + } + + return pkg + p.Name() +} + func ToCamel(s string) string { buffer := make([]rune, 0, len(s)) upper := true diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 0baa8c70250..f74b8933837 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -168,7 +168,6 @@ func (e *executableSchema) field_Query_mapInput_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 *map[string]interface{} if tmp, ok := rawArgs["input"]; ok { - var err error var ptr1 map[string]interface{} if tmp != nil { @@ -180,6 +179,13 @@ func (e *executableSchema) field_Query_mapInput_args(ctx context.Context, rawArg return nil, err } + if arg0 != nil { + var err error + arg0, err = e.ChangesMiddleware(ctx, arg0) + if err != nil { + return nil, err + } + } } args["input"] = arg0 return args, nil @@ -190,7 +196,6 @@ func (e *executableSchema) field_Query_recursive_args(ctx context.Context, rawAr args := map[string]interface{}{} var arg0 *RecursiveInputSlice if tmp, ok := rawArgs["input"]; ok { - var err error var ptr1 RecursiveInputSlice if tmp != nil { @@ -209,7 +214,6 @@ func (e *executableSchema) field_Query_recursive_args(ctx context.Context, rawAr return nil, err } } - } args["input"] = arg0 return args, nil @@ -220,7 +224,6 @@ func (e *executableSchema) field_Query_nestedInputs_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 [][]*OuterInput if tmp, ok := rawArgs["input"]; ok { - var err error var rawIf1 []interface{} if tmp != nil { @@ -252,7 +255,6 @@ func (e *executableSchema) field_Query_nestedInputs_args(ctx context.Context, ra if err != nil { return nil, err } - for idx1 := range arg0 { for idx2 := range arg0[idx1] { @@ -265,7 +267,6 @@ func (e *executableSchema) field_Query_nestedInputs_args(ctx context.Context, ra } } } - } args["input"] = arg0 return args, nil @@ -276,7 +277,6 @@ func (e *executableSchema) field_Query_keywords_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 *Keywords if tmp, ok := rawArgs["input"]; ok { - var err error var ptr1 Keywords if tmp != nil { @@ -295,7 +295,6 @@ func (e *executableSchema) field_Query_keywords_args(ctx context.Context, rawArg return nil, err } } - } args["input"] = arg0 return args, nil @@ -341,7 +340,6 @@ func (e *executableSchema) field_Query_directiveArg_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["arg"]; ok { - argm0, err := chainFieldMiddleware([]graphql.FieldMiddleware{ func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { max := 255 @@ -363,7 +361,6 @@ func (e *executableSchema) field_Query_directiveArg_args(ctx context.Context, ra } else { return nil, errors.New("expect string") } - } args["arg"] = arg0 return args, nil @@ -374,7 +371,6 @@ func (e *executableSchema) field_Query_directiveNullableArg_args(ctx context.Con args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["arg"]; ok { - argm0, err := chainFieldMiddleware([]graphql.FieldMiddleware{ func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { min := 0 @@ -401,12 +397,10 @@ func (e *executableSchema) field_Query_directiveNullableArg_args(ctx context.Con } else { return nil, errors.New("expect *int") } - } args["arg"] = arg0 var arg1 *int if tmp, ok := rawArgs["arg2"]; ok { - argm1, err := chainFieldMiddleware([]graphql.FieldMiddleware{ func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { min := 0 @@ -433,7 +427,6 @@ func (e *executableSchema) field_Query_directiveNullableArg_args(ctx context.Con } else { return nil, errors.New("expect *int") } - } args["arg2"] = arg1 return args, nil @@ -444,7 +437,6 @@ func (e *executableSchema) field_Query_directiveInputNullable_args(ctx context.C args := map[string]interface{}{} var arg0 *InputDirectives if tmp, ok := rawArgs["arg"]; ok { - var err error var ptr1 InputDirectives if tmp != nil { @@ -463,7 +455,6 @@ func (e *executableSchema) field_Query_directiveInputNullable_args(ctx context.C return nil, err } } - } args["arg"] = arg0 return args, nil @@ -474,7 +465,6 @@ func (e *executableSchema) field_Query_directiveInput_args(ctx context.Context, args := map[string]interface{}{} var arg0 InputDirectives if tmp, ok := rawArgs["arg"]; ok { - var err error arg0, err = UnmarshalInputDirectives(tmp) if err != nil { @@ -486,7 +476,6 @@ func (e *executableSchema) field_Query_directiveInput_args(ctx context.Context, return nil, err } arg0 = *mInputDirectives1 - } args["arg"] = arg0 return args, nil diff --git a/codegen/type_build.go b/codegen/type_build.go index f69bd19aaaf..bb6f2aa8f71 100644 --- a/codegen/type_build.go +++ b/codegen/type_build.go @@ -1,48 +1,86 @@ package codegen import ( + "fmt" "go/types" "strings" + "github.com/99designs/gqlgen/codegen/templates" + "github.com/pkg/errors" "github.com/vektah/gqlparser/ast" "golang.org/x/tools/go/loader" ) // namedTypeFromSchema objects for every graphql type, including scalars. There should only be one instance of TypeReference for each thing -func (g *Generator) buildNamedTypes() NamedTypes { - types := map[string]*TypeDefinition{} +func (g *Generator) buildNamedTypes(prog *loader.Program) (NamedTypes, error) { + ts := map[string]*TypeDefinition{} for _, schemaType := range g.schema.Types { t := namedTypeFromSchema(schemaType) + ts[t.GQLType] = t + var pkgName, typeName string if userEntry, ok := g.Models[t.GQLType]; ok && userEntry.Model != "" { - t.IsUserDefined = true - t.Package, t.GoType = pkgAndType(userEntry.Model) + // special case for maps + if userEntry.Model == "map[string]interface{}" { + t.GoType = types.NewMap(types.Typ[types.String], types.NewInterface(nil, nil).Complete()) + + continue + } + + pkgName, typeName = pkgAndType(userEntry.Model) } else if t.IsScalar { - t.Package = "github.com/99designs/gqlgen/graphql" - t.GoType = "String" + pkgName = "github.com/99designs/gqlgen/graphql" + typeName = "String" + } else { + // Missing models, but we need to set up the types so any references will point to the code that will + // get generated + t.GoType = types.NewNamed(types.NewTypeName(0, g.Config.Model.Pkg(), templates.ToCamel(t.GQLType), nil), nil, nil) + + continue } - types[t.GQLType] = t - } - return types -} + if pkgName == "" { + return nil, fmt.Errorf("missing package name for %s", schemaType.Name) + } -func (g *Generator) bindTypes(namedTypes NamedTypes, destDir string, prog *loader.Program) { - for _, t := range namedTypes { - if t.Package == "" { + // External marshal functions + def, _ := findGoType(prog, pkgName, "Marshal"+typeName) + if f, isFunc := def.(*types.Func); isFunc { + sig := def.Type().(*types.Signature) + t.GoType = sig.Params().At(0).Type() + t.Marshaler = f + + unmarshal, err := findGoType(prog, pkgName, "Unmarshal"+typeName) + if err != nil { + return nil, errors.Wrapf(err, "unable to find unmarshal func for %s.%s", pkgName, typeName) + } + t.Unmarshaler = unmarshal.(*types.Func) continue } - def, _ := findGoType(prog, t.Package, "Marshal"+t.GoType) - switch def := def.(type) { - case *types.Func: - sig := def.Type().(*types.Signature) - cpy := t.TypeImplementation - t.Marshaler = &cpy + // Normal object binding + obj, err := findGoType(prog, pkgName, typeName) + if err != nil { + return nil, errors.Wrapf(err, "unable to find %s.%s", pkgName, typeName) + } + t.GoType = obj.Type() - t.Package, t.GoType = pkgAndType(sig.Params().At(0).Type().String()) + namedType := obj.Type().(*types.Named) + hasUnmarshal := false + for i := 0; i < namedType.NumMethods(); i++ { + switch namedType.Method(i).Name() { + case "UnmarshalGQL": + hasUnmarshal = true + } } + + // Special case to reference generated unmarshal functions + if !hasUnmarshal { + t.Unmarshaler = types.NewFunc(0, g.Config.Exec.Pkg(), "Unmarshal"+schemaType.Name, nil) + } + } + return ts, nil } // namedTypeFromSchema objects for every graphql type, including primitives. diff --git a/codegen/type_definition.go b/codegen/type_definition.go index f0ccafc4ddc..20ab950b828 100644 --- a/codegen/type_definition.go +++ b/codegen/type_definition.go @@ -1,7 +1,8 @@ package codegen import ( - "github.com/99designs/gqlgen/codegen/templates" + "go/types" + "github.com/vektah/gqlparser/ast" ) @@ -10,20 +11,13 @@ type NamedTypes map[string]*TypeDefinition // TypeDefinition is the static reference to a graphql type. It can be referenced by many TypeReferences, // and has one or more backing implementations in go. type TypeDefinition struct { - TypeImplementation IsScalar bool IsInterface bool IsInput bool - GQLType string // Name of the graphql type - Marshaler *TypeImplementation // If this type has an external marshaler this will be set -} - -// TypeImplementation is a reference to exisiting golang code that either meets the graphql.Marshaler interface -// or points to the root of a pair of external Marshal[TYPE] and Unmarshal[TYPE] functions. -type TypeImplementation struct { - GoType string // Name of the go type - Package string // the package the go type lives in - IsUserDefined bool // does the type exist in the typemap + GQLType string // Name of the graphql type + GoType types.Type // The backing go type, may be nil until after model generation + Marshaler *types.Func // When using external marshalling functions this will point to the Marshal function + Unmarshaler *types.Func // When using external marshalling functions this will point to the Unmarshal function } const ( @@ -31,22 +25,13 @@ const ( modPtr = "*" ) -func (t TypeImplementation) FullName() string { - return t.PkgDot() + t.GoType -} - -func (t TypeImplementation) PkgDot() string { - name := templates.CurrentImports.Lookup(t.Package) - if name == "" { - return "" - - } - - return name + "." +func (t TypeDefinition) IsMarshaled() bool { + return t.Marshaler != nil || t.Unmarshaler != nil } -func (t TypeDefinition) IsMarshaled() bool { - return t.Marshaler != nil +func (t TypeDefinition) IsEmptyInterface() bool { + i, isInterface := t.GoType.(*types.Interface) + return isInterface && i.NumMethods() == 0 } func (n NamedTypes) getType(t *ast.Type) *TypeReference { diff --git a/codegen/type_reference.go b/codegen/type_reference.go index a50f5437651..3ba49ab02cc 100644 --- a/codegen/type_reference.go +++ b/codegen/type_reference.go @@ -1,9 +1,11 @@ package codegen import ( + "go/types" "strconv" "strings" + "github.com/99designs/gqlgen/codegen/templates" "github.com/vektah/gqlparser/ast" ) @@ -16,16 +18,11 @@ type TypeReference struct { } func (t TypeReference) Signature() string { - return strings.Join(t.Modifiers, "") + t.FullName() + return strings.Join(t.Modifiers, "") + templates.CurrentImports.LookupType(t.TypeDefinition.GoType) } func (t TypeReference) FullSignature() string { - pkg := "" - if t.Package != "" { - pkg = t.Package + "." - } - - return strings.Join(t.Modifiers, "") + pkg + t.GoType + return strings.Join(t.Modifiers, "") + types.TypeString(t.TypeDefinition.GoType, nil) } func (t TypeReference) IsPtr() bool { @@ -52,7 +49,7 @@ func (t TypeReference) unmarshal(result, raw string, remainingMods []string, dep switch { case len(remainingMods) > 0 && remainingMods[0] == modPtr: ptr := "ptr" + strconv.Itoa(depth) - return tpl(`var {{.ptr}} {{.mods}}{{.t.FullName}} + return tpl(`var {{.ptr}} {{.mods}}{{.t.GoType | ref }} if {{.raw}} != nil { {{.next}} {{.result}} = &{{.ptr -}} @@ -86,7 +83,7 @@ func (t TypeReference) unmarshal(result, raw string, remainingMods []string, dep "rawSlice": rawIf, "index": index, "result": result, - "type": strings.Join(remainingMods, "") + t.TypeDefinition.FullName(), + "type": strings.Join(remainingMods, "") + templates.CurrentImports.LookupType(t.GoType), "next": t.unmarshal(result+"["+index+"]", rawIf+"["+index+"]", remainingMods[1:], depth+1), }) } @@ -94,10 +91,10 @@ func (t TypeReference) unmarshal(result, raw string, remainingMods []string, dep realResult := result return tpl(` - {{- if eq .t.GoType "map[string]interface{}" }} + {{- if eq (.t.GoType | ref) "map[string]interface{}" }} {{- .result }} = {{.raw}}.(map[string]interface{}) - {{- else if .t.Marshaler }} - {{- .result }}, err = {{ .t.Marshaler.PkgDot }}Unmarshal{{.t.Marshaler.GoType}}({{.raw}}) + {{- else if .t.Unmarshaler }} + {{- .result }}, err = {{ .t.Unmarshaler | call }}({{.raw}}) {{- else -}} err = (&{{.result}}).UnmarshalGQL({{.raw}}) {{- end }}`, map[string]interface{}{ @@ -114,15 +111,14 @@ func (t TypeReference) Middleware(result, raw string) string { func (t TypeReference) middleware(result, raw string, remainingMods []string, depth int) string { if len(remainingMods) == 1 && remainingMods[0] == modPtr { - return tpl(`{{- if .t.Marshaler }} + return tpl(` if {{.raw}} != nil { var err error {{.result}}, err = e.{{ .t.GQLType }}Middleware(ctx, {{.raw}}) - if err != nil { + if err != nil { return nil, err } - } - {{- end }}`, map[string]interface{}{ + }`, map[string]interface{}{ "result": result, "raw": raw, "t": t, @@ -149,19 +145,18 @@ func (t TypeReference) middleware(result, raw string, remainingMods []string, de "raw": raw, "index": index, "result": result, - "type": strings.Join(remainingMods, "") + t.TypeDefinition.FullName(), + "type": strings.Join(remainingMods, "") + templates.CurrentImports.LookupType(t.TypeDefinition.GoType), "next": t.middleware(result+"["+index+"]", raw+"["+index+"]", remainingMods[1:], depth+1), }) } ptr := "m" + t.GQLType + strconv.Itoa(depth) - return tpl(`{{- if .t.Marshaler }} + return tpl(` {{.ptr}}, err := e.{{ .t.GQLType }}Middleware(ctx, &{{.raw}}) if err != nil { return nil, err } - {{ .result }} = *{{.ptr}} - {{- end }}`, map[string]interface{}{ + {{ .result }} = *{{.ptr}}`, map[string]interface{}{ "result": result, "raw": raw, "ptr": ptr, @@ -170,9 +165,8 @@ func (t TypeReference) middleware(result, raw string, remainingMods []string, de } func (t TypeReference) Marshal(val string) string { - if t.Marshaler != nil { - return "return " + t.Marshaler.PkgDot() + "Marshal" + t.Marshaler.GoType + "(" + val + ")" + return "return " + templates.Call(t.TypeDefinition.Marshaler) + "(" + val + ")" } return "return " + val diff --git a/codegen/util.go b/codegen/util.go index 076f2ab111c..e734e77c58d 100644 --- a/codegen/util.go +++ b/codegen/util.go @@ -41,25 +41,24 @@ func findGoType(prog *loader.Program, pkgName string, typeName string) (types.Ob return nil, errors.Errorf("unable to find type %s\n", fullName) } -func findGoNamedType(prog *loader.Program, pkgName string, typeName string) (*types.Named, error) { - def, err := findGoType(prog, pkgName, typeName) - if err != nil { - return nil, err - } +func findGoNamedType(def types.Type) (*types.Named, error) { if def == nil { return nil, nil } - namedType, ok := def.Type().(*types.Named) + namedType, ok := def.(*types.Named) if !ok { - return nil, errors.Errorf("expected %s to be a named type, instead found %T\n", typeName, def.Type()) + return nil, errors.Errorf("expected %s to be a named type, instead found %T\n", def.String(), def) } return namedType, nil } -func findGoInterface(prog *loader.Program, pkgName string, typeName string) (*types.Interface, error) { - namedType, err := findGoNamedType(prog, pkgName, typeName) +func findGoInterface(def types.Type) (*types.Interface, error) { + if def == nil { + return nil, nil + } + namedType, err := findGoNamedType(def) if err != nil { return nil, err } @@ -69,7 +68,7 @@ func findGoInterface(prog *loader.Program, pkgName string, typeName string) (*ty underlying, ok := namedType.Underlying().(*types.Interface) if !ok { - return nil, errors.Errorf("expected %s to be a named interface, instead found %s", typeName, namedType.String()) + return nil, errors.Errorf("expected %s to be a named interface, instead found %s", def.String(), namedType.String()) } return underlying, nil @@ -203,7 +202,7 @@ func (b BindErrors) Error() string { return strings.Join(errs, "\n\n") } -func bindObject(t types.Type, object *Object, structTag string) BindErrors { +func bindObject(object *Object, structTag string) BindErrors { var errs BindErrors for i := range object.Fields { field := &object.Fields[i] @@ -213,18 +212,18 @@ func bindObject(t types.Type, object *Object, structTag string) BindErrors { } // first try binding to a method - methodErr := bindMethod(t, field) + methodErr := bindMethod(object.GoType, field) if methodErr == nil { continue } // otherwise try binding to a var - varErr := bindVar(t, field, structTag) + varErr := bindVar(object.GoType, field, structTag) if varErr != nil { errs = append(errs, BindError{ object: object, - typ: t, + typ: object.GoType, field: field, varErr: varErr, methodErr: methodErr, diff --git a/example/config/generated.go b/example/config/generated.go index f84e1d10ce6..8c5d2bedc37 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -76,7 +76,6 @@ func (e *executableSchema) field_Mutation_createTodo_args(ctx context.Context, r args := map[string]interface{}{} var arg0 NewTodo if tmp, ok := rawArgs["input"]; ok { - var err error arg0, err = UnmarshalNewTodo(tmp) if err != nil { @@ -88,7 +87,6 @@ func (e *executableSchema) field_Mutation_createTodo_args(ctx context.Context, r return nil, err } arg0 = *mNewTodo1 - } args["input"] = arg0 return args, nil diff --git a/example/scalars/generated.go b/example/scalars/generated.go index 1bff78859aa..f6c8a2efc16 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -92,7 +92,6 @@ func (e *executableSchema) field_Query_search_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 *model.SearchArgs if tmp, ok := rawArgs["input"]; ok { - var err error var ptr1 model.SearchArgs if tmp != nil { @@ -111,7 +110,6 @@ func (e *executableSchema) field_Query_search_args(ctx context.Context, rawArgs return nil, err } } - } args["input"] = arg0 return args, nil diff --git a/example/starwars/generated.go b/example/starwars/generated.go index 6dde788e0d1..de4f736ea44 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -237,7 +237,6 @@ func (e *executableSchema) field_Mutation_createReview_args(ctx context.Context, args["episode"] = arg0 var arg1 Review if tmp, ok := rawArgs["review"]; ok { - var err error arg1, err = UnmarshalReviewInput(tmp) if err != nil { @@ -249,7 +248,6 @@ func (e *executableSchema) field_Mutation_createReview_args(ctx context.Context, return nil, err } arg1 = *mReviewInput1 - } args["review"] = arg1 return args, nil diff --git a/example/todo/generated.go b/example/todo/generated.go index cfc2816071c..e27a9494c54 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -72,7 +72,6 @@ func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, args := map[string]interface{}{} var arg0 TodoInput if tmp, ok := rawArgs["todo"]; ok { - var err error arg0, err = UnmarshalTodoInput(tmp) if err != nil { @@ -84,7 +83,6 @@ func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, return nil, err } arg0 = *mTodoInput1 - } args["todo"] = arg0 return args, nil diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index 92ac0bf9ddd..92b40875151 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -82,7 +82,6 @@ func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, args := map[string]interface{}{} var arg0 TodoInput if tmp, ok := rawArgs["todo"]; ok { - var err error arg0, err = UnmarshalTodoInput(tmp) if err != nil { @@ -94,7 +93,6 @@ func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, return nil, err } arg0 = *mTodoInput1 - } args["todo"] = arg0 return args, nil diff --git a/integration/generated.go b/integration/generated.go index 54f4535e8fc..6eca435adb2 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -87,7 +87,6 @@ func (e *executableSchema) field_Query_date_args(ctx context.Context, rawArgs ma args := map[string]interface{}{} var arg0 models.DateFilter if tmp, ok := rawArgs["filter"]; ok { - var err error arg0, err = UnmarshalDateFilter(tmp) if err != nil { @@ -99,7 +98,6 @@ func (e *executableSchema) field_Query_date_args(ctx context.Context, rawArgs ma return nil, err } arg0 = *mDateFilter1 - } args["filter"] = arg0 return args, nil From 38add2c22a6bc13fecc9bc9180b5c48b208b4cc0 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Tue, 8 Jan 2019 12:31:08 +1100 Subject: [PATCH 030/147] Remove definition embedding, use normal field instead --- codegen/directive_build.go | 2 +- codegen/enum.go | 2 +- codegen/enum_build.go | 10 +++++----- codegen/generator.go | 12 ++++++------ codegen/input_build.go | 10 +++++----- codegen/input_test.go | 6 ++---- codegen/interface.go | 6 ++---- codegen/interface_build.go | 8 ++++---- codegen/model.go | 2 +- codegen/models_build.go | 12 ++++++------ codegen/object.go | 27 +++++++++++++------------- codegen/object_build.go | 12 ++++++------ codegen/templates/args.gotpl | 2 +- codegen/templates/data.go | 16 ++++++++-------- codegen/templates/field.gotpl | 6 +++--- codegen/templates/generated.gotpl | 18 ++++++++--------- codegen/templates/input.gotpl | 16 ++++++++-------- codegen/templates/interface.gotpl | 10 +++++----- codegen/templates/models.gotpl | 32 +++++++++++++++---------------- codegen/templates/object.gotpl | 22 ++++++++++----------- codegen/templates/resolver.gotpl | 8 ++++---- codegen/type_definition.go | 8 ++++---- codegen/type_reference.go | 28 +++++++++++++-------------- codegen/util.go | 8 ++++---- 24 files changed, 139 insertions(+), 144 deletions(-) diff --git a/codegen/directive_build.go b/codegen/directive_build.go index f123b307abb..31a9d7f912f 100644 --- a/codegen/directive_build.go +++ b/codegen/directive_build.go @@ -25,7 +25,7 @@ func (g *Generator) buildDirectives(types NamedTypes) (map[string]*Directive, er GoVarName: sanitizeArgName(arg.Name), } - if !newArg.TypeReference.IsInput && !newArg.TypeReference.IsScalar { + if !newArg.TypeReference.Definition.IsInput && !newArg.TypeReference.Definition.IsScalar { return nil, errors.Errorf("%s cannot be used as argument of directive %s(%s) only input and scalar types are allowed", arg.Type, dir.Name, arg.Name) } diff --git a/codegen/enum.go b/codegen/enum.go index 0fc497eea1f..f062abbdb10 100644 --- a/codegen/enum.go +++ b/codegen/enum.go @@ -1,7 +1,7 @@ package codegen type Enum struct { - *TypeDefinition + Definition *TypeDefinition Description string Values []EnumValue } diff --git a/codegen/enum_build.go b/codegen/enum_build.go index 9519e687def..7fe2ae58687 100644 --- a/codegen/enum_build.go +++ b/codegen/enum_build.go @@ -24,18 +24,18 @@ func (g *Generator) buildEnums(ts NamedTypes) []Enum { } enum := Enum{ - TypeDefinition: namedType, - Values: values, - Description: typ.Description, + Definition: namedType, + Values: values, + Description: typ.Description, } - enum.GoType = types.NewNamed(types.NewTypeName(0, g.Config.Model.Pkg(), templates.ToCamel(enum.GQLType), nil), nil, nil) + enum.Definition.GoType = types.NewNamed(types.NewTypeName(0, g.Config.Model.Pkg(), templates.ToCamel(enum.Definition.GQLType), nil), nil, nil) enums = append(enums, enum) } sort.Slice(enums, func(i, j int) bool { - return enums[i].GQLType < enums[j].GQLType + return enums[i].Definition.GQLType < enums[j].Definition.GQLType }) return enums diff --git a/codegen/generator.go b/codegen/generator.go index 1edb0358f4e..f8caaf64b9a 100644 --- a/codegen/generator.go +++ b/codegen/generator.go @@ -51,15 +51,15 @@ func (g *Generator) Generate() error { } for _, model := range modelsBuild.Models { - modelCfg := g.Models[model.GQLType] - modelCfg.Model = types.TypeString(model.GoType, nil) - g.Models[model.GQLType] = modelCfg + modelCfg := g.Models[model.Definition.GQLType] + modelCfg.Model = types.TypeString(model.Definition.GoType, nil) + g.Models[model.Definition.GQLType] = modelCfg } for _, enum := range modelsBuild.Enums { - modelCfg := g.Models[enum.GQLType] - modelCfg.Model = types.TypeString(enum.GoType, nil) - g.Models[enum.GQLType] = modelCfg + modelCfg := g.Models[enum.Definition.GQLType] + modelCfg.Model = types.TypeString(enum.Definition.GoType, nil) + g.Models[enum.Definition.GQLType] = modelCfg } } diff --git a/codegen/input_build.go b/codegen/input_build.go index 1c572389ce3..88625759862 100644 --- a/codegen/input_build.go +++ b/codegen/input_build.go @@ -21,7 +21,7 @@ func (g *Generator) buildInputs(namedTypes NamedTypes, prog *loader.Program) (Ob return nil, err } - if _, isMap := input.GoType.(*types.Map); !isMap { + if _, isMap := input.Definition.GoType.(*types.Map); !isMap { bindErrs := bindObject(input, g.StructTag) if len(bindErrs) > 0 { return nil, bindErrs @@ -33,14 +33,14 @@ func (g *Generator) buildInputs(namedTypes NamedTypes, prog *loader.Program) (Ob } sort.Slice(inputs, func(i, j int) bool { - return inputs[i].GQLType < inputs[j].GQLType + return inputs[i].Definition.GQLType < inputs[j].Definition.GQLType }) return inputs, nil } func (g *Generator) buildInput(types NamedTypes, typ *ast.Definition) (*Object, error) { - obj := &Object{TypeDefinition: types[typ.Name]} + obj := &Object{Definition: types[typ.Name]} typeEntry, entryExists := g.Models[typ.Name] for _, field := range typ.Fields { @@ -69,8 +69,8 @@ func (g *Generator) buildInput(types NamedTypes, typ *ast.Definition) (*Object, } } - if !newField.TypeReference.IsInput && !newField.TypeReference.IsScalar { - return nil, errors.Errorf("%s cannot be used as a field of %s. only input and scalar types are allowed", newField.GQLType, obj.GQLType) + if !newField.TypeReference.Definition.IsInput && !newField.TypeReference.Definition.IsScalar { + return nil, errors.Errorf("%s cannot be used as a field of %s. only input and scalar types are allowed", newField.Definition.GQLType, obj.Definition.GQLType) } obj.Fields = append(obj.Fields, newField) diff --git a/codegen/input_test.go b/codegen/input_test.go index d13847658cf..744cf9c8ad1 100644 --- a/codegen/input_test.go +++ b/codegen/input_test.go @@ -3,13 +3,11 @@ package codegen import ( "testing" - "github.com/vektah/gqlparser/gqlerror" - - "github.com/vektah/gqlparser/ast" - "github.com/99designs/gqlgen/codegen/config" "github.com/stretchr/testify/require" "github.com/vektah/gqlparser" + "github.com/vektah/gqlparser/ast" + "github.com/vektah/gqlparser/gqlerror" "golang.org/x/tools/go/loader" ) diff --git a/codegen/interface.go b/codegen/interface.go index e18e849d20a..045bdba88e6 100644 --- a/codegen/interface.go +++ b/codegen/interface.go @@ -1,13 +1,11 @@ package codegen type Interface struct { - *TypeDefinition - + Definition *TypeDefinition Implementors []InterfaceImplementor } type InterfaceImplementor struct { ValueReceiver bool - - *TypeDefinition + Definition *TypeDefinition } diff --git a/codegen/interface_build.go b/codegen/interface_build.go index 6d085b185d2..a38d22af1fa 100644 --- a/codegen/interface_build.go +++ b/codegen/interface_build.go @@ -17,21 +17,21 @@ func (g *Generator) buildInterfaces(types NamedTypes, prog *loader.Program) []*I } sort.Slice(interfaces, func(i, j int) bool { - return interfaces[i].GQLType < interfaces[j].GQLType + return interfaces[i].Definition.GQLType < interfaces[j].Definition.GQLType }) return interfaces } func (g *Generator) buildInterface(types NamedTypes, typ *ast.Definition, prog *loader.Program) *Interface { - i := &Interface{TypeDefinition: types[typ.Name]} + i := &Interface{Definition: types[typ.Name]} for _, implementor := range g.schema.GetPossibleTypes(typ) { t := types[implementor.Name] i.Implementors = append(i.Implementors, InterfaceImplementor{ - TypeDefinition: t, - ValueReceiver: g.isValueReceiver(types[typ.Name], t, prog), + Definition: t, + ValueReceiver: g.isValueReceiver(types[typ.Name], t, prog), }) } diff --git a/codegen/model.go b/codegen/model.go index 8c3acba1986..09b2b4c8cf2 100644 --- a/codegen/model.go +++ b/codegen/model.go @@ -1,7 +1,7 @@ package codegen type Model struct { - *TypeDefinition + Definition *TypeDefinition Description string Fields []ModelField Implements []*TypeDefinition diff --git a/codegen/models_build.go b/codegen/models_build.go index 865b57cf14b..43775376570 100644 --- a/codegen/models_build.go +++ b/codegen/models_build.go @@ -43,7 +43,7 @@ func (g *Generator) buildModels(types NamedTypes, prog *loader.Program) ([]Model } sort.Slice(models, func(i, j int) bool { - return models[i].GQLType < models[j].GQLType + return models[i].Definition.GQLType < models[j].Definition.GQLType }) return models, nil @@ -51,9 +51,9 @@ func (g *Generator) buildModels(types NamedTypes, prog *loader.Program) ([]Model func (g *Generator) obj2Model(obj *Object) Model { model := Model{ - TypeDefinition: obj.TypeDefinition, - Implements: obj.Implements, - Fields: []ModelField{}, + Definition: obj.Definition, + Implements: obj.Implements, + Fields: []ModelField{}, } for i := range obj.Fields { @@ -74,8 +74,8 @@ func (g *Generator) obj2Model(obj *Object) Model { func int2Model(obj *Interface) Model { model := Model{ - TypeDefinition: obj.TypeDefinition, - Fields: []ModelField{}, + Definition: obj.Definition, + Fields: []ModelField{}, } return model diff --git a/codegen/object.go b/codegen/object.go index 4f4d2d5e179..fbcb6dabbb7 100644 --- a/codegen/object.go +++ b/codegen/object.go @@ -23,8 +23,7 @@ const ( ) type Object struct { - *TypeDefinition - + Definition *TypeDefinition Fields []Field Satisfies []string Implements []*TypeDefinition @@ -65,7 +64,7 @@ type FieldArgument struct { type Objects []*Object func (o *Object) Implementors() string { - satisfiedBy := strconv.Quote(o.GQLType) + satisfiedBy := strconv.Quote(o.Definition.GQLType) for _, s := range o.Satisfies { satisfiedBy += ", " + strconv.Quote(s) } @@ -103,7 +102,7 @@ func (o *Object) IsConcurrent() bool { } func (o *Object) IsReserved() bool { - return strings.HasPrefix(o.GQLType, "__") + return strings.HasPrefix(o.Definition.GQLType, "__") } func (f *Field) HasDirectives() bool { @@ -146,7 +145,7 @@ func (f *Field) ShortInvocation() string { return "" } - return fmt.Sprintf("%s().%s(%s)", f.Object.GQLType, f.GoNameExported(), f.CallArgs()) + return fmt.Sprintf("%s().%s(%s)", f.Object.Definition.GQLType, f.GoNameExported(), f.CallArgs()) } func (f *Field) ArgsFunc() string { @@ -154,7 +153,7 @@ func (f *Field) ArgsFunc() string { return "" } - return "field_" + f.Object.GQLType + "_" + f.GQLName + "_args" + return "field_" + f.Object.Definition.GQLType + "_" + f.GQLName + "_args" } func (f *Field) ResolverType() string { @@ -162,7 +161,7 @@ func (f *Field) ResolverType() string { return "" } - return fmt.Sprintf("%s().%s(%s)", f.Object.GQLType, f.GoNameExported(), f.CallArgs()) + return fmt.Sprintf("%s().%s(%s)", f.Object.Definition.GQLType, f.GoNameExported(), f.CallArgs()) } func (f *Field) ShortResolverDeclaration() string { @@ -172,7 +171,7 @@ func (f *Field) ShortResolverDeclaration() string { res := fmt.Sprintf("%s(ctx context.Context", f.GoNameExported()) if !f.Object.Root { - res += fmt.Sprintf(", obj *%s", templates.CurrentImports.LookupType(f.Object.GoType)) + res += fmt.Sprintf(", obj *%s", templates.CurrentImports.LookupType(f.Object.Definition.GoType)) } for _, arg := range f.Args { res += fmt.Sprintf(", %s %s", arg.GoVarName, arg.Signature()) @@ -191,10 +190,10 @@ func (f *Field) ResolverDeclaration() string { if !f.IsResolver() { return "" } - res := fmt.Sprintf("%s_%s(ctx context.Context", f.Object.GQLType, f.GoNameUnexported()) + res := fmt.Sprintf("%s_%s(ctx context.Context", f.Object.Definition.GQLType, f.GoNameUnexported()) if !f.Object.Root { - res += fmt.Sprintf(", obj *%s", templates.CurrentImports.LookupType(f.Object.GoType)) + res += fmt.Sprintf(", obj *%s", templates.CurrentImports.LookupType(f.Object.Definition.GoType)) } for _, arg := range f.Args { res += fmt.Sprintf(", %s %s", arg.GoVarName, arg.Signature()) @@ -326,12 +325,12 @@ func (f *Field) doWriteJson(val string, remainingMods []string, astType *ast.Typ "index": index, "top": depth == 1, "arrayLen": len(val), - "isScalar": f.IsScalar, + "isScalar": f.Definition.IsScalar, "usePtr": usePtr, "next": f.doWriteJson(val+"["+index+"]", remainingMods[1:], astType.Elem, false, depth+1), }) - case f.IsScalar: + case f.Definition.IsScalar: if isPtr { val = "*" + val } @@ -343,7 +342,7 @@ func (f *Field) doWriteJson(val string, remainingMods []string, astType *ast.Typ } return tpl(` return ec._{{.type}}(ctx, field.Selections, {{.val}})`, map[string]interface{}{ - "type": f.GQLType, + "type": f.Definition.GQLType, "val": val, }) } @@ -355,7 +354,7 @@ func (f *FieldArgument) Stream() bool { func (os Objects) ByName(name string) *Object { for i, o := range os { - if strings.EqualFold(o.GQLType, name) { + if strings.EqualFold(o.Definition.GQLType, name) { return os[i] } } diff --git a/codegen/object_build.go b/codegen/object_build.go index 498deae39e5..8d4e6a0e2e6 100644 --- a/codegen/object_build.go +++ b/codegen/object_build.go @@ -25,7 +25,7 @@ func (g *Generator) buildObjects(ts NamedTypes, prog *loader.Program) (Objects, return nil, err } - if _, isMap := obj.GoType.(*types.Map); !isMap { + if _, isMap := obj.Definition.GoType.(*types.Map); !isMap { for _, bindErr := range bindObject(obj, g.StructTag) { log.Println(bindErr.Error()) log.Println(" Adding resolver method") @@ -36,7 +36,7 @@ func (g *Generator) buildObjects(ts NamedTypes, prog *loader.Program) (Objects, } sort.Slice(objects, func(i, j int) bool { - return objects[i].GQLType < objects[j].GQLType + return objects[i].Definition.GQLType < objects[j].Definition.GQLType }) return objects, nil @@ -81,10 +81,10 @@ func sanitizeArgName(name string) string { } func (g *Generator) buildObject(ts NamedTypes, typ *ast.Definition) (*Object, error) { - obj := &Object{TypeDefinition: ts[typ.Name]} + obj := &Object{Definition: ts[typ.Name]} typeEntry, entryExists := g.Models[typ.Name] - tt := types.NewTypeName(0, g.Config.Exec.Pkg(), obj.GQLType+"Resolver", nil) + tt := types.NewTypeName(0, g.Config.Exec.Pkg(), obj.Definition.GQLType+"Resolver", nil) obj.ResolverInterface = types.NewNamed(tt, nil, nil) if typ == g.schema.Query { @@ -158,8 +158,8 @@ func (g *Generator) buildObject(ts NamedTypes, typ *ast.Definition) (*Object, er Directives: dirs, } - if !newArg.TypeReference.IsInput && !newArg.TypeReference.IsScalar { - return nil, errors.Errorf("%s cannot be used as argument of %s.%s. only input and scalar types are allowed", arg.Type, obj.GQLType, field.Name) + if !newArg.TypeReference.Definition.IsInput && !newArg.TypeReference.Definition.IsScalar { + return nil, errors.Errorf("%s cannot be used as argument of %s.%s. only input and scalar types are allowed", arg.Type, obj.Definition.GQLType, field.Name) } if arg.DefaultValue != nil { diff --git a/codegen/templates/args.gotpl b/codegen/templates/args.gotpl index bb894839285..57eca140884 100644 --- a/codegen/templates/args.gotpl +++ b/codegen/templates/args.gotpl @@ -37,7 +37,7 @@ return nil, err } {{- end }} - {{- if $arg.IsInput }} + {{- if $arg.Definition.IsInput }} {{ $arg.Middleware (print "arg" $i) (print "arg" $i) }} {{- end }} } diff --git a/codegen/templates/data.go b/codegen/templates/data.go index 2a54e75d592..ec6f00da1f3 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -1,13 +1,13 @@ package templates var data = map[string]string{ - "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if $arg.Directives }}\n\t\t\t\targm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $dArg.IsPtr ( notNil \"Value\" $dArg ) }}\n\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $dArg.Value | dump }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t},\n\t\t\t\t{{- end }}\n\t\t\t\t}...)(ctx, func(ctx2 context.Context) (interface{}, error) {\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn arg{{ $i }}, nil\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok {\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t{{- else }}\n\t\t\t\tvar err error\n\t\t\t\t{{ $arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\t{{- if $arg.IsInput }}\n\t\t\t\t{{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", - "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\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\treturn graphql.WriterFunc(func(w io.Writer) {\n\t\t\t\tw.Write([]byte{'{'})\n\t\t\t\tgraphql.MarshalString(field.Alias).MarshalGQL(w)\n\t\t\t\tw.Write([]byte{':'})\n\t\t\t\tfunc() graphql.Marshaler {\n\t\t\t\t\t{{ $field.WriteJson }}\n\t\t\t\t}().MarshalGQL(w)\n\t\t\t\tw.Write([]byte{'}'})\n\t\t\t})\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.GoType | ref}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.GQLType|quote}},\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.GQLType}}() {{$object.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\n)\n\n\n\n// ChainFieldMiddleware add chain by FieldMiddleware\n// nolint: deadcode\nfunc chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware {\n\tn := len(handleFunc)\n\n\tif n > 1 {\n\t\tlastI := n - 1\n\t\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\t\tvar (\n\t\t\t\tchainHandler graphql.Resolver\n\t\t\t\tcurI int\n\t\t\t)\n\t\t\tchainHandler = func(currentCtx context.Context) (interface{}, error) {\n\t\t\t\tif curI == lastI {\n\t\t\t\t\treturn next(currentCtx)\n\t\t\t\t}\n\t\t\t\tcurI++\n\t\t\t\tres, err := handleFunc[curI](currentCtx, chainHandler)\n\t\t\t\tcurI--\n\t\t\t\treturn res, err\n\n\t\t\t}\n\t\t\treturn handleFunc[0](ctx, chainHandler)\n\t\t}\n\t}\n\n\tif n == 1 {\n\t\treturn handleFunc[0]\n\t}\n\n\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\treturn next(ctx)\n\t}\n}\n", - "input.gotpl": "\t{{- if .IsMarshaled }}\n\tfunc Unmarshal{{ .GQLType }}(v interface{}) ({{.GoType | ref}}, error) {\n\t\tvar it {{.GoType | ref}}\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\n\tfunc (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.GoType | ref}}) (*{{.GoType | ref}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := chainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.GoType | ref}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.GoType | ref}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t\tc{{$field.GoFieldName}}, err := chainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\t{{ if $field.IsPtr -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"*obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- else -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{ if $field.IsPtr }}*{{end}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.GoType | ref }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\n", - "interface.gotpl": "{{- $interface := . }}\n\nfunc (ec *executionContext) _{{$interface.GQLType}}(ctx context.Context, sel ast.SelectionSet, obj *{{$interface.GoType | ref}}) 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.GoType | ref}}:\n\t\t\t\treturn ec._{{$implementor.GQLType}}(ctx, sel, &obj)\n\t\t{{- end}}\n\t\tcase *{{$implementor.GoType | ref}}:\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{ range $model := .Models }}\n\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .IsInterface }}\n\t\ttype {{.GoType | ref }} interface {\n\t\t\tIs{{.GoType | ref }}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.GoType | ref }} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\n\t\t\t\t{{ $field.GoFieldName }} {{$field.Signature}} `json:\"{{$field.GQLName}}\"`\n\t\t\t{{- end }}\n\t\t}\n\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.GoType | ref }}) Is{{$iface.GoType | ref }}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.GoType | ref }} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- end}}\n\t\t{{$enum.GoType | ref }}{{ .Name|toCamel }} {{$enum.GoType | ref }} = {{.Name|quote}}\n\t{{- end }}\n\t)\n\n\tvar All{{.GoType | ref }} = []{{.GoType | ref }}{\n\t{{- range $value := .Values}}\n\t\t{{$enum.GoType | ref }}{{ .Name|toCamel }},\n\t{{- end }}\n\t}\n\n\tfunc (e {{.GoType | ref }}) IsValid() bool {\n\t\tswitch e {\n\t\tcase {{ range $index, $element := .Values}}{{if $index}},{{end}}{{ $enum.GoType | ref }}{{ $element.Name|toCamel }}{{end}}:\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tfunc (e {{.GoType | ref }}) String() string {\n\t\treturn string(e)\n\t}\n\n\tfunc (e *{{.GoType | ref }}) 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 | ref }}(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 | ref }}) 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.GoType | ref }} {{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\tout := graphql.NewFieldSet(fields)\n\tinvalid := false\n\tfor i, field := range fields {\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\tfield := field\n\t\t\t\tout.Concurrently(i, func() (res graphql.Marshaler) {\n\t\t\t\t\tres = ec._{{$object.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\t\tif res == graphql.Null {\n\t\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t\t}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\treturn res\n\t\t\t\t})\n\t\t\t{{- else }}\n\t\t\t\tout.Values[i] = ec._{{$object.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\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\tout.Dispatch()\n\tif invalid { return graphql.Null }\n\treturn out\n}\n{{- end }}\n", - "resolver.gotpl": "package {{ .PackageName }}\n\nimport (\n\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/99designs/gqlgen/handler\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\ntype {{.ResolverType}} struct {}\n\n{{ range $object := .Objects -}}\n\t{{- if $object.HasResolvers -}}\n\t\tfunc (r *{{$.ResolverType}}) {{$object.GQLType}}() {{ $object.ResolverInterface | ref }} {\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", + "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if $arg.Directives }}\n\t\t\t\targm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $dArg.IsPtr ( notNil \"Value\" $dArg ) }}\n\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $dArg.Value | dump }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t},\n\t\t\t\t{{- end }}\n\t\t\t\t}...)(ctx, func(ctx2 context.Context) (interface{}, error) {\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn arg{{ $i }}, nil\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok {\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t{{- else }}\n\t\t\t\tvar err error\n\t\t\t\t{{ $arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\t{{- if $arg.Definition.IsInput }}\n\t\t\t\t{{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", + "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.Definition.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\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\treturn graphql.WriterFunc(func(w io.Writer) {\n\t\t\t\tw.Write([]byte{'{'})\n\t\t\t\tgraphql.MarshalString(field.Alias).MarshalGQL(w)\n\t\t\t\tw.Write([]byte{':'})\n\t\t\t\tfunc() graphql.Marshaler {\n\t\t\t\t\t{{ $field.WriteJson }}\n\t\t\t\t}().MarshalGQL(w)\n\t\t\t\tw.Write([]byte{'}'})\n\t\t\t})\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.Definition.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.Definition.GoType | ref}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.Definition.GQLType|quote}},\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.Definition.GQLType}}() {{$object.Definition.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.Definition.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.Definition.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.Definition.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.Definition.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.Definition.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.Definition.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.Definition.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.Definition.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\n)\n\n\n\n// ChainFieldMiddleware add chain by FieldMiddleware\n// nolint: deadcode\nfunc chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware {\n\tn := len(handleFunc)\n\n\tif n > 1 {\n\t\tlastI := n - 1\n\t\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\t\tvar (\n\t\t\t\tchainHandler graphql.Resolver\n\t\t\t\tcurI int\n\t\t\t)\n\t\t\tchainHandler = func(currentCtx context.Context) (interface{}, error) {\n\t\t\t\tif curI == lastI {\n\t\t\t\t\treturn next(currentCtx)\n\t\t\t\t}\n\t\t\t\tcurI++\n\t\t\t\tres, err := handleFunc[curI](currentCtx, chainHandler)\n\t\t\t\tcurI--\n\t\t\t\treturn res, err\n\n\t\t\t}\n\t\t\treturn handleFunc[0](ctx, chainHandler)\n\t\t}\n\t}\n\n\tif n == 1 {\n\t\treturn handleFunc[0]\n\t}\n\n\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\treturn next(ctx)\n\t}\n}\n", + "input.gotpl": "\t{{- if .Definition.IsMarshaled }}\n\tfunc Unmarshal{{ .Definition.GQLType }}(v interface{}) ({{.Definition.GoType | ref}}, error) {\n\t\tvar it {{.Definition.GoType | ref}}\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\n\tfunc (e *executableSchema) {{ .Definition.GQLType }}Middleware(ctx context.Context, obj *{{.Definition.GoType | ref}}) (*{{.Definition.GoType | ref}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := chainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.Definition.GoType | ref}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.Definition.GoType | ref}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t\tc{{$field.GoFieldName}}, err := chainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\t{{ if $field.IsPtr -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"*obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- else -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{ if $field.IsPtr }}*{{end}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.Definition.GoType | ref }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.Definition.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\n", + "interface.gotpl": "{{- $interface := . }}\n\nfunc (ec *executionContext) _{{$interface.Definition.GQLType}}(ctx context.Context, sel ast.SelectionSet, obj *{{$interface.Definition.GoType | ref}}) 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.Definition.GoType | ref}}:\n\t\t\t\treturn ec._{{$implementor.Definition.GQLType}}(ctx, sel, &obj)\n\t\t{{- end}}\n\t\tcase *{{$implementor.Definition.GoType | ref}}:\n\t\t\treturn ec._{{$implementor.Definition.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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{ range $model := .Models }}\n\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .Definition.IsInterface }}\n\t\ttype {{.Definition.GoType | ref }} interface {\n\t\t\tIs{{.Definition.GoType | ref }}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.Definition.GoType | ref }} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\n\t\t\t\t{{ $field.GoFieldName }} {{$field.Signature}} `json:\"{{$field.GQLName}}\"`\n\t\t\t{{- end }}\n\t\t}\n\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.Definition.GoType | ref }}) Is{{$iface.GoType | ref }}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.Definition.GoType | ref }} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- end}}\n\t\t{{$enum.Definition.GoType | ref }}{{ .Name|toCamel }} {{$enum.Definition.GoType | ref }} = {{.Name|quote}}\n\t{{- end }}\n\t)\n\n\tvar All{{.Definition.GoType | ref }} = []{{.Definition.GoType | ref }}{\n\t{{- range $value := .Values}}\n\t\t{{$enum.Definition.GoType | ref }}{{ .Name|toCamel }},\n\t{{- end }}\n\t}\n\n\tfunc (e {{.Definition.GoType | ref }}) IsValid() bool {\n\t\tswitch e {\n\t\tcase {{ range $index, $element := .Values}}{{if $index}},{{end}}{{ $enum.Definition.GoType | ref }}{{ $element.Name|toCamel }}{{end}}:\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tfunc (e {{.Definition.GoType | ref }}) String() string {\n\t\treturn string(e)\n\t}\n\n\tfunc (e *{{.Definition.GoType | ref }}) 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 = {{.Definition.GoType | ref }}(str)\n\t\tif !e.IsValid() {\n\t\t\treturn fmt.Errorf(\"%s is not a valid {{.Definition.GQLType}}\", str)\n\t\t}\n\t\treturn nil\n\t}\n\n\tfunc (e {{.Definition.GoType | ref }}) 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.Definition.GQLType|lcFirst}}Implementors = {{$object.Implementors}}\n\n// nolint: gocyclo, errcheck, gas, goconst\n{{- if .Stream }}\nfunc (ec *executionContext) _{{$object.Definition.GQLType}}(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, {{$object.Definition.GQLType|lcFirst}}Implementors)\n\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\tObject: {{$object.Definition.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.Definition.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.Definition.GQLType}}(ctx context.Context, sel ast.SelectionSet{{if not $object.Root}}, obj *{{$object.Definition.GoType | ref }} {{end}}) graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, {{$object.Definition.GQLType|lcFirst}}Implementors)\n\t{{if $object.Root}}\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tObject: {{$object.Definition.GQLType|quote}},\n\t\t})\n\t{{end}}\n\n\tout := graphql.NewFieldSet(fields)\n\tinvalid := false\n\tfor i, field := range fields {\n\t\tswitch field.Name {\n\t\tcase \"__typename\":\n\t\t\tout.Values[i] = graphql.MarshalString({{$object.Definition.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\tfield := field\n\t\t\t\tout.Concurrently(i, func() (res graphql.Marshaler) {\n\t\t\t\t\tres = ec._{{$object.Definition.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\t\tif res == graphql.Null {\n\t\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t\t}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\treturn res\n\t\t\t\t})\n\t\t\t{{- else }}\n\t\t\t\tout.Values[i] = ec._{{$object.Definition.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\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\tout.Dispatch()\n\tif invalid { return graphql.Null }\n\treturn out\n}\n{{- end }}\n", + "resolver.gotpl": "package {{ .PackageName }}\n\nimport (\n\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/99designs/gqlgen/handler\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\ntype {{.ResolverType}} struct {}\n\n{{ range $object := .Objects -}}\n\t{{- if $object.HasResolvers -}}\n\t\tfunc (r *{{$.ResolverType}}) {{$object.Definition.GQLType}}() {{ $object.ResolverInterface | ref }} {\n\t\t\treturn &{{lcFirst $object.Definition.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.Definition.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.Definition.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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"log\" }}\n\t{{ reserveImport \"net/http\" }}\n\t{{ reserveImport \"os\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/handler\" }}\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({{ lookupImport .ExecPackageName }}.NewExecutableSchema({{ lookupImport .ExecPackageName}}.Config{Resolvers: &{{ lookupImport .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 6b5d86f05af..2c1f89aa353 100644 --- a/codegen/templates/field.gotpl +++ b/codegen/templates/field.gotpl @@ -2,7 +2,7 @@ {{ $object := $field.Object }} {{- if $object.Stream }} - func (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { + func (ec *executionContext) _{{$object.Definition.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Field: field, Args: nil, @@ -41,11 +41,11 @@ } {{ else }} // nolint: vetshadow - func (ec *executionContext) _{{$object.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.GoType | ref}}{{end}}) graphql.Marshaler { + func (ec *executionContext) _{{$object.Definition.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.Definition.GoType | ref}}{{end}}) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func () { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: {{$object.GQLType|quote}}, + Object: {{$object.Definition.GQLType|quote}}, Field: field, Args: nil, } diff --git a/codegen/templates/generated.gotpl b/codegen/templates/generated.gotpl index eade2d59d5f..1a1c2250a4a 100644 --- a/codegen/templates/generated.gotpl +++ b/codegen/templates/generated.gotpl @@ -38,7 +38,7 @@ type Config struct { type ResolverRoot interface { {{- range $object := .Objects -}} {{ if $object.HasResolvers -}} - {{$object.GQLType}}() {{$object.GQLType}}Resolver + {{$object.Definition.GQLType}}() {{$object.Definition.GQLType}}Resolver {{ end }} {{- end }} } @@ -52,7 +52,7 @@ type DirectiveRoot struct { type ComplexityRoot struct { {{ range $object := .Objects }} {{ if not $object.IsReserved -}} - {{ $object.GQLType|toCamel }} struct { + {{ $object.Definition.GQLType|toCamel }} struct { {{ range $field := $object.Fields -}} {{ if not $field.IsReserved -}} {{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }} @@ -65,7 +65,7 @@ type ComplexityRoot struct { {{ range $object := .Objects -}} {{ if $object.HasResolvers }} - type {{$object.GQLType}}Resolver interface { + type {{$object.Definition.GQLType}}Resolver interface { {{ range $field := $object.Fields -}} {{ $field.ShortResolverDeclaration }} {{ end }} @@ -107,8 +107,8 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in {{ if not $object.IsReserved }} {{ range $field := $object.Fields }} {{ if not $field.IsReserved }} - case "{{$object.GQLType}}.{{$field.GQLName}}": - if e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil { + case "{{$object.Definition.GQLType}}.{{$field.GQLName}}": + if e.complexity.{{$object.Definition.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil { break } {{ if $field.Args }} @@ -117,7 +117,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } {{ end }} - return e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true + return e.complexity.{{$object.Definition.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true {{ end }} {{ end }} {{ end }} @@ -131,7 +131,7 @@ func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinitio ec := executionContext{graphql.GetRequestContext(ctx), e} buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._{{.QueryRoot.GQLType}}(ctx, op.SelectionSet) + data := ec._{{.QueryRoot.Definition.GQLType}}(ctx, op.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) return buf.Bytes() @@ -151,7 +151,7 @@ func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefini ec := executionContext{graphql.GetRequestContext(ctx), e} buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._{{.MutationRoot.GQLType}}(ctx, op.SelectionSet) + data := ec._{{.MutationRoot.Definition.GQLType}}(ctx, op.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) return buf.Bytes() @@ -171,7 +171,7 @@ func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDe {{- if .SubscriptionRoot }} ec := executionContext{graphql.GetRequestContext(ctx), e} - next := ec._{{.SubscriptionRoot.GQLType}}(ctx, op.SelectionSet) + next := ec._{{.SubscriptionRoot.Definition.GQLType}}(ctx, op.SelectionSet) if ec.Errors != nil { return graphql.OneShot(&graphql.Response{Data: []byte("null"), Errors: ec.Errors}) } diff --git a/codegen/templates/input.gotpl b/codegen/templates/input.gotpl index 7f1fd6d74e5..6b9167ec74d 100644 --- a/codegen/templates/input.gotpl +++ b/codegen/templates/input.gotpl @@ -1,6 +1,6 @@ - {{- if .IsMarshaled }} - func Unmarshal{{ .GQLType }}(v interface{}) ({{.GoType | ref}}, error) { - var it {{.GoType | ref}} + {{- if .Definition.IsMarshaled }} + func Unmarshal{{ .Definition.GQLType }}(v interface{}) ({{.Definition.GoType | ref}}, error) { + var it {{.Definition.GoType | ref}} var asMap = v.(map[string]interface{}) {{ range $field := .Fields}} {{- if $field.Default}} @@ -27,7 +27,7 @@ } {{- end }} - func (e *executableSchema) {{ .GQLType }}Middleware(ctx context.Context, obj *{{.GoType | ref}}) (*{{.GoType | ref}}, error) { + func (e *executableSchema) {{ .Definition.GQLType }}Middleware(ctx context.Context, obj *{{.Definition.GoType | ref}}) (*{{.Definition.GoType | ref}}, error) { {{ if .Directives }} cObj, err := chainFieldMiddleware( []graphql.FieldMiddleware{ @@ -50,9 +50,9 @@ if err != nil || cObj == nil { return nil ,err } - obj, ok := cObj.(*{{.GoType | ref}}) + obj, ok := cObj.(*{{.Definition.GoType | ref}}) if !ok { - return nil, errors.New("expect {{.GoType | ref}}") + return nil, errors.New("expect {{.Definition.GoType | ref}}") } {{ end }} @@ -85,7 +85,7 @@ } {{ if $field.IsPtr }} - if data, ok := c{{$field.GoFieldName}}.({{ $field.GoType | ref }}); ok { + if data, ok := c{{$field.GoFieldName}}.({{ $field.Definition.GoType | ref }}); ok { obj.{{$field.GoFieldName}} = &data } else { return obj, errors.New("expect {{ $field.Signature }}") @@ -100,7 +100,7 @@ {{- end }} - {{ if $field.IsInput }} + {{ if $field.Definition.IsInput }} {{ $field.Middleware (print "obj." $field.GoFieldName ) (print "obj." $field.GoFieldName ) }} {{- end }} {{- end }} diff --git a/codegen/templates/interface.gotpl b/codegen/templates/interface.gotpl index 9620f450e8d..490e0f62f82 100644 --- a/codegen/templates/interface.gotpl +++ b/codegen/templates/interface.gotpl @@ -1,16 +1,16 @@ {{- $interface := . }} -func (ec *executionContext) _{{$interface.GQLType}}(ctx context.Context, sel ast.SelectionSet, obj *{{$interface.GoType | ref}}) graphql.Marshaler { +func (ec *executionContext) _{{$interface.Definition.GQLType}}(ctx context.Context, sel ast.SelectionSet, obj *{{$interface.Definition.GoType | ref}}) graphql.Marshaler { switch obj := (*obj).(type) { case nil: return graphql.Null {{- range $implementor := $interface.Implementors }} {{- if $implementor.ValueReceiver }} - case {{$implementor.GoType | ref}}: - return ec._{{$implementor.GQLType}}(ctx, sel, &obj) + case {{$implementor.Definition.GoType | ref}}: + return ec._{{$implementor.Definition.GQLType}}(ctx, sel, &obj) {{- end}} - case *{{$implementor.GoType | ref}}: - return ec._{{$implementor.GQLType}}(ctx, sel, obj) + case *{{$implementor.Definition.GoType | ref}}: + return ec._{{$implementor.Definition.GQLType}}(ctx, sel, obj) {{- end }} default: panic(fmt.Errorf("unexpected type %T", obj)) diff --git a/codegen/templates/models.gotpl b/codegen/templates/models.gotpl index 53e48e4cf6b..606f732e314 100644 --- a/codegen/templates/models.gotpl +++ b/codegen/templates/models.gotpl @@ -22,12 +22,12 @@ import ( {{ range $model := .Models }} {{with .Description}} {{.|prefixLines "// "}} {{end}} - {{- if .IsInterface }} - type {{.GoType | ref }} interface { - Is{{.GoType | ref }}() + {{- if .Definition.IsInterface }} + type {{.Definition.GoType | ref }} interface { + Is{{.Definition.GoType | ref }}() } {{- else }} - type {{.GoType | ref }} struct { + type {{.Definition.GoType | ref }} struct { {{- range $field := .Fields }} {{- with .Description}} {{.|prefixLines "// "}} @@ -37,7 +37,7 @@ import ( } {{- range $iface := .Implements }} - func ({{$model.GoType | ref }}) Is{{$iface.GoType | ref }}() {} + func ({{$model.Definition.GoType | ref }}) Is{{$iface.GoType | ref }}() {} {{- end }} {{- end }} @@ -45,48 +45,48 @@ import ( {{ range $enum := .Enums }} {{with .Description}}{{.|prefixLines "// "}} {{end}} - type {{.GoType | ref }} string + type {{.Definition.GoType | ref }} string const ( {{- range $value := .Values}} {{- with .Description}} {{.|prefixLines "// "}} {{- end}} - {{$enum.GoType | ref }}{{ .Name|toCamel }} {{$enum.GoType | ref }} = {{.Name|quote}} + {{$enum.Definition.GoType | ref }}{{ .Name|toCamel }} {{$enum.Definition.GoType | ref }} = {{.Name|quote}} {{- end }} ) - var All{{.GoType | ref }} = []{{.GoType | ref }}{ + var All{{.Definition.GoType | ref }} = []{{.Definition.GoType | ref }}{ {{- range $value := .Values}} - {{$enum.GoType | ref }}{{ .Name|toCamel }}, + {{$enum.Definition.GoType | ref }}{{ .Name|toCamel }}, {{- end }} } - func (e {{.GoType | ref }}) IsValid() bool { + func (e {{.Definition.GoType | ref }}) IsValid() bool { switch e { - case {{ range $index, $element := .Values}}{{if $index}},{{end}}{{ $enum.GoType | ref }}{{ $element.Name|toCamel }}{{end}}: + case {{ range $index, $element := .Values}}{{if $index}},{{end}}{{ $enum.Definition.GoType | ref }}{{ $element.Name|toCamel }}{{end}}: return true } return false } - func (e {{.GoType | ref }}) String() string { + func (e {{.Definition.GoType | ref }}) String() string { return string(e) } - func (e *{{.GoType | ref }}) UnmarshalGQL(v interface{}) error { + func (e *{{.Definition.GoType | ref }}) UnmarshalGQL(v interface{}) error { str, ok := v.(string) if !ok { return fmt.Errorf("enums must be strings") } - *e = {{.GoType | ref }}(str) + *e = {{.Definition.GoType | ref }}(str) if !e.IsValid() { - return fmt.Errorf("%s is not a valid {{.GQLType}}", str) + return fmt.Errorf("%s is not a valid {{.Definition.GQLType}}", str) } return nil } - func (e {{.GoType | ref }}) MarshalGQL(w io.Writer) { + func (e {{.Definition.GoType | ref }}) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } diff --git a/codegen/templates/object.gotpl b/codegen/templates/object.gotpl index 9f39b6b6739..694faaa0bb8 100644 --- a/codegen/templates/object.gotpl +++ b/codegen/templates/object.gotpl @@ -1,13 +1,13 @@ {{ $object := . }} -var {{ $object.GQLType|lcFirst}}Implementors = {{$object.Implementors}} +var {{ $object.Definition.GQLType|lcFirst}}Implementors = {{$object.Implementors}} // nolint: gocyclo, errcheck, gas, goconst {{- if .Stream }} -func (ec *executionContext) _{{$object.GQLType}}(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, {{$object.GQLType|lcFirst}}Implementors) +func (ec *executionContext) _{{$object.Definition.GQLType}}(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, {{$object.Definition.GQLType|lcFirst}}Implementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: {{$object.GQLType|quote}}, + Object: {{$object.Definition.GQLType|quote}}, }) if len(fields) != 1 { ec.Errorf(ctx, "must subscribe to exactly one stream") @@ -17,18 +17,18 @@ func (ec *executionContext) _{{$object.GQLType}}(ctx context.Context, sel ast.Se switch fields[0].Name { {{- range $field := $object.Fields }} case "{{$field.GQLName}}": - return ec._{{$object.GQLType}}_{{$field.GQLName}}(ctx, fields[0]) + return ec._{{$object.Definition.GQLType}}_{{$field.GQLName}}(ctx, fields[0]) {{- end }} default: panic("unknown field " + strconv.Quote(fields[0].Name)) } } {{- else }} -func (ec *executionContext) _{{$object.GQLType}}(ctx context.Context, sel ast.SelectionSet{{if not $object.Root}}, obj *{{$object.GoType | ref }} {{end}}) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, {{$object.GQLType|lcFirst}}Implementors) +func (ec *executionContext) _{{$object.Definition.GQLType}}(ctx context.Context, sel ast.SelectionSet{{if not $object.Root}}, obj *{{$object.Definition.GoType | ref }} {{end}}) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, {{$object.Definition.GQLType|lcFirst}}Implementors) {{if $object.Root}} ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: {{$object.GQLType|quote}}, + Object: {{$object.Definition.GQLType|quote}}, }) {{end}} @@ -37,13 +37,13 @@ func (ec *executionContext) _{{$object.GQLType}}(ctx context.Context, sel ast.Se for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString({{$object.GQLType|quote}}) + out.Values[i] = graphql.MarshalString({{$object.Definition.GQLType|quote}}) {{- range $field := $object.Fields }} case "{{$field.GQLName}}": {{- if $field.IsConcurrent }} field := field out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._{{$object.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}}) + res = ec._{{$object.Definition.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}}) {{- if $field.ASTType.NonNull }} if res == graphql.Null { invalid = true @@ -52,7 +52,7 @@ func (ec *executionContext) _{{$object.GQLType}}(ctx context.Context, sel ast.Se return res }) {{- else }} - out.Values[i] = ec._{{$object.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}}) + out.Values[i] = ec._{{$object.Definition.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}}) {{- if $field.ASTType.NonNull }} if out.Values[i] == graphql.Null { invalid = true diff --git a/codegen/templates/resolver.gotpl b/codegen/templates/resolver.gotpl index 8919e329bef..3cd74d1b10e 100644 --- a/codegen/templates/resolver.gotpl +++ b/codegen/templates/resolver.gotpl @@ -23,19 +23,19 @@ type {{.ResolverType}} struct {} {{ range $object := .Objects -}} {{- if $object.HasResolvers -}} - func (r *{{$.ResolverType}}) {{$object.GQLType}}() {{ $object.ResolverInterface | ref }} { - return &{{lcFirst $object.GQLType}}Resolver{r} + func (r *{{$.ResolverType}}) {{$object.Definition.GQLType}}() {{ $object.ResolverInterface | ref }} { + return &{{lcFirst $object.Definition.GQLType}}Resolver{r} } {{ end -}} {{ end }} {{ range $object := .Objects -}} {{- if $object.HasResolvers -}} - type {{lcFirst $object.GQLType}}Resolver struct { *Resolver } + type {{lcFirst $object.Definition.GQLType}}Resolver struct { *Resolver } {{ range $field := $object.Fields -}} {{- if $field.IsResolver -}} - func (r *{{lcFirst $object.GQLType}}Resolver) {{ $field.ShortResolverDeclaration }} { + func (r *{{lcFirst $object.Definition.GQLType}}Resolver) {{ $field.ShortResolverDeclaration }} { panic("not implemented") } {{ end -}} diff --git a/codegen/type_definition.go b/codegen/type_definition.go index 20ab950b828..f7f68c41a7b 100644 --- a/codegen/type_definition.go +++ b/codegen/type_definition.go @@ -49,12 +49,12 @@ func (n NamedTypes) getType(t *ast.Type) *TypeReference { panic("missing type " + t.NamedType) } res := &TypeReference{ - TypeDefinition: n[t.NamedType], - Modifiers: modifiers, - ASTType: orig, + Definition: n[t.NamedType], + Modifiers: modifiers, + ASTType: orig, } - if res.IsInterface { + if res.Definition.IsInterface { res.StripPtr() } diff --git a/codegen/type_reference.go b/codegen/type_reference.go index 3ba49ab02cc..c8a9eb11831 100644 --- a/codegen/type_reference.go +++ b/codegen/type_reference.go @@ -11,18 +11,18 @@ import ( // TypeReference represents the type of a field or arg, referencing an underlying TypeDefinition (type, input, scalar) type TypeReference struct { - *TypeDefinition + Definition *TypeDefinition Modifiers []string ASTType *ast.Type } func (t TypeReference) Signature() string { - return strings.Join(t.Modifiers, "") + templates.CurrentImports.LookupType(t.TypeDefinition.GoType) + return strings.Join(t.Modifiers, "") + templates.CurrentImports.LookupType(t.Definition.GoType) } func (t TypeReference) FullSignature() string { - return strings.Join(t.Modifiers, "") + types.TypeString(t.TypeDefinition.GoType, nil) + return strings.Join(t.Modifiers, "") + types.TypeString(t.Definition.GoType, nil) } func (t TypeReference) IsPtr() bool { @@ -49,7 +49,7 @@ func (t TypeReference) unmarshal(result, raw string, remainingMods []string, dep switch { case len(remainingMods) > 0 && remainingMods[0] == modPtr: ptr := "ptr" + strconv.Itoa(depth) - return tpl(`var {{.ptr}} {{.mods}}{{.t.GoType | ref }} + return tpl(`var {{.ptr}} {{.mods}}{{.t.Definition.GoType | ref }} if {{.raw}} != nil { {{.next}} {{.result}} = &{{.ptr -}} @@ -83,7 +83,7 @@ func (t TypeReference) unmarshal(result, raw string, remainingMods []string, dep "rawSlice": rawIf, "index": index, "result": result, - "type": strings.Join(remainingMods, "") + templates.CurrentImports.LookupType(t.GoType), + "type": strings.Join(remainingMods, "") + templates.CurrentImports.LookupType(t.Definition.GoType), "next": t.unmarshal(result+"["+index+"]", rawIf+"["+index+"]", remainingMods[1:], depth+1), }) } @@ -91,10 +91,10 @@ func (t TypeReference) unmarshal(result, raw string, remainingMods []string, dep realResult := result return tpl(` - {{- if eq (.t.GoType | ref) "map[string]interface{}" }} + {{- if eq (.t.Definition.GoType | ref) "map[string]interface{}" }} {{- .result }} = {{.raw}}.(map[string]interface{}) - {{- else if .t.Unmarshaler }} - {{- .result }}, err = {{ .t.Unmarshaler | call }}({{.raw}}) + {{- else if .t.Definition.Unmarshaler }} + {{- .result }}, err = {{ .t.Definition.Unmarshaler | call }}({{.raw}}) {{- else -}} err = (&{{.result}}).UnmarshalGQL({{.raw}}) {{- end }}`, map[string]interface{}{ @@ -114,7 +114,7 @@ func (t TypeReference) middleware(result, raw string, remainingMods []string, de return tpl(` if {{.raw}} != nil { var err error - {{.result}}, err = e.{{ .t.GQLType }}Middleware(ctx, {{.raw}}) + {{.result}}, err = e.{{ .t.Definition.GQLType }}Middleware(ctx, {{.raw}}) if err != nil { return nil, err } @@ -145,14 +145,14 @@ func (t TypeReference) middleware(result, raw string, remainingMods []string, de "raw": raw, "index": index, "result": result, - "type": strings.Join(remainingMods, "") + templates.CurrentImports.LookupType(t.TypeDefinition.GoType), + "type": strings.Join(remainingMods, "") + templates.CurrentImports.LookupType(t.Definition.GoType), "next": t.middleware(result+"["+index+"]", raw+"["+index+"]", remainingMods[1:], depth+1), }) } - ptr := "m" + t.GQLType + strconv.Itoa(depth) + ptr := "m" + t.Definition.GQLType + strconv.Itoa(depth) return tpl(` - {{.ptr}}, err := e.{{ .t.GQLType }}Middleware(ctx, &{{.raw}}) + {{.ptr}}, err := e.{{ .t.Definition.GQLType }}Middleware(ctx, &{{.raw}}) if err != nil { return nil, err } @@ -165,8 +165,8 @@ func (t TypeReference) middleware(result, raw string, remainingMods []string, de } func (t TypeReference) Marshal(val string) string { - if t.Marshaler != nil { - return "return " + templates.Call(t.TypeDefinition.Marshaler) + "(" + val + ")" + if t.Definition.Marshaler != nil { + return "return " + templates.Call(t.Definition.Marshaler) + "(" + val + ")" } return "return " + val diff --git a/codegen/util.go b/codegen/util.go index e734e77c58d..2c91b45ccb6 100644 --- a/codegen/util.go +++ b/codegen/util.go @@ -184,7 +184,7 @@ type BindError struct { func (b BindError) Error() string { return fmt.Sprintf( "Unable to bind %s.%s to %s\n %s\n %s", - b.object.GQLType, + b.object.Definition.GQLType, b.field.GQLName, b.typ.String(), b.methodErr.Error(), @@ -212,18 +212,18 @@ func bindObject(object *Object, structTag string) BindErrors { } // first try binding to a method - methodErr := bindMethod(object.GoType, field) + methodErr := bindMethod(object.Definition.GoType, field) if methodErr == nil { continue } // otherwise try binding to a var - varErr := bindVar(object.GoType, field, structTag) + varErr := bindVar(object.Definition.GoType, field, structTag) if varErr != nil { errs = append(errs, BindError{ object: object, - typ: object.GoType, + typ: object.Definition.GoType, field: field, varErr: varErr, methodErr: methodErr, From 8298acb0903f76ae31f92c66ae251f53aa4c22fd Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Tue, 8 Jan 2019 13:50:31 +1100 Subject: [PATCH 031/147] bind to types.Types in field / arg references too --- codegen/config/config.go | 28 +++++---- codegen/directive.go | 4 +- codegen/models_build.go | 2 +- codegen/object.go | 47 +++++++------- codegen/object_build.go | 20 ++++-- codegen/templates/args.gotpl | 6 +- codegen/templates/data.go | 8 +-- codegen/templates/field.gotpl | 2 +- codegen/templates/input.gotpl | 6 +- codegen/templates/models.gotpl | 2 +- codegen/testserver/generated.go | 14 ++--- codegen/testserver/resolver.go | 2 +- codegen/type_build.go | 2 +- codegen/type_definition.go | 50 +++++++-------- codegen/type_reference.go | 105 +++++++++++++------------------- codegen/util.go | 25 +------- example/dataloader/generated.go | 2 +- 17 files changed, 146 insertions(+), 179 deletions(-) diff --git a/codegen/config/config.go b/codegen/config/config.go index 14e28c11e5d..bec8e00fb25 100644 --- a/codegen/config/config.go +++ b/codegen/config/config.go @@ -296,19 +296,21 @@ func (cfg *Config) normalize() error { } builtins := TypeMap{ - "__Directive": {Model: "github.com/99designs/gqlgen/graphql/introspection.Directive"}, - "__Type": {Model: "github.com/99designs/gqlgen/graphql/introspection.Type"}, - "__Field": {Model: "github.com/99designs/gqlgen/graphql/introspection.Field"}, - "__EnumValue": {Model: "github.com/99designs/gqlgen/graphql/introspection.EnumValue"}, - "__InputValue": {Model: "github.com/99designs/gqlgen/graphql/introspection.InputValue"}, - "__Schema": {Model: "github.com/99designs/gqlgen/graphql/introspection.Schema"}, - "Int": {Model: "github.com/99designs/gqlgen/graphql.Int"}, - "Float": {Model: "github.com/99designs/gqlgen/graphql.Float"}, - "String": {Model: "github.com/99designs/gqlgen/graphql.String"}, - "Boolean": {Model: "github.com/99designs/gqlgen/graphql.Boolean"}, - "ID": {Model: "github.com/99designs/gqlgen/graphql.ID"}, - "Time": {Model: "github.com/99designs/gqlgen/graphql.Time"}, - "Map": {Model: "github.com/99designs/gqlgen/graphql.Map"}, + "__Directive": {Model: "github.com/99designs/gqlgen/graphql/introspection.Directive"}, + "__DirectiveLocation": {Model: "github.com/99designs/gqlgen/graphql.String"}, + "__Type": {Model: "github.com/99designs/gqlgen/graphql/introspection.Type"}, + "__TypeKind": {Model: "github.com/99designs/gqlgen/graphql.String"}, + "__Field": {Model: "github.com/99designs/gqlgen/graphql/introspection.Field"}, + "__EnumValue": {Model: "github.com/99designs/gqlgen/graphql/introspection.EnumValue"}, + "__InputValue": {Model: "github.com/99designs/gqlgen/graphql/introspection.InputValue"}, + "__Schema": {Model: "github.com/99designs/gqlgen/graphql/introspection.Schema"}, + "Int": {Model: "github.com/99designs/gqlgen/graphql.Int"}, + "Float": {Model: "github.com/99designs/gqlgen/graphql.Float"}, + "String": {Model: "github.com/99designs/gqlgen/graphql.String"}, + "Boolean": {Model: "github.com/99designs/gqlgen/graphql.Boolean"}, + "ID": {Model: "github.com/99designs/gqlgen/graphql.ID"}, + "Time": {Model: "github.com/99designs/gqlgen/graphql.Time"}, + "Map": {Model: "github.com/99designs/gqlgen/graphql.Map"}, } if cfg.Models == nil { diff --git a/codegen/directive.go b/codegen/directive.go index 4cc30d36c56..f9f000bafba 100644 --- a/codegen/directive.go +++ b/codegen/directive.go @@ -25,7 +25,7 @@ func (d *Directive) CallArgs() string { args := []string{"ctx", "obj", "n"} for _, arg := range d.Args { - args = append(args, "args["+strconv.Quote(arg.GQLName)+"].("+arg.Signature()+")") + args = append(args, "args["+strconv.Quote(arg.GQLName)+"].("+templates.CurrentImports.LookupType(arg.GoType)+")") } return strings.Join(args, ", ") @@ -56,7 +56,7 @@ func (d *Directive) Declaration() string { res := ucFirst(d.Name) + " func(ctx context.Context, obj interface{}, next graphql.Resolver" for _, arg := range d.Args { - res += fmt.Sprintf(", %s %s", arg.GoVarName, arg.Signature()) + res += fmt.Sprintf(", %s %s", arg.GoVarName, templates.CurrentImports.LookupType(arg.GoType)) } res += ") (res interface{}, err error)" diff --git a/codegen/models_build.go b/codegen/models_build.go index 43775376570..bef81fac25b 100644 --- a/codegen/models_build.go +++ b/codegen/models_build.go @@ -17,7 +17,7 @@ func (g *Generator) buildModels(types NamedTypes, prog *loader.Program) ([]Model } switch typ.Kind { case ast.Object: - obj, err := g.buildObject(types, typ) + obj, err := g.buildObject(prog, types, typ) if err != nil { return nil, err } diff --git a/codegen/object.go b/codegen/object.go index fbcb6dabbb7..62b1835e69c 100644 --- a/codegen/object.go +++ b/codegen/object.go @@ -174,10 +174,10 @@ func (f *Field) ShortResolverDeclaration() string { res += fmt.Sprintf(", obj *%s", templates.CurrentImports.LookupType(f.Object.Definition.GoType)) } for _, arg := range f.Args { - res += fmt.Sprintf(", %s %s", arg.GoVarName, arg.Signature()) + res += fmt.Sprintf(", %s %s", arg.GoVarName, templates.CurrentImports.LookupType(arg.GoType)) } - result := f.Signature() + result := templates.CurrentImports.LookupType(f.GoType) if f.Object.Stream { result = "<-chan " + result } @@ -196,10 +196,10 @@ func (f *Field) ResolverDeclaration() string { res += fmt.Sprintf(", obj *%s", templates.CurrentImports.LookupType(f.Object.Definition.GoType)) } for _, arg := range f.Args { - res += fmt.Sprintf(", %s %s", arg.GoVarName, arg.Signature()) + res += fmt.Sprintf(", %s %s", arg.GoVarName, templates.CurrentImports.LookupType(arg.GoType)) } - result := f.Signature() + result := templates.CurrentImports.LookupType(f.GoType) if f.Object.Stream { result = "<-chan " + result } @@ -211,7 +211,7 @@ func (f *Field) ResolverDeclaration() string { func (f *Field) ComplexitySignature() string { res := fmt.Sprintf("func(childComplexity int") for _, arg := range f.Args { - res += fmt.Sprintf(", %s %s", arg.GoVarName, arg.Signature()) + res += fmt.Sprintf(", %s %s", arg.GoVarName, templates.CurrentImports.LookupType(arg.GoType)) } res += ") int" return res @@ -220,7 +220,7 @@ func (f *Field) ComplexitySignature() string { func (f *Field) ComplexityArgs() string { var args []string for _, arg := range f.Args { - args = append(args, "args["+strconv.Quote(arg.GQLName)+"].("+arg.Signature()+")") + args = append(args, "args["+strconv.Quote(arg.GQLName)+"].("+templates.CurrentImports.LookupType(arg.GoType)+")") } return strings.Join(args, ", ") @@ -242,7 +242,7 @@ func (f *Field) CallArgs() string { } for _, arg := range f.Args { - args = append(args, "args["+strconv.Quote(arg.GQLName)+"].("+arg.Signature()+")") + args = append(args, "args["+strconv.Quote(arg.GQLName)+"].("+templates.CurrentImports.LookupType(arg.GoType)+")") } return strings.Join(args, ", ") @@ -250,12 +250,12 @@ func (f *Field) CallArgs() string { // should be in the template, but its recursive and has a bunch of args func (f *Field) WriteJson() string { - return f.doWriteJson("res", f.TypeReference.Modifiers, f.ASTType, false, 1) + return f.doWriteJson("res", f.GoType, f.ASTType, false, 1) } -func (f *Field) doWriteJson(val string, remainingMods []string, astType *ast.Type, isPtr bool, depth int) string { - switch { - case len(remainingMods) > 0 && remainingMods[0] == modPtr: +func (f *Field) doWriteJson(val string, destType types.Type, astType *ast.Type, isPtr bool, depth int) string { + switch destType := destType.(type) { + case *types.Pointer: return tpl(` if {{.val}} == nil { {{- if .nonNull }} @@ -268,18 +268,22 @@ func (f *Field) doWriteJson(val string, remainingMods []string, astType *ast.Typ {{.next }}`, map[string]interface{}{ "val": val, "nonNull": astType.NonNull, - "next": f.doWriteJson(val, remainingMods[1:], astType, true, depth+1), + "next": f.doWriteJson(val, destType.Elem(), astType, true, depth+1), }) - case len(remainingMods) > 0 && remainingMods[0] == modList: + case *types.Slice: if isPtr { val = "*" + val } var arr = "arr" + strconv.Itoa(depth) var index = "idx" + strconv.Itoa(depth) var usePtr bool - if len(remainingMods) == 1 && !isPtr { - usePtr = true + if !isPtr { + switch destType.Elem().(type) { + case *types.Pointer, *types.Array: + default: + usePtr = true + } } return tpl(` @@ -327,16 +331,17 @@ func (f *Field) doWriteJson(val string, remainingMods []string, astType *ast.Typ "arrayLen": len(val), "isScalar": f.Definition.IsScalar, "usePtr": usePtr, - "next": f.doWriteJson(val+"["+index+"]", remainingMods[1:], astType.Elem, false, depth+1), + "next": f.doWriteJson(val+"["+index+"]", destType.Elem(), astType.Elem, false, depth+1), }) - case f.Definition.IsScalar: - if isPtr { - val = "*" + val + default: + if f.Definition.IsScalar { + if isPtr { + val = "*" + val + } + return f.Marshal(val) } - return f.Marshal(val) - default: if !isPtr { val = "&" + val } diff --git a/codegen/object_build.go b/codegen/object_build.go index 8d4e6a0e2e6..0b506eb6f93 100644 --- a/codegen/object_build.go +++ b/codegen/object_build.go @@ -20,7 +20,7 @@ func (g *Generator) buildObjects(ts NamedTypes, prog *loader.Program) (Objects, continue } - obj, err := g.buildObject(ts, typ) + obj, err := g.buildObject(prog, ts, typ) if err != nil { return nil, err } @@ -80,7 +80,7 @@ func sanitizeArgName(name string) string { return name } -func (g *Generator) buildObject(ts NamedTypes, typ *ast.Definition) (*Object, error) { +func (g *Generator) buildObject(prog *loader.Program, ts NamedTypes, typ *ast.Definition) (*Object, error) { obj := &Object{Definition: ts[typ.Name]} typeEntry, entryExists := g.Models[typ.Name] @@ -109,8 +109,13 @@ func (g *Generator) buildObject(ts NamedTypes, typ *ast.Definition) (*Object, er for _, field := range typ.Fields { if typ == g.schema.Query && field.Name == "__type" { + schemaType, err := findGoType(prog, "github.com/99designs/gqlgen/graphql/introspection", "Schema") + if err != nil { + return nil, errors.Wrap(err, "unable to find root schema introspection type") + } + obj.Fields = append(obj.Fields, Field{ - TypeReference: &TypeReference{ts["__Schema"], []string{modPtr}, ast.NamedType("__Schema", nil)}, + TypeReference: &TypeReference{ts["__Schema"], types.NewPointer(schemaType.Type()), ast.NamedType("__Schema", nil)}, GQLName: "__schema", GoFieldType: GoFieldMethod, GoReceiverName: "ec", @@ -121,14 +126,19 @@ func (g *Generator) buildObject(ts NamedTypes, typ *ast.Definition) (*Object, er continue } if typ == g.schema.Query && field.Name == "__schema" { + typeType, err := findGoType(prog, "github.com/99designs/gqlgen/graphql/introspection", "Type") + if err != nil { + return nil, errors.Wrap(err, "unable to find root schema introspection type") + } + obj.Fields = append(obj.Fields, Field{ - TypeReference: &TypeReference{ts["__Type"], []string{modPtr}, ast.NamedType("__Schema", nil)}, + TypeReference: &TypeReference{ts["__Type"], types.NewPointer(typeType.Type()), ast.NamedType("__Schema", nil)}, GQLName: "__type", GoFieldType: GoFieldMethod, GoReceiverName: "ec", GoFieldName: "introspectType", Args: []FieldArgument{ - {GQLName: "name", TypeReference: &TypeReference{ts["String"], []string{}, ast.NamedType("String", nil)}, Object: &Object{}}, + {GQLName: "name", TypeReference: &TypeReference{ts["String"], types.Typ[types.String], ast.NamedType("String", nil)}, Object: &Object{}}, }, Object: obj, }) diff --git a/codegen/templates/args.gotpl b/codegen/templates/args.gotpl index 57eca140884..18d11700e8b 100644 --- a/codegen/templates/args.gotpl +++ b/codegen/templates/args.gotpl @@ -1,6 +1,6 @@ args := map[string]interface{}{} {{- range $i, $arg := . }} - var arg{{$i}} {{$arg.Signature }} + var arg{{$i}} {{$arg.GoType | ref }} if tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok { {{- if $arg.Directives }} argm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{ @@ -25,10 +25,10 @@ if err != nil { return nil, err } - if data, ok := argm{{$i}}.({{$arg.Signature }}); ok { + if data, ok := argm{{$i}}.({{$arg.GoType | ref }}); ok { arg{{$i}} = data } else { - return nil, errors.New("expect {{$arg.Signature }}") + return nil, errors.New("expect {{$arg.GoType | ref }}") } {{- else }} var err error diff --git a/codegen/templates/data.go b/codegen/templates/data.go index ec6f00da1f3..2acdce22ea1 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -1,12 +1,12 @@ package templates var data = map[string]string{ - "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.Signature }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if $arg.Directives }}\n\t\t\t\targm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $dArg.IsPtr ( notNil \"Value\" $dArg ) }}\n\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $dArg.Value | dump }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t},\n\t\t\t\t{{- end }}\n\t\t\t\t}...)(ctx, func(ctx2 context.Context) (interface{}, error) {\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn arg{{ $i }}, nil\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.Signature }}); ok {\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.Signature }}\")\n\t\t\t\t}\n\t\t\t{{- else }}\n\t\t\t\tvar err error\n\t\t\t\t{{ $arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\t{{- if $arg.Definition.IsInput }}\n\t\t\t\t{{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", - "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.Definition.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\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\treturn graphql.WriterFunc(func(w io.Writer) {\n\t\t\t\tw.Write([]byte{'{'})\n\t\t\t\tgraphql.MarshalString(field.Alias).MarshalGQL(w)\n\t\t\t\tw.Write([]byte{':'})\n\t\t\t\tfunc() graphql.Marshaler {\n\t\t\t\t\t{{ $field.WriteJson }}\n\t\t\t\t}().MarshalGQL(w)\n\t\t\t\tw.Write([]byte{'}'})\n\t\t\t})\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.Definition.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.Definition.GoType | ref}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.Definition.GQLType|quote}},\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.Signature}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\n\t\t{{ $field.WriteJson }}\n\t}\n{{ end }}\n", + "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.GoType | ref }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if $arg.Directives }}\n\t\t\t\targm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $dArg.IsPtr ( notNil \"Value\" $dArg ) }}\n\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $dArg.Value | dump }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t},\n\t\t\t\t{{- end }}\n\t\t\t\t}...)(ctx, func(ctx2 context.Context) (interface{}, error) {\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn arg{{ $i }}, nil\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.GoType | ref }}); ok {\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.GoType | ref }}\")\n\t\t\t\t}\n\t\t\t{{- else }}\n\t\t\t\tvar err error\n\t\t\t\t{{ $arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\t{{- if $arg.Definition.IsInput }}\n\t\t\t\t{{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", + "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.Definition.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\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\treturn graphql.WriterFunc(func(w io.Writer) {\n\t\t\t\tw.Write([]byte{'{'})\n\t\t\t\tgraphql.MarshalString(field.Alias).MarshalGQL(w)\n\t\t\t\tw.Write([]byte{':'})\n\t\t\t\tfunc() graphql.Marshaler {\n\t\t\t\t\t{{ $field.WriteJson }}\n\t\t\t\t}().MarshalGQL(w)\n\t\t\t\tw.Write([]byte{'}'})\n\t\t\t})\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.Definition.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.Definition.GoType | ref}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.Definition.GQLType|quote}},\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.GoType | ref}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.Definition.GQLType}}() {{$object.Definition.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.Definition.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.Definition.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.Definition.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.Definition.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.Definition.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.Definition.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.Definition.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.Definition.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\n)\n\n\n\n// ChainFieldMiddleware add chain by FieldMiddleware\n// nolint: deadcode\nfunc chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware {\n\tn := len(handleFunc)\n\n\tif n > 1 {\n\t\tlastI := n - 1\n\t\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\t\tvar (\n\t\t\t\tchainHandler graphql.Resolver\n\t\t\t\tcurI int\n\t\t\t)\n\t\t\tchainHandler = func(currentCtx context.Context) (interface{}, error) {\n\t\t\t\tif curI == lastI {\n\t\t\t\t\treturn next(currentCtx)\n\t\t\t\t}\n\t\t\t\tcurI++\n\t\t\t\tres, err := handleFunc[curI](currentCtx, chainHandler)\n\t\t\t\tcurI--\n\t\t\t\treturn res, err\n\n\t\t\t}\n\t\t\treturn handleFunc[0](ctx, chainHandler)\n\t\t}\n\t}\n\n\tif n == 1 {\n\t\treturn handleFunc[0]\n\t}\n\n\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\treturn next(ctx)\n\t}\n}\n", - "input.gotpl": "\t{{- if .Definition.IsMarshaled }}\n\tfunc Unmarshal{{ .Definition.GQLType }}(v interface{}) ({{.Definition.GoType | ref}}, error) {\n\t\tvar it {{.Definition.GoType | ref}}\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\n\tfunc (e *executableSchema) {{ .Definition.GQLType }}Middleware(ctx context.Context, obj *{{.Definition.GoType | ref}}) (*{{.Definition.GoType | ref}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := chainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.Definition.GoType | ref}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.Definition.GoType | ref}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t\tc{{$field.GoFieldName}}, err := chainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\t{{ if $field.IsPtr -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"*obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- else -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{ if $field.IsPtr }}*{{end}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.Definition.GoType | ref }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.Signature }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.Signature }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.Definition.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\n", + "input.gotpl": "\t{{- if .Definition.IsMarshaled }}\n\tfunc Unmarshal{{ .Definition.GQLType }}(v interface{}) ({{.Definition.GoType | ref}}, error) {\n\t\tvar it {{.Definition.GoType | ref}}\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\n\tfunc (e *executableSchema) {{ .Definition.GQLType }}Middleware(ctx context.Context, obj *{{.Definition.GoType | ref}}) (*{{.Definition.GoType | ref}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := chainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.Definition.GoType | ref}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.Definition.GoType | ref}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t\tc{{$field.GoFieldName}}, err := chainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\t{{ if $field.IsPtr -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"*obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- else -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{ if $field.IsPtr }}*{{end}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.Definition.GoType | ref }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.GoType | ref }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.GoType | ref }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.GoType | ref }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.Definition.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\n", "interface.gotpl": "{{- $interface := . }}\n\nfunc (ec *executionContext) _{{$interface.Definition.GQLType}}(ctx context.Context, sel ast.SelectionSet, obj *{{$interface.Definition.GoType | ref}}) 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.Definition.GoType | ref}}:\n\t\t\t\treturn ec._{{$implementor.Definition.GQLType}}(ctx, sel, &obj)\n\t\t{{- end}}\n\t\tcase *{{$implementor.Definition.GoType | ref}}:\n\t\t\treturn ec._{{$implementor.Definition.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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{ range $model := .Models }}\n\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .Definition.IsInterface }}\n\t\ttype {{.Definition.GoType | ref }} interface {\n\t\t\tIs{{.Definition.GoType | ref }}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.Definition.GoType | ref }} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\n\t\t\t\t{{ $field.GoFieldName }} {{$field.Signature}} `json:\"{{$field.GQLName}}\"`\n\t\t\t{{- end }}\n\t\t}\n\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.Definition.GoType | ref }}) Is{{$iface.GoType | ref }}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.Definition.GoType | ref }} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- end}}\n\t\t{{$enum.Definition.GoType | ref }}{{ .Name|toCamel }} {{$enum.Definition.GoType | ref }} = {{.Name|quote}}\n\t{{- end }}\n\t)\n\n\tvar All{{.Definition.GoType | ref }} = []{{.Definition.GoType | ref }}{\n\t{{- range $value := .Values}}\n\t\t{{$enum.Definition.GoType | ref }}{{ .Name|toCamel }},\n\t{{- end }}\n\t}\n\n\tfunc (e {{.Definition.GoType | ref }}) IsValid() bool {\n\t\tswitch e {\n\t\tcase {{ range $index, $element := .Values}}{{if $index}},{{end}}{{ $enum.Definition.GoType | ref }}{{ $element.Name|toCamel }}{{end}}:\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tfunc (e {{.Definition.GoType | ref }}) String() string {\n\t\treturn string(e)\n\t}\n\n\tfunc (e *{{.Definition.GoType | ref }}) 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 = {{.Definition.GoType | ref }}(str)\n\t\tif !e.IsValid() {\n\t\t\treturn fmt.Errorf(\"%s is not a valid {{.Definition.GQLType}}\", str)\n\t\t}\n\t\treturn nil\n\t}\n\n\tfunc (e {{.Definition.GoType | ref }}) MarshalGQL(w io.Writer) {\n\t\tfmt.Fprint(w, strconv.Quote(e.String()))\n\t}\n\n{{- end }}\n", + "models.gotpl": "// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.\n\npackage {{ .PackageName }}\n\nimport (\n\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{ range $model := .Models }}\n\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .Definition.IsInterface }}\n\t\ttype {{.Definition.GoType | ref }} interface {\n\t\t\tIs{{.Definition.GoType | ref }}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.Definition.GoType | ref }} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\n\t\t\t\t{{ $field.GoFieldName }} {{$field.GoType | ref}} `json:\"{{$field.GQLName}}\"`\n\t\t\t{{- end }}\n\t\t}\n\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.Definition.GoType | ref }}) Is{{$iface.GoType | ref }}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.Definition.GoType | ref }} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- end}}\n\t\t{{$enum.Definition.GoType | ref }}{{ .Name|toCamel }} {{$enum.Definition.GoType | ref }} = {{.Name|quote}}\n\t{{- end }}\n\t)\n\n\tvar All{{.Definition.GoType | ref }} = []{{.Definition.GoType | ref }}{\n\t{{- range $value := .Values}}\n\t\t{{$enum.Definition.GoType | ref }}{{ .Name|toCamel }},\n\t{{- end }}\n\t}\n\n\tfunc (e {{.Definition.GoType | ref }}) IsValid() bool {\n\t\tswitch e {\n\t\tcase {{ range $index, $element := .Values}}{{if $index}},{{end}}{{ $enum.Definition.GoType | ref }}{{ $element.Name|toCamel }}{{end}}:\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tfunc (e {{.Definition.GoType | ref }}) String() string {\n\t\treturn string(e)\n\t}\n\n\tfunc (e *{{.Definition.GoType | ref }}) 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 = {{.Definition.GoType | ref }}(str)\n\t\tif !e.IsValid() {\n\t\t\treturn fmt.Errorf(\"%s is not a valid {{.Definition.GQLType}}\", str)\n\t\t}\n\t\treturn nil\n\t}\n\n\tfunc (e {{.Definition.GoType | ref }}) 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.Definition.GQLType|lcFirst}}Implementors = {{$object.Implementors}}\n\n// nolint: gocyclo, errcheck, gas, goconst\n{{- if .Stream }}\nfunc (ec *executionContext) _{{$object.Definition.GQLType}}(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, {{$object.Definition.GQLType|lcFirst}}Implementors)\n\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\tObject: {{$object.Definition.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.Definition.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.Definition.GQLType}}(ctx context.Context, sel ast.SelectionSet{{if not $object.Root}}, obj *{{$object.Definition.GoType | ref }} {{end}}) graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, {{$object.Definition.GQLType|lcFirst}}Implementors)\n\t{{if $object.Root}}\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tObject: {{$object.Definition.GQLType|quote}},\n\t\t})\n\t{{end}}\n\n\tout := graphql.NewFieldSet(fields)\n\tinvalid := false\n\tfor i, field := range fields {\n\t\tswitch field.Name {\n\t\tcase \"__typename\":\n\t\t\tout.Values[i] = graphql.MarshalString({{$object.Definition.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\tfield := field\n\t\t\t\tout.Concurrently(i, func() (res graphql.Marshaler) {\n\t\t\t\t\tres = ec._{{$object.Definition.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\t\tif res == graphql.Null {\n\t\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t\t}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\treturn res\n\t\t\t\t})\n\t\t\t{{- else }}\n\t\t\t\tout.Values[i] = ec._{{$object.Definition.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\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\tout.Dispatch()\n\tif invalid { return graphql.Null }\n\treturn out\n}\n{{- end }}\n", "resolver.gotpl": "package {{ .PackageName }}\n\nimport (\n\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/99designs/gqlgen/handler\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\ntype {{.ResolverType}} struct {}\n\n{{ range $object := .Objects -}}\n\t{{- if $object.HasResolvers -}}\n\t\tfunc (r *{{$.ResolverType}}) {{$object.Definition.GQLType}}() {{ $object.ResolverInterface | ref }} {\n\t\t\treturn &{{lcFirst $object.Definition.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.Definition.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.Definition.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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"log\" }}\n\t{{ reserveImport \"net/http\" }}\n\t{{ reserveImport \"os\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/handler\" }}\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({{ lookupImport .ExecPackageName }}.NewExecutableSchema({{ lookupImport .ExecPackageName}}.Config{Resolvers: &{{ lookupImport .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 2c1f89aa353..5a678cba422 100644 --- a/codegen/templates/field.gotpl +++ b/codegen/templates/field.gotpl @@ -82,7 +82,7 @@ {{- end }} return graphql.Null } - res := resTmp.({{$field.Signature}}) + res := resTmp.({{$field.GoType | ref}}) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) {{ $field.WriteJson }} diff --git a/codegen/templates/input.gotpl b/codegen/templates/input.gotpl index 6b9167ec74d..6e98739be00 100644 --- a/codegen/templates/input.gotpl +++ b/codegen/templates/input.gotpl @@ -88,13 +88,13 @@ if data, ok := c{{$field.GoFieldName}}.({{ $field.Definition.GoType | ref }}); ok { obj.{{$field.GoFieldName}} = &data } else { - return obj, errors.New("expect {{ $field.Signature }}") + return obj, errors.New("expect {{ $field.GoType | ref }}") } {{else}} - if data, ok := c{{$field.GoFieldName}}.({{ $field.Signature }}); ok{ + if data, ok := c{{$field.GoFieldName}}.({{ $field.GoType | ref }}); ok{ obj.{{$field.GoFieldName}} = data }else{ - return obj, errors.New("{{$field.GoFieldName}} expect {{$field.Signature }}") + return obj, errors.New("{{$field.GoFieldName}} expect {{$field.GoType | ref }}") } {{ end }} diff --git a/codegen/templates/models.gotpl b/codegen/templates/models.gotpl index 606f732e314..b00b84ab13a 100644 --- a/codegen/templates/models.gotpl +++ b/codegen/templates/models.gotpl @@ -32,7 +32,7 @@ import ( {{- with .Description}} {{.|prefixLines "// "}} {{- end}} - {{ $field.GoFieldName }} {{$field.Signature}} `json:"{{$field.GQLName}}"` + {{ $field.GoFieldName }} {{$field.GoType | ref}} `json:"{{$field.GQLName}}"` {{- end }} } diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index f74b8933837..c0173077736 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -144,7 +144,7 @@ type QueryResolver interface { NestedInputs(ctx context.Context, input [][]*OuterInput) (*bool, error) NestedOutputs(ctx context.Context) ([][]*OuterObject, error) Keywords(ctx context.Context, input *Keywords) (bool, error) - Shapes(ctx context.Context) ([]*Shape, error) + Shapes(ctx context.Context) ([]Shape, error) ErrorBubble(ctx context.Context) (*Error, error) ModelMethods(ctx context.Context) (*ModelMethods, error) Valid(ctx context.Context) (string, error) @@ -2317,7 +2317,7 @@ func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field grap idx1 := idx1 rctx := &graphql.ResolverContext{ Index: &idx1, - Result: res[idx1], + Result: &res[idx1], } ctx := graphql.WithResolverContext(ctx, rctx) f := func(idx1 int) { @@ -2427,7 +2427,7 @@ func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.Col if resTmp == nil { return graphql.Null } - res := resTmp.([]*Shape) + res := resTmp.([]Shape) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -2443,7 +2443,7 @@ func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.Col idx1 := idx1 rctx := &graphql.ResolverContext{ Index: &idx1, - Result: res[idx1], + Result: &res[idx1], } ctx := graphql.WithResolverContext(ctx, rctx) f := func(idx1 int) { @@ -2452,11 +2452,7 @@ func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.Col } arr1[idx1] = func() graphql.Marshaler { - if res[idx1] == nil { - return graphql.Null - } - - return ec._Shape(ctx, field.Selections, res[idx1]) + return ec._Shape(ctx, field.Selections, &res[idx1]) }() } if isLen1 { diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index e48a0354ac3..99f5e3b860f 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -60,7 +60,7 @@ func (r *queryResolver) NestedOutputs(ctx context.Context) ([][]*OuterObject, er func (r *queryResolver) Keywords(ctx context.Context, input *Keywords) (bool, error) { panic("not implemented") } -func (r *queryResolver) Shapes(ctx context.Context) ([]*Shape, error) { +func (r *queryResolver) Shapes(ctx context.Context) ([]Shape, error) { panic("not implemented") } func (r *queryResolver) ErrorBubble(ctx context.Context) (*Error, error) { diff --git a/codegen/type_build.go b/codegen/type_build.go index bb6f2aa8f71..f384c8fe289 100644 --- a/codegen/type_build.go +++ b/codegen/type_build.go @@ -28,7 +28,7 @@ func (g *Generator) buildNamedTypes(prog *loader.Program) (NamedTypes, error) { } pkgName, typeName = pkgAndType(userEntry.Model) - } else if t.IsScalar { + } else if t.IsScalar && schemaType.Kind != ast.Enum { pkgName = "github.com/99designs/gqlgen/graphql" typeName = "String" } else { diff --git a/codegen/type_definition.go b/codegen/type_definition.go index f7f68c41a7b..20b5353c213 100644 --- a/codegen/type_definition.go +++ b/codegen/type_definition.go @@ -20,11 +20,6 @@ type TypeDefinition struct { Unmarshaler *types.Func // When using external marshalling functions this will point to the Unmarshal function } -const ( - modList = "[]" - modPtr = "*" -) - func (t TypeDefinition) IsMarshaled() bool { return t.Marshaler != nil || t.Unmarshaler != nil } @@ -34,31 +29,28 @@ func (t TypeDefinition) IsEmptyInterface() bool { return isInterface && i.NumMethods() == 0 } -func (n NamedTypes) getType(t *ast.Type) *TypeReference { - orig := t - var modifiers []string - for { - if t.Elem != nil { - modifiers = append(modifiers, modList) - t = t.Elem - } else { - if !t.NonNull { - modifiers = append(modifiers, modPtr) - } - if n[t.NamedType] == nil { - panic("missing type " + t.NamedType) - } - res := &TypeReference{ - Definition: n[t.NamedType], - Modifiers: modifiers, - ASTType: orig, - } +func (n NamedTypes) goTypeForAst(t *ast.Type) types.Type { + if t.Elem != nil { + return types.NewSlice(n.goTypeForAst(t.Elem)) + } + + nt := n[t.NamedType] + gt := nt.GoType + if gt == nil { + panic("missing type " + t.NamedType) + } - if res.Definition.IsInterface { - res.StripPtr() - } + if !t.NonNull && !nt.IsInterface { + return types.NewPointer(gt) + } - return res - } + return gt +} + +func (n NamedTypes) getType(t *ast.Type) *TypeReference { + return &TypeReference{ + Definition: n[t.Name()], + GoType: n.goTypeForAst(t), + ASTType: t, } } diff --git a/codegen/type_reference.go b/codegen/type_reference.go index c8a9eb11831..1a2aaf48fbe 100644 --- a/codegen/type_reference.go +++ b/codegen/type_reference.go @@ -3,7 +3,6 @@ package codegen import ( "go/types" "strconv" - "strings" "github.com/99designs/gqlgen/codegen/templates" "github.com/vektah/gqlparser/ast" @@ -13,57 +12,39 @@ import ( type TypeReference struct { Definition *TypeDefinition - Modifiers []string - ASTType *ast.Type -} - -func (t TypeReference) Signature() string { - return strings.Join(t.Modifiers, "") + templates.CurrentImports.LookupType(t.Definition.GoType) -} - -func (t TypeReference) FullSignature() string { - return strings.Join(t.Modifiers, "") + types.TypeString(t.Definition.GoType, nil) + GoType types.Type + ASTType *ast.Type } +// todo @vektah: This should probably go away, its too easy to conflate gql required vs go pointer func (t TypeReference) IsPtr() bool { - return len(t.Modifiers) > 0 && t.Modifiers[0] == modPtr -} - -func (t *TypeReference) StripPtr() { - if !t.IsPtr() { - return - } - t.Modifiers = t.Modifiers[0 : len(t.Modifiers)-1] -} - -func (t TypeReference) IsSlice() bool { - return len(t.Modifiers) > 0 && t.Modifiers[0] == modList || - len(t.Modifiers) > 1 && t.Modifiers[0] == modPtr && t.Modifiers[1] == modList + _, isPtr := t.GoType.(*types.Pointer) + return isPtr } func (t TypeReference) Unmarshal(result, raw string) string { - return t.unmarshal(result, raw, t.Modifiers, 1) + return t.unmarshal(result, raw, t.GoType, 1) } -func (t TypeReference) unmarshal(result, raw string, remainingMods []string, depth int) string { - switch { - case len(remainingMods) > 0 && remainingMods[0] == modPtr: +func (t TypeReference) unmarshal(result, raw string, destType types.Type, depth int) string { + switch destType := destType.(type) { + case *types.Pointer: ptr := "ptr" + strconv.Itoa(depth) - return tpl(`var {{.ptr}} {{.mods}}{{.t.Definition.GoType | ref }} + return tpl(`var {{.ptr}} {{.destType | ref }} if {{.raw}} != nil { {{.next}} {{.result}} = &{{.ptr -}} } `, map[string]interface{}{ - "ptr": ptr, - "t": t, - "raw": raw, - "result": result, - "mods": strings.Join(remainingMods[1:], ""), - "next": t.unmarshal(ptr, raw, remainingMods[1:], depth+1), + "ptr": ptr, + "t": t, + "raw": raw, + "result": result, + "destType": destType.Elem(), + "next": t.unmarshal(ptr, raw, destType.Elem(), depth+1), }) - case len(remainingMods) > 0 && remainingMods[0] == modList: + case *types.Slice: var rawIf = "rawIf" + strconv.Itoa(depth) var index = "idx" + strconv.Itoa(depth) @@ -75,7 +56,7 @@ func (t TypeReference) unmarshal(result, raw string, remainingMods []string, dep {{.rawSlice}} = []interface{}{ {{.raw}} } } } - {{.result}} = make({{.type}}, len({{.rawSlice}})) + {{.result}} = make({{.destType | ref}}, len({{.rawSlice}})) for {{.index}} := range {{.rawSlice}} { {{ .next -}} }`, map[string]interface{}{ @@ -83,8 +64,8 @@ func (t TypeReference) unmarshal(result, raw string, remainingMods []string, dep "rawSlice": rawIf, "index": index, "result": result, - "type": strings.Join(remainingMods, "") + templates.CurrentImports.LookupType(t.Definition.GoType), - "next": t.unmarshal(result+"["+index+"]", rawIf+"["+index+"]", remainingMods[1:], depth+1), + "destType": destType, + "next": t.unmarshal(result+"["+index+"]", rawIf+"["+index+"]", destType.Elem(), depth+1), }) } @@ -106,12 +87,24 @@ func (t TypeReference) unmarshal(result, raw string, remainingMods []string, dep } func (t TypeReference) Middleware(result, raw string) string { - return t.middleware(result, raw, t.Modifiers, 1) + return t.middleware(result, raw, t.GoType, 1) } -func (t TypeReference) middleware(result, raw string, remainingMods []string, depth int) string { - if len(remainingMods) == 1 && remainingMods[0] == modPtr { - return tpl(` +func (t TypeReference) middleware(result, raw string, destType types.Type, depth int) string { + switch destType := destType.(type) { + case *types.Pointer: + switch destType.Elem().(type) { + case *types.Pointer, *types.Slice: + return tpl(`if {{.raw}} != nil { + {{.next}} + }`, map[string]interface{}{ + "t": t, + "raw": raw, + "result": result, + "next": t.middleware(result, raw, destType.Elem(), depth+1), + }) + default: + return tpl(` if {{.raw}} != nil { var err error {{.result}}, err = e.{{ .t.Definition.GQLType }}Middleware(ctx, {{.raw}}) @@ -119,24 +112,13 @@ func (t TypeReference) middleware(result, raw string, remainingMods []string, de return nil, err } }`, map[string]interface{}{ - "result": result, - "raw": raw, - "t": t, - }) - } - switch { - case len(remainingMods) > 0 && remainingMods[0] == modPtr: - return tpl(`if {{.raw}} != nil { - {{.next}} - }`, map[string]interface{}{ - "t": t, - "raw": raw, - "result": result, - "mods": strings.Join(remainingMods[1:], ""), - "next": t.middleware(result, raw, remainingMods[1:], depth+1), - }) + "result": result, + "raw": raw, + "t": t, + }) + } - case len(remainingMods) > 0 && remainingMods[0] == modList: + case *types.Slice: var index = "idx" + strconv.Itoa(depth) return tpl(`for {{.index}} := range {{.raw}} { @@ -145,8 +127,7 @@ func (t TypeReference) middleware(result, raw string, remainingMods []string, de "raw": raw, "index": index, "result": result, - "type": strings.Join(remainingMods, "") + templates.CurrentImports.LookupType(t.Definition.GoType), - "next": t.middleware(result+"["+index+"]", raw+"["+index+"]", remainingMods[1:], depth+1), + "next": t.middleware(result+"["+index+"]", raw+"["+index+"]", destType.Elem(), depth+1), }) } diff --git a/codegen/util.go b/codegen/util.go index 2c91b45ccb6..0b72abada3f 100644 --- a/codegen/util.go +++ b/codegen/util.go @@ -319,7 +319,7 @@ nextArg: for _, oldArg := range field.Args { if strings.EqualFold(oldArg.GQLName, param.Name()) { if !field.ForceResolver { - oldArg.TypeReference.Modifiers = modifiersFromGoType(param.Type()) + oldArg.TypeReference.GoType = param.Type() } newArgs = append(newArgs, oldArg) continue nextArg @@ -333,36 +333,17 @@ nextArg: } func validateTypeBinding(field *Field, goType types.Type) error { - gqlType := normalizeVendor(field.TypeReference.FullSignature()) + gqlType := normalizeVendor(field.TypeReference.GoType.String()) goTypeStr := normalizeVendor(goType.String()) if equalTypes(goTypeStr, gqlType) { - field.TypeReference.Modifiers = modifiersFromGoType(goType) + field.TypeReference.GoType = goType return nil } return fmt.Errorf("%s is not compatible with %s", gqlType, goTypeStr) } -func modifiersFromGoType(t types.Type) []string { - var modifiers []string - for { - switch val := t.(type) { - case *types.Pointer: - modifiers = append(modifiers, modPtr) - t = val.Elem() - case *types.Array: - modifiers = append(modifiers, modList) - t = val.Elem() - case *types.Slice: - modifiers = append(modifiers, modList) - t = val.Elem() - default: - return modifiers - } - } -} - var modsRegex = regexp.MustCompile(`^(\*|\[\])*`) func normalizeVendor(pkg string) string { diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index 5abb745658c..046d597b4cb 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -1106,7 +1106,7 @@ func (ec *executionContext) _Query_torture2d(ctx context.Context, field graphql. idx1 := idx1 rctx := &graphql.ResolverContext{ Index: &idx1, - Result: res[idx1], + Result: &res[idx1], } ctx := graphql.WithResolverContext(ctx, rctx) f := func(idx1 int) { From afc773b1133ae173c285e68c5b4d2a8f0e24209d Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Tue, 8 Jan 2019 14:21:37 +1100 Subject: [PATCH 032/147] Use ast definition directly, instead of copying --- codegen/directive_build.go | 2 +- codegen/enum_build.go | 4 ++-- codegen/generator.go | 8 ++++---- codegen/input_build.go | 10 +++++++--- codegen/interface_build.go | 2 +- codegen/models_build.go | 2 +- codegen/object.go | 20 ++++++++++---------- codegen/object_build.go | 8 ++++---- codegen/templates/args.gotpl | 2 +- codegen/templates/data.go | 16 ++++++++-------- codegen/templates/field.gotpl | 6 +++--- codegen/templates/generated.gotpl | 18 +++++++++--------- codegen/templates/input.gotpl | 6 +++--- codegen/templates/interface.gotpl | 6 +++--- codegen/templates/models.gotpl | 4 ++-- codegen/templates/object.gotpl | 22 +++++++++++----------- codegen/templates/resolver.gotpl | 8 ++++---- codegen/type_build.go | 27 +++++++-------------------- codegen/type_definition.go | 13 +++++-------- codegen/type_reference.go | 6 +++--- codegen/util.go | 2 +- 21 files changed, 90 insertions(+), 102 deletions(-) diff --git a/codegen/directive_build.go b/codegen/directive_build.go index 31a9d7f912f..e27a08ce479 100644 --- a/codegen/directive_build.go +++ b/codegen/directive_build.go @@ -25,7 +25,7 @@ func (g *Generator) buildDirectives(types NamedTypes) (map[string]*Directive, er GoVarName: sanitizeArgName(arg.Name), } - if !newArg.TypeReference.Definition.IsInput && !newArg.TypeReference.Definition.IsScalar { + if !newArg.TypeReference.Definition.GQLDefinition.IsInputType() { return nil, errors.Errorf("%s cannot be used as argument of directive %s(%s) only input and scalar types are allowed", arg.Type, dir.Name, arg.Name) } diff --git a/codegen/enum_build.go b/codegen/enum_build.go index 7fe2ae58687..c476ed01b74 100644 --- a/codegen/enum_build.go +++ b/codegen/enum_build.go @@ -29,13 +29,13 @@ func (g *Generator) buildEnums(ts NamedTypes) []Enum { Description: typ.Description, } - enum.Definition.GoType = types.NewNamed(types.NewTypeName(0, g.Config.Model.Pkg(), templates.ToCamel(enum.Definition.GQLType), nil), nil, nil) + enum.Definition.GoType = types.NewNamed(types.NewTypeName(0, g.Config.Model.Pkg(), templates.ToCamel(enum.Definition.GQLDefinition.Name), nil), nil, nil) enums = append(enums, enum) } sort.Slice(enums, func(i, j int) bool { - return enums[i].Definition.GQLType < enums[j].Definition.GQLType + return enums[i].Definition.GQLDefinition.Name < enums[j].Definition.GQLDefinition.Name }) return enums diff --git a/codegen/generator.go b/codegen/generator.go index f8caaf64b9a..a85a5ff8fed 100644 --- a/codegen/generator.go +++ b/codegen/generator.go @@ -51,15 +51,15 @@ func (g *Generator) Generate() error { } for _, model := range modelsBuild.Models { - modelCfg := g.Models[model.Definition.GQLType] + modelCfg := g.Models[model.Definition.GQLDefinition.Name] modelCfg.Model = types.TypeString(model.Definition.GoType, nil) - g.Models[model.Definition.GQLType] = modelCfg + g.Models[model.Definition.GQLDefinition.Name] = modelCfg } for _, enum := range modelsBuild.Enums { - modelCfg := g.Models[enum.Definition.GQLType] + modelCfg := g.Models[enum.Definition.GQLDefinition.Name] modelCfg.Model = types.TypeString(enum.Definition.GoType, nil) - g.Models[enum.Definition.GQLType] = modelCfg + g.Models[enum.Definition.GQLDefinition.Name] = modelCfg } } diff --git a/codegen/input_build.go b/codegen/input_build.go index 88625759862..519e3373038 100644 --- a/codegen/input_build.go +++ b/codegen/input_build.go @@ -33,7 +33,7 @@ func (g *Generator) buildInputs(namedTypes NamedTypes, prog *loader.Program) (Ob } sort.Slice(inputs, func(i, j int) bool { - return inputs[i].Definition.GQLType < inputs[j].Definition.GQLType + return inputs[i].Definition.GQLDefinition.Name < inputs[j].Definition.GQLDefinition.Name }) return inputs, nil @@ -69,8 +69,12 @@ func (g *Generator) buildInput(types NamedTypes, typ *ast.Definition) (*Object, } } - if !newField.TypeReference.Definition.IsInput && !newField.TypeReference.Definition.IsScalar { - return nil, errors.Errorf("%s cannot be used as a field of %s. only input and scalar types are allowed", newField.Definition.GQLType, obj.Definition.GQLType) + if !newField.TypeReference.Definition.GQLDefinition.IsInputType() { + return nil, errors.Errorf( + "%s cannot be used as a field of %s. only input and scalar types are allowed", + newField.Definition.GQLDefinition.Name, + obj.Definition.GQLDefinition.Name, + ) } obj.Fields = append(obj.Fields, newField) diff --git a/codegen/interface_build.go b/codegen/interface_build.go index a38d22af1fa..1cc63229ba0 100644 --- a/codegen/interface_build.go +++ b/codegen/interface_build.go @@ -17,7 +17,7 @@ func (g *Generator) buildInterfaces(types NamedTypes, prog *loader.Program) []*I } sort.Slice(interfaces, func(i, j int) bool { - return interfaces[i].Definition.GQLType < interfaces[j].Definition.GQLType + return interfaces[i].Definition.GQLDefinition.Name < interfaces[j].Definition.GQLDefinition.Name }) return interfaces diff --git a/codegen/models_build.go b/codegen/models_build.go index bef81fac25b..5eb707c7d4d 100644 --- a/codegen/models_build.go +++ b/codegen/models_build.go @@ -43,7 +43,7 @@ func (g *Generator) buildModels(types NamedTypes, prog *loader.Program) ([]Model } sort.Slice(models, func(i, j int) bool { - return models[i].Definition.GQLType < models[j].Definition.GQLType + return models[i].Definition.GQLDefinition.Name < models[j].Definition.GQLDefinition.Name }) return models, nil diff --git a/codegen/object.go b/codegen/object.go index 62b1835e69c..afdbcf12e40 100644 --- a/codegen/object.go +++ b/codegen/object.go @@ -64,7 +64,7 @@ type FieldArgument struct { type Objects []*Object func (o *Object) Implementors() string { - satisfiedBy := strconv.Quote(o.Definition.GQLType) + satisfiedBy := strconv.Quote(o.Definition.GQLDefinition.Name) for _, s := range o.Satisfies { satisfiedBy += ", " + strconv.Quote(s) } @@ -102,7 +102,7 @@ func (o *Object) IsConcurrent() bool { } func (o *Object) IsReserved() bool { - return strings.HasPrefix(o.Definition.GQLType, "__") + return strings.HasPrefix(o.Definition.GQLDefinition.Name, "__") } func (f *Field) HasDirectives() bool { @@ -145,7 +145,7 @@ func (f *Field) ShortInvocation() string { return "" } - return fmt.Sprintf("%s().%s(%s)", f.Object.Definition.GQLType, f.GoNameExported(), f.CallArgs()) + return fmt.Sprintf("%s().%s(%s)", f.Object.Definition.GQLDefinition.Name, f.GoNameExported(), f.CallArgs()) } func (f *Field) ArgsFunc() string { @@ -153,7 +153,7 @@ func (f *Field) ArgsFunc() string { return "" } - return "field_" + f.Object.Definition.GQLType + "_" + f.GQLName + "_args" + return "field_" + f.Object.Definition.GQLDefinition.Name + "_" + f.GQLName + "_args" } func (f *Field) ResolverType() string { @@ -161,7 +161,7 @@ func (f *Field) ResolverType() string { return "" } - return fmt.Sprintf("%s().%s(%s)", f.Object.Definition.GQLType, f.GoNameExported(), f.CallArgs()) + return fmt.Sprintf("%s().%s(%s)", f.Object.Definition.GQLDefinition.Name, f.GoNameExported(), f.CallArgs()) } func (f *Field) ShortResolverDeclaration() string { @@ -190,7 +190,7 @@ func (f *Field) ResolverDeclaration() string { if !f.IsResolver() { return "" } - res := fmt.Sprintf("%s_%s(ctx context.Context", f.Object.Definition.GQLType, f.GoNameUnexported()) + res := fmt.Sprintf("%s_%s(ctx context.Context", f.Object.Definition.GQLDefinition.Name, f.GoNameUnexported()) if !f.Object.Root { res += fmt.Sprintf(", obj *%s", templates.CurrentImports.LookupType(f.Object.Definition.GoType)) @@ -329,13 +329,13 @@ func (f *Field) doWriteJson(val string, destType types.Type, astType *ast.Type, "index": index, "top": depth == 1, "arrayLen": len(val), - "isScalar": f.Definition.IsScalar, + "isScalar": f.Definition.GQLDefinition.Kind == ast.Scalar || f.Definition.GQLDefinition.Kind == ast.Enum, "usePtr": usePtr, "next": f.doWriteJson(val+"["+index+"]", destType.Elem(), astType.Elem, false, depth+1), }) default: - if f.Definition.IsScalar { + if f.Definition.GQLDefinition.Kind == ast.Scalar || f.Definition.GQLDefinition.Kind == ast.Enum { if isPtr { val = "*" + val } @@ -347,7 +347,7 @@ func (f *Field) doWriteJson(val string, destType types.Type, astType *ast.Type, } return tpl(` return ec._{{.type}}(ctx, field.Selections, {{.val}})`, map[string]interface{}{ - "type": f.Definition.GQLType, + "type": f.Definition.GQLDefinition.Name, "val": val, }) } @@ -359,7 +359,7 @@ func (f *FieldArgument) Stream() bool { func (os Objects) ByName(name string) *Object { for i, o := range os { - if strings.EqualFold(o.Definition.GQLType, name) { + if strings.EqualFold(o.Definition.GQLDefinition.Name, name) { return os[i] } } diff --git a/codegen/object_build.go b/codegen/object_build.go index 0b506eb6f93..65f9066b9d5 100644 --- a/codegen/object_build.go +++ b/codegen/object_build.go @@ -36,7 +36,7 @@ func (g *Generator) buildObjects(ts NamedTypes, prog *loader.Program) (Objects, } sort.Slice(objects, func(i, j int) bool { - return objects[i].Definition.GQLType < objects[j].Definition.GQLType + return objects[i].Definition.GQLDefinition.Name < objects[j].Definition.GQLDefinition.Name }) return objects, nil @@ -84,7 +84,7 @@ func (g *Generator) buildObject(prog *loader.Program, ts NamedTypes, typ *ast.De obj := &Object{Definition: ts[typ.Name]} typeEntry, entryExists := g.Models[typ.Name] - tt := types.NewTypeName(0, g.Config.Exec.Pkg(), obj.Definition.GQLType+"Resolver", nil) + tt := types.NewTypeName(0, g.Config.Exec.Pkg(), obj.Definition.GQLDefinition.Name+"Resolver", nil) obj.ResolverInterface = types.NewNamed(tt, nil, nil) if typ == g.schema.Query { @@ -168,8 +168,8 @@ func (g *Generator) buildObject(prog *loader.Program, ts NamedTypes, typ *ast.De Directives: dirs, } - if !newArg.TypeReference.Definition.IsInput && !newArg.TypeReference.Definition.IsScalar { - return nil, errors.Errorf("%s cannot be used as argument of %s.%s. only input and scalar types are allowed", arg.Type, obj.Definition.GQLType, field.Name) + if !newArg.TypeReference.Definition.GQLDefinition.IsInputType() { + return nil, errors.Errorf("%s cannot be used as argument of %s.%s. only input and scalar types are allowed", arg.Type, obj.Definition.GQLDefinition.Name, field.Name) } if arg.DefaultValue != nil { diff --git a/codegen/templates/args.gotpl b/codegen/templates/args.gotpl index 18d11700e8b..7b1c934d67a 100644 --- a/codegen/templates/args.gotpl +++ b/codegen/templates/args.gotpl @@ -37,7 +37,7 @@ return nil, err } {{- end }} - {{- if $arg.Definition.IsInput }} + {{- if eq $arg.Definition.GQLDefinition.Kind "INPUT_OBJECT" }} {{ $arg.Middleware (print "arg" $i) (print "arg" $i) }} {{- end }} } diff --git a/codegen/templates/data.go b/codegen/templates/data.go index 2acdce22ea1..0d885d11e3c 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -1,13 +1,13 @@ package templates var data = map[string]string{ - "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.GoType | ref }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if $arg.Directives }}\n\t\t\t\targm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $dArg.IsPtr ( notNil \"Value\" $dArg ) }}\n\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $dArg.Value | dump }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t},\n\t\t\t\t{{- end }}\n\t\t\t\t}...)(ctx, func(ctx2 context.Context) (interface{}, error) {\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn arg{{ $i }}, nil\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.GoType | ref }}); ok {\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.GoType | ref }}\")\n\t\t\t\t}\n\t\t\t{{- else }}\n\t\t\t\tvar err error\n\t\t\t\t{{ $arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\t{{- if $arg.Definition.IsInput }}\n\t\t\t\t{{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", - "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.Definition.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\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\treturn graphql.WriterFunc(func(w io.Writer) {\n\t\t\t\tw.Write([]byte{'{'})\n\t\t\t\tgraphql.MarshalString(field.Alias).MarshalGQL(w)\n\t\t\t\tw.Write([]byte{':'})\n\t\t\t\tfunc() graphql.Marshaler {\n\t\t\t\t\t{{ $field.WriteJson }}\n\t\t\t\t}().MarshalGQL(w)\n\t\t\t\tw.Write([]byte{'}'})\n\t\t\t})\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.Definition.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.Definition.GoType | ref}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.Definition.GQLType|quote}},\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.GoType | ref}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.Definition.GQLType}}() {{$object.Definition.GQLType}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.Definition.GQLType|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.Definition.GQLType}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.Definition.GQLType}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.Definition.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.Definition.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.Definition.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.Definition.GQLType}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.Definition.GQLType}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\n)\n\n\n\n// ChainFieldMiddleware add chain by FieldMiddleware\n// nolint: deadcode\nfunc chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware {\n\tn := len(handleFunc)\n\n\tif n > 1 {\n\t\tlastI := n - 1\n\t\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\t\tvar (\n\t\t\t\tchainHandler graphql.Resolver\n\t\t\t\tcurI int\n\t\t\t)\n\t\t\tchainHandler = func(currentCtx context.Context) (interface{}, error) {\n\t\t\t\tif curI == lastI {\n\t\t\t\t\treturn next(currentCtx)\n\t\t\t\t}\n\t\t\t\tcurI++\n\t\t\t\tres, err := handleFunc[curI](currentCtx, chainHandler)\n\t\t\t\tcurI--\n\t\t\t\treturn res, err\n\n\t\t\t}\n\t\t\treturn handleFunc[0](ctx, chainHandler)\n\t\t}\n\t}\n\n\tif n == 1 {\n\t\treturn handleFunc[0]\n\t}\n\n\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\treturn next(ctx)\n\t}\n}\n", - "input.gotpl": "\t{{- if .Definition.IsMarshaled }}\n\tfunc Unmarshal{{ .Definition.GQLType }}(v interface{}) ({{.Definition.GoType | ref}}, error) {\n\t\tvar it {{.Definition.GoType | ref}}\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\n\tfunc (e *executableSchema) {{ .Definition.GQLType }}Middleware(ctx context.Context, obj *{{.Definition.GoType | ref}}) (*{{.Definition.GoType | ref}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := chainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.Definition.GoType | ref}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.Definition.GoType | ref}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t\tc{{$field.GoFieldName}}, err := chainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\t{{ if $field.IsPtr -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"*obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- else -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{ if $field.IsPtr }}*{{end}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.Definition.GoType | ref }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.GoType | ref }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.GoType | ref }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.GoType | ref }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if $field.Definition.IsInput }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\n", - "interface.gotpl": "{{- $interface := . }}\n\nfunc (ec *executionContext) _{{$interface.Definition.GQLType}}(ctx context.Context, sel ast.SelectionSet, obj *{{$interface.Definition.GoType | ref}}) 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.Definition.GoType | ref}}:\n\t\t\t\treturn ec._{{$implementor.Definition.GQLType}}(ctx, sel, &obj)\n\t\t{{- end}}\n\t\tcase *{{$implementor.Definition.GoType | ref}}:\n\t\t\treturn ec._{{$implementor.Definition.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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{ range $model := .Models }}\n\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .Definition.IsInterface }}\n\t\ttype {{.Definition.GoType | ref }} interface {\n\t\t\tIs{{.Definition.GoType | ref }}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.Definition.GoType | ref }} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\n\t\t\t\t{{ $field.GoFieldName }} {{$field.GoType | ref}} `json:\"{{$field.GQLName}}\"`\n\t\t\t{{- end }}\n\t\t}\n\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.Definition.GoType | ref }}) Is{{$iface.GoType | ref }}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.Definition.GoType | ref }} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- end}}\n\t\t{{$enum.Definition.GoType | ref }}{{ .Name|toCamel }} {{$enum.Definition.GoType | ref }} = {{.Name|quote}}\n\t{{- end }}\n\t)\n\n\tvar All{{.Definition.GoType | ref }} = []{{.Definition.GoType | ref }}{\n\t{{- range $value := .Values}}\n\t\t{{$enum.Definition.GoType | ref }}{{ .Name|toCamel }},\n\t{{- end }}\n\t}\n\n\tfunc (e {{.Definition.GoType | ref }}) IsValid() bool {\n\t\tswitch e {\n\t\tcase {{ range $index, $element := .Values}}{{if $index}},{{end}}{{ $enum.Definition.GoType | ref }}{{ $element.Name|toCamel }}{{end}}:\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tfunc (e {{.Definition.GoType | ref }}) String() string {\n\t\treturn string(e)\n\t}\n\n\tfunc (e *{{.Definition.GoType | ref }}) 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 = {{.Definition.GoType | ref }}(str)\n\t\tif !e.IsValid() {\n\t\t\treturn fmt.Errorf(\"%s is not a valid {{.Definition.GQLType}}\", str)\n\t\t}\n\t\treturn nil\n\t}\n\n\tfunc (e {{.Definition.GoType | ref }}) 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.Definition.GQLType|lcFirst}}Implementors = {{$object.Implementors}}\n\n// nolint: gocyclo, errcheck, gas, goconst\n{{- if .Stream }}\nfunc (ec *executionContext) _{{$object.Definition.GQLType}}(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, {{$object.Definition.GQLType|lcFirst}}Implementors)\n\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\tObject: {{$object.Definition.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.Definition.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.Definition.GQLType}}(ctx context.Context, sel ast.SelectionSet{{if not $object.Root}}, obj *{{$object.Definition.GoType | ref }} {{end}}) graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, {{$object.Definition.GQLType|lcFirst}}Implementors)\n\t{{if $object.Root}}\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tObject: {{$object.Definition.GQLType|quote}},\n\t\t})\n\t{{end}}\n\n\tout := graphql.NewFieldSet(fields)\n\tinvalid := false\n\tfor i, field := range fields {\n\t\tswitch field.Name {\n\t\tcase \"__typename\":\n\t\t\tout.Values[i] = graphql.MarshalString({{$object.Definition.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\tfield := field\n\t\t\t\tout.Concurrently(i, func() (res graphql.Marshaler) {\n\t\t\t\t\tres = ec._{{$object.Definition.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\t\tif res == graphql.Null {\n\t\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t\t}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\treturn res\n\t\t\t\t})\n\t\t\t{{- else }}\n\t\t\t\tout.Values[i] = ec._{{$object.Definition.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\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\tout.Dispatch()\n\tif invalid { return graphql.Null }\n\treturn out\n}\n{{- end }}\n", - "resolver.gotpl": "package {{ .PackageName }}\n\nimport (\n\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/99designs/gqlgen/handler\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\ntype {{.ResolverType}} struct {}\n\n{{ range $object := .Objects -}}\n\t{{- if $object.HasResolvers -}}\n\t\tfunc (r *{{$.ResolverType}}) {{$object.Definition.GQLType}}() {{ $object.ResolverInterface | ref }} {\n\t\t\treturn &{{lcFirst $object.Definition.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.Definition.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.Definition.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", + "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.GoType | ref }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if $arg.Directives }}\n\t\t\t\targm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $dArg.IsPtr ( notNil \"Value\" $dArg ) }}\n\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $dArg.Value | dump }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t},\n\t\t\t\t{{- end }}\n\t\t\t\t}...)(ctx, func(ctx2 context.Context) (interface{}, error) {\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn arg{{ $i }}, nil\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.GoType | ref }}); ok {\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.GoType | ref }}\")\n\t\t\t\t}\n\t\t\t{{- else }}\n\t\t\t\tvar err error\n\t\t\t\t{{ $arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\t{{- if eq $arg.Definition.GQLDefinition.Kind \"INPUT_OBJECT\" }}\n\t\t\t\t{{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", + "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.Definition.GQLDefinition.Name}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\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\treturn graphql.WriterFunc(func(w io.Writer) {\n\t\t\t\tw.Write([]byte{'{'})\n\t\t\t\tgraphql.MarshalString(field.Alias).MarshalGQL(w)\n\t\t\t\tw.Write([]byte{':'})\n\t\t\t\tfunc() graphql.Marshaler {\n\t\t\t\t\t{{ $field.WriteJson }}\n\t\t\t\t}().MarshalGQL(w)\n\t\t\t\tw.Write([]byte{'}'})\n\t\t\t})\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.Definition.GQLDefinition.Name}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.Definition.GoType | ref}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.Definition.GQLDefinition.Name|quote}},\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.GoType | ref}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.Definition.GQLDefinition.Name}}() {{$object.Definition.GQLDefinition.Name}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.Definition.GQLDefinition.Name|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.Definition.GQLDefinition.Name}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.Definition.GQLDefinition.Name}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.Definition.GQLDefinition.Name|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.Definition.GQLDefinition.Name|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.Definition.GQLDefinition.Name}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.Definition.GQLDefinition.Name}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.Definition.GQLDefinition.Name}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\n)\n\n\n\n// ChainFieldMiddleware add chain by FieldMiddleware\n// nolint: deadcode\nfunc chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware {\n\tn := len(handleFunc)\n\n\tif n > 1 {\n\t\tlastI := n - 1\n\t\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\t\tvar (\n\t\t\t\tchainHandler graphql.Resolver\n\t\t\t\tcurI int\n\t\t\t)\n\t\t\tchainHandler = func(currentCtx context.Context) (interface{}, error) {\n\t\t\t\tif curI == lastI {\n\t\t\t\t\treturn next(currentCtx)\n\t\t\t\t}\n\t\t\t\tcurI++\n\t\t\t\tres, err := handleFunc[curI](currentCtx, chainHandler)\n\t\t\t\tcurI--\n\t\t\t\treturn res, err\n\n\t\t\t}\n\t\t\treturn handleFunc[0](ctx, chainHandler)\n\t\t}\n\t}\n\n\tif n == 1 {\n\t\treturn handleFunc[0]\n\t}\n\n\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\treturn next(ctx)\n\t}\n}\n", + "input.gotpl": "\t{{- if .Definition.IsMarshaled }}\n\tfunc Unmarshal{{ .Definition.GQLDefinition.Name }}(v interface{}) ({{.Definition.GoType | ref}}, error) {\n\t\tvar it {{.Definition.GoType | ref}}\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\n\tfunc (e *executableSchema) {{ .Definition.GQLDefinition.Name }}Middleware(ctx context.Context, obj *{{.Definition.GoType | ref}}) (*{{.Definition.GoType | ref}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := chainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.Definition.GoType | ref}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.Definition.GoType | ref}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t\tc{{$field.GoFieldName}}, err := chainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\t{{ if $field.IsPtr -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"*obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- else -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{ if $field.IsPtr }}*{{end}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.Definition.GoType | ref }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.GoType | ref }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.GoType | ref }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.GoType | ref }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if eq $field.Definition.GQLDefinition.Kind \"INPUT_OBJECT\" }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\n", + "interface.gotpl": "{{- $interface := . }}\n\nfunc (ec *executionContext) _{{$interface.Definition.GQLDefinition.Name}}(ctx context.Context, sel ast.SelectionSet, obj *{{$interface.Definition.GoType | ref}}) 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.Definition.GoType | ref}}:\n\t\t\t\treturn ec._{{$implementor.Definition.GQLDefinition.Name}}(ctx, sel, &obj)\n\t\t{{- end}}\n\t\tcase *{{$implementor.Definition.GoType | ref}}:\n\t\t\treturn ec._{{$implementor.Definition.GQLDefinition.Name}}(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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{ range $model := .Models }}\n\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .Definition.GQLDefinition.IsAbstractType }}\n\t\ttype {{.Definition.GoType | ref }} interface {\n\t\t\tIs{{.Definition.GoType | ref }}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.Definition.GoType | ref }} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\n\t\t\t\t{{ $field.GoFieldName }} {{$field.GoType | ref}} `json:\"{{$field.GQLName}}\"`\n\t\t\t{{- end }}\n\t\t}\n\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.Definition.GoType | ref }}) Is{{$iface.GoType | ref }}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.Definition.GoType | ref }} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- end}}\n\t\t{{$enum.Definition.GoType | ref }}{{ .Name|toCamel }} {{$enum.Definition.GoType | ref }} = {{.Name|quote}}\n\t{{- end }}\n\t)\n\n\tvar All{{.Definition.GoType | ref }} = []{{.Definition.GoType | ref }}{\n\t{{- range $value := .Values}}\n\t\t{{$enum.Definition.GoType | ref }}{{ .Name|toCamel }},\n\t{{- end }}\n\t}\n\n\tfunc (e {{.Definition.GoType | ref }}) IsValid() bool {\n\t\tswitch e {\n\t\tcase {{ range $index, $element := .Values}}{{if $index}},{{end}}{{ $enum.Definition.GoType | ref }}{{ $element.Name|toCamel }}{{end}}:\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tfunc (e {{.Definition.GoType | ref }}) String() string {\n\t\treturn string(e)\n\t}\n\n\tfunc (e *{{.Definition.GoType | ref }}) 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 = {{.Definition.GoType | ref }}(str)\n\t\tif !e.IsValid() {\n\t\t\treturn fmt.Errorf(\"%s is not a valid {{.Definition.GQLDefinition.Name}}\", str)\n\t\t}\n\t\treturn nil\n\t}\n\n\tfunc (e {{.Definition.GoType | ref }}) 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.Definition.GQLDefinition.Name|lcFirst}}Implementors = {{$object.Implementors}}\n\n// nolint: gocyclo, errcheck, gas, goconst\n{{- if .Stream }}\nfunc (ec *executionContext) _{{$object.Definition.GQLDefinition.Name}}(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, {{$object.Definition.GQLDefinition.Name|lcFirst}}Implementors)\n\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\tObject: {{$object.Definition.GQLDefinition.Name|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.Definition.GQLDefinition.Name}}_{{$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.Definition.GQLDefinition.Name}}(ctx context.Context, sel ast.SelectionSet{{if not $object.Root}}, obj *{{$object.Definition.GoType | ref }} {{end}}) graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, {{$object.Definition.GQLDefinition.Name|lcFirst}}Implementors)\n\t{{if $object.Root}}\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tObject: {{$object.Definition.GQLDefinition.Name|quote}},\n\t\t})\n\t{{end}}\n\n\tout := graphql.NewFieldSet(fields)\n\tinvalid := false\n\tfor i, field := range fields {\n\t\tswitch field.Name {\n\t\tcase \"__typename\":\n\t\t\tout.Values[i] = graphql.MarshalString({{$object.Definition.GQLDefinition.Name|quote}})\n\t\t{{- range $field := $object.Fields }}\n\t\tcase \"{{$field.GQLName}}\":\n\t\t\t{{- if $field.IsConcurrent }}\n\t\t\t\tfield := field\n\t\t\t\tout.Concurrently(i, func() (res graphql.Marshaler) {\n\t\t\t\t\tres = ec._{{$object.Definition.GQLDefinition.Name}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\t\tif res == graphql.Null {\n\t\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t\t}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\treturn res\n\t\t\t\t})\n\t\t\t{{- else }}\n\t\t\t\tout.Values[i] = ec._{{$object.Definition.GQLDefinition.Name}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\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\tout.Dispatch()\n\tif invalid { return graphql.Null }\n\treturn out\n}\n{{- end }}\n", + "resolver.gotpl": "package {{ .PackageName }}\n\nimport (\n\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/99designs/gqlgen/handler\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\ntype {{.ResolverType}} struct {}\n\n{{ range $object := .Objects -}}\n\t{{- if $object.HasResolvers -}}\n\t\tfunc (r *{{$.ResolverType}}) {{$object.Definition.GQLDefinition.Name}}() {{ $object.ResolverInterface | ref }} {\n\t\t\treturn &{{lcFirst $object.Definition.GQLDefinition.Name}}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.Definition.GQLDefinition.Name}}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.Definition.GQLDefinition.Name}}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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"log\" }}\n\t{{ reserveImport \"net/http\" }}\n\t{{ reserveImport \"os\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/handler\" }}\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({{ lookupImport .ExecPackageName }}.NewExecutableSchema({{ lookupImport .ExecPackageName}}.Config{Resolvers: &{{ lookupImport .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 5a678cba422..6856d791558 100644 --- a/codegen/templates/field.gotpl +++ b/codegen/templates/field.gotpl @@ -2,7 +2,7 @@ {{ $object := $field.Object }} {{- if $object.Stream }} - func (ec *executionContext) _{{$object.Definition.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { + func (ec *executionContext) _{{$object.Definition.GQLDefinition.Name}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Field: field, Args: nil, @@ -41,11 +41,11 @@ } {{ else }} // nolint: vetshadow - func (ec *executionContext) _{{$object.Definition.GQLType}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.Definition.GoType | ref}}{{end}}) graphql.Marshaler { + func (ec *executionContext) _{{$object.Definition.GQLDefinition.Name}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.Definition.GoType | ref}}{{end}}) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func () { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: {{$object.Definition.GQLType|quote}}, + Object: {{$object.Definition.GQLDefinition.Name|quote}}, Field: field, Args: nil, } diff --git a/codegen/templates/generated.gotpl b/codegen/templates/generated.gotpl index 1a1c2250a4a..5b346eb62ba 100644 --- a/codegen/templates/generated.gotpl +++ b/codegen/templates/generated.gotpl @@ -38,7 +38,7 @@ type Config struct { type ResolverRoot interface { {{- range $object := .Objects -}} {{ if $object.HasResolvers -}} - {{$object.Definition.GQLType}}() {{$object.Definition.GQLType}}Resolver + {{$object.Definition.GQLDefinition.Name}}() {{$object.Definition.GQLDefinition.Name}}Resolver {{ end }} {{- end }} } @@ -52,7 +52,7 @@ type DirectiveRoot struct { type ComplexityRoot struct { {{ range $object := .Objects }} {{ if not $object.IsReserved -}} - {{ $object.Definition.GQLType|toCamel }} struct { + {{ $object.Definition.GQLDefinition.Name|toCamel }} struct { {{ range $field := $object.Fields -}} {{ if not $field.IsReserved -}} {{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }} @@ -65,7 +65,7 @@ type ComplexityRoot struct { {{ range $object := .Objects -}} {{ if $object.HasResolvers }} - type {{$object.Definition.GQLType}}Resolver interface { + type {{$object.Definition.GQLDefinition.Name}}Resolver interface { {{ range $field := $object.Fields -}} {{ $field.ShortResolverDeclaration }} {{ end }} @@ -107,8 +107,8 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in {{ if not $object.IsReserved }} {{ range $field := $object.Fields }} {{ if not $field.IsReserved }} - case "{{$object.Definition.GQLType}}.{{$field.GQLName}}": - if e.complexity.{{$object.Definition.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil { + case "{{$object.Definition.GQLDefinition.Name}}.{{$field.GQLName}}": + if e.complexity.{{$object.Definition.GQLDefinition.Name|toCamel}}.{{$field.GQLName|toCamel}} == nil { break } {{ if $field.Args }} @@ -117,7 +117,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } {{ end }} - return e.complexity.{{$object.Definition.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true + return e.complexity.{{$object.Definition.GQLDefinition.Name|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true {{ end }} {{ end }} {{ end }} @@ -131,7 +131,7 @@ func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinitio ec := executionContext{graphql.GetRequestContext(ctx), e} buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._{{.QueryRoot.Definition.GQLType}}(ctx, op.SelectionSet) + data := ec._{{.QueryRoot.Definition.GQLDefinition.Name}}(ctx, op.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) return buf.Bytes() @@ -151,7 +151,7 @@ func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefini ec := executionContext{graphql.GetRequestContext(ctx), e} buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._{{.MutationRoot.Definition.GQLType}}(ctx, op.SelectionSet) + data := ec._{{.MutationRoot.Definition.GQLDefinition.Name}}(ctx, op.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) return buf.Bytes() @@ -171,7 +171,7 @@ func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDe {{- if .SubscriptionRoot }} ec := executionContext{graphql.GetRequestContext(ctx), e} - next := ec._{{.SubscriptionRoot.Definition.GQLType}}(ctx, op.SelectionSet) + next := ec._{{.SubscriptionRoot.Definition.GQLDefinition.Name}}(ctx, op.SelectionSet) if ec.Errors != nil { return graphql.OneShot(&graphql.Response{Data: []byte("null"), Errors: ec.Errors}) } diff --git a/codegen/templates/input.gotpl b/codegen/templates/input.gotpl index 6e98739be00..62df22eface 100644 --- a/codegen/templates/input.gotpl +++ b/codegen/templates/input.gotpl @@ -1,5 +1,5 @@ {{- if .Definition.IsMarshaled }} - func Unmarshal{{ .Definition.GQLType }}(v interface{}) ({{.Definition.GoType | ref}}, error) { + func Unmarshal{{ .Definition.GQLDefinition.Name }}(v interface{}) ({{.Definition.GoType | ref}}, error) { var it {{.Definition.GoType | ref}} var asMap = v.(map[string]interface{}) {{ range $field := .Fields}} @@ -27,7 +27,7 @@ } {{- end }} - func (e *executableSchema) {{ .Definition.GQLType }}Middleware(ctx context.Context, obj *{{.Definition.GoType | ref}}) (*{{.Definition.GoType | ref}}, error) { + func (e *executableSchema) {{ .Definition.GQLDefinition.Name }}Middleware(ctx context.Context, obj *{{.Definition.GoType | ref}}) (*{{.Definition.GoType | ref}}, error) { {{ if .Directives }} cObj, err := chainFieldMiddleware( []graphql.FieldMiddleware{ @@ -100,7 +100,7 @@ {{- end }} - {{ if $field.Definition.IsInput }} + {{ if eq $field.Definition.GQLDefinition.Kind "INPUT_OBJECT" }} {{ $field.Middleware (print "obj." $field.GoFieldName ) (print "obj." $field.GoFieldName ) }} {{- end }} {{- end }} diff --git a/codegen/templates/interface.gotpl b/codegen/templates/interface.gotpl index 490e0f62f82..8d6ba51691a 100644 --- a/codegen/templates/interface.gotpl +++ b/codegen/templates/interface.gotpl @@ -1,16 +1,16 @@ {{- $interface := . }} -func (ec *executionContext) _{{$interface.Definition.GQLType}}(ctx context.Context, sel ast.SelectionSet, obj *{{$interface.Definition.GoType | ref}}) graphql.Marshaler { +func (ec *executionContext) _{{$interface.Definition.GQLDefinition.Name}}(ctx context.Context, sel ast.SelectionSet, obj *{{$interface.Definition.GoType | ref}}) graphql.Marshaler { switch obj := (*obj).(type) { case nil: return graphql.Null {{- range $implementor := $interface.Implementors }} {{- if $implementor.ValueReceiver }} case {{$implementor.Definition.GoType | ref}}: - return ec._{{$implementor.Definition.GQLType}}(ctx, sel, &obj) + return ec._{{$implementor.Definition.GQLDefinition.Name}}(ctx, sel, &obj) {{- end}} case *{{$implementor.Definition.GoType | ref}}: - return ec._{{$implementor.Definition.GQLType}}(ctx, sel, obj) + return ec._{{$implementor.Definition.GQLDefinition.Name}}(ctx, sel, obj) {{- end }} default: panic(fmt.Errorf("unexpected type %T", obj)) diff --git a/codegen/templates/models.gotpl b/codegen/templates/models.gotpl index b00b84ab13a..50c149fbf9c 100644 --- a/codegen/templates/models.gotpl +++ b/codegen/templates/models.gotpl @@ -22,7 +22,7 @@ import ( {{ range $model := .Models }} {{with .Description}} {{.|prefixLines "// "}} {{end}} - {{- if .Definition.IsInterface }} + {{- if .Definition.GQLDefinition.IsAbstractType }} type {{.Definition.GoType | ref }} interface { Is{{.Definition.GoType | ref }}() } @@ -81,7 +81,7 @@ import ( *e = {{.Definition.GoType | ref }}(str) if !e.IsValid() { - return fmt.Errorf("%s is not a valid {{.Definition.GQLType}}", str) + return fmt.Errorf("%s is not a valid {{.Definition.GQLDefinition.Name}}", str) } return nil } diff --git a/codegen/templates/object.gotpl b/codegen/templates/object.gotpl index 694faaa0bb8..d7eaf51f26a 100644 --- a/codegen/templates/object.gotpl +++ b/codegen/templates/object.gotpl @@ -1,13 +1,13 @@ {{ $object := . }} -var {{ $object.Definition.GQLType|lcFirst}}Implementors = {{$object.Implementors}} +var {{ $object.Definition.GQLDefinition.Name|lcFirst}}Implementors = {{$object.Implementors}} // nolint: gocyclo, errcheck, gas, goconst {{- if .Stream }} -func (ec *executionContext) _{{$object.Definition.GQLType}}(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, {{$object.Definition.GQLType|lcFirst}}Implementors) +func (ec *executionContext) _{{$object.Definition.GQLDefinition.Name}}(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, {{$object.Definition.GQLDefinition.Name|lcFirst}}Implementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: {{$object.Definition.GQLType|quote}}, + Object: {{$object.Definition.GQLDefinition.Name|quote}}, }) if len(fields) != 1 { ec.Errorf(ctx, "must subscribe to exactly one stream") @@ -17,18 +17,18 @@ func (ec *executionContext) _{{$object.Definition.GQLType}}(ctx context.Context, switch fields[0].Name { {{- range $field := $object.Fields }} case "{{$field.GQLName}}": - return ec._{{$object.Definition.GQLType}}_{{$field.GQLName}}(ctx, fields[0]) + return ec._{{$object.Definition.GQLDefinition.Name}}_{{$field.GQLName}}(ctx, fields[0]) {{- end }} default: panic("unknown field " + strconv.Quote(fields[0].Name)) } } {{- else }} -func (ec *executionContext) _{{$object.Definition.GQLType}}(ctx context.Context, sel ast.SelectionSet{{if not $object.Root}}, obj *{{$object.Definition.GoType | ref }} {{end}}) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, {{$object.Definition.GQLType|lcFirst}}Implementors) +func (ec *executionContext) _{{$object.Definition.GQLDefinition.Name}}(ctx context.Context, sel ast.SelectionSet{{if not $object.Root}}, obj *{{$object.Definition.GoType | ref }} {{end}}) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, {{$object.Definition.GQLDefinition.Name|lcFirst}}Implementors) {{if $object.Root}} ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: {{$object.Definition.GQLType|quote}}, + Object: {{$object.Definition.GQLDefinition.Name|quote}}, }) {{end}} @@ -37,13 +37,13 @@ func (ec *executionContext) _{{$object.Definition.GQLType}}(ctx context.Context, for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString({{$object.Definition.GQLType|quote}}) + out.Values[i] = graphql.MarshalString({{$object.Definition.GQLDefinition.Name|quote}}) {{- range $field := $object.Fields }} case "{{$field.GQLName}}": {{- if $field.IsConcurrent }} field := field out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._{{$object.Definition.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}}) + res = ec._{{$object.Definition.GQLDefinition.Name}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}}) {{- if $field.ASTType.NonNull }} if res == graphql.Null { invalid = true @@ -52,7 +52,7 @@ func (ec *executionContext) _{{$object.Definition.GQLType}}(ctx context.Context, return res }) {{- else }} - out.Values[i] = ec._{{$object.Definition.GQLType}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}}) + out.Values[i] = ec._{{$object.Definition.GQLDefinition.Name}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}}) {{- if $field.ASTType.NonNull }} if out.Values[i] == graphql.Null { invalid = true diff --git a/codegen/templates/resolver.gotpl b/codegen/templates/resolver.gotpl index 3cd74d1b10e..fb3c9125597 100644 --- a/codegen/templates/resolver.gotpl +++ b/codegen/templates/resolver.gotpl @@ -23,19 +23,19 @@ type {{.ResolverType}} struct {} {{ range $object := .Objects -}} {{- if $object.HasResolvers -}} - func (r *{{$.ResolverType}}) {{$object.Definition.GQLType}}() {{ $object.ResolverInterface | ref }} { - return &{{lcFirst $object.Definition.GQLType}}Resolver{r} + func (r *{{$.ResolverType}}) {{$object.Definition.GQLDefinition.Name}}() {{ $object.ResolverInterface | ref }} { + return &{{lcFirst $object.Definition.GQLDefinition.Name}}Resolver{r} } {{ end -}} {{ end }} {{ range $object := .Objects -}} {{- if $object.HasResolvers -}} - type {{lcFirst $object.Definition.GQLType}}Resolver struct { *Resolver } + type {{lcFirst $object.Definition.GQLDefinition.Name}}Resolver struct { *Resolver } {{ range $field := $object.Fields -}} {{- if $field.IsResolver -}} - func (r *{{lcFirst $object.Definition.GQLType}}Resolver) {{ $field.ShortResolverDeclaration }} { + func (r *{{lcFirst $object.Definition.GQLDefinition.Name}}Resolver) {{ $field.ShortResolverDeclaration }} { panic("not implemented") } {{ end -}} diff --git a/codegen/type_build.go b/codegen/type_build.go index f384c8fe289..d253652c3ca 100644 --- a/codegen/type_build.go +++ b/codegen/type_build.go @@ -15,11 +15,13 @@ import ( func (g *Generator) buildNamedTypes(prog *loader.Program) (NamedTypes, error) { ts := map[string]*TypeDefinition{} for _, schemaType := range g.schema.Types { - t := namedTypeFromSchema(schemaType) - ts[t.GQLType] = t + t := &TypeDefinition{ + GQLDefinition: schemaType, + } + ts[t.GQLDefinition.Name] = t var pkgName, typeName string - if userEntry, ok := g.Models[t.GQLType]; ok && userEntry.Model != "" { + if userEntry, ok := g.Models[t.GQLDefinition.Name]; ok && userEntry.Model != "" { // special case for maps if userEntry.Model == "map[string]interface{}" { t.GoType = types.NewMap(types.Typ[types.String], types.NewInterface(nil, nil).Complete()) @@ -28,13 +30,13 @@ func (g *Generator) buildNamedTypes(prog *loader.Program) (NamedTypes, error) { } pkgName, typeName = pkgAndType(userEntry.Model) - } else if t.IsScalar && schemaType.Kind != ast.Enum { + } else if t.GQLDefinition.Kind == ast.Scalar { pkgName = "github.com/99designs/gqlgen/graphql" typeName = "String" } else { // Missing models, but we need to set up the types so any references will point to the code that will // get generated - t.GoType = types.NewNamed(types.NewTypeName(0, g.Config.Model.Pkg(), templates.ToCamel(t.GQLType), nil), nil, nil) + t.GoType = types.NewNamed(types.NewTypeName(0, g.Config.Model.Pkg(), templates.ToCamel(t.GQLDefinition.Name), nil), nil, nil) continue } @@ -83,21 +85,6 @@ func (g *Generator) buildNamedTypes(prog *loader.Program) (NamedTypes, error) { return ts, nil } -// namedTypeFromSchema objects for every graphql type, including primitives. -// don't recurse into object fields or interfaces yet, lets make sure we have collected everything first. -func namedTypeFromSchema(schemaType *ast.Definition) *TypeDefinition { - switch schemaType.Kind { - case ast.Scalar, ast.Enum: - return &TypeDefinition{GQLType: schemaType.Name, IsScalar: true} - case ast.Interface, ast.Union: - return &TypeDefinition{GQLType: schemaType.Name, IsInterface: true} - case ast.InputObject: - return &TypeDefinition{GQLType: schemaType.Name, IsInput: true} - default: - return &TypeDefinition{GQLType: schemaType.Name} - } -} - // take a string in the form github.com/package/blah.TypeReference and split it into package and type func pkgAndType(name string) (string, string) { parts := strings.Split(name, ".") diff --git a/codegen/type_definition.go b/codegen/type_definition.go index 20b5353c213..dd78aee1369 100644 --- a/codegen/type_definition.go +++ b/codegen/type_definition.go @@ -11,13 +11,10 @@ type NamedTypes map[string]*TypeDefinition // TypeDefinition is the static reference to a graphql type. It can be referenced by many TypeReferences, // and has one or more backing implementations in go. type TypeDefinition struct { - IsScalar bool - IsInterface bool - IsInput bool - GQLType string // Name of the graphql type - GoType types.Type // The backing go type, may be nil until after model generation - Marshaler *types.Func // When using external marshalling functions this will point to the Marshal function - Unmarshaler *types.Func // When using external marshalling functions this will point to the Unmarshal function + GQLDefinition *ast.Definition + GoType types.Type // The backing go type, may be nil until after model generation + Marshaler *types.Func // When using external marshalling functions this will point to the Marshal function + Unmarshaler *types.Func // When using external marshalling functions this will point to the Unmarshal function } func (t TypeDefinition) IsMarshaled() bool { @@ -40,7 +37,7 @@ func (n NamedTypes) goTypeForAst(t *ast.Type) types.Type { panic("missing type " + t.NamedType) } - if !t.NonNull && !nt.IsInterface { + if !t.NonNull && nt.GQLDefinition.Kind != ast.Interface { return types.NewPointer(gt) } diff --git a/codegen/type_reference.go b/codegen/type_reference.go index 1a2aaf48fbe..107c62647f4 100644 --- a/codegen/type_reference.go +++ b/codegen/type_reference.go @@ -107,7 +107,7 @@ func (t TypeReference) middleware(result, raw string, destType types.Type, depth return tpl(` if {{.raw}} != nil { var err error - {{.result}}, err = e.{{ .t.Definition.GQLType }}Middleware(ctx, {{.raw}}) + {{.result}}, err = e.{{ .t.Definition.GQLDefinition.Name }}Middleware(ctx, {{.raw}}) if err != nil { return nil, err } @@ -131,9 +131,9 @@ func (t TypeReference) middleware(result, raw string, destType types.Type, depth }) } - ptr := "m" + t.Definition.GQLType + strconv.Itoa(depth) + ptr := "m" + t.Definition.GQLDefinition.Name + strconv.Itoa(depth) return tpl(` - {{.ptr}}, err := e.{{ .t.Definition.GQLType }}Middleware(ctx, &{{.raw}}) + {{.ptr}}, err := e.{{ .t.Definition.GQLDefinition.Name }}Middleware(ctx, &{{.raw}}) if err != nil { return nil, err } diff --git a/codegen/util.go b/codegen/util.go index 0b72abada3f..ff822ac9a6c 100644 --- a/codegen/util.go +++ b/codegen/util.go @@ -184,7 +184,7 @@ type BindError struct { func (b BindError) Error() string { return fmt.Sprintf( "Unable to bind %s.%s to %s\n %s\n %s", - b.object.Definition.GQLType, + b.object.Definition.GQLDefinition.Name, b.field.GQLName, b.typ.String(), b.methodErr.Error(), From db33d7b71c20737e2237139e46c9fc910c6a9d90 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Wed, 9 Jan 2019 13:14:07 +1100 Subject: [PATCH 033/147] Extract graphql go merge into its own package --- cmd/gen.go | 8 +- cmd/init.go | 9 +- codegen/build.go | 210 ----------------- codegen/codegen_test.go | 55 +---- codegen/config/config.go | 32 +-- codegen/config/loader.go | 25 ++ codegen/enum.go | 12 - codegen/enum_build.go | 42 ---- codegen/exec.go | 42 ++++ codegen/generate.go | 60 +++++ codegen/generator.go | 132 ----------- codegen/input_build.go | 90 ------- codegen/input_test.go | 77 ------ codegen/interface_build.go | 53 ----- codegen/model.go | 73 +++++- codegen/models_build.go | 82 ------- codegen/object_build.go | 196 --------------- codegen/resolver.go | 53 +++++ codegen/server.go | 42 ++++ codegen/templates/data.go | 4 +- codegen/templates/generated.gotpl | 2 +- codegen/templates/models.gotpl | 36 +-- codegen/templates/templates.go | 2 +- codegen/testdata/generateserver.graphqls | 11 + codegen/type_build.go | 96 -------- codegen/unified/build.go | 146 ++++++++++++ codegen/{util.go => unified/build_bind.go} | 178 +------------- .../build_bind_test.go} | 2 +- .../build_directive.go} | 53 +++-- codegen/unified/build_enum.go | 31 +++ codegen/unified/build_input.go | 47 ++++ codegen/unified/build_interface.go | 50 ++++ codegen/unified/build_object.go | 137 +++++++++++ codegen/unified/build_typedef.go | 109 +++++++++ codegen/{ => unified}/directive.go | 2 +- codegen/unified/enum.go | 12 + codegen/{ => unified}/interface.go | 3 +- codegen/{ => unified}/object.go | 64 ++--- codegen/unified/schema.go | 22 ++ codegen/unified/schema_test.go | 30 +++ codegen/unified/testdata/typeinput.graphqls | 7 + codegen/unified/testdata/unioninput.graphqls | 5 + codegen/{ => unified}/type_definition.go | 28 +-- codegen/{ => unified}/type_reference.go | 2 +- codegen/unified/util.go | 223 ++++++++++++++++++ example/starwars/models_gen.go | 8 +- 46 files changed, 1225 insertions(+), 1378 deletions(-) delete mode 100644 codegen/build.go create mode 100644 codegen/config/loader.go delete mode 100644 codegen/enum.go delete mode 100644 codegen/enum_build.go create mode 100644 codegen/exec.go create mode 100644 codegen/generate.go delete mode 100644 codegen/generator.go delete mode 100644 codegen/input_build.go delete mode 100644 codegen/input_test.go delete mode 100644 codegen/interface_build.go delete mode 100644 codegen/models_build.go delete mode 100644 codegen/object_build.go create mode 100644 codegen/resolver.go create mode 100644 codegen/server.go create mode 100644 codegen/testdata/generateserver.graphqls delete mode 100644 codegen/type_build.go create mode 100644 codegen/unified/build.go rename codegen/{util.go => unified/build_bind.go} (52%) rename codegen/{util_test.go => unified/build_bind_test.go} (99%) rename codegen/{directive_build.go => unified/build_directive.go} (62%) create mode 100644 codegen/unified/build_enum.go create mode 100644 codegen/unified/build_input.go create mode 100644 codegen/unified/build_interface.go create mode 100644 codegen/unified/build_object.go create mode 100644 codegen/unified/build_typedef.go rename codegen/{ => unified}/directive.go (98%) create mode 100644 codegen/unified/enum.go rename codegen/{ => unified}/interface.go (83%) rename codegen/{ => unified}/object.go (89%) create mode 100644 codegen/unified/schema.go create mode 100644 codegen/unified/schema_test.go create mode 100644 codegen/unified/testdata/typeinput.graphqls create mode 100644 codegen/unified/testdata/unioninput.graphqls rename codegen/{ => unified}/type_definition.go (63%) rename codegen/{ => unified}/type_reference.go (99%) create mode 100644 codegen/unified/util.go diff --git a/cmd/gen.go b/cmd/gen.go index 7d328861e61..182231d6256 100644 --- a/cmd/gen.go +++ b/cmd/gen.go @@ -36,16 +36,10 @@ var genCmd = cli.Command{ } } - gen, err := codegen.New(cfg) + err = codegen.Generate(cfg) if err != nil { fmt.Fprintln(os.Stderr, err.Error()) os.Exit(3) } - - err = gen.Generate() - if err != nil { - fmt.Fprintln(os.Stderr, err.Error()) - os.Exit(4) - } }, } diff --git a/cmd/init.go b/cmd/init.go index cdb9e60ec8c..992a37b1680 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -70,17 +70,12 @@ var initCmd = cli.Command{ } func GenerateGraphServer(cfg *config.Config, serverFilename string) { - gen, err := codegen.New(cfg) + err := codegen.Generate(cfg) if err != nil { fmt.Fprintln(os.Stderr, err.Error()) } - if err := gen.Generate(); err != nil { - fmt.Fprintln(os.Stderr, err.Error()) - os.Exit(1) - } - - if err := gen.GenerateServer(serverFilename); err != nil { + if err := codegen.GenerateServer(serverFilename, cfg); err != nil { fmt.Fprintln(os.Stderr, err.Error()) os.Exit(1) } diff --git a/codegen/build.go b/codegen/build.go deleted file mode 100644 index 3bfddba7005..00000000000 --- a/codegen/build.go +++ /dev/null @@ -1,210 +0,0 @@ -package codegen - -import ( - "fmt" - "go/build" - "go/types" - "os" - - "github.com/99designs/gqlgen/codegen/config" - "github.com/pkg/errors" - "golang.org/x/tools/go/loader" -) - -type Build struct { - PackageName string - Objects Objects - Inputs Objects - Interfaces []*Interface - QueryRoot *Object - MutationRoot *Object - SubscriptionRoot *Object - SchemaRaw map[string]string - SchemaFilename config.SchemaFilenames - Directives map[string]*Directive -} - -type ModelBuild struct { - PackageName string - Models []Model - Enums []Enum -} - -type ResolverBuild struct { - PackageName string - ResolverType string - Objects Objects - ResolverFound bool -} - -type ServerBuild struct { - PackageName string - ExecPackageName string - ResolverPackageName string -} - -// Create a list of models that need to be generated -func (g *Generator) models() (*ModelBuild, error) { - progLoader := g.newLoaderWithoutErrors() - - prog, err := progLoader.Load() - if err != nil { - return nil, errors.Wrap(err, "loading failed") - } - - namedTypes, err := g.buildNamedTypes(prog) - if err != nil { - return nil, errors.Wrap(err, "binding types failed") - } - - directives, err := g.buildDirectives(namedTypes) - if err != nil { - return nil, err - } - g.Directives = directives - - models, err := g.buildModels(namedTypes, prog) - if err != nil { - return nil, err - } - return &ModelBuild{ - PackageName: g.Model.Package, - Models: models, - Enums: g.buildEnums(namedTypes), - }, nil -} - -// bind a schema together with some code to generate a Build -func (g *Generator) resolver() (*ResolverBuild, error) { - progLoader := g.newLoaderWithoutErrors() - progLoader.Import(g.Resolver.ImportPath()) - - prog, err := progLoader.Load() - if err != nil { - return nil, err - } - - namedTypes, err := g.buildNamedTypes(prog) - if err != nil { - return nil, errors.Wrap(err, "binding types failed") - } - - directives, err := g.buildDirectives(namedTypes) - if err != nil { - return nil, err - } - g.Directives = directives - - objects, err := g.buildObjects(namedTypes, prog) - if err != nil { - return nil, err - } - - def, _ := findGoType(prog, g.Resolver.ImportPath(), g.Resolver.Type) - resolverFound := def != nil - - return &ResolverBuild{ - PackageName: g.Resolver.Package, - Objects: objects, - ResolverType: g.Resolver.Type, - ResolverFound: resolverFound, - }, nil -} - -func (g *Generator) server(destDir string) *ServerBuild { - return &ServerBuild{ - PackageName: g.Resolver.Package, - ExecPackageName: g.Exec.ImportPath(), - ResolverPackageName: g.Resolver.ImportPath(), - } -} - -// bind a schema together with some code to generate a Build -func (g *Generator) bind() (*Build, error) { - progLoader := g.newLoaderWithoutErrors() - prog, err := progLoader.Load() - if err != nil { - return nil, errors.Wrap(err, "loading failed") - } - - namedTypes, err := g.buildNamedTypes(prog) - if err != nil { - return nil, errors.Wrap(err, "binding types failed") - } - - directives, err := g.buildDirectives(namedTypes) - if err != nil { - return nil, err - } - g.Directives = directives - - objects, err := g.buildObjects(namedTypes, prog) - if err != nil { - return nil, err - } - - inputs, err := g.buildInputs(namedTypes, prog) - if err != nil { - return nil, err - } - - b := &Build{ - PackageName: g.Exec.Package, - Objects: objects, - Interfaces: g.buildInterfaces(namedTypes, prog), - Inputs: inputs, - SchemaRaw: g.SchemaStr, - SchemaFilename: g.SchemaFilename, - Directives: directives, - } - - if g.schema.Query != nil { - b.QueryRoot = b.Objects.ByName(g.schema.Query.Name) - } else { - return b, fmt.Errorf("query entry point missing") - } - - if g.schema.Mutation != nil { - b.MutationRoot = b.Objects.ByName(g.schema.Mutation.Name) - } - - if g.schema.Subscription != nil { - b.SubscriptionRoot = b.Objects.ByName(g.schema.Subscription.Name) - } - return b, nil -} - -func (g *Generator) validate() error { - progLoader := g.newLoaderWithErrors() - _, err := progLoader.Load() - return err -} - -func (g *Generator) newLoaderWithErrors() loader.Config { - conf := loader.Config{} - - for _, pkg := range g.Models.ReferencedPackages() { - conf.Import(pkg) - } - return conf -} - -func (g *Generator) newLoaderWithoutErrors() loader.Config { - conf := g.newLoaderWithErrors() - conf.AllowErrors = true - conf.TypeChecker = types.Config{ - Error: func(e error) {}, - } - return conf -} - -func resolvePkg(pkgName string) (string, error) { - cwd, _ := os.Getwd() - - pkg, err := build.Default.Import(pkgName, cwd, build.FindOnly) - if err != nil { - return "", err - } - - return pkg.ImportPath, nil -} diff --git a/codegen/codegen_test.go b/codegen/codegen_test.go index abe0e39c259..3045f286b2a 100644 --- a/codegen/codegen_test.go +++ b/codegen/codegen_test.go @@ -1,68 +1,31 @@ package codegen import ( - "syscall" "testing" "github.com/99designs/gqlgen/codegen/config" "github.com/stretchr/testify/require" - "github.com/vektah/gqlparser" - "github.com/vektah/gqlparser/ast" - "github.com/vektah/gqlparser/gqlerror" "golang.org/x/tools/go/loader" ) func TestGenerateServer(t *testing.T) { name := "graphserver" - schema := ` - type Query { - user: User - } - type User { - id: Int - fist_name: String - } - enum Status { - OK - ERROR - } -` - serverFilename := "gen/" + name + "/server/server.go" - gen := Generator{ - Config: &config.Config{ - SchemaFilename: config.SchemaFilenames{"schema.graphql"}, - Exec: config.PackageConfig{Filename: "gen/" + name + "/exec.go"}, - Model: config.PackageConfig{Filename: "gen/" + name + "/model.go"}, - Resolver: config.PackageConfig{Filename: "gen/" + name + "/resolver.go", Type: "Resolver"}, - }, - SchemaStr: map[string]string{"schema.graphql": schema}, + cfg := &config.Config{ + SchemaFilename: config.SchemaFilenames{"testdata/generateserver.graphqls"}, + Exec: config.PackageConfig{Filename: "gen/" + name + "/exec.go"}, + Model: config.PackageConfig{Filename: "gen/" + name + "/model.go"}, + Resolver: config.PackageConfig{Filename: "gen/" + name + "/resolver.go", Type: "Resolver"}, } + serverFilename := "gen/" + name + "/server/server.go" - err := gen.Config.Check() - if err != nil { - panic(err) - } - - var gerr *gqlerror.Error - gen.schema, gerr = gqlparser.LoadSchema(&ast.Source{Name: "schema.graphql", Input: schema}) - if gerr != nil { - panic(gerr) - } - - _ = syscall.Unlink(gen.Resolver.Filename) - _ = syscall.Unlink(serverFilename) - - err = gen.Generate() - require.NoError(t, err) - - err = gen.GenerateServer(serverFilename) - require.NoError(t, err) + require.NoError(t, Generate(cfg)) + require.NoError(t, GenerateServer(serverFilename, cfg)) conf := loader.Config{} conf.CreateFromFilenames("gen/"+name, serverFilename) - _, err = conf.Load() + _, err := conf.Load() require.NoError(t, err) t.Run("list of enums", func(t *testing.T) { diff --git a/codegen/config/config.go b/codegen/config/config.go index bec8e00fb25..fb6c9522a82 100644 --- a/codegen/config/config.go +++ b/codegen/config/config.go @@ -178,23 +178,23 @@ func (c *PackageConfig) IsDefined() bool { return c.Filename != "" } -func (cfg *Config) Check() error { - if err := cfg.Models.Check(); err != nil { +func (c *Config) Check() error { + if err := c.Models.Check(); err != nil { return errors.Wrap(err, "config.models") } - if err := cfg.Exec.Check(); err != nil { + if err := c.Exec.Check(); err != nil { return errors.Wrap(err, "config.exec") } - if err := cfg.Model.Check(); err != nil { + if err := c.Model.Check(); err != nil { return errors.Wrap(err, "config.model") } - if cfg.Resolver.IsDefined() { - if err := cfg.Resolver.Check(); err != nil { + if c.Resolver.IsDefined() { + if err := c.Resolver.Check(); err != nil { return errors.Wrap(err, "config.resolver") } } - return cfg.normalize() + return c.normalize() } type TypeMap map[string]TypeMapEntry @@ -280,17 +280,17 @@ func findCfgInDir(dir string) string { return "" } -func (cfg *Config) normalize() error { - if err := cfg.Model.normalize(); err != nil { +func (c *Config) normalize() error { + if err := c.Model.normalize(); err != nil { return errors.Wrap(err, "model") } - if err := cfg.Exec.normalize(); err != nil { + if err := c.Exec.normalize(); err != nil { return errors.Wrap(err, "exec") } - if cfg.Resolver.IsDefined() { - if err := cfg.Resolver.normalize(); err != nil { + if c.Resolver.IsDefined() { + if err := c.Resolver.normalize(); err != nil { return errors.Wrap(err, "resolver") } } @@ -313,12 +313,12 @@ func (cfg *Config) normalize() error { "Map": {Model: "github.com/99designs/gqlgen/graphql.Map"}, } - if cfg.Models == nil { - cfg.Models = TypeMap{} + if c.Models == nil { + c.Models = TypeMap{} } for typeName, entry := range builtins { - if !cfg.Models.Exists(typeName) { - cfg.Models[typeName] = entry + if !c.Models.Exists(typeName) { + c.Models[typeName] = entry } } diff --git a/codegen/config/loader.go b/codegen/config/loader.go new file mode 100644 index 00000000000..2fa9013cea0 --- /dev/null +++ b/codegen/config/loader.go @@ -0,0 +1,25 @@ +package config + +import ( + "go/types" + + "golang.org/x/tools/go/loader" +) + +func (c *Config) NewLoaderWithErrors() loader.Config { + conf := loader.Config{} + + for _, pkg := range c.Models.ReferencedPackages() { + conf.Import(pkg) + } + return conf +} + +func (c *Config) NewLoaderWithoutErrors() loader.Config { + conf := c.NewLoaderWithErrors() + conf.AllowErrors = true + conf.TypeChecker = types.Config{ + Error: func(e error) {}, + } + return conf +} diff --git a/codegen/enum.go b/codegen/enum.go deleted file mode 100644 index f062abbdb10..00000000000 --- a/codegen/enum.go +++ /dev/null @@ -1,12 +0,0 @@ -package codegen - -type Enum struct { - Definition *TypeDefinition - Description string - Values []EnumValue -} - -type EnumValue struct { - Name string - Description string -} diff --git a/codegen/enum_build.go b/codegen/enum_build.go deleted file mode 100644 index c476ed01b74..00000000000 --- a/codegen/enum_build.go +++ /dev/null @@ -1,42 +0,0 @@ -package codegen - -import ( - "go/types" - "sort" - "strings" - - "github.com/99designs/gqlgen/codegen/templates" - "github.com/vektah/gqlparser/ast" -) - -func (g *Generator) buildEnums(ts NamedTypes) []Enum { - var enums []Enum - - for _, typ := range g.schema.Types { - namedType := ts[typ.Name] - if typ.Kind != ast.Enum || strings.HasPrefix(typ.Name, "__") || g.Models.UserDefined(typ.Name) { - continue - } - - var values []EnumValue - for _, v := range typ.EnumValues { - values = append(values, EnumValue{v.Name, v.Description}) - } - - enum := Enum{ - Definition: namedType, - Values: values, - Description: typ.Description, - } - - enum.Definition.GoType = types.NewNamed(types.NewTypeName(0, g.Config.Model.Pkg(), templates.ToCamel(enum.Definition.GQLDefinition.Name), nil), nil, nil) - - enums = append(enums, enum) - } - - sort.Slice(enums, func(i, j int) bool { - return enums[i].Definition.GQLDefinition.Name < enums[j].Definition.GQLDefinition.Name - }) - - return enums -} diff --git a/codegen/exec.go b/codegen/exec.go new file mode 100644 index 00000000000..34f5cbd9cde --- /dev/null +++ b/codegen/exec.go @@ -0,0 +1,42 @@ +package codegen + +import ( + "fmt" + + "github.com/99designs/gqlgen/codegen/templates" + "github.com/99designs/gqlgen/codegen/unified" +) + +type ExecBuild struct { + *unified.Schema + + PackageName string + QueryRoot *unified.Object + MutationRoot *unified.Object + SubscriptionRoot *unified.Object +} + +// bind a schema together with some code to generate a Build +func buildExec(s *unified.Schema) error { + b := &ExecBuild{ + Schema: s, + PackageName: s.Config.Exec.Package, + } + + if s.Schema.Query != nil { + b.QueryRoot = b.Objects.ByName(s.Schema.Query.Name) + } else { + return fmt.Errorf("query entry point missing") + } + + if s.Schema.Mutation != nil { + b.MutationRoot = b.Objects.ByName(s.Schema.Mutation.Name) + } + + if s.Schema.Subscription != nil { + b.SubscriptionRoot = b.Objects.ByName(s.Schema.Subscription.Name) + } + + return templates.RenderToFile("generated.gotpl", s.Config.Exec.Filename, b) + +} diff --git a/codegen/generate.go b/codegen/generate.go new file mode 100644 index 00000000000..36b8e211d63 --- /dev/null +++ b/codegen/generate.go @@ -0,0 +1,60 @@ +package codegen + +import ( + "path/filepath" + "syscall" + + "github.com/99designs/gqlgen/codegen/config" + "github.com/99designs/gqlgen/codegen/unified" + "github.com/pkg/errors" +) + +func Generate(cfg *config.Config) error { + _ = syscall.Unlink(cfg.Exec.Filename) + _ = syscall.Unlink(cfg.Model.Filename) + + schema, err := unified.NewSchema(cfg) + if err != nil { + return errors.Wrap(err, "merging failed") + } + + if err := buildModels(schema); err != nil { + return errors.Wrap(err, "generating models failed") + } + + // Create a new schema now that the generated models have been injected into the typemap + schema, err = unified.NewSchema(schema.Config) + if err != nil { + return errors.Wrap(err, "merging failed") + } + + if err := buildExec(schema); err != nil { + return errors.Wrap(err, "generating exec failed") + } + + if cfg.Resolver.IsDefined() { + if err := GenerateResolver(schema); err != nil { + return errors.Wrap(err, "generating resolver failed") + } + } + + if err := validate(cfg); err != nil { + return errors.Wrap(err, "validation failed") + } + + return nil +} + +func validate(cfg *config.Config) error { + progLoader := cfg.NewLoaderWithErrors() + _, err := progLoader.Load() + return err +} + +func abs(path string) string { + absPath, err := filepath.Abs(path) + if err != nil { + panic(err) + } + return filepath.ToSlash(absPath) +} diff --git a/codegen/generator.go b/codegen/generator.go deleted file mode 100644 index a85a5ff8fed..00000000000 --- a/codegen/generator.go +++ /dev/null @@ -1,132 +0,0 @@ -package codegen - -import ( - "go/types" - "log" - "os" - "path/filepath" - "syscall" - - "github.com/99designs/gqlgen/codegen/config" - "github.com/99designs/gqlgen/codegen/templates" - "github.com/pkg/errors" - "github.com/vektah/gqlparser/ast" -) - -type Generator struct { - *config.Config - schema *ast.Schema `yaml:"-"` - SchemaStr map[string]string `yaml:"-"` - Directives map[string]*Directive -} - -func New(cfg *config.Config) (*Generator, error) { - g := &Generator{Config: cfg} - - var err error - g.schema, g.SchemaStr, err = cfg.LoadSchema() - if err != nil { - return nil, err - } - - err = cfg.Check() - if err != nil { - return nil, err - } - - return g, nil -} - -func (g *Generator) Generate() error { - _ = syscall.Unlink(g.Exec.Filename) - _ = syscall.Unlink(g.Model.Filename) - - modelsBuild, err := g.models() - if err != nil { - return errors.Wrap(err, "model plan failed") - } - if len(modelsBuild.Models) > 0 || len(modelsBuild.Enums) > 0 { - if err = templates.RenderToFile("models.gotpl", g.Model.Filename, modelsBuild); err != nil { - return err - } - - for _, model := range modelsBuild.Models { - modelCfg := g.Models[model.Definition.GQLDefinition.Name] - modelCfg.Model = types.TypeString(model.Definition.GoType, nil) - g.Models[model.Definition.GQLDefinition.Name] = modelCfg - } - - for _, enum := range modelsBuild.Enums { - modelCfg := g.Models[enum.Definition.GQLDefinition.Name] - modelCfg.Model = types.TypeString(enum.Definition.GoType, nil) - g.Models[enum.Definition.GQLDefinition.Name] = modelCfg - } - } - - build, err := g.bind() - if err != nil { - return errors.Wrap(err, "exec plan failed") - } - - if err := templates.RenderToFile("generated.gotpl", g.Exec.Filename, build); err != nil { - return err - } - - if g.Resolver.IsDefined() { - if err := g.GenerateResolver(); err != nil { - return errors.Wrap(err, "generating resolver failed") - } - } - - if err := g.validate(); err != nil { - return errors.Wrap(err, "validation failed") - } - - return nil -} - -func (g *Generator) GenerateServer(filename string) error { - serverFilename := abs(filename) - serverBuild := g.server(filepath.Dir(serverFilename)) - - if _, err := os.Stat(serverFilename); os.IsNotExist(errors.Cause(err)) { - err = templates.RenderToFile("server.gotpl", serverFilename, serverBuild) - if err != nil { - return errors.Wrap(err, "generate server failed") - } - } else { - log.Printf("Skipped server: %s already exists\n", serverFilename) - } - return nil -} - -func (g *Generator) GenerateResolver() error { - resolverBuild, err := g.resolver() - if err != nil { - return errors.Wrap(err, "resolver build failed") - } - filename := g.Resolver.Filename - - if resolverBuild.ResolverFound { - log.Printf("Skipped resolver: %s.%s already exists\n", g.Resolver.ImportPath(), g.Resolver.Type) - return nil - } - - if _, err := os.Stat(filename); os.IsNotExist(errors.Cause(err)) { - if err := templates.RenderToFile("resolver.gotpl", filename, resolverBuild); err != nil { - return err - } - } else { - log.Printf("Skipped resolver: %s already exists\n", filename) - } - - return nil -} - -func abs(path string) string { - absPath, err := filepath.Abs(path) - if err != nil { - panic(err) - } - return filepath.ToSlash(absPath) -} diff --git a/codegen/input_build.go b/codegen/input_build.go deleted file mode 100644 index 519e3373038..00000000000 --- a/codegen/input_build.go +++ /dev/null @@ -1,90 +0,0 @@ -package codegen - -import ( - "sort" - - "go/types" - - "github.com/pkg/errors" - "github.com/vektah/gqlparser/ast" - "golang.org/x/tools/go/loader" -) - -func (g *Generator) buildInputs(namedTypes NamedTypes, prog *loader.Program) (Objects, error) { - var inputs Objects - - for _, typ := range g.schema.Types { - switch typ.Kind { - case ast.InputObject: - input, err := g.buildInput(namedTypes, typ) - if err != nil { - return nil, err - } - - if _, isMap := input.Definition.GoType.(*types.Map); !isMap { - bindErrs := bindObject(input, g.StructTag) - if len(bindErrs) > 0 { - return nil, bindErrs - } - } - - inputs = append(inputs, input) - } - } - - sort.Slice(inputs, func(i, j int) bool { - return inputs[i].Definition.GQLDefinition.Name < inputs[j].Definition.GQLDefinition.Name - }) - - return inputs, nil -} - -func (g *Generator) buildInput(types NamedTypes, typ *ast.Definition) (*Object, error) { - obj := &Object{Definition: types[typ.Name]} - typeEntry, entryExists := g.Models[typ.Name] - - for _, field := range typ.Fields { - dirs, err := g.getDirectives(field.Directives) - if err != nil { - return nil, err - } - newField := Field{ - GQLName: field.Name, - TypeReference: types.getType(field.Type), - Object: obj, - Directives: dirs, - } - - if entryExists { - if typeField, ok := typeEntry.Fields[field.Name]; ok { - newField.GoFieldName = typeField.FieldName - } - } - - if field.DefaultValue != nil { - var err error - newField.Default, err = field.DefaultValue.Value(nil) - if err != nil { - return nil, errors.Errorf("default value for %s.%s is not valid: %s", typ.Name, field.Name, err.Error()) - } - } - - if !newField.TypeReference.Definition.GQLDefinition.IsInputType() { - return nil, errors.Errorf( - "%s cannot be used as a field of %s. only input and scalar types are allowed", - newField.Definition.GQLDefinition.Name, - obj.Definition.GQLDefinition.Name, - ) - } - - obj.Fields = append(obj.Fields, newField) - - } - dirs, err := g.getDirectives(typ.Directives) - if err != nil { - return nil, err - } - obj.Directives = dirs - - return obj, nil -} diff --git a/codegen/input_test.go b/codegen/input_test.go deleted file mode 100644 index 744cf9c8ad1..00000000000 --- a/codegen/input_test.go +++ /dev/null @@ -1,77 +0,0 @@ -package codegen - -import ( - "testing" - - "github.com/99designs/gqlgen/codegen/config" - "github.com/stretchr/testify/require" - "github.com/vektah/gqlparser" - "github.com/vektah/gqlparser/ast" - "github.com/vektah/gqlparser/gqlerror" - "golang.org/x/tools/go/loader" -) - -func TestTypeUnionAsInput(t *testing.T) { - err := generate("inputunion", ` - type Query { - addBookmark(b: Bookmarkable!): Boolean! - } - type Item {name: String} - union Bookmarkable = Item - `) - - require.EqualError(t, err, "model plan failed: Bookmarkable! cannot be used as argument of Query.addBookmark. only input and scalar types are allowed") -} - -func TestTypeInInput(t *testing.T) { - err := generate("typeinput", ` - type Query { - addBookmark(b: BookmarkableInput!): Boolean! - } - type Item {name: String} - input BookmarkableInput { - item: Item - } - `) - - require.EqualError(t, err, "model plan failed: Item cannot be used as a field of BookmarkableInput. only input and scalar types are allowed") -} - -func generate(name string, schema string, typemap ...config.TypeMap) error { - gen := Generator{ - Config: &config.Config{ - SchemaFilename: config.SchemaFilenames{"schema.graphql"}, - Exec: config.PackageConfig{Filename: "gen/" + name + "/exec.go"}, - Model: config.PackageConfig{Filename: "gen/" + name + "/model.go"}, - }, - - SchemaStr: map[string]string{"schema.graphql": schema}, - } - - err := gen.Config.Check() - if err != nil { - panic(err) - } - - var gerr *gqlerror.Error - gen.schema, gerr = gqlparser.LoadSchema(&ast.Source{Name: "schema.graphql", Input: schema}) - if gerr != nil { - panic(gerr) - } - - if len(typemap) > 0 { - gen.Models = typemap[0] - } - err = gen.Generate() - if err != nil { - return err - } - conf := loader.Config{} - conf.Import("github.com/99designs/gqlgen/codegen/testdata/gen/" + name) - - _, err = conf.Load() - if err != nil { - panic(err) - } - return nil -} diff --git a/codegen/interface_build.go b/codegen/interface_build.go deleted file mode 100644 index 1cc63229ba0..00000000000 --- a/codegen/interface_build.go +++ /dev/null @@ -1,53 +0,0 @@ -package codegen - -import ( - "go/types" - "sort" - - "github.com/vektah/gqlparser/ast" - "golang.org/x/tools/go/loader" -) - -func (g *Generator) buildInterfaces(types NamedTypes, prog *loader.Program) []*Interface { - var interfaces []*Interface - for _, typ := range g.schema.Types { - if typ.Kind == ast.Union || typ.Kind == ast.Interface { - interfaces = append(interfaces, g.buildInterface(types, typ, prog)) - } - } - - sort.Slice(interfaces, func(i, j int) bool { - return interfaces[i].Definition.GQLDefinition.Name < interfaces[j].Definition.GQLDefinition.Name - }) - - return interfaces -} - -func (g *Generator) buildInterface(types NamedTypes, typ *ast.Definition, prog *loader.Program) *Interface { - i := &Interface{Definition: types[typ.Name]} - - for _, implementor := range g.schema.GetPossibleTypes(typ) { - t := types[implementor.Name] - - i.Implementors = append(i.Implementors, InterfaceImplementor{ - Definition: t, - ValueReceiver: g.isValueReceiver(types[typ.Name], t, prog), - }) - } - - return i -} - -func (g *Generator) isValueReceiver(intf *TypeDefinition, implementor *TypeDefinition, prog *loader.Program) bool { - interfaceType, err := findGoInterface(intf.GoType) - if interfaceType == nil || err != nil { - return true - } - - implementorType, err := findGoNamedType(implementor.GoType) - if implementorType == nil || err != nil { - return true - } - - return types.Implements(implementorType, interfaceType) -} diff --git a/codegen/model.go b/codegen/model.go index 09b2b4c8cf2..df377b9cfd5 100644 --- a/codegen/model.go +++ b/codegen/model.go @@ -1,17 +1,66 @@ package codegen -type Model struct { - Definition *TypeDefinition - Description string - Fields []ModelField - Implements []*TypeDefinition +import ( + "sort" + + "go/types" + + "github.com/99designs/gqlgen/codegen/templates" + "github.com/99designs/gqlgen/codegen/unified" +) + +type ModelBuild struct { + Interfaces []*unified.Interface + Models unified.Objects + Enums []unified.Enum + PackageName string } -type ModelField struct { - *TypeReference - GQLName string - GoFieldName string - GoFKName string - GoFKType string - Description string +// Create a list of models that need to be generated +func buildModels(s *unified.Schema) error { + b := &ModelBuild{ + PackageName: s.Config.Model.Package, + } + + for _, o := range s.Interfaces { + if !o.InTypemap { + b.Interfaces = append(b.Interfaces, o) + } + } + + for _, o := range append(s.Objects, s.Inputs...) { + if !o.InTypemap { + b.Models = append(b.Models, o) + } + } + + for _, e := range s.Enums { + if !e.InTypemap { + b.Enums = append(b.Enums, e) + } + } + + if len(b.Models) == 0 && len(b.Enums) == 0 { + return nil + } + + sort.Slice(b.Models, func(i, j int) bool { + return b.Models[i].Definition.GQLDefinition.Name < b.Models[j].Definition.GQLDefinition.Name + }) + + err := templates.RenderToFile("models.gotpl", s.Config.Model.Filename, b) + + for _, model := range b.Models { + modelCfg := s.Config.Models[model.Definition.GQLDefinition.Name] + modelCfg.Model = types.TypeString(model.Definition.GoType, nil) + s.Config.Models[model.Definition.GQLDefinition.Name] = modelCfg + } + + for _, enum := range b.Enums { + modelCfg := s.Config.Models[enum.Definition.GQLDefinition.Name] + modelCfg.Model = types.TypeString(enum.Definition.GoType, nil) + s.Config.Models[enum.Definition.GQLDefinition.Name] = modelCfg + } + + return err } diff --git a/codegen/models_build.go b/codegen/models_build.go deleted file mode 100644 index 5eb707c7d4d..00000000000 --- a/codegen/models_build.go +++ /dev/null @@ -1,82 +0,0 @@ -package codegen - -import ( - "sort" - - "github.com/vektah/gqlparser/ast" - "golang.org/x/tools/go/loader" -) - -func (g *Generator) buildModels(types NamedTypes, prog *loader.Program) ([]Model, error) { - var models []Model - - for _, typ := range g.schema.Types { - var model Model - if g.Models.UserDefined(typ.Name) { - continue - } - switch typ.Kind { - case ast.Object: - obj, err := g.buildObject(prog, types, typ) - if err != nil { - return nil, err - } - if obj.Root { - continue - } - model = g.obj2Model(obj) - case ast.InputObject: - obj, err := g.buildInput(types, typ) - if err != nil { - return nil, err - } - model = g.obj2Model(obj) - case ast.Interface, ast.Union: - intf := g.buildInterface(types, typ, prog) - model = int2Model(intf) - default: - continue - } - model.Description = typ.Description // It's this or change both obj2Model and buildObject - - models = append(models, model) - } - - sort.Slice(models, func(i, j int) bool { - return models[i].Definition.GQLDefinition.Name < models[j].Definition.GQLDefinition.Name - }) - - return models, nil -} - -func (g *Generator) obj2Model(obj *Object) Model { - model := Model{ - Definition: obj.Definition, - Implements: obj.Implements, - Fields: []ModelField{}, - } - - for i := range obj.Fields { - field := &obj.Fields[i] - mf := ModelField{TypeReference: field.TypeReference, GQLName: field.GQLName} - - if field.GoFieldName != "" { - mf.GoFieldName = field.GoFieldName - } else { - mf.GoFieldName = field.GoNameExported() - } - - model.Fields = append(model.Fields, mf) - } - - return model -} - -func int2Model(obj *Interface) Model { - model := Model{ - Definition: obj.Definition, - Fields: []ModelField{}, - } - - return model -} diff --git a/codegen/object_build.go b/codegen/object_build.go deleted file mode 100644 index 65f9066b9d5..00000000000 --- a/codegen/object_build.go +++ /dev/null @@ -1,196 +0,0 @@ -package codegen - -import ( - "sort" - - "go/types" - - "log" - - "github.com/pkg/errors" - "github.com/vektah/gqlparser/ast" - "golang.org/x/tools/go/loader" -) - -func (g *Generator) buildObjects(ts NamedTypes, prog *loader.Program) (Objects, error) { - var objects Objects - - for _, typ := range g.schema.Types { - if typ.Kind != ast.Object { - continue - } - - obj, err := g.buildObject(prog, ts, typ) - if err != nil { - return nil, err - } - - if _, isMap := obj.Definition.GoType.(*types.Map); !isMap { - for _, bindErr := range bindObject(obj, g.StructTag) { - log.Println(bindErr.Error()) - log.Println(" Adding resolver method") - } - } - - objects = append(objects, obj) - } - - sort.Slice(objects, func(i, j int) bool { - return objects[i].Definition.GQLDefinition.Name < objects[j].Definition.GQLDefinition.Name - }) - - return objects, nil -} - -var keywords = []string{ - "break", - "default", - "func", - "interface", - "select", - "case", - "defer", - "go", - "map", - "struct", - "chan", - "else", - "goto", - "package", - "switch", - "const", - "fallthrough", - "if", - "range", - "type", - "continue", - "for", - "import", - "return", - "var", -} - -// sanitizeArgName prevents collisions with go keywords for arguments to resolver functions -func sanitizeArgName(name string) string { - for _, k := range keywords { - if name == k { - return name + "Arg" - } - } - return name -} - -func (g *Generator) buildObject(prog *loader.Program, ts NamedTypes, typ *ast.Definition) (*Object, error) { - obj := &Object{Definition: ts[typ.Name]} - typeEntry, entryExists := g.Models[typ.Name] - - tt := types.NewTypeName(0, g.Config.Exec.Pkg(), obj.Definition.GQLDefinition.Name+"Resolver", nil) - obj.ResolverInterface = types.NewNamed(tt, nil, nil) - - if typ == g.schema.Query { - obj.Root = true - } - - if typ == g.schema.Mutation { - obj.Root = true - obj.DisableConcurrency = true - } - - if typ == g.schema.Subscription { - obj.Root = true - obj.Stream = true - } - - obj.Satisfies = append(obj.Satisfies, typ.Interfaces...) - - for _, intf := range g.schema.GetImplements(typ) { - obj.Implements = append(obj.Implements, ts[intf.Name]) - } - - for _, field := range typ.Fields { - if typ == g.schema.Query && field.Name == "__type" { - schemaType, err := findGoType(prog, "github.com/99designs/gqlgen/graphql/introspection", "Schema") - if err != nil { - return nil, errors.Wrap(err, "unable to find root schema introspection type") - } - - obj.Fields = append(obj.Fields, Field{ - TypeReference: &TypeReference{ts["__Schema"], types.NewPointer(schemaType.Type()), ast.NamedType("__Schema", nil)}, - GQLName: "__schema", - GoFieldType: GoFieldMethod, - GoReceiverName: "ec", - GoFieldName: "introspectSchema", - Object: obj, - Description: field.Description, - }) - continue - } - if typ == g.schema.Query && field.Name == "__schema" { - typeType, err := findGoType(prog, "github.com/99designs/gqlgen/graphql/introspection", "Type") - if err != nil { - return nil, errors.Wrap(err, "unable to find root schema introspection type") - } - - obj.Fields = append(obj.Fields, Field{ - TypeReference: &TypeReference{ts["__Type"], types.NewPointer(typeType.Type()), ast.NamedType("__Schema", nil)}, - GQLName: "__type", - GoFieldType: GoFieldMethod, - GoReceiverName: "ec", - GoFieldName: "introspectType", - Args: []FieldArgument{ - {GQLName: "name", TypeReference: &TypeReference{ts["String"], types.Typ[types.String], ast.NamedType("String", nil)}, Object: &Object{}}, - }, - Object: obj, - }) - continue - } - - var forceResolver bool - var goName string - if entryExists { - if typeField, ok := typeEntry.Fields[field.Name]; ok { - goName = typeField.FieldName - forceResolver = typeField.Resolver - } - } - - var args []FieldArgument - for _, arg := range field.Arguments { - dirs, err := g.getDirectives(arg.Directives) - if err != nil { - return nil, err - } - newArg := FieldArgument{ - GQLName: arg.Name, - TypeReference: ts.getType(arg.Type), - Object: obj, - GoVarName: sanitizeArgName(arg.Name), - Directives: dirs, - } - - if !newArg.TypeReference.Definition.GQLDefinition.IsInputType() { - return nil, errors.Errorf("%s cannot be used as argument of %s.%s. only input and scalar types are allowed", arg.Type, obj.Definition.GQLDefinition.Name, field.Name) - } - - if arg.DefaultValue != nil { - var err error - newArg.Default, err = arg.DefaultValue.Value(nil) - if err != nil { - return nil, errors.Errorf("default value for %s.%s is not valid: %s", typ.Name, field.Name, err.Error()) - } - } - args = append(args, newArg) - } - - obj.Fields = append(obj.Fields, Field{ - GQLName: field.Name, - TypeReference: ts.getType(field.Type), - Args: args, - Object: obj, - GoFieldName: goName, - ForceResolver: forceResolver, - }) - } - - return obj, nil -} diff --git a/codegen/resolver.go b/codegen/resolver.go new file mode 100644 index 00000000000..ae5a2bb1228 --- /dev/null +++ b/codegen/resolver.go @@ -0,0 +1,53 @@ +package codegen + +import ( + "log" + "os" + + "github.com/99designs/gqlgen/codegen/templates" + "github.com/99designs/gqlgen/codegen/unified" + "github.com/pkg/errors" +) + +type ResolverBuild struct { + *unified.Schema + + PackageName string + ResolverType string + ResolverFound bool +} + +func GenerateResolver(schema *unified.Schema) error { + resolverBuild, err := buildResolver(schema) + if err != nil { + return errors.Wrap(err, "resolver build failed") + } + filename := schema.Config.Resolver.Filename + + if resolverBuild.ResolverFound { + log.Printf("Skipped resolver: %s.%s already exists\n", schema.Config.Resolver.ImportPath(), schema.Config.Resolver.Type) + return nil + } + + if _, err := os.Stat(filename); os.IsNotExist(errors.Cause(err)) { + if err := templates.RenderToFile("resolver.gotpl", filename, resolverBuild); err != nil { + return err + } + } else { + log.Printf("Skipped resolver: %s already exists\n", filename) + } + + return nil +} + +func buildResolver(s *unified.Schema) (*ResolverBuild, error) { + def, _ := s.FindGoType(s.Config.Resolver.ImportPath(), s.Config.Resolver.Type) + resolverFound := def != nil + + return &ResolverBuild{ + Schema: s, + PackageName: s.Config.Resolver.Package, + ResolverType: s.Config.Resolver.Type, + ResolverFound: resolverFound, + }, nil +} diff --git a/codegen/server.go b/codegen/server.go new file mode 100644 index 00000000000..3a42f8baf1f --- /dev/null +++ b/codegen/server.go @@ -0,0 +1,42 @@ +package codegen + +import ( + "log" + "os" + + "github.com/99designs/gqlgen/codegen/config" + "github.com/99designs/gqlgen/codegen/templates" + "github.com/99designs/gqlgen/codegen/unified" + "github.com/pkg/errors" +) + +type ServerBuild struct { + unified.Schema + + PackageName string + ExecPackageName string + ResolverPackageName string +} + +func GenerateServer(filename string, cfg *config.Config) error { + serverBuild := buildServer(cfg) + + serverFilename := abs(filename) + if _, err := os.Stat(serverFilename); os.IsNotExist(errors.Cause(err)) { + err = templates.RenderToFile("server.gotpl", serverFilename, serverBuild) + if err != nil { + return errors.Wrap(err, "generate server failed") + } + } else { + log.Printf("Skipped server: %s already exists\n", serverFilename) + } + return nil +} + +func buildServer(config *config.Config) *ServerBuild { + return &ServerBuild{ + PackageName: config.Resolver.Package, + ExecPackageName: config.Exec.ImportPath(), + ResolverPackageName: config.Resolver.ImportPath(), + } +} diff --git a/codegen/templates/data.go b/codegen/templates/data.go index 0d885d11e3c..4e4739df4ab 100644 --- a/codegen/templates/data.go +++ b/codegen/templates/data.go @@ -3,10 +3,10 @@ package templates var data = map[string]string{ "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.GoType | ref }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if $arg.Directives }}\n\t\t\t\targm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $dArg.IsPtr ( notNil \"Value\" $dArg ) }}\n\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $dArg.Value | dump }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t},\n\t\t\t\t{{- end }}\n\t\t\t\t}...)(ctx, func(ctx2 context.Context) (interface{}, error) {\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn arg{{ $i }}, nil\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.GoType | ref }}); ok {\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.GoType | ref }}\")\n\t\t\t\t}\n\t\t\t{{- else }}\n\t\t\t\tvar err error\n\t\t\t\t{{ $arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\t{{- if eq $arg.Definition.GQLDefinition.Kind \"INPUT_OBJECT\" }}\n\t\t\t\t{{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.Definition.GQLDefinition.Name}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\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\treturn graphql.WriterFunc(func(w io.Writer) {\n\t\t\t\tw.Write([]byte{'{'})\n\t\t\t\tgraphql.MarshalString(field.Alias).MarshalGQL(w)\n\t\t\t\tw.Write([]byte{':'})\n\t\t\t\tfunc() graphql.Marshaler {\n\t\t\t\t\t{{ $field.WriteJson }}\n\t\t\t\t}().MarshalGQL(w)\n\t\t\t\tw.Write([]byte{'}'})\n\t\t\t})\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.Definition.GQLDefinition.Name}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.Definition.GoType | ref}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.Definition.GQLDefinition.Name|quote}},\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.GoType | ref}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.Definition.GQLDefinition.Name}}() {{$object.Definition.GQLDefinition.Name}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.Definition.GQLDefinition.Name|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.Definition.GQLDefinition.Name}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.Definition.GQLDefinition.Name}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.Definition.GQLDefinition.Name|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.Definition.GQLDefinition.Name|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.Definition.GQLDefinition.Name}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.Definition.GQLDefinition.Name}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.Definition.GQLDefinition.Name}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaRaw }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\n)\n\n\n\n// ChainFieldMiddleware add chain by FieldMiddleware\n// nolint: deadcode\nfunc chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware {\n\tn := len(handleFunc)\n\n\tif n > 1 {\n\t\tlastI := n - 1\n\t\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\t\tvar (\n\t\t\t\tchainHandler graphql.Resolver\n\t\t\t\tcurI int\n\t\t\t)\n\t\t\tchainHandler = func(currentCtx context.Context) (interface{}, error) {\n\t\t\t\tif curI == lastI {\n\t\t\t\t\treturn next(currentCtx)\n\t\t\t\t}\n\t\t\t\tcurI++\n\t\t\t\tres, err := handleFunc[curI](currentCtx, chainHandler)\n\t\t\t\tcurI--\n\t\t\t\treturn res, err\n\n\t\t\t}\n\t\t\treturn handleFunc[0](ctx, chainHandler)\n\t\t}\n\t}\n\n\tif n == 1 {\n\t\treturn handleFunc[0]\n\t}\n\n\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\treturn next(ctx)\n\t}\n}\n", + "generated.gotpl": "// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.\n\npackage {{ .PackageName }}\n\nimport (\n\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.Definition.GQLDefinition.Name}}() {{$object.Definition.GQLDefinition.Name}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.Definition.GQLDefinition.Name|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.Definition.GQLDefinition.Name}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.Definition.GQLDefinition.Name}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.Definition.GQLDefinition.Name|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.Definition.GQLDefinition.Name|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.Definition.GQLDefinition.Name}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.Definition.GQLDefinition.Name}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.Definition.GQLDefinition.Name}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaStr }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\n)\n\n\n\n// ChainFieldMiddleware add chain by FieldMiddleware\n// nolint: deadcode\nfunc chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware {\n\tn := len(handleFunc)\n\n\tif n > 1 {\n\t\tlastI := n - 1\n\t\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\t\tvar (\n\t\t\t\tchainHandler graphql.Resolver\n\t\t\t\tcurI int\n\t\t\t)\n\t\t\tchainHandler = func(currentCtx context.Context) (interface{}, error) {\n\t\t\t\tif curI == lastI {\n\t\t\t\t\treturn next(currentCtx)\n\t\t\t\t}\n\t\t\t\tcurI++\n\t\t\t\tres, err := handleFunc[curI](currentCtx, chainHandler)\n\t\t\t\tcurI--\n\t\t\t\treturn res, err\n\n\t\t\t}\n\t\t\treturn handleFunc[0](ctx, chainHandler)\n\t\t}\n\t}\n\n\tif n == 1 {\n\t\treturn handleFunc[0]\n\t}\n\n\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\treturn next(ctx)\n\t}\n}\n", "input.gotpl": "\t{{- if .Definition.IsMarshaled }}\n\tfunc Unmarshal{{ .Definition.GQLDefinition.Name }}(v interface{}) ({{.Definition.GoType | ref}}, error) {\n\t\tvar it {{.Definition.GoType | ref}}\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\n\tfunc (e *executableSchema) {{ .Definition.GQLDefinition.Name }}Middleware(ctx context.Context, obj *{{.Definition.GoType | ref}}) (*{{.Definition.GoType | ref}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := chainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.Definition.GoType | ref}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.Definition.GoType | ref}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t\tc{{$field.GoFieldName}}, err := chainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\t{{ if $field.IsPtr -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"*obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- else -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{ if $field.IsPtr }}*{{end}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.Definition.GoType | ref }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.GoType | ref }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.GoType | ref }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.GoType | ref }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if eq $field.Definition.GQLDefinition.Kind \"INPUT_OBJECT\" }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\n", "interface.gotpl": "{{- $interface := . }}\n\nfunc (ec *executionContext) _{{$interface.Definition.GQLDefinition.Name}}(ctx context.Context, sel ast.SelectionSet, obj *{{$interface.Definition.GoType | ref}}) 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.Definition.GoType | ref}}:\n\t\t\t\treturn ec._{{$implementor.Definition.GQLDefinition.Name}}(ctx, sel, &obj)\n\t\t{{- end}}\n\t\tcase *{{$implementor.Definition.GoType | ref}}:\n\t\t\treturn ec._{{$implementor.Definition.GQLDefinition.Name}}(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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{ range $model := .Models }}\n\t{{with .Description}} {{.|prefixLines \"// \"}} {{end}}\n\t{{- if .Definition.GQLDefinition.IsAbstractType }}\n\t\ttype {{.Definition.GoType | ref }} interface {\n\t\t\tIs{{.Definition.GoType | ref }}()\n\t\t}\n\t{{- else }}\n\t\ttype {{.Definition.GoType | ref }} struct {\n\t\t\t{{- range $field := .Fields }}\n\t\t\t\t{{- with .Description}}\n\t\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t\t{{- end}}\n\t\t\t\t{{ $field.GoFieldName }} {{$field.GoType | ref}} `json:\"{{$field.GQLName}}\"`\n\t\t\t{{- end }}\n\t\t}\n\n\t\t{{- range $iface := .Implements }}\n\t\t\tfunc ({{$model.Definition.GoType | ref }}) Is{{$iface.GoType | ref }}() {}\n\t\t{{- end }}\n\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Description}}{{.|prefixLines \"// \"}} {{end}}\n\ttype {{.Definition.GoType | ref }} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- end}}\n\t\t{{$enum.Definition.GoType | ref }}{{ .Name|toCamel }} {{$enum.Definition.GoType | ref }} = {{.Name|quote}}\n\t{{- end }}\n\t)\n\n\tvar All{{.Definition.GoType | ref }} = []{{.Definition.GoType | ref }}{\n\t{{- range $value := .Values}}\n\t\t{{$enum.Definition.GoType | ref }}{{ .Name|toCamel }},\n\t{{- end }}\n\t}\n\n\tfunc (e {{.Definition.GoType | ref }}) IsValid() bool {\n\t\tswitch e {\n\t\tcase {{ range $index, $element := .Values}}{{if $index}},{{end}}{{ $enum.Definition.GoType | ref }}{{ $element.Name|toCamel }}{{end}}:\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tfunc (e {{.Definition.GoType | ref }}) String() string {\n\t\treturn string(e)\n\t}\n\n\tfunc (e *{{.Definition.GoType | ref }}) 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 = {{.Definition.GoType | ref }}(str)\n\t\tif !e.IsValid() {\n\t\t\treturn fmt.Errorf(\"%s is not a valid {{.Definition.GQLDefinition.Name}}\", str)\n\t\t}\n\t\treturn nil\n\t}\n\n\tfunc (e {{.Definition.GoType | ref }}) MarshalGQL(w io.Writer) {\n\t\tfmt.Fprint(w, strconv.Quote(e.String()))\n\t}\n\n{{- end }}\n", + "models.gotpl": "// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.\n\npackage {{ .PackageName }}\n\nimport (\n\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{- range $model := .Interfaces }}\n\t{{with .Definition.GQLDefinition.Description }} {{.|prefixLines \"// \"}} {{end}}\n\ttype {{.Definition.GoType | ref }} interface {\n\t\tIs{{.Definition.GoType | ref }}()\n\t}\n{{- end }}\n\n{{ range $model := .Models }}\n\t{{with .Definition.GQLDefinition.Description }} {{.|prefixLines \"// \"}} {{end}}\n\ttype {{.Definition.GoType | ref }} struct {\n\t\t{{- range $field := .Fields }}\n\t\t\t{{- with .Definition.GQLDefinition.Description }}\n\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t{{- end}}\n\t\t\t{{ $field.GoFieldName }} {{$field.GoType | ref}} `json:\"{{$field.GQLName}}\"`\n\t\t{{- end }}\n\t}\n\n\t{{- range $iface := .Implements }}\n\t\tfunc ({{$model.Definition.GoType | ref }}) Is{{$iface.GoType | ref }}() {}\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Definition.GQLDefinition.Description }} {{.|prefixLines \"// \"}} {{end}}\n\ttype {{.Definition.GoType | ref }} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- end}}\n\t\t{{$enum.Definition.GoType | ref }}{{ .Name|toCamel }} {{$enum.Definition.GoType | ref }} = {{.Name|quote}}\n\t{{- end }}\n\t)\n\n\tvar All{{.Definition.GoType | ref }} = []{{.Definition.GoType | ref }}{\n\t{{- range $value := .Values}}\n\t\t{{$enum.Definition.GoType | ref }}{{ .Name|toCamel }},\n\t{{- end }}\n\t}\n\n\tfunc (e {{.Definition.GoType | ref }}) IsValid() bool {\n\t\tswitch e {\n\t\tcase {{ range $index, $element := .Values}}{{if $index}},{{end}}{{ $enum.Definition.GoType | ref }}{{ $element.Name|toCamel }}{{end}}:\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tfunc (e {{.Definition.GoType | ref }}) String() string {\n\t\treturn string(e)\n\t}\n\n\tfunc (e *{{.Definition.GoType | ref }}) 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 = {{.Definition.GoType | ref }}(str)\n\t\tif !e.IsValid() {\n\t\t\treturn fmt.Errorf(\"%s is not a valid {{.Definition.GQLDefinition.Name}}\", str)\n\t\t}\n\t\treturn nil\n\t}\n\n\tfunc (e {{.Definition.GoType | ref }}) 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.Definition.GQLDefinition.Name|lcFirst}}Implementors = {{$object.Implementors}}\n\n// nolint: gocyclo, errcheck, gas, goconst\n{{- if .Stream }}\nfunc (ec *executionContext) _{{$object.Definition.GQLDefinition.Name}}(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, {{$object.Definition.GQLDefinition.Name|lcFirst}}Implementors)\n\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\tObject: {{$object.Definition.GQLDefinition.Name|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.Definition.GQLDefinition.Name}}_{{$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.Definition.GQLDefinition.Name}}(ctx context.Context, sel ast.SelectionSet{{if not $object.Root}}, obj *{{$object.Definition.GoType | ref }} {{end}}) graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, {{$object.Definition.GQLDefinition.Name|lcFirst}}Implementors)\n\t{{if $object.Root}}\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tObject: {{$object.Definition.GQLDefinition.Name|quote}},\n\t\t})\n\t{{end}}\n\n\tout := graphql.NewFieldSet(fields)\n\tinvalid := false\n\tfor i, field := range fields {\n\t\tswitch field.Name {\n\t\tcase \"__typename\":\n\t\t\tout.Values[i] = graphql.MarshalString({{$object.Definition.GQLDefinition.Name|quote}})\n\t\t{{- range $field := $object.Fields }}\n\t\tcase \"{{$field.GQLName}}\":\n\t\t\t{{- if $field.IsConcurrent }}\n\t\t\t\tfield := field\n\t\t\t\tout.Concurrently(i, func() (res graphql.Marshaler) {\n\t\t\t\t\tres = ec._{{$object.Definition.GQLDefinition.Name}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\t\tif res == graphql.Null {\n\t\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t\t}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\treturn res\n\t\t\t\t})\n\t\t\t{{- else }}\n\t\t\t\tout.Values[i] = ec._{{$object.Definition.GQLDefinition.Name}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\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\tout.Dispatch()\n\tif invalid { return graphql.Null }\n\treturn out\n}\n{{- end }}\n", "resolver.gotpl": "package {{ .PackageName }}\n\nimport (\n\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/99designs/gqlgen/handler\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\ntype {{.ResolverType}} struct {}\n\n{{ range $object := .Objects -}}\n\t{{- if $object.HasResolvers -}}\n\t\tfunc (r *{{$.ResolverType}}) {{$object.Definition.GQLDefinition.Name}}() {{ $object.ResolverInterface | ref }} {\n\t\t\treturn &{{lcFirst $object.Definition.GQLDefinition.Name}}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.Definition.GQLDefinition.Name}}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.Definition.GQLDefinition.Name}}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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"log\" }}\n\t{{ reserveImport \"net/http\" }}\n\t{{ reserveImport \"os\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/handler\" }}\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({{ lookupImport .ExecPackageName }}.NewExecutableSchema({{ lookupImport .ExecPackageName}}.Config{Resolvers: &{{ lookupImport .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/generated.gotpl b/codegen/templates/generated.gotpl index 5b346eb62ba..d275aac920c 100644 --- a/codegen/templates/generated.gotpl +++ b/codegen/templates/generated.gotpl @@ -279,7 +279,7 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er } var parsedSchema = gqlparser.MustLoadSchema( - {{- range $filename, $schema := .SchemaRaw }} + {{- range $filename, $schema := .SchemaStr }} &ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}}, {{- end }} ) diff --git a/codegen/templates/models.gotpl b/codegen/templates/models.gotpl index 50c149fbf9c..8e1071e8c55 100644 --- a/codegen/templates/models.gotpl +++ b/codegen/templates/models.gotpl @@ -20,31 +20,31 @@ import ( {{ reserveImport "github.com/99designs/gqlgen/graphql/introspection" }} ) -{{ range $model := .Models }} - {{with .Description}} {{.|prefixLines "// "}} {{end}} - {{- if .Definition.GQLDefinition.IsAbstractType }} - type {{.Definition.GoType | ref }} interface { - Is{{.Definition.GoType | ref }}() - } - {{- else }} - type {{.Definition.GoType | ref }} struct { - {{- range $field := .Fields }} - {{- with .Description}} - {{.|prefixLines "// "}} - {{- end}} - {{ $field.GoFieldName }} {{$field.GoType | ref}} `json:"{{$field.GQLName}}"` - {{- end }} - } +{{- range $model := .Interfaces }} + {{with .Definition.GQLDefinition.Description }} {{.|prefixLines "// "}} {{end}} + type {{.Definition.GoType | ref }} interface { + Is{{.Definition.GoType | ref }}() + } +{{- end }} - {{- range $iface := .Implements }} - func ({{$model.Definition.GoType | ref }}) Is{{$iface.GoType | ref }}() {} +{{ range $model := .Models }} + {{with .Definition.GQLDefinition.Description }} {{.|prefixLines "// "}} {{end}} + type {{.Definition.GoType | ref }} struct { + {{- range $field := .Fields }} + {{- with .Definition.GQLDefinition.Description }} + {{.|prefixLines "// "}} + {{- end}} + {{ $field.GoFieldName }} {{$field.GoType | ref}} `json:"{{$field.GQLName}}"` {{- end }} + } + {{- range $iface := .Implements }} + func ({{$model.Definition.GoType | ref }}) Is{{$iface.GoType | ref }}() {} {{- end }} {{- end}} {{ range $enum := .Enums }} - {{with .Description}}{{.|prefixLines "// "}} {{end}} + {{with .Definition.GQLDefinition.Description }} {{.|prefixLines "// "}} {{end}} type {{.Definition.GoType | ref }} string const ( {{- range $value := .Values}} diff --git a/codegen/templates/templates.go b/codegen/templates/templates.go index 44a3cc09d21..e45be8b7fba 100644 --- a/codegen/templates/templates.go +++ b/codegen/templates/templates.go @@ -203,7 +203,7 @@ func RenderToFile(tpl string, filename string, data interface{}) error { var buf *bytes.Buffer buf, err := Run(tpl, data) if err != nil { - return errors.Wrap(err, filename+" generation failed") + return errors.Wrap(err, filename) } b := bytes.Replace(buf.Bytes(), []byte("%%%IMPORTS%%%"), []byte(CurrentImports.String()), -1) diff --git a/codegen/testdata/generateserver.graphqls b/codegen/testdata/generateserver.graphqls new file mode 100644 index 00000000000..bcb0a83a375 --- /dev/null +++ b/codegen/testdata/generateserver.graphqls @@ -0,0 +1,11 @@ +type Query { + user: User +} +type User { + id: Int + fist_name: String +} +enum Status { + OK + ERROR +} diff --git a/codegen/type_build.go b/codegen/type_build.go deleted file mode 100644 index d253652c3ca..00000000000 --- a/codegen/type_build.go +++ /dev/null @@ -1,96 +0,0 @@ -package codegen - -import ( - "fmt" - "go/types" - "strings" - - "github.com/99designs/gqlgen/codegen/templates" - "github.com/pkg/errors" - "github.com/vektah/gqlparser/ast" - "golang.org/x/tools/go/loader" -) - -// namedTypeFromSchema objects for every graphql type, including scalars. There should only be one instance of TypeReference for each thing -func (g *Generator) buildNamedTypes(prog *loader.Program) (NamedTypes, error) { - ts := map[string]*TypeDefinition{} - for _, schemaType := range g.schema.Types { - t := &TypeDefinition{ - GQLDefinition: schemaType, - } - ts[t.GQLDefinition.Name] = t - - var pkgName, typeName string - if userEntry, ok := g.Models[t.GQLDefinition.Name]; ok && userEntry.Model != "" { - // special case for maps - if userEntry.Model == "map[string]interface{}" { - t.GoType = types.NewMap(types.Typ[types.String], types.NewInterface(nil, nil).Complete()) - - continue - } - - pkgName, typeName = pkgAndType(userEntry.Model) - } else if t.GQLDefinition.Kind == ast.Scalar { - pkgName = "github.com/99designs/gqlgen/graphql" - typeName = "String" - } else { - // Missing models, but we need to set up the types so any references will point to the code that will - // get generated - t.GoType = types.NewNamed(types.NewTypeName(0, g.Config.Model.Pkg(), templates.ToCamel(t.GQLDefinition.Name), nil), nil, nil) - - continue - } - - if pkgName == "" { - return nil, fmt.Errorf("missing package name for %s", schemaType.Name) - } - - // External marshal functions - def, _ := findGoType(prog, pkgName, "Marshal"+typeName) - if f, isFunc := def.(*types.Func); isFunc { - sig := def.Type().(*types.Signature) - t.GoType = sig.Params().At(0).Type() - t.Marshaler = f - - unmarshal, err := findGoType(prog, pkgName, "Unmarshal"+typeName) - if err != nil { - return nil, errors.Wrapf(err, "unable to find unmarshal func for %s.%s", pkgName, typeName) - } - t.Unmarshaler = unmarshal.(*types.Func) - continue - } - - // Normal object binding - obj, err := findGoType(prog, pkgName, typeName) - if err != nil { - return nil, errors.Wrapf(err, "unable to find %s.%s", pkgName, typeName) - } - t.GoType = obj.Type() - - namedType := obj.Type().(*types.Named) - hasUnmarshal := false - for i := 0; i < namedType.NumMethods(); i++ { - switch namedType.Method(i).Name() { - case "UnmarshalGQL": - hasUnmarshal = true - } - } - - // Special case to reference generated unmarshal functions - if !hasUnmarshal { - t.Unmarshaler = types.NewFunc(0, g.Config.Exec.Pkg(), "Unmarshal"+schemaType.Name, nil) - } - - } - return ts, nil -} - -// take a string in the form github.com/package/blah.TypeReference and split it into package and type -func pkgAndType(name string) (string, string) { - parts := strings.Split(name, ".") - if len(parts) == 1 { - return "", name - } - - return normalizeVendor(strings.Join(parts[:len(parts)-1], ".")), parts[len(parts)-1] -} diff --git a/codegen/unified/build.go b/codegen/unified/build.go new file mode 100644 index 00000000000..6742ed61aad --- /dev/null +++ b/codegen/unified/build.go @@ -0,0 +1,146 @@ +package unified + +import ( + "go/types" + "sort" + + "fmt" + + "github.com/99designs/gqlgen/codegen/config" + "github.com/pkg/errors" + "github.com/vektah/gqlparser/ast" +) + +func NewSchema(cfg *config.Config) (*Schema, error) { + g := Schema{ + Config: cfg, + } + + var err error + g.Schema, g.SchemaStr, err = cfg.LoadSchema() + if err != nil { + return nil, err + } + + err = cfg.Check() + if err != nil { + return nil, err + } + + progLoader := g.Config.NewLoaderWithoutErrors() + g.Program, err = progLoader.Load() + if err != nil { + return nil, errors.Wrap(err, "loading failed") + } + + g.NamedTypes = NamedTypes{} + + for _, schemaType := range g.Schema.Types { + g.NamedTypes[schemaType.Name], err = g.buildTypeDef(schemaType) + if err != nil { + return nil, errors.Wrap(err, "unable to build type definition") + } + } + + g.Directives, err = g.buildDirectives() + if err != nil { + return nil, err + } + + for _, schemaType := range g.Schema.Types { + switch schemaType.Kind { + case ast.Object: + obj, err := g.buildObject(schemaType) + if err != nil { + return nil, errors.Wrap(err, "unable to build object definition") + } + + g.Objects = append(g.Objects, obj) + case ast.InputObject: + input, err := g.buildInput(schemaType) + if err != nil { + return nil, errors.Wrap(err, "unable to build input definition") + } + + g.Inputs = append(g.Inputs, input) + + case ast.Union, ast.Interface: + g.Interfaces = append(g.Interfaces, g.buildInterface(schemaType)) + + case ast.Enum: + if enum := g.buildEnum(schemaType); enum != nil { + g.Enums = append(g.Enums, *enum) + } + } + } + + if err := g.injectIntrospectionRoots(); err != nil { + return nil, err + } + + sort.Slice(g.Objects, func(i, j int) bool { + return g.Objects[i].Definition.GQLDefinition.Name < g.Objects[j].Definition.GQLDefinition.Name + }) + + sort.Slice(g.Inputs, func(i, j int) bool { + return g.Inputs[i].Definition.GQLDefinition.Name < g.Inputs[j].Definition.GQLDefinition.Name + }) + + sort.Slice(g.Interfaces, func(i, j int) bool { + return g.Interfaces[i].Definition.GQLDefinition.Name < g.Interfaces[j].Definition.GQLDefinition.Name + }) + + sort.Slice(g.Enums, func(i, j int) bool { + return g.Enums[i].Definition.GQLDefinition.Name < g.Enums[j].Definition.GQLDefinition.Name + }) + + return &g, nil +} + +func (g *Schema) injectIntrospectionRoots() error { + obj := g.Objects.ByName(g.Schema.Query.Name) + if obj == nil { + return fmt.Errorf("root query type must be defined") + } + + typeType, err := g.FindGoType("github.com/99designs/gqlgen/graphql/introspection", "Type") + if err != nil { + return errors.Wrap(err, "unable to find root Type introspection type") + } + + obj.Fields = append(obj.Fields, &Field{ + TypeReference: &TypeReference{g.NamedTypes["__Type"], types.NewPointer(typeType.Type()), ast.NamedType("__Schema", nil)}, + GQLName: "__type", + GoFieldType: GoFieldMethod, + GoReceiverName: "ec", + GoFieldName: "introspectType", + Args: []FieldArgument{ + { + GQLName: "name", + TypeReference: &TypeReference{ + g.NamedTypes["String"], + types.Typ[types.String], + ast.NamedType("String", nil), + }, + Object: &Object{}, + }, + }, + Object: obj, + }) + + schemaType, err := g.FindGoType("github.com/99designs/gqlgen/graphql/introspection", "Schema") + if err != nil { + return errors.Wrap(err, "unable to find root Schema introspection type") + } + + obj.Fields = append(obj.Fields, &Field{ + TypeReference: &TypeReference{g.NamedTypes["__Schema"], types.NewPointer(schemaType.Type()), ast.NamedType("__Schema", nil)}, + GQLName: "__schema", + GoFieldType: GoFieldMethod, + GoReceiverName: "ec", + GoFieldName: "introspectSchema", + Object: obj, + }) + + return nil +} diff --git a/codegen/util.go b/codegen/unified/build_bind.go similarity index 52% rename from codegen/util.go rename to codegen/unified/build_bind.go index ff822ac9a6c..fdc83b9a35e 100644 --- a/codegen/util.go +++ b/codegen/unified/build_bind.go @@ -1,178 +1,14 @@ -package codegen +package unified import ( "fmt" "go/types" - "reflect" "regexp" "strings" "github.com/pkg/errors" - "golang.org/x/tools/go/loader" ) -func findGoType(prog *loader.Program, pkgName string, typeName string) (types.Object, error) { - if pkgName == "" { - return nil, nil - } - fullName := typeName - if pkgName != "" { - fullName = pkgName + "." + typeName - } - - pkgName, err := resolvePkg(pkgName) - if err != nil { - return nil, errors.Errorf("unable to resolve package for %s: %s\n", fullName, err.Error()) - } - - pkg := prog.Imported[pkgName] - if pkg == nil { - return nil, errors.Errorf("required package was not loaded: %s", fullName) - } - - for astNode, def := range pkg.Defs { - if astNode.Name != typeName || def.Parent() == nil || def.Parent() != pkg.Pkg.Scope() { - continue - } - - return def, nil - } - - return nil, errors.Errorf("unable to find type %s\n", fullName) -} - -func findGoNamedType(def types.Type) (*types.Named, error) { - if def == nil { - return nil, nil - } - - namedType, ok := def.(*types.Named) - if !ok { - return nil, errors.Errorf("expected %s to be a named type, instead found %T\n", def.String(), def) - } - - return namedType, nil -} - -func findGoInterface(def types.Type) (*types.Interface, error) { - if def == nil { - return nil, nil - } - namedType, err := findGoNamedType(def) - if err != nil { - return nil, err - } - if namedType == nil { - return nil, nil - } - - underlying, ok := namedType.Underlying().(*types.Interface) - if !ok { - return nil, errors.Errorf("expected %s to be a named interface, instead found %s", def.String(), namedType.String()) - } - - return underlying, nil -} - -func findMethod(typ *types.Named, name string) *types.Func { - for i := 0; i < typ.NumMethods(); i++ { - method := typ.Method(i) - if !method.Exported() { - continue - } - - if strings.EqualFold(method.Name(), name) { - return method - } - } - - if s, ok := typ.Underlying().(*types.Struct); ok { - for i := 0; i < s.NumFields(); i++ { - field := s.Field(i) - if !field.Anonymous() { - continue - } - - if named, ok := field.Type().(*types.Named); ok { - if f := findMethod(named, name); f != nil { - return f - } - } - } - } - - return nil -} - -func equalFieldName(source, target string) bool { - source = strings.Replace(source, "_", "", -1) - target = strings.Replace(target, "_", "", -1) - return strings.EqualFold(source, target) -} - -// findField attempts to match the name to a struct field with the following -// priorites: -// 1. If struct tag is passed then struct tag has highest priority -// 2. Field in an embedded struct -// 3. Actual Field name -func findField(typ *types.Struct, name, structTag string) (*types.Var, error) { - var foundField *types.Var - foundFieldWasTag := false - - for i := 0; i < typ.NumFields(); i++ { - field := typ.Field(i) - - if structTag != "" { - tags := reflect.StructTag(typ.Tag(i)) - if val, ok := tags.Lookup(structTag); ok { - if equalFieldName(val, name) { - if foundField != nil && foundFieldWasTag { - return nil, errors.Errorf("tag %s is ambigious; multiple fields have the same tag value of %s", structTag, val) - } - - foundField = field - foundFieldWasTag = true - } - } - } - - if field.Anonymous() { - - fieldType := field.Type() - - if ptr, ok := fieldType.(*types.Pointer); ok { - fieldType = ptr.Elem() - } - - // Type.Underlying() returns itself for all types except types.Named, where it returns a struct type. - // It should be safe to always call. - if named, ok := fieldType.Underlying().(*types.Struct); ok { - f, err := findField(named, name, structTag) - if err != nil && !strings.HasPrefix(err.Error(), "no field named") { - return nil, err - } - if f != nil && foundField == nil { - foundField = f - } - } - } - - if !field.Exported() { - continue - } - - if equalFieldName(field.Name(), name) && foundField == nil { // aqui! - foundField = field - } - } - - if foundField == nil { - return nil, fmt.Errorf("no field named %s", name) - } - - return foundField, nil -} - type BindError struct { object *Object field *Field @@ -183,7 +19,7 @@ type BindError struct { func (b BindError) Error() string { return fmt.Sprintf( - "Unable to bind %s.%s to %s\n %s\n %s", + "\nunable to bind %s.%s to %s\n %s\n %s", b.object.Definition.GQLDefinition.Name, b.field.GQLName, b.typ.String(), @@ -204,10 +40,8 @@ func (b BindErrors) Error() string { func bindObject(object *Object, structTag string) BindErrors { var errs BindErrors - for i := range object.Fields { - field := &object.Fields[i] - - if field.ForceResolver { + for _, field := range object.Fields { + if field.IsResolver { continue } @@ -221,6 +55,8 @@ func bindObject(object *Object, structTag string) BindErrors { varErr := bindVar(object.Definition.GoType, field, structTag) if varErr != nil { + field.IsResolver = true + errs = append(errs, BindError{ object: object, typ: object.Definition.GoType, @@ -318,7 +154,7 @@ nextArg: param := params.At(j) for _, oldArg := range field.Args { if strings.EqualFold(oldArg.GQLName, param.Name()) { - if !field.ForceResolver { + if !field.IsResolver { oldArg.TypeReference.GoType = param.Type() } newArgs = append(newArgs, oldArg) diff --git a/codegen/util_test.go b/codegen/unified/build_bind_test.go similarity index 99% rename from codegen/util_test.go rename to codegen/unified/build_bind_test.go index 37b54c4c4f8..5e0f6f997c9 100644 --- a/codegen/util_test.go +++ b/codegen/unified/build_bind_test.go @@ -1,4 +1,4 @@ -package codegen +package unified import ( "go/ast" diff --git a/codegen/directive_build.go b/codegen/unified/build_directive.go similarity index 62% rename from codegen/directive_build.go rename to codegen/unified/build_directive.go index e27a08ce479..0b7c7f53b54 100644 --- a/codegen/directive_build.go +++ b/codegen/unified/build_directive.go @@ -1,14 +1,16 @@ -package codegen +package unified import ( + "fmt" + "github.com/pkg/errors" "github.com/vektah/gqlparser/ast" ) -func (g *Generator) buildDirectives(types NamedTypes) (map[string]*Directive, error) { - directives := make(map[string]*Directive, len(g.schema.Directives)) +func (g *Schema) buildDirectives() (map[string]*Directive, error) { + directives := make(map[string]*Directive, len(g.Schema.Directives)) - for name, dir := range g.schema.Directives { + for name, dir := range g.Schema.Directives { if _, ok := directives[name]; ok { return nil, errors.Errorf("directive with name %s already exists", name) } @@ -21,7 +23,7 @@ func (g *Generator) buildDirectives(types NamedTypes) (map[string]*Directive, er newArg := FieldArgument{ GQLName: arg.Name, - TypeReference: types.getType(arg.Type), + TypeReference: g.NamedTypes.getType(arg.Type), GoVarName: sanitizeArgName(arg.Name), } @@ -48,8 +50,7 @@ func (g *Generator) buildDirectives(types NamedTypes) (map[string]*Directive, er return directives, nil } -func (g *Generator) getDirectives(list ast.DirectiveList) ([]*Directive, error) { - +func (g *Schema) getDirectives(list ast.DirectiveList) ([]*Directive, error) { dirs := make([]*Directive, len(list)) for i, d := range list { argValues := make(map[string]interface{}, len(d.Arguments)) @@ -60,27 +61,29 @@ func (g *Generator) getDirectives(list ast.DirectiveList) ([]*Directive, error) } argValues[da.Name] = val } + def, ok := g.Directives[d.Name] + if !ok { + return nil, fmt.Errorf("directive %s not found", d.Name) + } - if def, ok := g.Directives[d.Name]; ok { - var args []FieldArgument - for _, a := range def.Args { - - value := a.Default - if argValue, ok := argValues[a.GQLName]; ok { - value = argValue - } - args = append(args, FieldArgument{ - GQLName: a.GQLName, - Value: value, - GoVarName: a.GoVarName, - TypeReference: a.TypeReference, - }) - } - dirs[i] = &Directive{ - Name: d.Name, - Args: args, + var args []FieldArgument + for _, a := range def.Args { + value := a.Default + if argValue, ok := argValues[a.GQLName]; ok { + value = argValue } + args = append(args, FieldArgument{ + GQLName: a.GQLName, + Value: value, + GoVarName: a.GoVarName, + TypeReference: a.TypeReference, + }) } + dirs[i] = &Directive{ + Name: d.Name, + Args: args, + } + } return dirs, nil diff --git a/codegen/unified/build_enum.go b/codegen/unified/build_enum.go new file mode 100644 index 00000000000..5602e138026 --- /dev/null +++ b/codegen/unified/build_enum.go @@ -0,0 +1,31 @@ +package unified + +import ( + "go/types" + "strings" + + "github.com/99designs/gqlgen/codegen/templates" + "github.com/vektah/gqlparser/ast" +) + +func (g *Schema) buildEnum(typ *ast.Definition) *Enum { + namedType := g.NamedTypes[typ.Name] + if typ.Kind != ast.Enum || strings.HasPrefix(typ.Name, "__") || g.Config.Models.UserDefined(typ.Name) { + return nil + } + + var values []EnumValue + for _, v := range typ.EnumValues { + values = append(values, EnumValue{v.Name, v.Description}) + } + + enum := Enum{ + Definition: namedType, + Values: values, + InTypemap: g.Config.Models.UserDefined(typ.Name), + } + + enum.Definition.GoType = types.NewNamed(types.NewTypeName(0, g.Config.Model.Pkg(), templates.ToCamel(enum.Definition.GQLDefinition.Name), nil), nil, nil) + + return &enum +} diff --git a/codegen/unified/build_input.go b/codegen/unified/build_input.go new file mode 100644 index 00000000000..6f6b78c47df --- /dev/null +++ b/codegen/unified/build_input.go @@ -0,0 +1,47 @@ +package unified + +import ( + "go/types" + + "github.com/pkg/errors" + "github.com/vektah/gqlparser/ast" +) + +func (g *Schema) buildInput(typ *ast.Definition) (*Object, error) { + obj := &Object{ + Definition: g.NamedTypes[typ.Name], + InTypemap: g.Config.Models.UserDefined(typ.Name), + } + + for _, field := range typ.Fields { + newField, err := g.buildField(obj, field) + if err != nil { + return nil, err + } + + if !newField.TypeReference.Definition.GQLDefinition.IsInputType() { + return nil, errors.Errorf( + "%s cannot be used as a field of %s. only input and scalar types are allowed", + newField.Definition.GQLDefinition.Name, + obj.Definition.GQLDefinition.Name, + ) + } + + obj.Fields = append(obj.Fields, newField) + + } + dirs, err := g.getDirectives(typ.Directives) + if err != nil { + return nil, err + } + obj.Directives = dirs + + if _, isMap := obj.Definition.GoType.(*types.Map); !isMap && obj.InTypemap { + bindErrs := bindObject(obj, g.Config.StructTag) + if len(bindErrs) > 0 { + return nil, bindErrs + } + } + + return obj, nil +} diff --git a/codegen/unified/build_interface.go b/codegen/unified/build_interface.go new file mode 100644 index 00000000000..861d3415c8b --- /dev/null +++ b/codegen/unified/build_interface.go @@ -0,0 +1,50 @@ +package unified + +import ( + "go/types" + "strings" + + "github.com/vektah/gqlparser/ast" +) + +func (g *Schema) buildInterface(typ *ast.Definition) *Interface { + i := &Interface{ + Definition: g.NamedTypes[typ.Name], + InTypemap: g.Config.Models.UserDefined(typ.Name), + } + + for _, implementor := range g.Schema.GetPossibleTypes(typ) { + t := g.NamedTypes[implementor.Name] + + i.Implementors = append(i.Implementors, InterfaceImplementor{ + Definition: t, + ValueReceiver: g.isValueReceiver(g.NamedTypes[typ.Name], t), + }) + } + + return i +} + +func (g *Schema) isValueReceiver(intf *TypeDefinition, implementor *TypeDefinition) bool { + interfaceType, err := findGoInterface(intf.GoType) + if interfaceType == nil || err != nil { + return true + } + + implementorType, err := findGoNamedType(implementor.GoType) + if implementorType == nil || err != nil { + return true + } + + return types.Implements(implementorType, interfaceType) +} + +// take a string in the form github.com/package/blah.TypeReference and split it into package and type +func pkgAndType(name string) (string, string) { + parts := strings.Split(name, ".") + if len(parts) == 1 { + return "", name + } + + return normalizeVendor(strings.Join(parts[:len(parts)-1], ".")), parts[len(parts)-1] +} diff --git a/codegen/unified/build_object.go b/codegen/unified/build_object.go new file mode 100644 index 00000000000..f2f999ddaaf --- /dev/null +++ b/codegen/unified/build_object.go @@ -0,0 +1,137 @@ +package unified + +import ( + "go/types" + "log" + + "strings" + + "github.com/pkg/errors" + "github.com/vektah/gqlparser/ast" +) + +func (g *Schema) buildObject(typ *ast.Definition) (*Object, error) { + obj := &Object{ + Definition: g.NamedTypes[typ.Name], + InTypemap: g.Config.Models.UserDefined(typ.Name), + } + + tt := types.NewTypeName(0, g.Config.Exec.Pkg(), obj.Definition.GQLDefinition.Name+"Resolver", nil) + obj.ResolverInterface = types.NewNamed(tt, nil, nil) + + if typ == g.Schema.Query { + obj.Root = true + obj.InTypemap = true + } + + if typ == g.Schema.Mutation { + obj.Root = true + obj.DisableConcurrency = true + obj.InTypemap = true + } + + if typ == g.Schema.Subscription { + obj.Root = true + obj.Stream = true + obj.InTypemap = true + } + + obj.Satisfies = append(obj.Satisfies, typ.Interfaces...) + + for _, intf := range g.Schema.GetImplements(typ) { + obj.Implements = append(obj.Implements, g.NamedTypes[intf.Name]) + } + + for _, field := range typ.Fields { + if strings.HasPrefix(field.Name, "__") { + continue + } + + f, err := g.buildField(obj, field) + if err != nil { + return nil, err + } + + obj.Fields = append(obj.Fields, f) + } + + dirs, err := g.getDirectives(typ.Directives) + if err != nil { + return nil, err + } + obj.Directives = dirs + + if _, isMap := obj.Definition.GoType.(*types.Map); !isMap && obj.InTypemap { + for _, bindErr := range bindObject(obj, g.Config.StructTag) { + log.Println(bindErr.Error()) + log.Println(" Adding resolver method") + } + } + + return obj, nil +} + +func (g *Schema) buildField(obj *Object, field *ast.FieldDefinition) (*Field, error) { + dirs, err := g.getDirectives(field.Directives) + if err != nil { + return nil, err + } + + f := Field{ + GQLName: field.Name, + TypeReference: g.NamedTypes.getType(field.Type), + Object: obj, + Directives: dirs, + GoFieldName: lintName(ucFirst(field.Name)), + GoFieldType: GoFieldVariable, + GoReceiverName: "obj", + } + + if field.DefaultValue != nil { + var err error + f.Default, err = field.DefaultValue.Value(nil) + if err != nil { + return nil, errors.Errorf("default value for %s.%s is not valid: %s", obj.Definition.GQLDefinition.Name, field.Name, err.Error()) + } + } + + typeEntry, entryExists := g.Config.Models[obj.Definition.GQLDefinition.Name] + if entryExists { + if typeField, ok := typeEntry.Fields[field.Name]; ok { + if typeField.Resolver { + f.IsResolver = true + } + if typeField.FieldName != "" { + f.GoFieldName = lintName(ucFirst(typeField.FieldName)) + } + } + } + + for _, arg := range field.Arguments { + argDirs, err := g.getDirectives(arg.Directives) + if err != nil { + return nil, err + } + newArg := FieldArgument{ + GQLName: arg.Name, + TypeReference: g.NamedTypes.getType(arg.Type), + Object: obj, + GoVarName: sanitizeArgName(arg.Name), + Directives: argDirs, + } + + if !newArg.TypeReference.Definition.GQLDefinition.IsInputType() { + return nil, errors.Errorf("%s cannot be used as argument of %s.%s. only input and scalar types are allowed", arg.Type, obj.Definition.GQLDefinition.Name, field.Name) + } + + if arg.DefaultValue != nil { + var err error + newArg.Default, err = arg.DefaultValue.Value(nil) + if err != nil { + return nil, errors.Errorf("default value for %s.%s is not valid: %s", obj.Definition.GQLDefinition.Name, field.Name, err.Error()) + } + } + f.Args = append(f.Args, newArg) + } + return &f, nil +} diff --git a/codegen/unified/build_typedef.go b/codegen/unified/build_typedef.go new file mode 100644 index 00000000000..0ef8fea2882 --- /dev/null +++ b/codegen/unified/build_typedef.go @@ -0,0 +1,109 @@ +package unified + +import ( + "fmt" + "go/types" + + "github.com/99designs/gqlgen/codegen/templates" + "github.com/pkg/errors" + "github.com/vektah/gqlparser/ast" +) + +func (g *Schema) buildTypeDef(schemaType *ast.Definition) (*TypeDefinition, error) { + t := &TypeDefinition{ + GQLDefinition: schemaType, + } + + var pkgName, typeName string + if userEntry, ok := g.Config.Models[t.GQLDefinition.Name]; ok && userEntry.Model != "" { + // special case for maps + if userEntry.Model == "map[string]interface{}" { + t.GoType = types.NewMap(types.Typ[types.String], types.NewInterface(nil, nil).Complete()) + + return t, nil + } + + pkgName, typeName = pkgAndType(userEntry.Model) + } else if t.GQLDefinition.Kind == ast.Scalar { + pkgName = "github.com/99designs/gqlgen/graphql" + typeName = "String" + } else { + // Missing models, but we need to set up the types so any references will point to the code that will + // get generated + t.GoType = types.NewNamed(types.NewTypeName(0, g.Config.Model.Pkg(), templates.ToCamel(t.GQLDefinition.Name), nil), nil, nil) + + if t.GQLDefinition.Kind != ast.Enum { + t.Unmarshaler = types.NewFunc(0, g.Config.Exec.Pkg(), "Unmarshal"+schemaType.Name, nil) + } + + return t, nil + } + + if pkgName == "" { + return nil, fmt.Errorf("missing package name for %s", schemaType.Name) + } + + // External marshal functions + def, _ := g.FindGoType(pkgName, "Marshal"+typeName) + if f, isFunc := def.(*types.Func); isFunc { + sig := def.Type().(*types.Signature) + t.GoType = sig.Params().At(0).Type() + t.Marshaler = f + + unmarshal, err := g.FindGoType(pkgName, "Unmarshal"+typeName) + if err != nil { + return nil, errors.Wrapf(err, "unable to find unmarshal func for %s.%s", pkgName, typeName) + } + t.Unmarshaler = unmarshal.(*types.Func) + return t, nil + } + + // Normal object binding + obj, err := g.FindGoType(pkgName, typeName) + if err != nil { + return nil, errors.Wrapf(err, "unable to find %s.%s", pkgName, typeName) + } + t.GoType = obj.Type() + + namedType := obj.Type().(*types.Named) + hasUnmarshal := false + for i := 0; i < namedType.NumMethods(); i++ { + switch namedType.Method(i).Name() { + case "UnmarshalGQL": + hasUnmarshal = true + } + } + + // Special case to reference generated unmarshal functions + if !hasUnmarshal { + t.Unmarshaler = types.NewFunc(0, g.Config.Exec.Pkg(), "Unmarshal"+schemaType.Name, nil) + } + + return t, nil +} + +func (n NamedTypes) goTypeForAst(t *ast.Type) types.Type { + if t.Elem != nil { + return types.NewSlice(n.goTypeForAst(t.Elem)) + } + + nt := n[t.NamedType] + gt := nt.GoType + if gt == nil { + panic("missing type " + t.NamedType) + } + + if !t.NonNull && nt.GQLDefinition.Kind != ast.Interface { + return types.NewPointer(gt) + } + + return gt +} + +func (n NamedTypes) getType(t *ast.Type) *TypeReference { + return &TypeReference{ + Definition: n[t.Name()], + GoType: n.goTypeForAst(t), + ASTType: t, + } +} diff --git a/codegen/directive.go b/codegen/unified/directive.go similarity index 98% rename from codegen/directive.go rename to codegen/unified/directive.go index f9f000bafba..2cc65c244c6 100644 --- a/codegen/directive.go +++ b/codegen/unified/directive.go @@ -1,4 +1,4 @@ -package codegen +package unified import ( "fmt" diff --git a/codegen/unified/enum.go b/codegen/unified/enum.go new file mode 100644 index 00000000000..e7f365f6789 --- /dev/null +++ b/codegen/unified/enum.go @@ -0,0 +1,12 @@ +package unified + +type Enum struct { + Definition *TypeDefinition + Values []EnumValue + InTypemap bool +} + +type EnumValue struct { + Name string + Description string +} diff --git a/codegen/interface.go b/codegen/unified/interface.go similarity index 83% rename from codegen/interface.go rename to codegen/unified/interface.go index 045bdba88e6..3517b853cfa 100644 --- a/codegen/interface.go +++ b/codegen/unified/interface.go @@ -1,8 +1,9 @@ -package codegen +package unified type Interface struct { Definition *TypeDefinition Implementors []InterfaceImplementor + InTypemap bool } type InterfaceImplementor struct { diff --git a/codegen/object.go b/codegen/unified/object.go similarity index 89% rename from codegen/object.go rename to codegen/unified/object.go index afdbcf12e40..dd6dfec5061 100644 --- a/codegen/object.go +++ b/codegen/unified/object.go @@ -1,4 +1,4 @@ -package codegen +package unified import ( "bytes" @@ -24,7 +24,7 @@ const ( type Object struct { Definition *TypeDefinition - Fields []Field + Fields []*Field Satisfies []string Implements []*TypeDefinition ResolverInterface types.Type @@ -32,17 +32,17 @@ type Object struct { DisableConcurrency bool Stream bool Directives []*Directive + InTypemap bool } type Field struct { *TypeReference - Description string // Description of a field GQLName string // The name of the field in graphql GoFieldType GoFieldType // The field type in go, if any GoReceiverName string // The name of method & var receiver in go, if any GoFieldName string // The name of the method or var in go, if any + IsResolver bool // Does this field need a resolver Args []FieldArgument // A list of arguments to be passed to this field - ForceResolver bool // Should be emit Resolver method MethodHasContext bool // If this is bound to a go method, does the method also take a context NoErr bool // If this is bound to a go method, does that method have an error as the second argument Object *Object // A link back to the parent object @@ -58,7 +58,7 @@ type FieldArgument struct { Object *Object // A link back to the parent object Default interface{} // The default value Directives []*Directive - Value interface{} // value set in schema + Value interface{} // value set in Schema } type Objects []*Object @@ -73,7 +73,7 @@ func (o *Object) Implementors() string { func (o *Object) HasResolvers() bool { for _, f := range o.Fields { - if f.IsResolver() { + if f.IsResolver { return true } } @@ -105,12 +105,12 @@ func (o *Object) IsReserved() bool { return strings.HasPrefix(o.Definition.GQLDefinition.Name, "__") } -func (f *Field) HasDirectives() bool { - return len(f.Directives) > 0 +func (o *Object) Description() string { + return o.Definition.GQLDefinition.Description } -func (f *Field) IsResolver() bool { - return f.GoFieldName == "" +func (f *Field) HasDirectives() bool { + return len(f.Directives) > 0 } func (f *Field) IsReserved() bool { @@ -129,11 +129,7 @@ func (f *Field) IsConcurrent() bool { if f.Object.DisableConcurrency { return false } - return f.MethodHasContext || f.IsResolver() -} - -func (f *Field) GoNameExported() string { - return lintName(ucFirst(f.GQLName)) + return f.MethodHasContext || f.IsResolver } func (f *Field) GoNameUnexported() string { @@ -141,11 +137,7 @@ func (f *Field) GoNameUnexported() string { } func (f *Field) ShortInvocation() string { - if !f.IsResolver() { - return "" - } - - return fmt.Sprintf("%s().%s(%s)", f.Object.Definition.GQLDefinition.Name, f.GoNameExported(), f.CallArgs()) + return fmt.Sprintf("%s().%s(%s)", f.Object.Definition.GQLDefinition.Name, f.GoFieldName, f.CallArgs()) } func (f *Field) ArgsFunc() string { @@ -157,40 +149,18 @@ func (f *Field) ArgsFunc() string { } func (f *Field) ResolverType() string { - if !f.IsResolver() { + if !f.IsResolver { return "" } - return fmt.Sprintf("%s().%s(%s)", f.Object.Definition.GQLDefinition.Name, f.GoNameExported(), f.CallArgs()) + return fmt.Sprintf("%s().%s(%s)", f.Object.Definition.GQLDefinition.Name, f.GoFieldName, f.CallArgs()) } func (f *Field) ShortResolverDeclaration() string { - if !f.IsResolver() { - return "" - } - res := fmt.Sprintf("%s(ctx context.Context", f.GoNameExported()) - - if !f.Object.Root { - res += fmt.Sprintf(", obj *%s", templates.CurrentImports.LookupType(f.Object.Definition.GoType)) - } - for _, arg := range f.Args { - res += fmt.Sprintf(", %s %s", arg.GoVarName, templates.CurrentImports.LookupType(arg.GoType)) - } - - result := templates.CurrentImports.LookupType(f.GoType) - if f.Object.Stream { - result = "<-chan " + result - } - - res += fmt.Sprintf(") (%s, error)", result) - return res -} - -func (f *Field) ResolverDeclaration() string { - if !f.IsResolver() { + if !f.IsResolver { return "" } - res := fmt.Sprintf("%s_%s(ctx context.Context", f.Object.Definition.GQLDefinition.Name, f.GoNameUnexported()) + res := fmt.Sprintf("%s(ctx context.Context", f.GoFieldName) if !f.Object.Root { res += fmt.Sprintf(", obj *%s", templates.CurrentImports.LookupType(f.Object.Definition.GoType)) @@ -229,7 +199,7 @@ func (f *Field) ComplexityArgs() string { func (f *Field) CallArgs() string { var args []string - if f.IsResolver() { + if f.IsResolver { args = append(args, "rctx") if !f.Object.Root { diff --git a/codegen/unified/schema.go b/codegen/unified/schema.go new file mode 100644 index 00000000000..315c3172b34 --- /dev/null +++ b/codegen/unified/schema.go @@ -0,0 +1,22 @@ +package unified + +import ( + "github.com/99designs/gqlgen/codegen/config" + "github.com/vektah/gqlparser/ast" + "golang.org/x/tools/go/loader" +) + +// Schema is the result of merging the GraphQL Schema with the existing go code +type Schema struct { + SchemaFilename config.SchemaFilenames + Config *config.Config + Schema *ast.Schema + SchemaStr map[string]string + Program *loader.Program + Directives map[string]*Directive + NamedTypes NamedTypes + Objects Objects + Inputs Objects + Interfaces []*Interface + Enums []Enum +} diff --git a/codegen/unified/schema_test.go b/codegen/unified/schema_test.go new file mode 100644 index 00000000000..599c485fa3e --- /dev/null +++ b/codegen/unified/schema_test.go @@ -0,0 +1,30 @@ +package unified + +import ( + "testing" + + "github.com/99designs/gqlgen/codegen/config" + "github.com/stretchr/testify/require" +) + +func TestTypeUnionAsInput(t *testing.T) { + err := generate("inputunion", `testdata/unioninput.graphqls`) + + require.EqualError(t, err, "unable to build object definition: Bookmarkable! cannot be used as argument of Query.addBookmark. only input and scalar types are allowed") +} + +func TestTypeInInput(t *testing.T) { + err := generate("typeinput", `testdata/typeinput.graphqls`) + + require.EqualError(t, err, "unable to build input definition: Item cannot be used as a field of BookmarkableInput. only input and scalar types are allowed") +} + +func generate(name string, schemaFilename string) error { + _, err := NewSchema(&config.Config{ + SchemaFilename: config.SchemaFilenames{schemaFilename}, + Exec: config.PackageConfig{Filename: "gen/" + name + "/exec.go"}, + Model: config.PackageConfig{Filename: "gen/" + name + "/model.go"}, + }) + + return err +} diff --git a/codegen/unified/testdata/typeinput.graphqls b/codegen/unified/testdata/typeinput.graphqls new file mode 100644 index 00000000000..ba0438afca4 --- /dev/null +++ b/codegen/unified/testdata/typeinput.graphqls @@ -0,0 +1,7 @@ +type Query { + addBookmark(b: BookmarkableInput!): Boolean! +} +type Item {name: String} +input BookmarkableInput { + item: Item +} diff --git a/codegen/unified/testdata/unioninput.graphqls b/codegen/unified/testdata/unioninput.graphqls new file mode 100644 index 00000000000..b1a17b1dd1f --- /dev/null +++ b/codegen/unified/testdata/unioninput.graphqls @@ -0,0 +1,5 @@ +type Query { + addBookmark(b: Bookmarkable!): Boolean! +} +type Item {name: String} +union Bookmarkable = Item diff --git a/codegen/type_definition.go b/codegen/unified/type_definition.go similarity index 63% rename from codegen/type_definition.go rename to codegen/unified/type_definition.go index dd78aee1369..49e91edf71b 100644 --- a/codegen/type_definition.go +++ b/codegen/unified/type_definition.go @@ -1,4 +1,4 @@ -package codegen +package unified import ( "go/types" @@ -25,29 +25,3 @@ func (t TypeDefinition) IsEmptyInterface() bool { i, isInterface := t.GoType.(*types.Interface) return isInterface && i.NumMethods() == 0 } - -func (n NamedTypes) goTypeForAst(t *ast.Type) types.Type { - if t.Elem != nil { - return types.NewSlice(n.goTypeForAst(t.Elem)) - } - - nt := n[t.NamedType] - gt := nt.GoType - if gt == nil { - panic("missing type " + t.NamedType) - } - - if !t.NonNull && nt.GQLDefinition.Kind != ast.Interface { - return types.NewPointer(gt) - } - - return gt -} - -func (n NamedTypes) getType(t *ast.Type) *TypeReference { - return &TypeReference{ - Definition: n[t.Name()], - GoType: n.goTypeForAst(t), - ASTType: t, - } -} diff --git a/codegen/type_reference.go b/codegen/unified/type_reference.go similarity index 99% rename from codegen/type_reference.go rename to codegen/unified/type_reference.go index 107c62647f4..b420eaf523c 100644 --- a/codegen/type_reference.go +++ b/codegen/unified/type_reference.go @@ -1,4 +1,4 @@ -package codegen +package unified import ( "go/types" diff --git a/codegen/unified/util.go b/codegen/unified/util.go new file mode 100644 index 00000000000..fe61aeb20cf --- /dev/null +++ b/codegen/unified/util.go @@ -0,0 +1,223 @@ +package unified + +import ( + "fmt" + "go/build" + "go/types" + "os" + "reflect" + "strings" + + "github.com/pkg/errors" +) + +func (g *Schema) FindGoType(pkgName string, typeName string) (types.Object, error) { + if pkgName == "" { + return nil, nil + } + fullName := typeName + if pkgName != "" { + fullName = pkgName + "." + typeName + } + + pkgName, err := resolvePkg(pkgName) + if err != nil { + return nil, errors.Errorf("unable to resolve package for %s: %s\n", fullName, err.Error()) + } + + pkg := g.Program.Imported[pkgName] + if pkg == nil { + return nil, errors.Errorf("required package was not loaded: %s", fullName) + } + + for astNode, def := range pkg.Defs { + if astNode.Name != typeName || def.Parent() == nil || def.Parent() != pkg.Pkg.Scope() { + continue + } + + return def, nil + } + + return nil, errors.Errorf("unable to find type %s\n", fullName) +} + +func findGoNamedType(def types.Type) (*types.Named, error) { + if def == nil { + return nil, nil + } + + namedType, ok := def.(*types.Named) + if !ok { + return nil, errors.Errorf("expected %s to be a named type, instead found %T\n", def.String(), def) + } + + return namedType, nil +} + +func findGoInterface(def types.Type) (*types.Interface, error) { + if def == nil { + return nil, nil + } + namedType, err := findGoNamedType(def) + if err != nil { + return nil, err + } + if namedType == nil { + return nil, nil + } + + underlying, ok := namedType.Underlying().(*types.Interface) + if !ok { + return nil, errors.Errorf("expected %s to be a named interface, instead found %s", def.String(), namedType.String()) + } + + return underlying, nil +} + +func findMethod(typ *types.Named, name string) *types.Func { + for i := 0; i < typ.NumMethods(); i++ { + method := typ.Method(i) + if !method.Exported() { + continue + } + + if strings.EqualFold(method.Name(), name) { + return method + } + } + + if s, ok := typ.Underlying().(*types.Struct); ok { + for i := 0; i < s.NumFields(); i++ { + field := s.Field(i) + if !field.Anonymous() { + continue + } + + if named, ok := field.Type().(*types.Named); ok { + if f := findMethod(named, name); f != nil { + return f + } + } + } + } + + return nil +} + +func equalFieldName(source, target string) bool { + source = strings.Replace(source, "_", "", -1) + target = strings.Replace(target, "_", "", -1) + return strings.EqualFold(source, target) +} + +// findField attempts to match the name to a struct field with the following +// priorites: +// 1. If struct tag is passed then struct tag has highest priority +// 2. Field in an embedded struct +// 3. Actual Field name +func findField(typ *types.Struct, name, structTag string) (*types.Var, error) { + var foundField *types.Var + foundFieldWasTag := false + + for i := 0; i < typ.NumFields(); i++ { + field := typ.Field(i) + + if structTag != "" { + tags := reflect.StructTag(typ.Tag(i)) + if val, ok := tags.Lookup(structTag); ok { + if equalFieldName(val, name) { + if foundField != nil && foundFieldWasTag { + return nil, errors.Errorf("tag %s is ambigious; multiple fields have the same tag value of %s", structTag, val) + } + + foundField = field + foundFieldWasTag = true + } + } + } + + if field.Anonymous() { + + fieldType := field.Type() + + if ptr, ok := fieldType.(*types.Pointer); ok { + fieldType = ptr.Elem() + } + + // Type.Underlying() returns itself for all types except types.Named, where it returns a struct type. + // It should be safe to always call. + if named, ok := fieldType.Underlying().(*types.Struct); ok { + f, err := findField(named, name, structTag) + if err != nil && !strings.HasPrefix(err.Error(), "no field named") { + return nil, err + } + if f != nil && foundField == nil { + foundField = f + } + } + } + + if !field.Exported() { + continue + } + + if equalFieldName(field.Name(), name) && foundField == nil { // aqui! + foundField = field + } + } + + if foundField == nil { + return nil, fmt.Errorf("no field named %s", name) + } + + return foundField, nil +} + +func resolvePkg(pkgName string) (string, error) { + cwd, _ := os.Getwd() + + pkg, err := build.Default.Import(pkgName, cwd, build.FindOnly) + if err != nil { + return "", err + } + + return pkg.ImportPath, nil +} + +var keywords = []string{ + "break", + "default", + "func", + "interface", + "select", + "case", + "defer", + "go", + "map", + "struct", + "chan", + "else", + "goto", + "package", + "switch", + "const", + "fallthrough", + "if", + "range", + "type", + "continue", + "for", + "import", + "return", + "var", +} + +// sanitizeArgName prevents collisions with go keywords for arguments to resolver functions +func sanitizeArgName(name string) string { + for _, k := range keywords { + if name == k { + return name + "Arg" + } + } + return name +} diff --git a/example/starwars/models_gen.go b/example/starwars/models_gen.go index 07e36ad6f7a..e418cd89e42 100644 --- a/example/starwars/models_gen.go +++ b/example/starwars/models_gen.go @@ -12,6 +12,10 @@ type Character interface { IsCharacter() } +type SearchResult interface { + IsSearchResult() +} + type FriendsEdge struct { Cursor string `json:"cursor"` Node Character `json:"node"` @@ -23,10 +27,6 @@ type PageInfo struct { HasNextPage bool `json:"hasNextPage"` } -type SearchResult interface { - IsSearchResult() -} - type Starship struct { ID string `json:"id"` Name string `json:"name"` From 4b85d1b0363824814bab903fe8d86d661102aa53 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Wed, 9 Jan 2019 15:19:22 +1100 Subject: [PATCH 034/147] Merge buildInput into buildObject --- codegen/unified/build.go | 2 +- codegen/unified/build_input.go | 47 ----------------------------- codegen/unified/build_object.go | 53 +++++++++++++++------------------ codegen/unified/object.go | 3 +- 4 files changed, 26 insertions(+), 79 deletions(-) delete mode 100644 codegen/unified/build_input.go diff --git a/codegen/unified/build.go b/codegen/unified/build.go index 6742ed61aad..5fd008cc745 100644 --- a/codegen/unified/build.go +++ b/codegen/unified/build.go @@ -57,7 +57,7 @@ func NewSchema(cfg *config.Config) (*Schema, error) { g.Objects = append(g.Objects, obj) case ast.InputObject: - input, err := g.buildInput(schemaType) + input, err := g.buildObject(schemaType) if err != nil { return nil, errors.Wrap(err, "unable to build input definition") } diff --git a/codegen/unified/build_input.go b/codegen/unified/build_input.go deleted file mode 100644 index 6f6b78c47df..00000000000 --- a/codegen/unified/build_input.go +++ /dev/null @@ -1,47 +0,0 @@ -package unified - -import ( - "go/types" - - "github.com/pkg/errors" - "github.com/vektah/gqlparser/ast" -) - -func (g *Schema) buildInput(typ *ast.Definition) (*Object, error) { - obj := &Object{ - Definition: g.NamedTypes[typ.Name], - InTypemap: g.Config.Models.UserDefined(typ.Name), - } - - for _, field := range typ.Fields { - newField, err := g.buildField(obj, field) - if err != nil { - return nil, err - } - - if !newField.TypeReference.Definition.GQLDefinition.IsInputType() { - return nil, errors.Errorf( - "%s cannot be used as a field of %s. only input and scalar types are allowed", - newField.Definition.GQLDefinition.Name, - obj.Definition.GQLDefinition.Name, - ) - } - - obj.Fields = append(obj.Fields, newField) - - } - dirs, err := g.getDirectives(typ.Directives) - if err != nil { - return nil, err - } - obj.Directives = dirs - - if _, isMap := obj.Definition.GoType.(*types.Map); !isMap && obj.InTypemap { - bindErrs := bindObject(obj, g.Config.StructTag) - if len(bindErrs) > 0 { - return nil, bindErrs - } - } - - return obj, nil -} diff --git a/codegen/unified/build_object.go b/codegen/unified/build_object.go index f2f999ddaaf..de42da4339d 100644 --- a/codegen/unified/build_object.go +++ b/codegen/unified/build_object.go @@ -3,7 +3,6 @@ package unified import ( "go/types" "log" - "strings" "github.com/pkg/errors" @@ -11,33 +10,27 @@ import ( ) func (g *Schema) buildObject(typ *ast.Definition) (*Object, error) { - obj := &Object{ - Definition: g.NamedTypes[typ.Name], - InTypemap: g.Config.Models.UserDefined(typ.Name), - } - - tt := types.NewTypeName(0, g.Config.Exec.Pkg(), obj.Definition.GQLDefinition.Name+"Resolver", nil) - obj.ResolverInterface = types.NewNamed(tt, nil, nil) - - if typ == g.Schema.Query { - obj.Root = true - obj.InTypemap = true + dirs, err := g.getDirectives(typ.Directives) + if err != nil { + return nil, err } - if typ == g.Schema.Mutation { - obj.Root = true - obj.DisableConcurrency = true - obj.InTypemap = true - } + isRoot := typ == g.Schema.Query || typ == g.Schema.Mutation || typ == g.Schema.Subscription - if typ == g.Schema.Subscription { - obj.Root = true - obj.Stream = true - obj.InTypemap = true + obj := &Object{ + Definition: g.NamedTypes[typ.Name], + InTypemap: g.Config.Models.UserDefined(typ.Name) || isRoot, + Root: isRoot, + DisableConcurrency: typ == g.Schema.Mutation, + Stream: typ == g.Schema.Subscription, + Directives: dirs, + ResolverInterface: types.NewNamed( + types.NewTypeName(0, g.Config.Exec.Pkg(), typ.Name+"Resolver", nil), + nil, + nil, + ), } - obj.Satisfies = append(obj.Satisfies, typ.Interfaces...) - for _, intf := range g.Schema.GetImplements(typ) { obj.Implements = append(obj.Implements, g.NamedTypes[intf.Name]) } @@ -52,14 +45,16 @@ func (g *Schema) buildObject(typ *ast.Definition) (*Object, error) { return nil, err } - obj.Fields = append(obj.Fields, f) - } + if typ.Kind == ast.InputObject && !f.TypeReference.Definition.GQLDefinition.IsInputType() { + return nil, errors.Errorf( + "%s cannot be used as a field of %s. only input and scalar types are allowed", + f.Definition.GQLDefinition.Name, + obj.Definition.GQLDefinition.Name, + ) + } - dirs, err := g.getDirectives(typ.Directives) - if err != nil { - return nil, err + obj.Fields = append(obj.Fields, f) } - obj.Directives = dirs if _, isMap := obj.Definition.GoType.(*types.Map); !isMap && obj.InTypemap { for _, bindErr := range bindObject(obj, g.Config.StructTag) { diff --git a/codegen/unified/object.go b/codegen/unified/object.go index dd6dfec5061..3deaf8e930e 100644 --- a/codegen/unified/object.go +++ b/codegen/unified/object.go @@ -25,7 +25,6 @@ const ( type Object struct { Definition *TypeDefinition Fields []*Field - Satisfies []string Implements []*TypeDefinition ResolverInterface types.Type Root bool @@ -65,7 +64,7 @@ type Objects []*Object func (o *Object) Implementors() string { satisfiedBy := strconv.Quote(o.Definition.GQLDefinition.Name) - for _, s := range o.Satisfies { + for _, s := range o.Definition.GQLDefinition.Interfaces { satisfiedBy += ", " + strconv.Quote(s) } return "[]string{" + satisfiedBy + "}" From 1d86f9883da24d175611d2268b1ecf4485030a85 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Wed, 9 Jan 2019 15:42:25 +1100 Subject: [PATCH 035/147] extract argument construction --- codegen/generate.go | 2 +- codegen/unified/build.go | 2 +- codegen/unified/build_bind.go | 4 +-- codegen/unified/build_object.go | 64 ++++++++++++++++++++------------- codegen/unified/object.go | 20 +++++------ codegen/unified/schema_test.go | 4 +-- 6 files changed, 56 insertions(+), 40 deletions(-) diff --git a/codegen/generate.go b/codegen/generate.go index 36b8e211d63..2e91c0dbf77 100644 --- a/codegen/generate.go +++ b/codegen/generate.go @@ -18,7 +18,7 @@ func Generate(cfg *config.Config) error { return errors.Wrap(err, "merging failed") } - if err := buildModels(schema); err != nil { + if err = buildModels(schema); err != nil { return errors.Wrap(err, "generating models failed") } diff --git a/codegen/unified/build.go b/codegen/unified/build.go index 5fd008cc745..6803c02fa83 100644 --- a/codegen/unified/build.go +++ b/codegen/unified/build.go @@ -114,7 +114,7 @@ func (g *Schema) injectIntrospectionRoots() error { GoFieldType: GoFieldMethod, GoReceiverName: "ec", GoFieldName: "introspectType", - Args: []FieldArgument{ + Args: []*FieldArgument{ { GQLName: "name", TypeReference: &TypeReference{ diff --git a/codegen/unified/build_bind.go b/codegen/unified/build_bind.go index fdc83b9a35e..6d4779100bb 100644 --- a/codegen/unified/build_bind.go +++ b/codegen/unified/build_bind.go @@ -146,8 +146,8 @@ func bindVar(t types.Type, field *Field, structTag string) error { return nil } -func matchArgs(field *Field, params *types.Tuple) ([]FieldArgument, error) { - var newArgs []FieldArgument +func matchArgs(field *Field, params *types.Tuple) ([]*FieldArgument, error) { + var newArgs []*FieldArgument nextArg: for j := 0; j < params.Len(); j++ { diff --git a/codegen/unified/build_object.go b/codegen/unified/build_object.go index de42da4339d..48298a62ccb 100644 --- a/codegen/unified/build_object.go +++ b/codegen/unified/build_object.go @@ -12,7 +12,7 @@ import ( func (g *Schema) buildObject(typ *ast.Definition) (*Object, error) { dirs, err := g.getDirectives(typ.Directives) if err != nil { - return nil, err + return nil, errors.Wrap(err, typ.Name) } isRoot := typ == g.Schema.Query || typ == g.Schema.Mutation || typ == g.Schema.Subscription @@ -42,14 +42,16 @@ func (g *Schema) buildObject(typ *ast.Definition) (*Object, error) { f, err := g.buildField(obj, field) if err != nil { - return nil, err + return nil, errors.Wrap(err, typ.Name+"."+field.Name) } if typ.Kind == ast.InputObject && !f.TypeReference.Definition.GQLDefinition.IsInputType() { return nil, errors.Errorf( - "%s cannot be used as a field of %s. only input and scalar types are allowed", + "%s.%s: cannot use %s because %s is not a valid input type", + typ.Name, + field.Name, f.Definition.GQLDefinition.Name, - obj.Definition.GQLDefinition.Name, + f.TypeReference.Definition.GQLDefinition.Kind, ) } @@ -86,7 +88,7 @@ func (g *Schema) buildField(obj *Object, field *ast.FieldDefinition) (*Field, er var err error f.Default, err = field.DefaultValue.Value(nil) if err != nil { - return nil, errors.Errorf("default value for %s.%s is not valid: %s", obj.Definition.GQLDefinition.Name, field.Name, err.Error()) + return nil, errors.Errorf("default value %s is not valid: %s", field.Name, err.Error()) } } @@ -103,30 +105,44 @@ func (g *Schema) buildField(obj *Object, field *ast.FieldDefinition) (*Field, er } for _, arg := range field.Arguments { - argDirs, err := g.getDirectives(arg.Directives) + newArg, err := g.buildArg(obj, arg) if err != nil { return nil, err } - newArg := FieldArgument{ - GQLName: arg.Name, - TypeReference: g.NamedTypes.getType(arg.Type), - Object: obj, - GoVarName: sanitizeArgName(arg.Name), - Directives: argDirs, - } + f.Args = append(f.Args, newArg) + } + return &f, nil +} - if !newArg.TypeReference.Definition.GQLDefinition.IsInputType() { - return nil, errors.Errorf("%s cannot be used as argument of %s.%s. only input and scalar types are allowed", arg.Type, obj.Definition.GQLDefinition.Name, field.Name) - } +func (g *Schema) buildArg(obj *Object, arg *ast.ArgumentDefinition) (*FieldArgument, error) { + argDirs, err := g.getDirectives(arg.Directives) + if err != nil { + return nil, err + } + newArg := FieldArgument{ + GQLName: arg.Name, + TypeReference: g.NamedTypes.getType(arg.Type), + Object: obj, + GoVarName: sanitizeArgName(arg.Name), + Directives: argDirs, + } - if arg.DefaultValue != nil { - var err error - newArg.Default, err = arg.DefaultValue.Value(nil) - if err != nil { - return nil, errors.Errorf("default value for %s.%s is not valid: %s", obj.Definition.GQLDefinition.Name, field.Name, err.Error()) - } + if !newArg.TypeReference.Definition.GQLDefinition.IsInputType() { + return nil, errors.Errorf( + "cannot use %s as argument %s because %s is not a valid input type", + newArg.Definition.GQLDefinition.Name, + arg.Name, + newArg.TypeReference.Definition.GQLDefinition.Kind, + ) + } + + if arg.DefaultValue != nil { + var err error + newArg.Default, err = arg.DefaultValue.Value(nil) + if err != nil { + return nil, errors.Errorf("default value is not valid: %s", err.Error()) } - f.Args = append(f.Args, newArg) } - return &f, nil + + return &newArg, nil } diff --git a/codegen/unified/object.go b/codegen/unified/object.go index 3deaf8e930e..46598d2d3e2 100644 --- a/codegen/unified/object.go +++ b/codegen/unified/object.go @@ -36,16 +36,16 @@ type Object struct { type Field struct { *TypeReference - GQLName string // The name of the field in graphql - GoFieldType GoFieldType // The field type in go, if any - GoReceiverName string // The name of method & var receiver in go, if any - GoFieldName string // The name of the method or var in go, if any - IsResolver bool // Does this field need a resolver - Args []FieldArgument // A list of arguments to be passed to this field - MethodHasContext bool // If this is bound to a go method, does the method also take a context - NoErr bool // If this is bound to a go method, does that method have an error as the second argument - Object *Object // A link back to the parent object - Default interface{} // The default value + GQLName string // The name of the field in graphql + GoFieldType GoFieldType // The field type in go, if any + GoReceiverName string // The name of method & var receiver in go, if any + GoFieldName string // The name of the method or var in go, if any + IsResolver bool // Does this field need a resolver + Args []*FieldArgument // A list of arguments to be passed to this field + MethodHasContext bool // If this is bound to a go method, does the method also take a context + NoErr bool // If this is bound to a go method, does that method have an error as the second argument + Object *Object // A link back to the parent object + Default interface{} // The default value Directives []*Directive } diff --git a/codegen/unified/schema_test.go b/codegen/unified/schema_test.go index 599c485fa3e..fd2f6aeb4fd 100644 --- a/codegen/unified/schema_test.go +++ b/codegen/unified/schema_test.go @@ -10,13 +10,13 @@ import ( func TestTypeUnionAsInput(t *testing.T) { err := generate("inputunion", `testdata/unioninput.graphqls`) - require.EqualError(t, err, "unable to build object definition: Bookmarkable! cannot be used as argument of Query.addBookmark. only input and scalar types are allowed") + require.EqualError(t, err, "unable to build object definition: Query.addBookmark: cannot use Bookmarkable as argument b because UNION is not a valid input type") } func TestTypeInInput(t *testing.T) { err := generate("typeinput", `testdata/typeinput.graphqls`) - require.EqualError(t, err, "unable to build input definition: Item cannot be used as a field of BookmarkableInput. only input and scalar types are allowed") + require.EqualError(t, err, "unable to build input definition: BookmarkableInput.item: cannot use Item because OBJECT is not a valid input type") } func generate(name string, schemaFilename string) error { From 87b37b0c30b98f311d18db56c404679bf40b68e5 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Wed, 9 Jan 2019 18:48:50 +1100 Subject: [PATCH 036/147] Replace string based type comparisons with recursive types.Type check --- codegen/generate.go | 2 +- codegen/unified/build_bind.go | 314 +++++++++++++++++++++++++---- codegen/unified/build_bind_test.go | 83 ++++++-- codegen/unified/build_object.go | 4 +- codegen/unified/util.go | 100 +-------- 5 files changed, 349 insertions(+), 154 deletions(-) diff --git a/codegen/generate.go b/codegen/generate.go index 2e91c0dbf77..34ab76f6f67 100644 --- a/codegen/generate.go +++ b/codegen/generate.go @@ -22,7 +22,7 @@ func Generate(cfg *config.Config) error { return errors.Wrap(err, "generating models failed") } - // Create a new schema now that the generated models have been injected into the typemap + // Merge again now that the generated models have been injected into the typemap schema, err = unified.NewSchema(schema.Config) if err != nil { return errors.Wrap(err, "merging failed") diff --git a/codegen/unified/build_bind.go b/codegen/unified/build_bind.go index 6d4779100bb..cf8d8147bf3 100644 --- a/codegen/unified/build_bind.go +++ b/codegen/unified/build_bind.go @@ -3,6 +3,7 @@ package unified import ( "fmt" "go/types" + "reflect" "regexp" "strings" @@ -38,7 +39,7 @@ func (b BindErrors) Error() string { return strings.Join(errs, "\n\n") } -func bindObject(object *Object, structTag string) BindErrors { +func (g *Schema) bindObject(object *Object) BindErrors { var errs BindErrors for _, field := range object.Fields { if field.IsResolver { @@ -46,14 +47,15 @@ func bindObject(object *Object, structTag string) BindErrors { } // first try binding to a method - methodErr := bindMethod(object.Definition.GoType, field) + methodErr := g.bindMethod(object.Definition.GoType, field) if methodErr == nil { continue } // otherwise try binding to a var - varErr := bindVar(object.Definition.GoType, field, structTag) + varErr := g.bindVar(object.Definition.GoType, field) + // if both failed, add a resolver if varErr != nil { field.IsResolver = true @@ -69,19 +71,15 @@ func bindObject(object *Object, structTag string) BindErrors { return errs } -func bindMethod(t types.Type, field *Field) error { - namedType, ok := t.(*types.Named) - if !ok { - return fmt.Errorf("not a named type") +func (g *Schema) bindMethod(t types.Type, field *Field) error { + namedType, err := findGoNamedType(t) + if err != nil { + return err } - goName := field.GQLName - if field.GoFieldName != "" { - goName = field.GoFieldName - } - method := findMethod(namedType, goName) + method := g.findMethod(namedType, field.GoFieldName) if method == nil { - return fmt.Errorf("no method named %s", field.GQLName) + return fmt.Errorf("no method named %s", field.GoFieldName) } sig := method.Type().(*types.Signature) @@ -102,51 +100,47 @@ func bindMethod(t types.Type, field *Field) error { params = types.NewTuple(vars...) } - newArgs, err := matchArgs(field, params) - if err != nil { + if err := g.bindArgs(field, params); err != nil { return err } result := sig.Results().At(0) - if err := validateTypeBinding(field, result.Type()); err != nil { - return errors.Wrap(err, "method has wrong return type") + if err := compatibleTypes(field.TypeReference.GoType, result.Type()); err != nil { + return errors.Wrapf(err, "%s is not compatible with %s", field.TypeReference.GoType.String(), result.String()) } // success, args and return type match. Bind to method field.GoFieldType = GoFieldMethod field.GoReceiverName = "obj" field.GoFieldName = method.Name() - field.Args = newArgs + field.TypeReference.GoType = result.Type() return nil } -func bindVar(t types.Type, field *Field, structTag string) error { +func (g *Schema) bindVar(t types.Type, field *Field) error { underlying, ok := t.Underlying().(*types.Struct) if !ok { return fmt.Errorf("not a struct") } - goName := field.GQLName - if field.GoFieldName != "" { - goName = field.GoFieldName - } - structField, err := findField(underlying, goName, structTag) + structField, err := g.findField(underlying, field.GoFieldName) if err != nil { return err } - if err := validateTypeBinding(field, structField.Type()); err != nil { - return errors.Wrap(err, "field has wrong type") + if err := compatibleTypes(field.TypeReference.GoType, structField.Type()); err != nil { + return errors.Wrapf(err, "%s is not compatible with %s", field.TypeReference.GoType.String(), field.TypeReference.GoType.String()) } // success, bind to var field.GoFieldType = GoFieldVariable field.GoReceiverName = "obj" field.GoFieldName = structField.Name() + field.TypeReference.GoType = structField.Type() return nil } -func matchArgs(field *Field, params *types.Tuple) ([]*FieldArgument, error) { +func (g *Schema) bindArgs(field *Field, params *types.Tuple) error { var newArgs []*FieldArgument nextArg: @@ -154,30 +148,175 @@ nextArg: param := params.At(j) for _, oldArg := range field.Args { if strings.EqualFold(oldArg.GQLName, param.Name()) { - if !field.IsResolver { - oldArg.TypeReference.GoType = param.Type() - } + oldArg.TypeReference.GoType = param.Type() newArgs = append(newArgs, oldArg) continue nextArg } } // no matching arg found, abort - return nil, fmt.Errorf("arg %s not found on method", param.Name()) + return fmt.Errorf("arg %s not found on method", param.Name()) } - return newArgs, nil + + field.Args = newArgs + return nil } -func validateTypeBinding(field *Field, goType types.Type) error { - gqlType := normalizeVendor(field.TypeReference.GoType.String()) - goTypeStr := normalizeVendor(goType.String()) +// compatibleTypes isnt a strict comparison, it allows for pointer differences +func compatibleTypes(expected types.Type, actual types.Type) error { + //fmt.Println("Comparing ", expected.String(), actual.String()) + + // Special case to deal with pointer mismatches + { + expectedPtr, expectedIsPtr := expected.(*types.Pointer) + actualPtr, actualIsPtr := actual.(*types.Pointer) + + if expectedIsPtr && actualIsPtr { + return compatibleTypes(expectedPtr.Elem(), actualPtr.Elem()) + } + if expectedIsPtr && !actualIsPtr { + return compatibleTypes(expectedPtr.Elem(), actual) + } + if !expectedIsPtr && actualIsPtr { + return compatibleTypes(expected, actualPtr.Elem()) + } + } + + switch expected := expected.(type) { + case *types.Slice: + if actual, ok := actual.(*types.Slice); ok { + return compatibleTypes(expected.Elem(), actual.Elem()) + } + + case *types.Array: + if actual, ok := actual.(*types.Array); ok { + if expected.Len() != actual.Len() { + return fmt.Errorf("array length differs") + } + + return compatibleTypes(expected.Elem(), actual.Elem()) + } + + case *types.Basic: + if actual, ok := actual.(*types.Basic); ok { + if actual.Kind() != expected.Kind() { + return fmt.Errorf("basic kind differs, %s != %s", expected.Name(), actual.Name()) + } + + return nil + } + + case *types.Struct: + if actual, ok := actual.(*types.Struct); ok { + if expected.NumFields() != actual.NumFields() { + return fmt.Errorf("number of struct fields differ") + } + + for i := 0; i < expected.NumFields(); i++ { + if expected.Field(i).Name() != actual.Field(i).Name() { + return fmt.Errorf("struct field %d name differs, %s != %s", i, expected.Field(i).Name(), actual.Field(i).Name()) + } + if err := compatibleTypes(expected.Field(i).Type(), actual.Field(i).Type()); err != nil { + return err + } + } + return nil + } + + case *types.Tuple: + if actual, ok := actual.(*types.Tuple); ok { + if expected.Len() != actual.Len() { + return fmt.Errorf("tuple length differs, %d != %d", expected.Len(), actual.Len()) + } + + for i := 0; i < expected.Len(); i++ { + if err := compatibleTypes(expected.At(i).Type(), actual.At(i).Type()); err != nil { + return err + } + } + + return nil + } + + case *types.Signature: + if actual, ok := actual.(*types.Signature); ok { + if err := compatibleTypes(expected.Params(), actual.Params()); err != nil { + return err + } + if err := compatibleTypes(expected.Results(), actual.Results()); err != nil { + return err + } + + return nil + } + case *types.Interface: + if actual, ok := actual.(*types.Interface); ok { + if expected.NumMethods() != actual.NumMethods() { + return fmt.Errorf("interface method count differs, %d != %d", expected.NumMethods(), actual.NumMethods()) + } + + for i := 0; i < expected.NumMethods(); i++ { + if expected.Method(i).Name() != actual.Method(i).Name() { + return fmt.Errorf("interface method %d name differs, %s != %s", i, expected.Method(i).Name(), actual.Method(i).Name()) + } + if err := compatibleTypes(expected.Method(i).Type(), actual.Method(i).Type()); err != nil { + return err + } + } + + return nil + } + + case *types.Map: + if actual, ok := actual.(*types.Map); ok { + if err := compatibleTypes(expected.Key(), actual.Key()); err != nil { + return err + } + + if err := compatibleTypes(expected.Elem(), actual.Elem()); err != nil { + return err + } + + return nil + } + + case *types.Chan: + if actual, ok := actual.(*types.Chan); ok { + return compatibleTypes(expected.Elem(), actual.Elem()) + } + + case *types.Named: + if actual, ok := actual.(*types.Named); ok { + if normalizeVendor(expected.Obj().Pkg().Path()) != normalizeVendor(actual.Obj().Pkg().Path()) { + return fmt.Errorf( + "package name of named type differs, %s != %s", + normalizeVendor(expected.Obj().Pkg().Path()), + normalizeVendor(actual.Obj().Pkg().Path()), + ) + } + + if expected.Obj().Name() != actual.Obj().Name() { + return fmt.Errorf( + "named type name differs, %s != %s", + normalizeVendor(expected.Obj().Name()), + normalizeVendor(actual.Obj().Name()), + ) + } + + return nil + } + + // Before models are generated all missing references will be Invalid Basic references. + // lets assume these are valid too. + if actual, ok := actual.(*types.Basic); ok && actual.Kind() == types.Invalid { + return nil + } - if equalTypes(goTypeStr, gqlType) { - field.TypeReference.GoType = goType - return nil + default: + return fmt.Errorf("missing support for %T", expected) } - return fmt.Errorf("%s is not compatible with %s", gqlType, goTypeStr) + return fmt.Errorf("type mismatch %T != %T", expected, actual) } var modsRegex = regexp.MustCompile(`^(\*|\[\])*`) @@ -189,6 +328,99 @@ func normalizeVendor(pkg string) string { return modifiers + parts[len(parts)-1] } -func equalTypes(goType string, gqlType string) bool { - return goType == gqlType || "*"+goType == gqlType || goType == "*"+gqlType || strings.Replace(goType, "[]*", "[]", -1) == gqlType +func (g *Schema) findMethod(typ *types.Named, name string) *types.Func { + for i := 0; i < typ.NumMethods(); i++ { + method := typ.Method(i) + if !method.Exported() { + continue + } + + if strings.EqualFold(method.Name(), name) { + return method + } + } + + if s, ok := typ.Underlying().(*types.Struct); ok { + for i := 0; i < s.NumFields(); i++ { + field := s.Field(i) + if !field.Anonymous() { + continue + } + + if named, ok := field.Type().(*types.Named); ok { + if f := g.findMethod(named, name); f != nil { + return f + } + } + } + } + + return nil +} + +// findField attempts to match the name to a struct field with the following +// priorites: +// 1. If struct tag is passed then struct tag has highest priority +// 2. Actual Field name +// 3. Field in an embedded struct +func (g *Schema) findField(typ *types.Struct, name string) (*types.Var, error) { + if g.Config.StructTag != "" { + var foundField *types.Var + for i := 0; i < typ.NumFields(); i++ { + field := typ.Field(i) + if !field.Exported() { + continue + } + tags := reflect.StructTag(typ.Tag(i)) + if val, ok := tags.Lookup(g.Config.StructTag); ok && equalFieldName(val, name) { + if foundField != nil { + return nil, errors.Errorf("tag %s is ambigious; multiple fields have the same tag value of %s", g.Config.StructTag, val) + } + + foundField = field + } + } + if foundField != nil { + return foundField, nil + } + } + + for i := 0; i < typ.NumFields(); i++ { + field := typ.Field(i) + if !field.Exported() { + continue + } + if equalFieldName(field.Name(), name) { // aqui! + return field, nil + } + } + + for i := 0; i < typ.NumFields(); i++ { + field := typ.Field(i) + if !field.Exported() { + continue + } + + if field.Anonymous() { + fieldType := field.Type() + + if ptr, ok := fieldType.(*types.Pointer); ok { + fieldType = ptr.Elem() + } + + // Type.Underlying() returns itself for all types except types.Named, where it returns a struct type. + // It should be safe to always call. + if named, ok := fieldType.Underlying().(*types.Struct); ok { + f, err := g.findField(named, name) + if err != nil && !strings.HasPrefix(err.Error(), "no field named") { + return nil, err + } + if f != nil { + return f, nil + } + } + } + } + + return nil, fmt.Errorf("no field named %s", name) } diff --git a/codegen/unified/build_bind_test.go b/codegen/unified/build_bind_test.go index 5e0f6f997c9..80f6303fa6c 100644 --- a/codegen/unified/build_bind_test.go +++ b/codegen/unified/build_bind_test.go @@ -8,6 +8,7 @@ import ( "go/types" "testing" + "github.com/99designs/gqlgen/codegen/config" "github.com/stretchr/testify/require" ) @@ -71,8 +72,8 @@ type Embed struct { } for _, tt := range tests { - tt := tt - field, err := findField(tt.Struct, tt.Field, tt.Tag) + schema := Schema{Config: &config.Config{StructTag: tt.Tag}} + field, err := schema.findField(tt.Struct, tt.Field) if tt.ShouldError { require.Nil(t, field, tt.Name) require.Error(t, err, tt.Name) @@ -123,22 +124,74 @@ func TestEqualFieldName(t *testing.T) { } func TestEqualTypes(t *testing.T) { - tt := []struct { - Name string - Source string - Target string - Expected bool + valid := []struct { + expected string + actual string }{ - {Name: "basic", Source: "bar/baz", Target: "bar/baz", Expected: true}, - {Name: "basic slice", Source: "[]bar/baz", Target: "[]bar/baz", Expected: true}, - {Name: "pointer", Source: "*bar/baz", Target: "bar/baz", Expected: true}, - {Name: "pointer slice", Source: "[]*bar/baz", Target: "[]bar/baz", Expected: true}, + {"string", "string"}, + {"*string", "string"}, + {"string", "*string"}, + {"*string", "*string"}, + {"[]string", "[]string"}, + {"*[]string", "[]string"}, + {"*[]string", "[]*string"}, + {"*[]*[]*[]string", "[][][]string"}, + {"map[string]interface{}", "map[string]interface{}"}, + {"map[string]string", "map[string]string"}, + {"Bar", "Bar"}, + {"interface{}", "interface{}"}, + {"interface{Foo() bool}", "interface{Foo() bool}"}, + {"struct{Foo bool}", "struct{Foo bool}"}, } - for _, tc := range tt { - t.Run(tc.Name, func(t *testing.T) { - result := equalTypes(tc.Source, tc.Target) - require.Equal(t, tc.Expected, result) + for _, tc := range valid { + t.Run(tc.expected+"="+tc.actual, func(t *testing.T) { + expectedType := parseTypeStr(t, tc.expected) + actualType := parseTypeStr(t, tc.actual) + require.NoError(t, compatibleTypes(expectedType, actualType)) }) } + + invalid := []struct { + expected string + actual string + }{ + {"string", "int"}, + {"*string", "[]string"}, + {"[]string", "[][]string"}, + {"Bar", "Baz"}, + {"map[string]interface{}", "map[string]string"}, + {"map[string]string", "[]string"}, + {"interface{Foo() bool}", "interface{}"}, + {"struct{Foo bool}", "struct{Bar bool}"}, + } + + for _, tc := range invalid { + t.Run(tc.expected+"!="+tc.actual, func(t *testing.T) { + expectedType := parseTypeStr(t, tc.expected) + actualType := parseTypeStr(t, tc.actual) + require.Error(t, compatibleTypes(expectedType, actualType)) + }) + } +} + +func parseTypeStr(t *testing.T, s string) types.Type { + t.Helper() + + fset := token.NewFileSet() + f, err := parser.ParseFile(fset, "test.go", `package test + type Bar string + type Baz string + + type Foo struct { + Field `+s+` + } + `, 0) + require.NoError(t, err) + + conf := types.Config{Importer: importer.Default()} + pkg, err := conf.Check("test", fset, []*ast.File{f}, nil) + require.NoError(t, err) + + return pkg.Scope().Lookup("Foo").Type().(*types.Named).Underlying().(*types.Struct).Field(0).Type() } diff --git a/codegen/unified/build_object.go b/codegen/unified/build_object.go index 48298a62ccb..e908be1df6f 100644 --- a/codegen/unified/build_object.go +++ b/codegen/unified/build_object.go @@ -58,8 +58,8 @@ func (g *Schema) buildObject(typ *ast.Definition) (*Object, error) { obj.Fields = append(obj.Fields, f) } - if _, isMap := obj.Definition.GoType.(*types.Map); !isMap && obj.InTypemap { - for _, bindErr := range bindObject(obj, g.Config.StructTag) { + if obj.InTypemap && !isMap(obj.Definition.GoType) { + for _, bindErr := range g.bindObject(obj) { log.Println(bindErr.Error()) log.Println(" Adding resolver method") } diff --git a/codegen/unified/util.go b/codegen/unified/util.go index fe61aeb20cf..472e6090fe2 100644 --- a/codegen/unified/util.go +++ b/codegen/unified/util.go @@ -1,11 +1,9 @@ package unified import ( - "fmt" "go/build" "go/types" "os" - "reflect" "strings" "github.com/pkg/errors" @@ -74,105 +72,12 @@ func findGoInterface(def types.Type) (*types.Interface, error) { return underlying, nil } -func findMethod(typ *types.Named, name string) *types.Func { - for i := 0; i < typ.NumMethods(); i++ { - method := typ.Method(i) - if !method.Exported() { - continue - } - - if strings.EqualFold(method.Name(), name) { - return method - } - } - - if s, ok := typ.Underlying().(*types.Struct); ok { - for i := 0; i < s.NumFields(); i++ { - field := s.Field(i) - if !field.Anonymous() { - continue - } - - if named, ok := field.Type().(*types.Named); ok { - if f := findMethod(named, name); f != nil { - return f - } - } - } - } - - return nil -} - func equalFieldName(source, target string) bool { source = strings.Replace(source, "_", "", -1) target = strings.Replace(target, "_", "", -1) return strings.EqualFold(source, target) } -// findField attempts to match the name to a struct field with the following -// priorites: -// 1. If struct tag is passed then struct tag has highest priority -// 2. Field in an embedded struct -// 3. Actual Field name -func findField(typ *types.Struct, name, structTag string) (*types.Var, error) { - var foundField *types.Var - foundFieldWasTag := false - - for i := 0; i < typ.NumFields(); i++ { - field := typ.Field(i) - - if structTag != "" { - tags := reflect.StructTag(typ.Tag(i)) - if val, ok := tags.Lookup(structTag); ok { - if equalFieldName(val, name) { - if foundField != nil && foundFieldWasTag { - return nil, errors.Errorf("tag %s is ambigious; multiple fields have the same tag value of %s", structTag, val) - } - - foundField = field - foundFieldWasTag = true - } - } - } - - if field.Anonymous() { - - fieldType := field.Type() - - if ptr, ok := fieldType.(*types.Pointer); ok { - fieldType = ptr.Elem() - } - - // Type.Underlying() returns itself for all types except types.Named, where it returns a struct type. - // It should be safe to always call. - if named, ok := fieldType.Underlying().(*types.Struct); ok { - f, err := findField(named, name, structTag) - if err != nil && !strings.HasPrefix(err.Error(), "no field named") { - return nil, err - } - if f != nil && foundField == nil { - foundField = f - } - } - } - - if !field.Exported() { - continue - } - - if equalFieldName(field.Name(), name) && foundField == nil { // aqui! - foundField = field - } - } - - if foundField == nil { - return nil, fmt.Errorf("no field named %s", name) - } - - return foundField, nil -} - func resolvePkg(pkgName string) (string, error) { cwd, _ := os.Getwd() @@ -221,3 +126,8 @@ func sanitizeArgName(name string) string { } return name } + +func isMap(t types.Type) bool { + _, isMap := t.(*types.Map) + return isMap +} From 6b829037855aa73c0dc3f41553cb40e7604217d0 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Wed, 9 Jan 2019 19:14:38 +1100 Subject: [PATCH 037/147] Extract builder object --- codegen/resolver.go | 20 ++--- codegen/unified/build.go | 115 ++++++++++++++++++++--------- codegen/unified/build_bind.go | 32 ++++---- codegen/unified/build_bind_test.go | 4 +- codegen/unified/build_directive.go | 12 +-- codegen/unified/build_enum.go | 10 +-- codegen/unified/build_interface.go | 14 ++-- codegen/unified/build_object.go | 40 +++++----- codegen/unified/build_typedef.go | 16 ++-- codegen/unified/schema.go | 24 +++--- codegen/unified/util.go | 30 -------- 11 files changed, 162 insertions(+), 155 deletions(-) diff --git a/codegen/resolver.go b/codegen/resolver.go index ae5a2bb1228..a917917c249 100644 --- a/codegen/resolver.go +++ b/codegen/resolver.go @@ -12,9 +12,8 @@ import ( type ResolverBuild struct { *unified.Schema - PackageName string - ResolverType string - ResolverFound bool + PackageName string + ResolverType string } func GenerateResolver(schema *unified.Schema) error { @@ -24,11 +23,6 @@ func GenerateResolver(schema *unified.Schema) error { } filename := schema.Config.Resolver.Filename - if resolverBuild.ResolverFound { - log.Printf("Skipped resolver: %s.%s already exists\n", schema.Config.Resolver.ImportPath(), schema.Config.Resolver.Type) - return nil - } - if _, err := os.Stat(filename); os.IsNotExist(errors.Cause(err)) { if err := templates.RenderToFile("resolver.gotpl", filename, resolverBuild); err != nil { return err @@ -41,13 +35,9 @@ func GenerateResolver(schema *unified.Schema) error { } func buildResolver(s *unified.Schema) (*ResolverBuild, error) { - def, _ := s.FindGoType(s.Config.Resolver.ImportPath(), s.Config.Resolver.Type) - resolverFound := def != nil - return &ResolverBuild{ - Schema: s, - PackageName: s.Config.Resolver.Package, - ResolverType: s.Config.Resolver.Type, - ResolverFound: resolverFound, + Schema: s, + PackageName: s.Config.Resolver.Package, + ResolverType: s.Config.Resolver.Type, }, nil } diff --git a/codegen/unified/build.go b/codegen/unified/build.go index 6803c02fa83..069c983737a 100644 --- a/codegen/unified/build.go +++ b/codegen/unified/build.go @@ -9,15 +9,25 @@ import ( "github.com/99designs/gqlgen/codegen/config" "github.com/pkg/errors" "github.com/vektah/gqlparser/ast" + "golang.org/x/tools/go/loader" ) -func NewSchema(cfg *config.Config) (*Schema, error) { - g := Schema{ +type builder struct { + Config *config.Config + Schema *ast.Schema + SchemaStr map[string]string + Program *loader.Program + Directives map[string]*Directive + NamedTypes NamedTypes +} + +func buildSchema(cfg *config.Config) (*Schema, error) { + b := builder{ Config: cfg, } var err error - g.Schema, g.SchemaStr, err = cfg.LoadSchema() + b.Schema, b.SchemaStr, err = cfg.LoadSchema() if err != nil { return nil, err } @@ -27,89 +37,96 @@ func NewSchema(cfg *config.Config) (*Schema, error) { return nil, err } - progLoader := g.Config.NewLoaderWithoutErrors() - g.Program, err = progLoader.Load() + progLoader := b.Config.NewLoaderWithoutErrors() + b.Program, err = progLoader.Load() if err != nil { return nil, errors.Wrap(err, "loading failed") } - g.NamedTypes = NamedTypes{} + b.NamedTypes = NamedTypes{} - for _, schemaType := range g.Schema.Types { - g.NamedTypes[schemaType.Name], err = g.buildTypeDef(schemaType) + for _, schemaType := range b.Schema.Types { + b.NamedTypes[schemaType.Name], err = b.buildTypeDef(schemaType) if err != nil { return nil, errors.Wrap(err, "unable to build type definition") } } - g.Directives, err = g.buildDirectives() + b.Directives, err = b.buildDirectives() if err != nil { return nil, err } - for _, schemaType := range g.Schema.Types { + s := Schema{ + Config: cfg, + Directives: b.Directives, + Schema: b.Schema, + SchemaStr: b.SchemaStr, + } + + for _, schemaType := range b.Schema.Types { switch schemaType.Kind { case ast.Object: - obj, err := g.buildObject(schemaType) + obj, err := b.buildObject(schemaType) if err != nil { return nil, errors.Wrap(err, "unable to build object definition") } - g.Objects = append(g.Objects, obj) + s.Objects = append(s.Objects, obj) case ast.InputObject: - input, err := g.buildObject(schemaType) + input, err := b.buildObject(schemaType) if err != nil { return nil, errors.Wrap(err, "unable to build input definition") } - g.Inputs = append(g.Inputs, input) + s.Inputs = append(s.Inputs, input) case ast.Union, ast.Interface: - g.Interfaces = append(g.Interfaces, g.buildInterface(schemaType)) + s.Interfaces = append(s.Interfaces, b.buildInterface(schemaType)) case ast.Enum: - if enum := g.buildEnum(schemaType); enum != nil { - g.Enums = append(g.Enums, *enum) + if enum := b.buildEnum(schemaType); enum != nil { + s.Enums = append(s.Enums, *enum) } } } - if err := g.injectIntrospectionRoots(); err != nil { + if err := b.injectIntrospectionRoots(&s); err != nil { return nil, err } - sort.Slice(g.Objects, func(i, j int) bool { - return g.Objects[i].Definition.GQLDefinition.Name < g.Objects[j].Definition.GQLDefinition.Name + sort.Slice(s.Objects, func(i, j int) bool { + return s.Objects[i].Definition.GQLDefinition.Name < s.Objects[j].Definition.GQLDefinition.Name }) - sort.Slice(g.Inputs, func(i, j int) bool { - return g.Inputs[i].Definition.GQLDefinition.Name < g.Inputs[j].Definition.GQLDefinition.Name + sort.Slice(s.Inputs, func(i, j int) bool { + return s.Inputs[i].Definition.GQLDefinition.Name < s.Inputs[j].Definition.GQLDefinition.Name }) - sort.Slice(g.Interfaces, func(i, j int) bool { - return g.Interfaces[i].Definition.GQLDefinition.Name < g.Interfaces[j].Definition.GQLDefinition.Name + sort.Slice(s.Interfaces, func(i, j int) bool { + return s.Interfaces[i].Definition.GQLDefinition.Name < s.Interfaces[j].Definition.GQLDefinition.Name }) - sort.Slice(g.Enums, func(i, j int) bool { - return g.Enums[i].Definition.GQLDefinition.Name < g.Enums[j].Definition.GQLDefinition.Name + sort.Slice(s.Enums, func(i, j int) bool { + return s.Enums[i].Definition.GQLDefinition.Name < s.Enums[j].Definition.GQLDefinition.Name }) - return &g, nil + return &s, nil } -func (g *Schema) injectIntrospectionRoots() error { - obj := g.Objects.ByName(g.Schema.Query.Name) +func (b *builder) injectIntrospectionRoots(s *Schema) error { + obj := s.Objects.ByName(b.Schema.Query.Name) if obj == nil { return fmt.Errorf("root query type must be defined") } - typeType, err := g.FindGoType("github.com/99designs/gqlgen/graphql/introspection", "Type") + typeType, err := b.FindGoType("github.com/99designs/gqlgen/graphql/introspection", "Type") if err != nil { return errors.Wrap(err, "unable to find root Type introspection type") } obj.Fields = append(obj.Fields, &Field{ - TypeReference: &TypeReference{g.NamedTypes["__Type"], types.NewPointer(typeType.Type()), ast.NamedType("__Schema", nil)}, + TypeReference: &TypeReference{b.NamedTypes["__Type"], types.NewPointer(typeType.Type()), ast.NamedType("__Schema", nil)}, GQLName: "__type", GoFieldType: GoFieldMethod, GoReceiverName: "ec", @@ -118,7 +135,7 @@ func (g *Schema) injectIntrospectionRoots() error { { GQLName: "name", TypeReference: &TypeReference{ - g.NamedTypes["String"], + b.NamedTypes["String"], types.Typ[types.String], ast.NamedType("String", nil), }, @@ -128,13 +145,13 @@ func (g *Schema) injectIntrospectionRoots() error { Object: obj, }) - schemaType, err := g.FindGoType("github.com/99designs/gqlgen/graphql/introspection", "Schema") + schemaType, err := b.FindGoType("github.com/99designs/gqlgen/graphql/introspection", "Schema") if err != nil { return errors.Wrap(err, "unable to find root Schema introspection type") } obj.Fields = append(obj.Fields, &Field{ - TypeReference: &TypeReference{g.NamedTypes["__Schema"], types.NewPointer(schemaType.Type()), ast.NamedType("__Schema", nil)}, + TypeReference: &TypeReference{b.NamedTypes["__Schema"], types.NewPointer(schemaType.Type()), ast.NamedType("__Schema", nil)}, GQLName: "__schema", GoFieldType: GoFieldMethod, GoReceiverName: "ec", @@ -144,3 +161,33 @@ func (g *Schema) injectIntrospectionRoots() error { return nil } + +func (b *builder) FindGoType(pkgName string, typeName string) (types.Object, error) { + if pkgName == "" { + return nil, nil + } + fullName := typeName + if pkgName != "" { + fullName = pkgName + "." + typeName + } + + pkgName, err := resolvePkg(pkgName) + if err != nil { + return nil, errors.Errorf("unable to resolve package for %s: %s\n", fullName, err.Error()) + } + + pkg := b.Program.Imported[pkgName] + if pkg == nil { + return nil, errors.Errorf("required package was not loaded: %s", fullName) + } + + for astNode, def := range pkg.Defs { + if astNode.Name != typeName || def.Parent() == nil || def.Parent() != pkg.Pkg.Scope() { + continue + } + + return def, nil + } + + return nil, errors.Errorf("unable to find type %s\n", fullName) +} diff --git a/codegen/unified/build_bind.go b/codegen/unified/build_bind.go index cf8d8147bf3..c1bd5ba5b9c 100644 --- a/codegen/unified/build_bind.go +++ b/codegen/unified/build_bind.go @@ -39,7 +39,7 @@ func (b BindErrors) Error() string { return strings.Join(errs, "\n\n") } -func (g *Schema) bindObject(object *Object) BindErrors { +func (b *builder) bindObject(object *Object) BindErrors { var errs BindErrors for _, field := range object.Fields { if field.IsResolver { @@ -47,13 +47,13 @@ func (g *Schema) bindObject(object *Object) BindErrors { } // first try binding to a method - methodErr := g.bindMethod(object.Definition.GoType, field) + methodErr := b.bindMethod(object.Definition.GoType, field) if methodErr == nil { continue } // otherwise try binding to a var - varErr := g.bindVar(object.Definition.GoType, field) + varErr := b.bindVar(object.Definition.GoType, field) // if both failed, add a resolver if varErr != nil { @@ -71,13 +71,13 @@ func (g *Schema) bindObject(object *Object) BindErrors { return errs } -func (g *Schema) bindMethod(t types.Type, field *Field) error { +func (b *builder) bindMethod(t types.Type, field *Field) error { namedType, err := findGoNamedType(t) if err != nil { return err } - method := g.findMethod(namedType, field.GoFieldName) + method := b.findMethod(namedType, field.GoFieldName) if method == nil { return fmt.Errorf("no method named %s", field.GoFieldName) } @@ -100,7 +100,7 @@ func (g *Schema) bindMethod(t types.Type, field *Field) error { params = types.NewTuple(vars...) } - if err := g.bindArgs(field, params); err != nil { + if err := b.bindArgs(field, params); err != nil { return err } @@ -117,13 +117,13 @@ func (g *Schema) bindMethod(t types.Type, field *Field) error { return nil } -func (g *Schema) bindVar(t types.Type, field *Field) error { +func (b *builder) bindVar(t types.Type, field *Field) error { underlying, ok := t.Underlying().(*types.Struct) if !ok { return fmt.Errorf("not a struct") } - structField, err := g.findField(underlying, field.GoFieldName) + structField, err := b.findField(underlying, field.GoFieldName) if err != nil { return err } @@ -140,7 +140,7 @@ func (g *Schema) bindVar(t types.Type, field *Field) error { return nil } -func (g *Schema) bindArgs(field *Field, params *types.Tuple) error { +func (b *builder) bindArgs(field *Field, params *types.Tuple) error { var newArgs []*FieldArgument nextArg: @@ -328,7 +328,7 @@ func normalizeVendor(pkg string) string { return modifiers + parts[len(parts)-1] } -func (g *Schema) findMethod(typ *types.Named, name string) *types.Func { +func (b *builder) findMethod(typ *types.Named, name string) *types.Func { for i := 0; i < typ.NumMethods(); i++ { method := typ.Method(i) if !method.Exported() { @@ -348,7 +348,7 @@ func (g *Schema) findMethod(typ *types.Named, name string) *types.Func { } if named, ok := field.Type().(*types.Named); ok { - if f := g.findMethod(named, name); f != nil { + if f := b.findMethod(named, name); f != nil { return f } } @@ -363,8 +363,8 @@ func (g *Schema) findMethod(typ *types.Named, name string) *types.Func { // 1. If struct tag is passed then struct tag has highest priority // 2. Actual Field name // 3. Field in an embedded struct -func (g *Schema) findField(typ *types.Struct, name string) (*types.Var, error) { - if g.Config.StructTag != "" { +func (b *builder) findField(typ *types.Struct, name string) (*types.Var, error) { + if b.Config.StructTag != "" { var foundField *types.Var for i := 0; i < typ.NumFields(); i++ { field := typ.Field(i) @@ -372,9 +372,9 @@ func (g *Schema) findField(typ *types.Struct, name string) (*types.Var, error) { continue } tags := reflect.StructTag(typ.Tag(i)) - if val, ok := tags.Lookup(g.Config.StructTag); ok && equalFieldName(val, name) { + if val, ok := tags.Lookup(b.Config.StructTag); ok && equalFieldName(val, name) { if foundField != nil { - return nil, errors.Errorf("tag %s is ambigious; multiple fields have the same tag value of %s", g.Config.StructTag, val) + return nil, errors.Errorf("tag %s is ambigious; multiple fields have the same tag value of %s", b.Config.StructTag, val) } foundField = field @@ -411,7 +411,7 @@ func (g *Schema) findField(typ *types.Struct, name string) (*types.Var, error) { // Type.Underlying() returns itself for all types except types.Named, where it returns a struct type. // It should be safe to always call. if named, ok := fieldType.Underlying().(*types.Struct); ok { - f, err := g.findField(named, name) + f, err := b.findField(named, name) if err != nil && !strings.HasPrefix(err.Error(), "no field named") { return nil, err } diff --git a/codegen/unified/build_bind_test.go b/codegen/unified/build_bind_test.go index 80f6303fa6c..341393b08a1 100644 --- a/codegen/unified/build_bind_test.go +++ b/codegen/unified/build_bind_test.go @@ -72,8 +72,8 @@ type Embed struct { } for _, tt := range tests { - schema := Schema{Config: &config.Config{StructTag: tt.Tag}} - field, err := schema.findField(tt.Struct, tt.Field) + b := builder{Config: &config.Config{StructTag: tt.Tag}} + field, err := b.findField(tt.Struct, tt.Field) if tt.ShouldError { require.Nil(t, field, tt.Name) require.Error(t, err, tt.Name) diff --git a/codegen/unified/build_directive.go b/codegen/unified/build_directive.go index 0b7c7f53b54..d5cf1c37805 100644 --- a/codegen/unified/build_directive.go +++ b/codegen/unified/build_directive.go @@ -7,10 +7,10 @@ import ( "github.com/vektah/gqlparser/ast" ) -func (g *Schema) buildDirectives() (map[string]*Directive, error) { - directives := make(map[string]*Directive, len(g.Schema.Directives)) +func (b *builder) buildDirectives() (map[string]*Directive, error) { + directives := make(map[string]*Directive, len(b.Schema.Directives)) - for name, dir := range g.Schema.Directives { + for name, dir := range b.Schema.Directives { if _, ok := directives[name]; ok { return nil, errors.Errorf("directive with name %s already exists", name) } @@ -23,7 +23,7 @@ func (g *Schema) buildDirectives() (map[string]*Directive, error) { newArg := FieldArgument{ GQLName: arg.Name, - TypeReference: g.NamedTypes.getType(arg.Type), + TypeReference: b.NamedTypes.getType(arg.Type), GoVarName: sanitizeArgName(arg.Name), } @@ -50,7 +50,7 @@ func (g *Schema) buildDirectives() (map[string]*Directive, error) { return directives, nil } -func (g *Schema) getDirectives(list ast.DirectiveList) ([]*Directive, error) { +func (b *builder) getDirectives(list ast.DirectiveList) ([]*Directive, error) { dirs := make([]*Directive, len(list)) for i, d := range list { argValues := make(map[string]interface{}, len(d.Arguments)) @@ -61,7 +61,7 @@ func (g *Schema) getDirectives(list ast.DirectiveList) ([]*Directive, error) { } argValues[da.Name] = val } - def, ok := g.Directives[d.Name] + def, ok := b.Directives[d.Name] if !ok { return nil, fmt.Errorf("directive %s not found", d.Name) } diff --git a/codegen/unified/build_enum.go b/codegen/unified/build_enum.go index 5602e138026..d11b67fc900 100644 --- a/codegen/unified/build_enum.go +++ b/codegen/unified/build_enum.go @@ -8,9 +8,9 @@ import ( "github.com/vektah/gqlparser/ast" ) -func (g *Schema) buildEnum(typ *ast.Definition) *Enum { - namedType := g.NamedTypes[typ.Name] - if typ.Kind != ast.Enum || strings.HasPrefix(typ.Name, "__") || g.Config.Models.UserDefined(typ.Name) { +func (b *builder) buildEnum(typ *ast.Definition) *Enum { + namedType := b.NamedTypes[typ.Name] + if typ.Kind != ast.Enum || strings.HasPrefix(typ.Name, "__") || b.Config.Models.UserDefined(typ.Name) { return nil } @@ -22,10 +22,10 @@ func (g *Schema) buildEnum(typ *ast.Definition) *Enum { enum := Enum{ Definition: namedType, Values: values, - InTypemap: g.Config.Models.UserDefined(typ.Name), + InTypemap: b.Config.Models.UserDefined(typ.Name), } - enum.Definition.GoType = types.NewNamed(types.NewTypeName(0, g.Config.Model.Pkg(), templates.ToCamel(enum.Definition.GQLDefinition.Name), nil), nil, nil) + enum.Definition.GoType = types.NewNamed(types.NewTypeName(0, b.Config.Model.Pkg(), templates.ToCamel(enum.Definition.GQLDefinition.Name), nil), nil, nil) return &enum } diff --git a/codegen/unified/build_interface.go b/codegen/unified/build_interface.go index 861d3415c8b..8acb6978009 100644 --- a/codegen/unified/build_interface.go +++ b/codegen/unified/build_interface.go @@ -7,25 +7,25 @@ import ( "github.com/vektah/gqlparser/ast" ) -func (g *Schema) buildInterface(typ *ast.Definition) *Interface { +func (b *builder) buildInterface(typ *ast.Definition) *Interface { i := &Interface{ - Definition: g.NamedTypes[typ.Name], - InTypemap: g.Config.Models.UserDefined(typ.Name), + Definition: b.NamedTypes[typ.Name], + InTypemap: b.Config.Models.UserDefined(typ.Name), } - for _, implementor := range g.Schema.GetPossibleTypes(typ) { - t := g.NamedTypes[implementor.Name] + for _, implementor := range b.Schema.GetPossibleTypes(typ) { + t := b.NamedTypes[implementor.Name] i.Implementors = append(i.Implementors, InterfaceImplementor{ Definition: t, - ValueReceiver: g.isValueReceiver(g.NamedTypes[typ.Name], t), + ValueReceiver: b.isValueReceiver(b.NamedTypes[typ.Name], t), }) } return i } -func (g *Schema) isValueReceiver(intf *TypeDefinition, implementor *TypeDefinition) bool { +func (b *builder) isValueReceiver(intf *TypeDefinition, implementor *TypeDefinition) bool { interfaceType, err := findGoInterface(intf.GoType) if interfaceType == nil || err != nil { return true diff --git a/codegen/unified/build_object.go b/codegen/unified/build_object.go index e908be1df6f..ca29ffc73c9 100644 --- a/codegen/unified/build_object.go +++ b/codegen/unified/build_object.go @@ -9,30 +9,30 @@ import ( "github.com/vektah/gqlparser/ast" ) -func (g *Schema) buildObject(typ *ast.Definition) (*Object, error) { - dirs, err := g.getDirectives(typ.Directives) +func (b *builder) buildObject(typ *ast.Definition) (*Object, error) { + dirs, err := b.getDirectives(typ.Directives) if err != nil { return nil, errors.Wrap(err, typ.Name) } - isRoot := typ == g.Schema.Query || typ == g.Schema.Mutation || typ == g.Schema.Subscription + isRoot := typ == b.Schema.Query || typ == b.Schema.Mutation || typ == b.Schema.Subscription obj := &Object{ - Definition: g.NamedTypes[typ.Name], - InTypemap: g.Config.Models.UserDefined(typ.Name) || isRoot, + Definition: b.NamedTypes[typ.Name], + InTypemap: b.Config.Models.UserDefined(typ.Name) || isRoot, Root: isRoot, - DisableConcurrency: typ == g.Schema.Mutation, - Stream: typ == g.Schema.Subscription, + DisableConcurrency: typ == b.Schema.Mutation, + Stream: typ == b.Schema.Subscription, Directives: dirs, ResolverInterface: types.NewNamed( - types.NewTypeName(0, g.Config.Exec.Pkg(), typ.Name+"Resolver", nil), + types.NewTypeName(0, b.Config.Exec.Pkg(), typ.Name+"Resolver", nil), nil, nil, ), } - for _, intf := range g.Schema.GetImplements(typ) { - obj.Implements = append(obj.Implements, g.NamedTypes[intf.Name]) + for _, intf := range b.Schema.GetImplements(typ) { + obj.Implements = append(obj.Implements, b.NamedTypes[intf.Name]) } for _, field := range typ.Fields { @@ -40,7 +40,7 @@ func (g *Schema) buildObject(typ *ast.Definition) (*Object, error) { continue } - f, err := g.buildField(obj, field) + f, err := b.buildField(obj, field) if err != nil { return nil, errors.Wrap(err, typ.Name+"."+field.Name) } @@ -59,7 +59,7 @@ func (g *Schema) buildObject(typ *ast.Definition) (*Object, error) { } if obj.InTypemap && !isMap(obj.Definition.GoType) { - for _, bindErr := range g.bindObject(obj) { + for _, bindErr := range b.bindObject(obj) { log.Println(bindErr.Error()) log.Println(" Adding resolver method") } @@ -68,15 +68,15 @@ func (g *Schema) buildObject(typ *ast.Definition) (*Object, error) { return obj, nil } -func (g *Schema) buildField(obj *Object, field *ast.FieldDefinition) (*Field, error) { - dirs, err := g.getDirectives(field.Directives) +func (b *builder) buildField(obj *Object, field *ast.FieldDefinition) (*Field, error) { + dirs, err := b.getDirectives(field.Directives) if err != nil { return nil, err } f := Field{ GQLName: field.Name, - TypeReference: g.NamedTypes.getType(field.Type), + TypeReference: b.NamedTypes.getType(field.Type), Object: obj, Directives: dirs, GoFieldName: lintName(ucFirst(field.Name)), @@ -92,7 +92,7 @@ func (g *Schema) buildField(obj *Object, field *ast.FieldDefinition) (*Field, er } } - typeEntry, entryExists := g.Config.Models[obj.Definition.GQLDefinition.Name] + typeEntry, entryExists := b.Config.Models[obj.Definition.GQLDefinition.Name] if entryExists { if typeField, ok := typeEntry.Fields[field.Name]; ok { if typeField.Resolver { @@ -105,7 +105,7 @@ func (g *Schema) buildField(obj *Object, field *ast.FieldDefinition) (*Field, er } for _, arg := range field.Arguments { - newArg, err := g.buildArg(obj, arg) + newArg, err := b.buildArg(obj, arg) if err != nil { return nil, err } @@ -114,14 +114,14 @@ func (g *Schema) buildField(obj *Object, field *ast.FieldDefinition) (*Field, er return &f, nil } -func (g *Schema) buildArg(obj *Object, arg *ast.ArgumentDefinition) (*FieldArgument, error) { - argDirs, err := g.getDirectives(arg.Directives) +func (b *builder) buildArg(obj *Object, arg *ast.ArgumentDefinition) (*FieldArgument, error) { + argDirs, err := b.getDirectives(arg.Directives) if err != nil { return nil, err } newArg := FieldArgument{ GQLName: arg.Name, - TypeReference: g.NamedTypes.getType(arg.Type), + TypeReference: b.NamedTypes.getType(arg.Type), Object: obj, GoVarName: sanitizeArgName(arg.Name), Directives: argDirs, diff --git a/codegen/unified/build_typedef.go b/codegen/unified/build_typedef.go index 0ef8fea2882..918140f0e2e 100644 --- a/codegen/unified/build_typedef.go +++ b/codegen/unified/build_typedef.go @@ -9,13 +9,13 @@ import ( "github.com/vektah/gqlparser/ast" ) -func (g *Schema) buildTypeDef(schemaType *ast.Definition) (*TypeDefinition, error) { +func (b *builder) buildTypeDef(schemaType *ast.Definition) (*TypeDefinition, error) { t := &TypeDefinition{ GQLDefinition: schemaType, } var pkgName, typeName string - if userEntry, ok := g.Config.Models[t.GQLDefinition.Name]; ok && userEntry.Model != "" { + if userEntry, ok := b.Config.Models[t.GQLDefinition.Name]; ok && userEntry.Model != "" { // special case for maps if userEntry.Model == "map[string]interface{}" { t.GoType = types.NewMap(types.Typ[types.String], types.NewInterface(nil, nil).Complete()) @@ -30,10 +30,10 @@ func (g *Schema) buildTypeDef(schemaType *ast.Definition) (*TypeDefinition, erro } else { // Missing models, but we need to set up the types so any references will point to the code that will // get generated - t.GoType = types.NewNamed(types.NewTypeName(0, g.Config.Model.Pkg(), templates.ToCamel(t.GQLDefinition.Name), nil), nil, nil) + t.GoType = types.NewNamed(types.NewTypeName(0, b.Config.Model.Pkg(), templates.ToCamel(t.GQLDefinition.Name), nil), nil, nil) if t.GQLDefinition.Kind != ast.Enum { - t.Unmarshaler = types.NewFunc(0, g.Config.Exec.Pkg(), "Unmarshal"+schemaType.Name, nil) + t.Unmarshaler = types.NewFunc(0, b.Config.Exec.Pkg(), "Unmarshal"+schemaType.Name, nil) } return t, nil @@ -44,13 +44,13 @@ func (g *Schema) buildTypeDef(schemaType *ast.Definition) (*TypeDefinition, erro } // External marshal functions - def, _ := g.FindGoType(pkgName, "Marshal"+typeName) + def, _ := b.FindGoType(pkgName, "Marshal"+typeName) if f, isFunc := def.(*types.Func); isFunc { sig := def.Type().(*types.Signature) t.GoType = sig.Params().At(0).Type() t.Marshaler = f - unmarshal, err := g.FindGoType(pkgName, "Unmarshal"+typeName) + unmarshal, err := b.FindGoType(pkgName, "Unmarshal"+typeName) if err != nil { return nil, errors.Wrapf(err, "unable to find unmarshal func for %s.%s", pkgName, typeName) } @@ -59,7 +59,7 @@ func (g *Schema) buildTypeDef(schemaType *ast.Definition) (*TypeDefinition, erro } // Normal object binding - obj, err := g.FindGoType(pkgName, typeName) + obj, err := b.FindGoType(pkgName, typeName) if err != nil { return nil, errors.Wrapf(err, "unable to find %s.%s", pkgName, typeName) } @@ -76,7 +76,7 @@ func (g *Schema) buildTypeDef(schemaType *ast.Definition) (*TypeDefinition, erro // Special case to reference generated unmarshal functions if !hasUnmarshal { - t.Unmarshaler = types.NewFunc(0, g.Config.Exec.Pkg(), "Unmarshal"+schemaType.Name, nil) + t.Unmarshaler = types.NewFunc(0, b.Config.Exec.Pkg(), "Unmarshal"+schemaType.Name, nil) } return t, nil diff --git a/codegen/unified/schema.go b/codegen/unified/schema.go index 315c3172b34..0485c8121b1 100644 --- a/codegen/unified/schema.go +++ b/codegen/unified/schema.go @@ -3,20 +3,20 @@ package unified import ( "github.com/99designs/gqlgen/codegen/config" "github.com/vektah/gqlparser/ast" - "golang.org/x/tools/go/loader" ) // Schema is the result of merging the GraphQL Schema with the existing go code type Schema struct { - SchemaFilename config.SchemaFilenames - Config *config.Config - Schema *ast.Schema - SchemaStr map[string]string - Program *loader.Program - Directives map[string]*Directive - NamedTypes NamedTypes - Objects Objects - Inputs Objects - Interfaces []*Interface - Enums []Enum + Config *config.Config + Schema *ast.Schema + SchemaStr map[string]string + Directives map[string]*Directive + Objects Objects + Inputs Objects + Interfaces []*Interface + Enums []Enum +} + +func NewSchema(cfg *config.Config) (*Schema, error) { + return buildSchema(cfg) } diff --git a/codegen/unified/util.go b/codegen/unified/util.go index 472e6090fe2..787bc3ad2e0 100644 --- a/codegen/unified/util.go +++ b/codegen/unified/util.go @@ -9,36 +9,6 @@ import ( "github.com/pkg/errors" ) -func (g *Schema) FindGoType(pkgName string, typeName string) (types.Object, error) { - if pkgName == "" { - return nil, nil - } - fullName := typeName - if pkgName != "" { - fullName = pkgName + "." + typeName - } - - pkgName, err := resolvePkg(pkgName) - if err != nil { - return nil, errors.Errorf("unable to resolve package for %s: %s\n", fullName, err.Error()) - } - - pkg := g.Program.Imported[pkgName] - if pkg == nil { - return nil, errors.Errorf("required package was not loaded: %s", fullName) - } - - for astNode, def := range pkg.Defs { - if astNode.Name != typeName || def.Parent() == nil || def.Parent() != pkg.Pkg.Scope() { - continue - } - - return def, nil - } - - return nil, errors.Errorf("unable to find type %s\n", fullName) -} - func findGoNamedType(def types.Type) (*types.Named, error) { if def == nil { return nil, nil From f46b7c8e38a8309243a46002cd9bb47b2f750dcb Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Thu, 10 Jan 2019 11:52:03 +1100 Subject: [PATCH 038/147] Reclaim main package for public interface to code generator --- codegen/ambient.go => ambient.go | 2 +- cmd/gen.go | 5 ++- cmd/init.go | 7 ++-- codegen/{unified => }/build.go | 2 +- codegen/{unified => }/build_bind.go | 2 +- codegen/{unified => }/build_bind_test.go | 2 +- codegen/{unified => }/build_directive.go | 2 +- codegen/{unified => }/build_enum.go | 2 +- codegen/{unified => }/build_interface.go | 2 +- codegen/{unified => }/build_object.go | 2 +- codegen/{unified => }/build_typedef.go | 2 +- codegen/{unified => }/directive.go | 2 +- codegen/{unified => }/enum.go | 2 +- codegen/{unified => }/interface.go | 2 +- codegen/{unified => }/object.go | 2 +- codegen/{unified => }/schema.go | 2 +- codegen/{unified => }/schema_test.go | 2 +- .../{unified => }/testdata/typeinput.graphqls | 0 .../testdata/unioninput.graphqls | 0 codegen/testserver/generated_test.go | 5 +-- codegen/{unified => }/type_definition.go | 2 +- codegen/{unified => }/type_reference.go | 2 +- codegen/{unified => }/util.go | 2 +- codegen/codegen_test.go => codegen_test.go | 2 +- example/chat/resolvers.go | 2 +- example/config/resolver.go | 2 +- example/dataloader/resolvers.go | 2 +- example/scalars/resolvers.go | 2 +- example/selection/.gqlgen.yml | 5 +++ example/selection/selection.go | 2 +- example/starwars/resolvers.go | 2 +- example/todo/todo.go | 2 +- example/type-system-extension/resolver.go | 2 +- codegen/exec.go => exec.go | 14 ++++---- codegen/generate.go => generate.go | 8 ++--- integration/resolver.go | 2 +- internal/imports/testdata/unused.go | 7 ++-- main.go | 13 -------- codegen/model.go => model.go | 12 +++---- codegen/resolver.go => resolver.go | 10 +++--- codegen/server.go => server.go | 6 ++-- .../generateserver.graphqls | 0 testdata/gqlgen.go | 32 +++++++++++++++++++ 43 files changed, 102 insertions(+), 78 deletions(-) rename codegen/ambient.go => ambient.go (95%) rename codegen/{unified => }/build.go (99%) rename codegen/{unified => }/build_bind.go (99%) rename codegen/{unified => }/build_bind_test.go (99%) rename codegen/{unified => }/build_directive.go (99%) rename codegen/{unified => }/build_enum.go (97%) rename codegen/{unified => }/build_interface.go (98%) rename codegen/{unified => }/build_object.go (99%) rename codegen/{unified => }/build_typedef.go (99%) rename codegen/{unified => }/directive.go (98%) rename codegen/{unified => }/enum.go (90%) rename codegen/{unified => }/interface.go (92%) rename codegen/{unified => }/object.go (99%) rename codegen/{unified => }/schema.go (96%) rename codegen/{unified => }/schema_test.go (98%) rename codegen/{unified => }/testdata/typeinput.graphqls (100%) rename codegen/{unified => }/testdata/unioninput.graphqls (100%) rename codegen/{unified => }/type_definition.go (98%) rename codegen/{unified => }/type_reference.go (99%) rename codegen/{unified => }/util.go (99%) rename codegen/codegen_test.go => codegen_test.go (98%) create mode 100644 example/selection/.gqlgen.yml rename codegen/exec.go => exec.go (75%) rename codegen/generate.go => generate.go (88%) delete mode 100644 main.go rename codegen/model.go => model.go (86%) rename codegen/resolver.go => resolver.go (78%) rename codegen/server.go => server.go (92%) rename {codegen/testdata => testdata}/generateserver.graphqls (100%) create mode 100644 testdata/gqlgen.go diff --git a/codegen/ambient.go b/ambient.go similarity index 95% rename from codegen/ambient.go rename to ambient.go index c9909fcc78d..3ec2601cc91 100644 --- a/codegen/ambient.go +++ b/ambient.go @@ -1,4 +1,4 @@ -package codegen +package gqlgen import ( // Import and ignore the ambient imports listed below so dependency managers diff --git a/cmd/gen.go b/cmd/gen.go index 182231d6256..6a077ec97e4 100644 --- a/cmd/gen.go +++ b/cmd/gen.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - "github.com/99designs/gqlgen/codegen" + "github.com/99designs/gqlgen" "github.com/99designs/gqlgen/codegen/config" "github.com/pkg/errors" "github.com/urfave/cli" @@ -36,8 +36,7 @@ var genCmd = cli.Command{ } } - err = codegen.Generate(cfg) - if err != nil { + if err = gqlgen.Generate(cfg); err != nil { fmt.Fprintln(os.Stderr, err.Error()) os.Exit(3) } diff --git a/cmd/init.go b/cmd/init.go index 992a37b1680..aad42ad5d67 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -7,7 +7,8 @@ import ( "os" "strings" - "github.com/99designs/gqlgen/codegen" + "github.com/99designs/gqlgen" + "github.com/99designs/gqlgen/codegen/config" "github.com/pkg/errors" "github.com/urfave/cli" @@ -70,12 +71,12 @@ var initCmd = cli.Command{ } func GenerateGraphServer(cfg *config.Config, serverFilename string) { - err := codegen.Generate(cfg) + err := gqlgen.Generate(cfg) if err != nil { fmt.Fprintln(os.Stderr, err.Error()) } - if err := codegen.GenerateServer(serverFilename, cfg); err != nil { + if err := gqlgen.GenerateServer(serverFilename, cfg); err != nil { fmt.Fprintln(os.Stderr, err.Error()) os.Exit(1) } diff --git a/codegen/unified/build.go b/codegen/build.go similarity index 99% rename from codegen/unified/build.go rename to codegen/build.go index 069c983737a..588ca01d234 100644 --- a/codegen/unified/build.go +++ b/codegen/build.go @@ -1,4 +1,4 @@ -package unified +package codegen import ( "go/types" diff --git a/codegen/unified/build_bind.go b/codegen/build_bind.go similarity index 99% rename from codegen/unified/build_bind.go rename to codegen/build_bind.go index c1bd5ba5b9c..208785ec6f2 100644 --- a/codegen/unified/build_bind.go +++ b/codegen/build_bind.go @@ -1,4 +1,4 @@ -package unified +package codegen import ( "fmt" diff --git a/codegen/unified/build_bind_test.go b/codegen/build_bind_test.go similarity index 99% rename from codegen/unified/build_bind_test.go rename to codegen/build_bind_test.go index 341393b08a1..ef4d6564b77 100644 --- a/codegen/unified/build_bind_test.go +++ b/codegen/build_bind_test.go @@ -1,4 +1,4 @@ -package unified +package codegen import ( "go/ast" diff --git a/codegen/unified/build_directive.go b/codegen/build_directive.go similarity index 99% rename from codegen/unified/build_directive.go rename to codegen/build_directive.go index d5cf1c37805..9edb653f4a3 100644 --- a/codegen/unified/build_directive.go +++ b/codegen/build_directive.go @@ -1,4 +1,4 @@ -package unified +package codegen import ( "fmt" diff --git a/codegen/unified/build_enum.go b/codegen/build_enum.go similarity index 97% rename from codegen/unified/build_enum.go rename to codegen/build_enum.go index d11b67fc900..552fa8c4255 100644 --- a/codegen/unified/build_enum.go +++ b/codegen/build_enum.go @@ -1,4 +1,4 @@ -package unified +package codegen import ( "go/types" diff --git a/codegen/unified/build_interface.go b/codegen/build_interface.go similarity index 98% rename from codegen/unified/build_interface.go rename to codegen/build_interface.go index 8acb6978009..173f4805cda 100644 --- a/codegen/unified/build_interface.go +++ b/codegen/build_interface.go @@ -1,4 +1,4 @@ -package unified +package codegen import ( "go/types" diff --git a/codegen/unified/build_object.go b/codegen/build_object.go similarity index 99% rename from codegen/unified/build_object.go rename to codegen/build_object.go index ca29ffc73c9..8e57651a685 100644 --- a/codegen/unified/build_object.go +++ b/codegen/build_object.go @@ -1,4 +1,4 @@ -package unified +package codegen import ( "go/types" diff --git a/codegen/unified/build_typedef.go b/codegen/build_typedef.go similarity index 99% rename from codegen/unified/build_typedef.go rename to codegen/build_typedef.go index 918140f0e2e..44b6eafbda7 100644 --- a/codegen/unified/build_typedef.go +++ b/codegen/build_typedef.go @@ -1,4 +1,4 @@ -package unified +package codegen import ( "fmt" diff --git a/codegen/unified/directive.go b/codegen/directive.go similarity index 98% rename from codegen/unified/directive.go rename to codegen/directive.go index 2cc65c244c6..f9f000bafba 100644 --- a/codegen/unified/directive.go +++ b/codegen/directive.go @@ -1,4 +1,4 @@ -package unified +package codegen import ( "fmt" diff --git a/codegen/unified/enum.go b/codegen/enum.go similarity index 90% rename from codegen/unified/enum.go rename to codegen/enum.go index e7f365f6789..526e9aa9f0f 100644 --- a/codegen/unified/enum.go +++ b/codegen/enum.go @@ -1,4 +1,4 @@ -package unified +package codegen type Enum struct { Definition *TypeDefinition diff --git a/codegen/unified/interface.go b/codegen/interface.go similarity index 92% rename from codegen/unified/interface.go rename to codegen/interface.go index 3517b853cfa..a8e422d5efb 100644 --- a/codegen/unified/interface.go +++ b/codegen/interface.go @@ -1,4 +1,4 @@ -package unified +package codegen type Interface struct { Definition *TypeDefinition diff --git a/codegen/unified/object.go b/codegen/object.go similarity index 99% rename from codegen/unified/object.go rename to codegen/object.go index 46598d2d3e2..d35e39eacf3 100644 --- a/codegen/unified/object.go +++ b/codegen/object.go @@ -1,4 +1,4 @@ -package unified +package codegen import ( "bytes" diff --git a/codegen/unified/schema.go b/codegen/schema.go similarity index 96% rename from codegen/unified/schema.go rename to codegen/schema.go index 0485c8121b1..d9956d221b2 100644 --- a/codegen/unified/schema.go +++ b/codegen/schema.go @@ -1,4 +1,4 @@ -package unified +package codegen import ( "github.com/99designs/gqlgen/codegen/config" diff --git a/codegen/unified/schema_test.go b/codegen/schema_test.go similarity index 98% rename from codegen/unified/schema_test.go rename to codegen/schema_test.go index fd2f6aeb4fd..072500dd226 100644 --- a/codegen/unified/schema_test.go +++ b/codegen/schema_test.go @@ -1,4 +1,4 @@ -package unified +package codegen import ( "testing" diff --git a/codegen/unified/testdata/typeinput.graphqls b/codegen/testdata/typeinput.graphqls similarity index 100% rename from codegen/unified/testdata/typeinput.graphqls rename to codegen/testdata/typeinput.graphqls diff --git a/codegen/unified/testdata/unioninput.graphqls b/codegen/testdata/unioninput.graphqls similarity index 100% rename from codegen/unified/testdata/unioninput.graphqls rename to codegen/testdata/unioninput.graphqls diff --git a/codegen/testserver/generated_test.go b/codegen/testserver/generated_test.go index 50f62a60b91..8ea80bef1b3 100644 --- a/codegen/testserver/generated_test.go +++ b/codegen/testserver/generated_test.go @@ -1,12 +1,11 @@ //go:generate rm -f resolver.go -//go:generate gorunpkg github.com/99designs/gqlgen +//go:generate go run ../../testdata/gqlgen.go package testserver import ( "context" "fmt" - "github.com/pkg/errors" "net/http" "net/http/httptest" "reflect" @@ -16,6 +15,8 @@ import ( "testing" "time" + "github.com/pkg/errors" + "github.com/99designs/gqlgen/graphql/introspection" "github.com/99designs/gqlgen/client" diff --git a/codegen/unified/type_definition.go b/codegen/type_definition.go similarity index 98% rename from codegen/unified/type_definition.go rename to codegen/type_definition.go index 49e91edf71b..90655ea2e49 100644 --- a/codegen/unified/type_definition.go +++ b/codegen/type_definition.go @@ -1,4 +1,4 @@ -package unified +package codegen import ( "go/types" diff --git a/codegen/unified/type_reference.go b/codegen/type_reference.go similarity index 99% rename from codegen/unified/type_reference.go rename to codegen/type_reference.go index b420eaf523c..107c62647f4 100644 --- a/codegen/unified/type_reference.go +++ b/codegen/type_reference.go @@ -1,4 +1,4 @@ -package unified +package codegen import ( "go/types" diff --git a/codegen/unified/util.go b/codegen/util.go similarity index 99% rename from codegen/unified/util.go rename to codegen/util.go index 787bc3ad2e0..c06801cdbe9 100644 --- a/codegen/unified/util.go +++ b/codegen/util.go @@ -1,4 +1,4 @@ -package unified +package codegen import ( "go/build" diff --git a/codegen/codegen_test.go b/codegen_test.go similarity index 98% rename from codegen/codegen_test.go rename to codegen_test.go index 3045f286b2a..0d24de856f6 100644 --- a/codegen/codegen_test.go +++ b/codegen_test.go @@ -1,4 +1,4 @@ -package codegen +package gqlgen import ( "testing" diff --git a/example/chat/resolvers.go b/example/chat/resolvers.go index ff7a2af24cf..735a1d4eeb4 100644 --- a/example/chat/resolvers.go +++ b/example/chat/resolvers.go @@ -1,4 +1,4 @@ -//go:generate gorunpkg github.com/99designs/gqlgen +//go:generate go run ../../testdata/gqlgen.go package chat diff --git a/example/config/resolver.go b/example/config/resolver.go index 1e17bba53eb..c089094fa33 100644 --- a/example/config/resolver.go +++ b/example/config/resolver.go @@ -1,4 +1,4 @@ -//go:generate gorunpkg github.com/99designs/gqlgen +//go:generate go run ../../testdata/gqlgen.go package config diff --git a/example/dataloader/resolvers.go b/example/dataloader/resolvers.go index 8c132b1f28a..956251cdb0e 100644 --- a/example/dataloader/resolvers.go +++ b/example/dataloader/resolvers.go @@ -1,4 +1,4 @@ -//go:generate gorunpkg github.com/99designs/gqlgen +//go:generate go run ../../testdata/gqlgen.go package dataloader diff --git a/example/scalars/resolvers.go b/example/scalars/resolvers.go index af7c62122e8..3a89683fdbd 100644 --- a/example/scalars/resolvers.go +++ b/example/scalars/resolvers.go @@ -1,4 +1,4 @@ -//go:generate gorunpkg github.com/99designs/gqlgen +//go:generate go run ../../testdata/gqlgen.go package scalars diff --git a/example/selection/.gqlgen.yml b/example/selection/.gqlgen.yml new file mode 100644 index 00000000000..846418d6bce --- /dev/null +++ b/example/selection/.gqlgen.yml @@ -0,0 +1,5 @@ +schema: schema.graphql +model: + filename: models_gen.go +exec: + filename: generated.go diff --git a/example/selection/selection.go b/example/selection/selection.go index 6e836925957..e423a8a7e16 100644 --- a/example/selection/selection.go +++ b/example/selection/selection.go @@ -1,4 +1,4 @@ -//go:generate gorunpkg github.com/99designs/gqlgen +//go:generate go run ../../testdata/gqlgen.go package selection diff --git a/example/starwars/resolvers.go b/example/starwars/resolvers.go index 55c4c3e019c..a472ac22fa4 100644 --- a/example/starwars/resolvers.go +++ b/example/starwars/resolvers.go @@ -1,4 +1,4 @@ -//go:generate gorunpkg github.com/99designs/gqlgen +//go:generate go run ../../testdata/gqlgen.go package starwars diff --git a/example/todo/todo.go b/example/todo/todo.go index 05846810e2b..899f1ac3e6e 100644 --- a/example/todo/todo.go +++ b/example/todo/todo.go @@ -1,4 +1,4 @@ -//go:generate gorunpkg github.com/99designs/gqlgen +//go:generate go run ../../testdata/gqlgen.go package todo diff --git a/example/type-system-extension/resolver.go b/example/type-system-extension/resolver.go index 73215cb8b2c..5a8d590cd0e 100644 --- a/example/type-system-extension/resolver.go +++ b/example/type-system-extension/resolver.go @@ -1,4 +1,4 @@ -//go:generate gorunpkg github.com/99designs/gqlgen +//go:generate go run ../../testdata/gqlgen.go package type_system_extension diff --git a/codegen/exec.go b/exec.go similarity index 75% rename from codegen/exec.go rename to exec.go index 34f5cbd9cde..4ec4f7c6669 100644 --- a/codegen/exec.go +++ b/exec.go @@ -1,23 +1,23 @@ -package codegen +package gqlgen import ( "fmt" + "github.com/99designs/gqlgen/codegen" "github.com/99designs/gqlgen/codegen/templates" - "github.com/99designs/gqlgen/codegen/unified" ) type ExecBuild struct { - *unified.Schema + *codegen.Schema PackageName string - QueryRoot *unified.Object - MutationRoot *unified.Object - SubscriptionRoot *unified.Object + QueryRoot *codegen.Object + MutationRoot *codegen.Object + SubscriptionRoot *codegen.Object } // bind a schema together with some code to generate a Build -func buildExec(s *unified.Schema) error { +func buildExec(s *codegen.Schema) error { b := &ExecBuild{ Schema: s, PackageName: s.Config.Exec.Package, diff --git a/codegen/generate.go b/generate.go similarity index 88% rename from codegen/generate.go rename to generate.go index 34ab76f6f67..b339fd7b380 100644 --- a/codegen/generate.go +++ b/generate.go @@ -1,11 +1,11 @@ -package codegen +package gqlgen import ( "path/filepath" "syscall" + "github.com/99designs/gqlgen/codegen" "github.com/99designs/gqlgen/codegen/config" - "github.com/99designs/gqlgen/codegen/unified" "github.com/pkg/errors" ) @@ -13,7 +13,7 @@ func Generate(cfg *config.Config) error { _ = syscall.Unlink(cfg.Exec.Filename) _ = syscall.Unlink(cfg.Model.Filename) - schema, err := unified.NewSchema(cfg) + schema, err := codegen.NewSchema(cfg) if err != nil { return errors.Wrap(err, "merging failed") } @@ -23,7 +23,7 @@ func Generate(cfg *config.Config) error { } // Merge again now that the generated models have been injected into the typemap - schema, err = unified.NewSchema(schema.Config) + schema, err = codegen.NewSchema(schema.Config) if err != nil { return errors.Wrap(err, "merging failed") } diff --git a/integration/resolver.go b/integration/resolver.go index c0486f7b87a..5f28e1d741f 100644 --- a/integration/resolver.go +++ b/integration/resolver.go @@ -1,4 +1,4 @@ -//go:generate gorunpkg github.com/99designs/gqlgen +//go:generate go run ../testdata/gqlgen.go package integration diff --git a/internal/imports/testdata/unused.go b/internal/imports/testdata/unused.go index 63ea8d7f84b..db4c9b4d278 100644 --- a/internal/imports/testdata/unused.go +++ b/internal/imports/testdata/unused.go @@ -1,6 +1,5 @@ package testdata -import "unused" import _ "underscore" import a "fmt" import "time" @@ -14,8 +13,8 @@ func fn() { } type Message struct { - ID string `json:"id"` - Text string `json:"text"` - CreatedBy string `json:"createdBy"` + ID string `json:"id"` + Text string `json:"text"` + CreatedBy string `json:"createdBy"` CreatedAt time.Time `json:"createdAt"` } diff --git a/main.go b/main.go deleted file mode 100644 index 04c2bf54008..00000000000 --- a/main.go +++ /dev/null @@ -1,13 +0,0 @@ -package main - -import ( - "fmt" - "os" - - "github.com/99designs/gqlgen/cmd" -) - -func main() { - fmt.Fprintf(os.Stderr, "warning: running gqlgen from this binary is deprecated and may be removed in a future release. See https://github.com/99designs/gqlgen/issues/415\n") - cmd.Execute() -} diff --git a/codegen/model.go b/model.go similarity index 86% rename from codegen/model.go rename to model.go index df377b9cfd5..ec0dd65f677 100644 --- a/codegen/model.go +++ b/model.go @@ -1,23 +1,23 @@ -package codegen +package gqlgen import ( "sort" "go/types" + "github.com/99designs/gqlgen/codegen" "github.com/99designs/gqlgen/codegen/templates" - "github.com/99designs/gqlgen/codegen/unified" ) type ModelBuild struct { - Interfaces []*unified.Interface - Models unified.Objects - Enums []unified.Enum + Interfaces []*codegen.Interface + Models codegen.Objects + Enums []codegen.Enum PackageName string } // Create a list of models that need to be generated -func buildModels(s *unified.Schema) error { +func buildModels(s *codegen.Schema) error { b := &ModelBuild{ PackageName: s.Config.Model.Package, } diff --git a/codegen/resolver.go b/resolver.go similarity index 78% rename from codegen/resolver.go rename to resolver.go index a917917c249..8146856481b 100644 --- a/codegen/resolver.go +++ b/resolver.go @@ -1,22 +1,22 @@ -package codegen +package gqlgen import ( "log" "os" + "github.com/99designs/gqlgen/codegen" "github.com/99designs/gqlgen/codegen/templates" - "github.com/99designs/gqlgen/codegen/unified" "github.com/pkg/errors" ) type ResolverBuild struct { - *unified.Schema + *codegen.Schema PackageName string ResolverType string } -func GenerateResolver(schema *unified.Schema) error { +func GenerateResolver(schema *codegen.Schema) error { resolverBuild, err := buildResolver(schema) if err != nil { return errors.Wrap(err, "resolver build failed") @@ -34,7 +34,7 @@ func GenerateResolver(schema *unified.Schema) error { return nil } -func buildResolver(s *unified.Schema) (*ResolverBuild, error) { +func buildResolver(s *codegen.Schema) (*ResolverBuild, error) { return &ResolverBuild{ Schema: s, PackageName: s.Config.Resolver.Package, diff --git a/codegen/server.go b/server.go similarity index 92% rename from codegen/server.go rename to server.go index 3a42f8baf1f..39b19262e5b 100644 --- a/codegen/server.go +++ b/server.go @@ -1,17 +1,17 @@ -package codegen +package gqlgen import ( "log" "os" + "github.com/99designs/gqlgen/codegen" "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/codegen/templates" - "github.com/99designs/gqlgen/codegen/unified" "github.com/pkg/errors" ) type ServerBuild struct { - unified.Schema + codegen.Schema PackageName string ExecPackageName string diff --git a/codegen/testdata/generateserver.graphqls b/testdata/generateserver.graphqls similarity index 100% rename from codegen/testdata/generateserver.graphqls rename to testdata/generateserver.graphqls diff --git a/testdata/gqlgen.go b/testdata/gqlgen.go new file mode 100644 index 00000000000..6b37275a0dc --- /dev/null +++ b/testdata/gqlgen.go @@ -0,0 +1,32 @@ +package main + +import ( + "fmt" + "io/ioutil" + "log" + "os" + "time" + + "github.com/99designs/gqlgen" + "github.com/99designs/gqlgen/codegen/config" +) + +func main() { + log.SetOutput(ioutil.Discard) + + start := time.Now() + + cfg, err := config.LoadConfigFromDefaultLocations() + if err != nil { + fmt.Fprintln(os.Stderr, "failed to load config", err.Error()) + os.Exit(2) + } + + err = gqlgen.Generate(cfg) + if err != nil { + fmt.Fprintln(os.Stderr, err.Error()) + os.Exit(3) + } + + fmt.Printf("Generated %s in %4.2fs\n", cfg.Exec.ImportPath(), time.Since(start).Seconds()) +} From a7f719a3982c24bd36c1f60545a146f59d494cbe Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Thu, 10 Jan 2019 13:05:39 +1100 Subject: [PATCH 039/147] update appveyour to not rely on main --- .gitignore | 1 + appveyor.yml | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c0ff0ef28b9..3dbd96815b6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ /integration/schema-fetched.graphql /example/chat/package-lock.json /codegen/gen +/gen .idea/ *.test diff --git a/appveyor.yml b/appveyor.yml index 9f43012041d..142446a2534 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -43,4 +43,16 @@ test_script: - cd c:\gopath\src\github.com\99designs\ - mkdir init-project - cd init-project - - gqlgen init + - ps: | + Set-Content -Value @" + // +build ignore + + package main + + import "github.com/99designs/gqlgen/cmd" + + func main() { + cmd.Execute() + } + "@ -Path .\gqlgen.go + - go run gqlgen.go init From 940db1f962c24864fea7e41362f383e163bedd1a Mon Sep 17 00:00:00 2001 From: Andrii Zavorotnii Date: Mon, 14 Jan 2019 10:34:47 -0800 Subject: [PATCH 040/147] Fix cacheSize usage in handler --- handler/graphql.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handler/graphql.go b/handler/graphql.go index eb8880deb3b..3be36ae6d77 100644 --- a/handler/graphql.go +++ b/handler/graphql.go @@ -259,7 +259,7 @@ func GraphQL(exec graphql.ExecutableSchema, options ...Option) http.HandlerFunc var cache *lru.Cache if cfg.cacheSize > 0 { var err error - cache, err = lru.New(DefaultCacheSize) + cache, err = lru.New(cfg.cacheSize) if err != nil { // An error is only returned for non-positive cache size // and we already checked for that. From a76e022803d49a5e4cdc95504766e2060fb7124a Mon Sep 17 00:00:00 2001 From: Andrii Zavorotnii Date: Mon, 14 Jan 2019 10:35:44 -0800 Subject: [PATCH 041/147] Add cache usage for websocket connection --- handler/graphql.go | 2 +- handler/websocket.go | 30 +++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/handler/graphql.go b/handler/graphql.go index 3be36ae6d77..b27e967a3c9 100644 --- a/handler/graphql.go +++ b/handler/graphql.go @@ -295,7 +295,7 @@ func (gh *graphqlHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } if strings.Contains(r.Header.Get("Upgrade"), "websocket") { - connectWs(gh.exec, w, r, gh.cfg) + connectWs(gh.exec, w, r, gh.cfg, gh.cache) return } diff --git a/handler/websocket.go b/handler/websocket.go index dae262bdf3a..c3dc38e0ead 100644 --- a/handler/websocket.go +++ b/handler/websocket.go @@ -11,6 +11,7 @@ import ( "github.com/99designs/gqlgen/graphql" "github.com/gorilla/websocket" + "github.com/hashicorp/golang-lru" "github.com/vektah/gqlparser" "github.com/vektah/gqlparser/ast" "github.com/vektah/gqlparser/gqlerror" @@ -43,11 +44,12 @@ type wsConnection struct { active map[string]context.CancelFunc mu sync.Mutex cfg *Config + cache *lru.Cache initPayload InitPayload } -func connectWs(exec graphql.ExecutableSchema, w http.ResponseWriter, r *http.Request, cfg *Config) { +func connectWs(exec graphql.ExecutableSchema, w http.ResponseWriter, r *http.Request, cfg *Config, cache *lru.Cache) { ws, err := cfg.upgrader.Upgrade(w, r, http.Header{ "Sec-Websocket-Protocol": []string{"graphql-ws"}, }) @@ -63,6 +65,7 @@ func connectWs(exec graphql.ExecutableSchema, w http.ResponseWriter, r *http.Req conn: ws, ctx: r.Context(), cfg: cfg, + cache: cache, } if !conn.init() { @@ -148,10 +151,27 @@ func (c *wsConnection) subscribe(message *operationMessage) bool { return false } - doc, qErr := gqlparser.LoadQuery(c.exec.Schema(), reqParams.Query) - if qErr != nil { - c.sendError(message.ID, qErr...) - return true + var ( + doc *ast.QueryDocument + cacheHit bool + ) + if c.cache != nil { + val, ok := c.cache.Get(reqParams.Query) + if ok { + doc = val.(*ast.QueryDocument) + cacheHit = true + } + } + if !cacheHit { + var qErr gqlerror.List + doc, qErr = gqlparser.LoadQuery(c.exec.Schema(), reqParams.Query) + if qErr != nil { + c.sendError(message.ID, qErr...) + return true + } + if c.cache != nil { + c.cache.Add(reqParams.Query, doc) + } } op := doc.Operations.ForName(reqParams.OperationName) From 10f4ccde2a5fd79d8cd0fd66d79ceed19dbcd2de Mon Sep 17 00:00:00 2001 From: Andrii Zavorotnii Date: Mon, 14 Jan 2019 10:37:59 -0800 Subject: [PATCH 042/147] newRequestContext: remove redundant else part --- handler/graphql.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/handler/graphql.go b/handler/graphql.go index b27e967a3c9..918671a9a22 100644 --- a/handler/graphql.go +++ b/handler/graphql.go @@ -58,8 +58,6 @@ func (c *Config) newRequestContext(es graphql.ExecutableSchema, doc *ast.QueryDo if hook := c.tracer; hook != nil { reqCtx.Tracer = hook - } else { - reqCtx.Tracer = &graphql.NopTracer{} } if c.complexityLimit > 0 { From 21769d937f1d0f96d31e95d1adcd0f17da13b009 Mon Sep 17 00:00:00 2001 From: Andrii Zavorotnii Date: Mon, 14 Jan 2019 11:47:04 -0800 Subject: [PATCH 043/147] Ensure no side affect from preceding tests in wont_leak_goroutines test --- codegen/testserver/generated_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/codegen/testserver/generated_test.go b/codegen/testserver/generated_test.go index 704869a0813..9ec692b4d6d 100644 --- a/codegen/testserver/generated_test.go +++ b/codegen/testserver/generated_test.go @@ -125,6 +125,7 @@ func TestGeneratedServer(t *testing.T) { t.Run("subscriptions", func(t *testing.T) { t.Run("wont leak goroutines", func(t *testing.T) { + runtime.GC() // ensure no go-routines left from preceding tests initialGoroutineCount := runtime.NumGoroutine() sub := c.Websocket(`subscription { updated }`) From d3f1195ce28ba0dab5b7df9a4044777fbfc999db Mon Sep 17 00:00:00 2001 From: Pete Vilter Date: Tue, 15 Jan 2019 11:34:18 -0500 Subject: [PATCH 044/147] add `content-type: text/html` header to playground handler This ensures that the browser doesn't think it should download the page instead of rendering it, if the handler goes through a gzipping middleware. --- handler/playground.go | 1 + 1 file changed, 1 insertion(+) diff --git a/handler/playground.go b/handler/playground.go index f1687defb76..b3297f44ab3 100644 --- a/handler/playground.go +++ b/handler/playground.go @@ -42,6 +42,7 @@ var page = template.Must(template.New("graphiql").Parse(` func Playground(title string, endpoint string) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { + w.Header().Add("Content-Type", "text/html") err := page.Execute(w, map[string]string{ "title": title, "endpoint": endpoint, From c6eb1a854225c2618ee6f281401a90a58f535c59 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Mon, 21 Jan 2019 17:49:42 +1100 Subject: [PATCH 045/147] Extract model generation into a plugin --- codegen/build.go | 45 +--- codegen/build_object.go | 6 +- codegen/build_typedef.go | 15 +- codegen/config/binder.go | 98 +++++++++ codegen/config/config.go | 15 ++ codegen/config/loader.go | 25 --- codegen/object.go | 116 +--------- codegen/templates/data.go | 13 -- codegen/templates/generated.gotpl | 12 +- codegen/templates/inliner/inliner.go | 47 ---- codegen/templates/templates.go | 202 +++++++++++++++--- codegen/util.go | 13 -- example/todo/models_gen.go | 4 +- generate.go | 39 +++- model.go | 66 ------ option.go | 20 ++ plugin/modelgen/models.go | 193 +++++++++++++++++ .../modelgen}/models.gotpl | 40 ++-- plugin/modelgen/models_test.go | 20 ++ plugin/modelgen/out/existing.go | 23 ++ plugin/modelgen/out/generated.go | 89 ++++++++ plugin/modelgen/testdata/gqlgen.yml | 21 ++ plugin/modelgen/testdata/schema.graphql | 62 ++++++ plugin/plugin.go | 13 ++ 24 files changed, 800 insertions(+), 397 deletions(-) create mode 100644 codegen/config/binder.go delete mode 100644 codegen/config/loader.go delete mode 100644 codegen/templates/data.go delete mode 100644 codegen/templates/inliner/inliner.go delete mode 100644 model.go create mode 100644 option.go create mode 100644 plugin/modelgen/models.go rename {codegen/templates => plugin/modelgen}/models.gotpl (50%) create mode 100644 plugin/modelgen/models_test.go create mode 100644 plugin/modelgen/out/existing.go create mode 100644 plugin/modelgen/out/generated.go create mode 100644 plugin/modelgen/testdata/gqlgen.yml create mode 100644 plugin/modelgen/testdata/schema.graphql create mode 100644 plugin/plugin.go diff --git a/codegen/build.go b/codegen/build.go index 588ca01d234..82ee4da7dcd 100644 --- a/codegen/build.go +++ b/codegen/build.go @@ -1,22 +1,20 @@ package codegen import ( + "fmt" "go/types" "sort" - "fmt" - "github.com/99designs/gqlgen/codegen/config" "github.com/pkg/errors" "github.com/vektah/gqlparser/ast" - "golang.org/x/tools/go/loader" ) type builder struct { Config *config.Config Schema *ast.Schema SchemaStr map[string]string - Program *loader.Program + Binder *config.Binder Directives map[string]*Directive NamedTypes NamedTypes } @@ -37,10 +35,9 @@ func buildSchema(cfg *config.Config) (*Schema, error) { return nil, err } - progLoader := b.Config.NewLoaderWithoutErrors() - b.Program, err = progLoader.Load() + b.Binder, err = b.Config.NewBinder() if err != nil { - return nil, errors.Wrap(err, "loading failed") + return nil, err } b.NamedTypes = NamedTypes{} @@ -120,7 +117,7 @@ func (b *builder) injectIntrospectionRoots(s *Schema) error { return fmt.Errorf("root query type must be defined") } - typeType, err := b.FindGoType("github.com/99designs/gqlgen/graphql/introspection", "Type") + typeType, err := b.Binder.FindObject("github.com/99designs/gqlgen/graphql/introspection", "Type") if err != nil { return errors.Wrap(err, "unable to find root Type introspection type") } @@ -145,7 +142,7 @@ func (b *builder) injectIntrospectionRoots(s *Schema) error { Object: obj, }) - schemaType, err := b.FindGoType("github.com/99designs/gqlgen/graphql/introspection", "Schema") + schemaType, err := b.Binder.FindObject("github.com/99designs/gqlgen/graphql/introspection", "Schema") if err != nil { return errors.Wrap(err, "unable to find root Schema introspection type") } @@ -161,33 +158,3 @@ func (b *builder) injectIntrospectionRoots(s *Schema) error { return nil } - -func (b *builder) FindGoType(pkgName string, typeName string) (types.Object, error) { - if pkgName == "" { - return nil, nil - } - fullName := typeName - if pkgName != "" { - fullName = pkgName + "." + typeName - } - - pkgName, err := resolvePkg(pkgName) - if err != nil { - return nil, errors.Errorf("unable to resolve package for %s: %s\n", fullName, err.Error()) - } - - pkg := b.Program.Imported[pkgName] - if pkg == nil { - return nil, errors.Errorf("required package was not loaded: %s", fullName) - } - - for astNode, def := range pkg.Defs { - if astNode.Name != typeName || def.Parent() == nil || def.Parent() != pkg.Pkg.Scope() { - continue - } - - return def, nil - } - - return nil, errors.Errorf("unable to find type %s\n", fullName) -} diff --git a/codegen/build_object.go b/codegen/build_object.go index 8e57651a685..2a66a2fc8dc 100644 --- a/codegen/build_object.go +++ b/codegen/build_object.go @@ -5,6 +5,8 @@ import ( "log" "strings" + "github.com/99designs/gqlgen/codegen/templates" + "github.com/pkg/errors" "github.com/vektah/gqlparser/ast" ) @@ -79,7 +81,7 @@ func (b *builder) buildField(obj *Object, field *ast.FieldDefinition) (*Field, e TypeReference: b.NamedTypes.getType(field.Type), Object: obj, Directives: dirs, - GoFieldName: lintName(ucFirst(field.Name)), + GoFieldName: templates.ToGo(field.Name), GoFieldType: GoFieldVariable, GoReceiverName: "obj", } @@ -99,7 +101,7 @@ func (b *builder) buildField(obj *Object, field *ast.FieldDefinition) (*Field, e f.IsResolver = true } if typeField.FieldName != "" { - f.GoFieldName = lintName(ucFirst(typeField.FieldName)) + f.GoFieldName = templates.ToGo(typeField.FieldName) } } } diff --git a/codegen/build_typedef.go b/codegen/build_typedef.go index 44b6eafbda7..9bfb272b7cd 100644 --- a/codegen/build_typedef.go +++ b/codegen/build_typedef.go @@ -44,13 +44,16 @@ func (b *builder) buildTypeDef(schemaType *ast.Definition) (*TypeDefinition, err } // External marshal functions - def, _ := b.FindGoType(pkgName, "Marshal"+typeName) + def, err := b.Binder.FindObject(pkgName, typeName) + if err != nil { + return nil, err + } if f, isFunc := def.(*types.Func); isFunc { sig := def.Type().(*types.Signature) t.GoType = sig.Params().At(0).Type() t.Marshaler = f - unmarshal, err := b.FindGoType(pkgName, "Unmarshal"+typeName) + unmarshal, err := b.Binder.FindObject(pkgName, "Unmarshal"+typeName) if err != nil { return nil, errors.Wrapf(err, "unable to find unmarshal func for %s.%s", pkgName, typeName) } @@ -59,13 +62,9 @@ func (b *builder) buildTypeDef(schemaType *ast.Definition) (*TypeDefinition, err } // Normal object binding - obj, err := b.FindGoType(pkgName, typeName) - if err != nil { - return nil, errors.Wrapf(err, "unable to find %s.%s", pkgName, typeName) - } - t.GoType = obj.Type() + t.GoType = def.Type() - namedType := obj.Type().(*types.Named) + namedType := def.Type().(*types.Named) hasUnmarshal := false for i := 0; i < namedType.NumMethods(); i++ { switch namedType.Method(i).Name() { diff --git a/codegen/config/binder.go b/codegen/config/binder.go new file mode 100644 index 00000000000..9adb868e8cb --- /dev/null +++ b/codegen/config/binder.go @@ -0,0 +1,98 @@ +package config + +import ( + "fmt" + "go/types" + "regexp" + "strings" + + "github.com/pkg/errors" + "golang.org/x/tools/go/loader" +) + +// Binder connects graphql types to golang types using static analysis +type Binder struct { + program *loader.Program + types TypeMap +} + +func (c *Config) NewBinder() (*Binder, error) { + conf := loader.Config{ + AllowErrors: true, + TypeChecker: types.Config{ + Error: func(e error) {}, + }, + } + + for _, pkg := range c.Models.ReferencedPackages() { + conf.Import(pkg) + } + + prog, err := conf.Load() + if err != nil { + return nil, errors.Wrap(err, "loading program") + } + + return &Binder{ + program: prog, + types: c.Models, + }, nil +} + +func (b *Binder) FindType(pkgName string, typeName string) (types.Type, error) { + obj, err := b.FindObject(pkgName, typeName) + if err != nil { + return nil, err + } + + if fun, isFunc := obj.(*types.Func); isFunc { + return fun.Type().(*types.Signature).Params().At(0).Type(), nil + } + return obj.Type(), nil +} + +func (b *Binder) getPkg(find string) *loader.PackageInfo { + for n, p := range b.program.Imported { + if normalizeVendor(find) == normalizeVendor(n) { + return p + } + } + return nil +} + +func (b *Binder) FindObject(pkgName string, typeName string) (types.Object, error) { + if pkgName == "" { + return nil, fmt.Errorf("package cannot be nil") + } + fullName := typeName + if pkgName != "" { + fullName = pkgName + "." + typeName + } + + pkg := b.getPkg(pkgName) + if pkg == nil { + return nil, errors.Errorf("required package was not loaded: %s", fullName) + } + + for astNode, def := range pkg.Defs { + // only look at defs in the top scope + if def == nil || def.Parent() == nil || def.Parent() != pkg.Pkg.Scope() { + continue + } + + if astNode.Name == typeName || astNode.Name == "Marshal"+typeName { + return def, nil + } + } + + return nil, errors.Errorf("unable to find type %s\n", fullName) +} + +var modsRegex = regexp.MustCompile(`^(\*|\[\])*`) + +func normalizeVendor(pkg string) string { + modifiers := modsRegex.FindAllString(pkg, 1)[0] + pkg = strings.TrimPrefix(pkg, modifiers) + parts := strings.Split(pkg, "/vendor/") + return modifiers + parts[len(parts)-1] +} diff --git a/codegen/config/config.go b/codegen/config/config.go index fb6c9522a82..1c05fcf3186 100644 --- a/codegen/config/config.go +++ b/codegen/config/config.go @@ -238,6 +238,12 @@ func (tm TypeMap) ReferencedPackages() []string { return pkgs } +func (tm TypeMap) Add(gqlName string, goType string) { + modelCfg := tm[gqlName] + modelCfg.Model = goType + tm[gqlName] = modelCfg +} + func inStrSlice(haystack []string, needle string) bool { for _, v := range haystack { if needle == v { @@ -325,6 +331,15 @@ func (c *Config) normalize() error { return nil } +func (c *TypeMapEntry) PkgAndType() (string, string) { + parts := strings.Split(c.Model, ".") + if len(parts) == 1 { + return "", c.Model + } + + return normalizeVendor(strings.Join(parts[:len(parts)-1], ".")), parts[len(parts)-1] +} + func (c *Config) LoadSchema() (*ast.Schema, map[string]string, error) { schemaStrings := map[string]string{} diff --git a/codegen/config/loader.go b/codegen/config/loader.go deleted file mode 100644 index 2fa9013cea0..00000000000 --- a/codegen/config/loader.go +++ /dev/null @@ -1,25 +0,0 @@ -package config - -import ( - "go/types" - - "golang.org/x/tools/go/loader" -) - -func (c *Config) NewLoaderWithErrors() loader.Config { - conf := loader.Config{} - - for _, pkg := range c.Models.ReferencedPackages() { - conf.Import(pkg) - } - return conf -} - -func (c *Config) NewLoaderWithoutErrors() loader.Config { - conf := c.NewLoaderWithErrors() - conf.AllowErrors = true - conf.TypeChecker = types.Config{ - Error: func(e error) {}, - } - return conf -} diff --git a/codegen/object.go b/codegen/object.go index d35e39eacf3..67c04c7915c 100644 --- a/codegen/object.go +++ b/codegen/object.go @@ -132,7 +132,7 @@ func (f *Field) IsConcurrent() bool { } func (f *Field) GoNameUnexported() string { - return lintName(f.GQLName) + return templates.ToGoPrivate(f.GQLName) } func (f *Field) ShortInvocation() string { @@ -353,117 +353,3 @@ func ucFirst(s string) string { r[0] = unicode.ToUpper(r[0]) return string(r) } - -// copy from https://github.com/golang/lint/blob/06c8688daad7faa9da5a0c2f163a3d14aac986ca/lint.go#L679 - -// lintName returns a different name if it should be different. -func lintName(name string) (should string) { - // Fast path for simple cases: "_" and all lowercase. - if name == "_" { - return name - } - allLower := true - for _, r := range name { - if !unicode.IsLower(r) { - allLower = false - break - } - } - if allLower { - return name - } - - // Split camelCase at any lower->upper transition, and split on underscores. - // Check each word for common initialisms. - runes := []rune(name) - w, i := 0, 0 // index of start of word, scan - for i+1 <= len(runes) { - eow := false // whether we hit the end of a word - if i+1 == len(runes) { - eow = true - } else if runes[i+1] == '_' { - // underscore; shift the remainder forward over any run of underscores - eow = true - n := 1 - for i+n+1 < len(runes) && runes[i+n+1] == '_' { - n++ - } - - // Leave at most one underscore if the underscore is between two digits - if i+n+1 < len(runes) && unicode.IsDigit(runes[i]) && unicode.IsDigit(runes[i+n+1]) { - n-- - } - - copy(runes[i+1:], runes[i+n+1:]) - runes = runes[:len(runes)-n] - } else if unicode.IsLower(runes[i]) && !unicode.IsLower(runes[i+1]) { - // lower->non-lower - eow = true - } - i++ - if !eow { - continue - } - - // [w,i) is a word. - word := string(runes[w:i]) - if u := strings.ToUpper(word); commonInitialisms[u] { - // Keep consistent case, which is lowercase only at the start. - if w == 0 && unicode.IsLower(runes[w]) { - u = strings.ToLower(u) - } - // All the common initialisms are ASCII, - // so we can replace the bytes exactly. - copy(runes[w:], []rune(u)) - } else if w > 0 && strings.ToLower(word) == word { - // already all lowercase, and not the first word, so uppercase the first character. - runes[w] = unicode.ToUpper(runes[w]) - } - w = i - } - return string(runes) -} - -// commonInitialisms is a set of common initialisms. -// Only add entries that are highly unlikely to be non-initialisms. -// For instance, "ID" is fine (Freudian code is rare), but "AND" is not. -var commonInitialisms = map[string]bool{ - "ACL": true, - "API": true, - "ASCII": true, - "CPU": true, - "CSS": true, - "DNS": true, - "EOF": true, - "GUID": true, - "HTML": true, - "HTTP": true, - "HTTPS": true, - "ID": true, - "IP": true, - "JSON": true, - "LHS": true, - "QPS": true, - "RAM": true, - "RHS": true, - "RPC": true, - "SLA": true, - "SMTP": true, - "SQL": true, - "SSH": true, - "TCP": true, - "TLS": true, - "TTL": true, - "UDP": true, - "UI": true, - "UID": true, - "UUID": true, - "URI": true, - "URL": true, - "UTF8": true, - "VM": true, - "XML": true, - "XMPP": true, - "XSRF": true, - "XSS": true, -} diff --git a/codegen/templates/data.go b/codegen/templates/data.go deleted file mode 100644 index 4e4739df4ab..00000000000 --- a/codegen/templates/data.go +++ /dev/null @@ -1,13 +0,0 @@ -package templates - -var data = map[string]string{ - "args.gotpl": "\targs := map[string]interface{}{}\n\t{{- range $i, $arg := . }}\n\t\tvar arg{{$i}} {{$arg.GoType | ref }}\n\t\tif tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {\n\t\t\t{{- if $arg.Directives }}\n\t\t\t\targm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := $arg.Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- range $dArg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $dArg.IsPtr ( notNil \"Value\" $dArg ) }}\n\t\t\t\t\t\t\t{{ $dArg.GoVarName }} := {{ $dArg.Value | dump }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"tmp\" \"n\" }})\n\t\t\t\t\t},\n\t\t\t\t{{- end }}\n\t\t\t\t}...)(ctx, func(ctx2 context.Context) (interface{}, error) {\n\t\t\t\t\tvar err error\n\t\t\t\t\t{{$arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t}\n\t\t\t\t\treturn arg{{ $i }}, nil\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif data, ok := argm{{$i}}.({{$arg.GoType | ref }}); ok {\n\t\t\t\t\targ{{$i}} = data\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, errors.New(\"expect {{$arg.GoType | ref }}\")\n\t\t\t\t}\n\t\t\t{{- else }}\n\t\t\t\tvar err error\n\t\t\t\t{{ $arg.Unmarshal (print \"arg\" $i) \"tmp\" }}\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\t{{- if eq $arg.Definition.GQLDefinition.Kind \"INPUT_OBJECT\" }}\n\t\t\t\t{{ $arg.Middleware (print \"arg\" $i) (print \"arg\" $i) }}\n\t\t\t{{- end }}\n\t\t}\n\t\targs[{{$arg.GQLName|quote}}] = arg{{$i}}\n\t{{- end }}\n\treturn args, nil\n", - "field.gotpl": "{{ $field := . }}\n{{ $object := $field.Object }}\n\n{{- if $object.Stream }}\n\tfunc (ec *executionContext) _{{$object.Definition.GQLDefinition.Name}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler {\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t})\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn nil\n\t\t\t}\n\t\t{{- end }}\n\t\t// FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259\n\t\t// and Tracer stack\n\t\trctx := ctx\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\treturn graphql.WriterFunc(func(w io.Writer) {\n\t\t\t\tw.Write([]byte{'{'})\n\t\t\t\tgraphql.MarshalString(field.Alias).MarshalGQL(w)\n\t\t\t\tw.Write([]byte{':'})\n\t\t\t\tfunc() graphql.Marshaler {\n\t\t\t\t\t{{ $field.WriteJson }}\n\t\t\t\t}().MarshalGQL(w)\n\t\t\t\tw.Write([]byte{'}'})\n\t\t\t})\n\t\t}\n\t}\n{{ else }}\n\t// nolint: vetshadow\n\tfunc (ec *executionContext) _{{$object.Definition.GQLDefinition.Name}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.Definition.GoType | ref}}{{end}}) graphql.Marshaler {\n\t\tctx = ec.Tracer.StartFieldExecution(ctx, field)\n\t\tdefer func () { ec.Tracer.EndFieldExecution(ctx) }()\n\t\trctx := &graphql.ResolverContext{\n\t\t\tObject: {{$object.Definition.GQLDefinition.Name|quote}},\n\t\t\tField: field,\n\t\t\tArgs: nil,\n\t\t}\n\t\tctx = graphql.WithResolverContext(ctx, rctx)\n\t\t{{- if $field.Args }}\n\t\t\trawArgs := field.ArgumentMap(ec.Variables)\n\t\t\targs, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs)\n\t\t\tif err != nil {\n\t\t\t\tec.Error(ctx, err)\n\t\t\t\treturn graphql.Null\n\t\t\t}\n\t\t\trctx.Args = args\n\t\t{{- end }}\n\t\tctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx)\n\t\tresTmp := ec.FieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, func(rctx context.Context) (interface{}, error) {\n\t\t\tctx = rctx // use context from middleware stack in children\n\t\t\t{{- if $field.IsResolver }}\n\t\t\t\treturn ec.resolvers.{{ $field.ShortInvocation }}\n\t\t\t{{- else if $field.IsMethod }}\n\t\t\t\t{{- if $field.NoErr }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil\n\t\t\t\t{{- else }}\n\t\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }})\n\t\t\t\t{{- end }}\n\t\t\t{{- else if $field.IsVariable }}\n\t\t\t\treturn {{$field.GoReceiverName}}.{{$field.GoFieldName}}, nil\n\t\t\t{{- end }}\n\t\t})\n\t\tif resTmp == nil {\n\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\tif !ec.HasError(rctx) {\n\t\t\t\t\tec.Errorf(ctx, \"must not be null\")\n\t\t\t\t}\n\t\t\t{{- end }}\n\t\t\treturn graphql.Null\n\t\t}\n\t\tres := resTmp.({{$field.GoType | ref}})\n\t\trctx.Result = res\n\t\tctx = ec.Tracer.StartFieldChildExecution(ctx)\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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.\nfunc NewExecutableSchema(cfg Config) graphql.ExecutableSchema {\n\treturn &executableSchema{\n\t\tresolvers: cfg.Resolvers,\n\t\tdirectives: cfg.Directives,\n\t\tcomplexity: cfg.Complexity,\n\t}\n}\n\ntype Config struct {\n\tResolvers ResolverRoot\n\tDirectives DirectiveRoot\n\tComplexity ComplexityRoot\n}\n\ntype ResolverRoot interface {\n{{- range $object := .Objects -}}\n\t{{ if $object.HasResolvers -}}\n\t\t{{$object.Definition.GQLDefinition.Name}}() {{$object.Definition.GQLDefinition.Name}}Resolver\n\t{{ end }}\n{{- end }}\n}\n\ntype DirectiveRoot struct {\n{{ range $directive := .Directives }}\n\t{{ $directive.Declaration }}\n{{ end }}\n}\n\ntype ComplexityRoot struct {\n{{ range $object := .Objects }}\n\t{{ if not $object.IsReserved -}}\n\t\t{{ $object.Definition.GQLDefinition.Name|toCamel }} struct {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ if not $field.IsReserved -}}\n\t\t\t\t{{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }}\n\t\t\t{{ end }}\n\t\t{{- end }}\n\t\t}\n\t{{- end }}\n{{ end }}\n}\n\n{{ range $object := .Objects -}}\n\t{{ if $object.HasResolvers }}\n\t\ttype {{$object.Definition.GQLDefinition.Name}}Resolver interface {\n\t\t{{ range $field := $object.Fields -}}\n\t\t\t{{ $field.ShortResolverDeclaration }}\n\t\t{{ end }}\n\t\t}\n\t{{- end }}\n{{- end }}\n\n{{ range $object := .Objects -}}\n\t{{ range $field := $object.Fields -}}\n\t\t{{ if $field.Args }}\n\t\t\tfunc (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t\t{{ template \"args.gotpl\" $field.Args }}\n\t\t\t}\n\t\t{{ end }}\n\t{{ end }}\n{{- end }}\n\n{{ range $directive := .Directives }}\n\t{{ if $directive.Args }}\n\t\tfunc (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {\n\t\t{{ template \"args.gotpl\" $directive.Args }}\n\t\t}\n\t{{ end }}\n{{ end }}\n\ntype executableSchema struct {\n\tresolvers ResolverRoot\n\tdirectives DirectiveRoot\n\tcomplexity ComplexityRoot\n}\n\nfunc (e *executableSchema) Schema() *ast.Schema {\n\treturn parsedSchema\n}\n\nfunc (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) {\n\tswitch typeName + \".\" + field {\n\t{{ range $object := .Objects }}\n\t\t{{ if not $object.IsReserved }}\n\t\t\t{{ range $field := $object.Fields }}\n\t\t\t\t{{ if not $field.IsReserved }}\n\t\t\t\t\tcase \"{{$object.Definition.GQLDefinition.Name}}.{{$field.GQLName}}\":\n\t\t\t\t\t\tif e.complexity.{{$object.Definition.GQLDefinition.Name|toCamel}}.{{$field.GQLName|toCamel}} == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ if $field.Args }}\n\t\t\t\t\t\t\targs, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs)\n\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\treturn 0, false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t{{ end }}\n\t\t\t\t\t\treturn e.complexity.{{$object.Definition.GQLDefinition.Name|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true\n\t\t\t\t{{ end }}\n\t\t\t{{ end }}\n\t\t{{ end }}\n\t{{ end }}\n\t}\n\treturn 0, false\n}\n\nfunc (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .QueryRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.QueryRoot.Definition.GQLDefinition.Name}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"queries are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response {\n\t{{- if .MutationRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\tdata := ec._{{.MutationRoot.Definition.GQLDefinition.Name}}(ctx, op.SelectionSet)\n\t\t\tvar buf bytes.Buffer\n\t\t\tdata.MarshalGQL(&buf)\n\t\t\treturn buf.Bytes()\n\t\t})\n\n\t\treturn &graphql.Response{\n\t\t\tData: buf,\n\t\t\tErrors: ec.Errors,\n\t\t\tExtensions: ec.Extensions,\n\t\t}\n\t{{- else }}\n\t\treturn graphql.ErrorResponse(ctx, \"mutations are not supported\")\n\t{{- end }}\n}\n\nfunc (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response {\n\t{{- if .SubscriptionRoot }}\n\t\tec := executionContext{graphql.GetRequestContext(ctx), e}\n\n\t\tnext := ec._{{.SubscriptionRoot.Definition.GQLDefinition.Name}}(ctx, op.SelectionSet)\n\t\tif ec.Errors != nil {\n\t\t\treturn graphql.OneShot(&graphql.Response{Data: []byte(\"null\"), Errors: ec.Errors})\n\t\t}\n\n\t\tvar buf bytes.Buffer\n\t\treturn func() *graphql.Response {\n\t\t\tbuf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte {\n\t\t\t\tbuf.Reset()\n\t\t\t\tdata := next()\n\n\t\t\t\tif data == nil {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tdata.MarshalGQL(&buf)\n\t\t\t\treturn buf.Bytes()\n\t\t\t})\n\n\t\t\tif buf == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\treturn &graphql.Response{\n\t\t\t\tData: buf,\n\t\t\t\tErrors: ec.Errors,\n\t\t\t\tExtensions: ec.Extensions,\n\t\t\t}\n\t\t}\n\t{{- else }}\n\t\treturn graphql.OneShot(graphql.ErrorResponse(ctx, \"subscriptions are not supported\"))\n\t{{- end }}\n}\n\ntype executionContext struct {\n\t*graphql.RequestContext\n\t*executableSchema\n}\n\n{{- range $object := .Objects }}\n\t{{ template \"object.gotpl\" $object }}\n\n\t{{- range $field := $object.Fields }}\n\t\t{{ template \"field.gotpl\" $field }}\n\t{{ end }}\n{{- end}}\n\n{{- range $interface := .Interfaces }}\n\t{{ template \"interface.gotpl\" $interface }}\n{{- end }}\n\n{{- range $input := .Inputs }}\n\t{{ template \"input.gotpl\" $input }}\n{{- end }}\n\nfunc (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tec.Error(ctx, ec.Recover(ctx, r))\n\t\t\tret = nil\n\t\t}\n\t}()\n\t{{- if .Directives }}\n\trctx := graphql.GetResolverContext(ctx)\n\tfor _, d := range rctx.Field.Definition.Directives {\n\t\tswitch d.Name {\n\t\t{{- range $directive := .Directives }}\n\t\tcase \"{{$directive.Name}}\":\n\t\t\tif ec.directives.{{$directive.Name|ucFirst}} != nil {\n\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\trawArgs := d.ArgumentMap(ec.Variables)\n\t\t\t\t\targs, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tec.Error(ctx, err)\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\n\t\t\t\tn := next\n\t\t\t\tnext = func(ctx context.Context) (interface{}, error) {\n\t\t\t\t\treturn ec.directives.{{$directive.Name|ucFirst}}({{$directive.CallArgs}})\n\t\t\t\t}\n\t\t\t}\n\t\t{{- end }}\n\t\t}\n\t}\n\t{{- end }}\n\tres, err := ec.ResolverMiddleware(ctx, next)\n\tif err != nil {\n\t\tec.Error(ctx, err)\n\t\treturn nil\n\t}\n\treturn res\n}\n\nfunc (ec *executionContext) introspectSchema() (*introspection.Schema, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapSchema(parsedSchema), nil\n}\n\nfunc (ec *executionContext) introspectType(name string) (*introspection.Type, error) {\n\tif ec.DisableIntrospection {\n\t\treturn nil, errors.New(\"introspection disabled\")\n\t}\n\treturn introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil\n}\n\nvar parsedSchema = gqlparser.MustLoadSchema(\n\t{{- range $filename, $schema := .SchemaStr }}\n\t\t&ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}},\n\t{{- end }}\n)\n\n\n\n// ChainFieldMiddleware add chain by FieldMiddleware\n// nolint: deadcode\nfunc chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware {\n\tn := len(handleFunc)\n\n\tif n > 1 {\n\t\tlastI := n - 1\n\t\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\t\tvar (\n\t\t\t\tchainHandler graphql.Resolver\n\t\t\t\tcurI int\n\t\t\t)\n\t\t\tchainHandler = func(currentCtx context.Context) (interface{}, error) {\n\t\t\t\tif curI == lastI {\n\t\t\t\t\treturn next(currentCtx)\n\t\t\t\t}\n\t\t\t\tcurI++\n\t\t\t\tres, err := handleFunc[curI](currentCtx, chainHandler)\n\t\t\t\tcurI--\n\t\t\t\treturn res, err\n\n\t\t\t}\n\t\t\treturn handleFunc[0](ctx, chainHandler)\n\t\t}\n\t}\n\n\tif n == 1 {\n\t\treturn handleFunc[0]\n\t}\n\n\treturn func(ctx context.Context, next graphql.Resolver) (interface{}, error) {\n\t\treturn next(ctx)\n\t}\n}\n", - "input.gotpl": "\t{{- if .Definition.IsMarshaled }}\n\tfunc Unmarshal{{ .Definition.GQLDefinition.Name }}(v interface{}) ({{.Definition.GoType | ref}}, error) {\n\t\tvar it {{.Definition.GoType | ref}}\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\n\tfunc (e *executableSchema) {{ .Definition.GQLDefinition.Name }}Middleware(ctx context.Context, obj *{{.Definition.GoType | ref}}) (*{{.Definition.GoType | ref}}, error) {\n\t\t\t{{ if .Directives }}\n\t\tcObj, err := chainFieldMiddleware(\n\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t{{- range $directive := .Directives }}\n\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\t{{- end -}}\n\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs \"obj\" \"n\"}})\n\t\t\t\t\t},\n\t\t\t\t{{ end }}\n\t\t\t}...\n\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\treturn obj, nil\n\t\t})\n\t\tif err != nil || cObj == nil {\n\t\t\treturn nil ,err\n\t\t}\n\t\tobj, ok := cObj.(*{{.Definition.GoType | ref}})\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"expect {{.Definition.GoType | ref}}\")\n\t\t}\n\t\t{{ end }}\n\n\t\t{{- range $field := .Fields }}\n\t\t{{ if $field.HasDirectives }}\n\t\t\tc{{$field.GoFieldName}}, err := chainFieldMiddleware(\n\t\t\t\t[]graphql.FieldMiddleware{\n\t\t\t\t\t{{- range $directive := $field.Directives }}\n\t\t\t\t\t\tfunc(ctx context.Context, n graphql.Resolver) (res interface{}, err error) {\n\t\t\t\t\t\t{{- if $directive.Args }}\n\t\t\t\t\t\t{{- range $arg := $directive.Args }}\n\t\t\t\t\t\t\t{{- if and $arg.IsPtr ( notNil \"Value\" $arg ) }}\n\t\t\t\t\t\t\t\t{{ $arg.GoVarName }} := {{ $arg.Value | dump }}\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t\t{{ if $field.IsPtr -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"*obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- else -}}\n\t\t\t\t\t\t\t\treturn e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print \"obj.\" $field.GoFieldName ) \"n\"}})\n\t\t\t\t\t\t\t{{- end }}\n\t\t\t\t\t\t},\n\t\t\t\t\t{{ end }}\n\t\t\t\t}...\n\t\t\t)(ctx, func(ctx context.Context)(interface{}, error){\n\t\t\t\treturn {{ if $field.IsPtr }}*{{end}}obj.{{$field.GoFieldName}}, nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn obj ,err\n\t\t\t}\n\n\t\t\t{{ if $field.IsPtr }}\n\t\t\t\tif data, ok := c{{$field.GoFieldName}}.({{ $field.Definition.GoType | ref }}); ok {\n \t\tobj.{{$field.GoFieldName}} = &data\n \t} else {\n \t\treturn obj, errors.New(\"expect {{ $field.GoType | ref }}\")\n \t}\n\t\t\t{{else}}\n \tif data, ok := c{{$field.GoFieldName}}.({{ $field.GoType | ref }}); ok{\n \t\tobj.{{$field.GoFieldName}} = data\n \t}else{\n \t\treturn obj, errors.New(\"{{$field.GoFieldName}} expect {{$field.GoType | ref }}\")\n \t}\n\t\t\t{{ end }}\n\n\t\t\t{{- end }}\n\n\t\t\t{{ if eq $field.Definition.GQLDefinition.Kind \"INPUT_OBJECT\" }}\n\t\t\t\t{{ $field.Middleware (print \"obj.\" $field.GoFieldName ) (print \"obj.\" $field.GoFieldName ) }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t\treturn obj, nil\n\t}\n", - "interface.gotpl": "{{- $interface := . }}\n\nfunc (ec *executionContext) _{{$interface.Definition.GQLDefinition.Name}}(ctx context.Context, sel ast.SelectionSet, obj *{{$interface.Definition.GoType | ref}}) 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.Definition.GoType | ref}}:\n\t\t\t\treturn ec._{{$implementor.Definition.GQLDefinition.Name}}(ctx, sel, &obj)\n\t\t{{- end}}\n\t\tcase *{{$implementor.Definition.GoType | ref}}:\n\t\t\treturn ec._{{$implementor.Definition.GQLDefinition.Name}}(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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\n{{- range $model := .Interfaces }}\n\t{{with .Definition.GQLDefinition.Description }} {{.|prefixLines \"// \"}} {{end}}\n\ttype {{.Definition.GoType | ref }} interface {\n\t\tIs{{.Definition.GoType | ref }}()\n\t}\n{{- end }}\n\n{{ range $model := .Models }}\n\t{{with .Definition.GQLDefinition.Description }} {{.|prefixLines \"// \"}} {{end}}\n\ttype {{.Definition.GoType | ref }} struct {\n\t\t{{- range $field := .Fields }}\n\t\t\t{{- with .Definition.GQLDefinition.Description }}\n\t\t\t\t{{.|prefixLines \"// \"}}\n\t\t\t{{- end}}\n\t\t\t{{ $field.GoFieldName }} {{$field.GoType | ref}} `json:\"{{$field.GQLName}}\"`\n\t\t{{- end }}\n\t}\n\n\t{{- range $iface := .Implements }}\n\t\tfunc ({{$model.Definition.GoType | ref }}) Is{{$iface.GoType | ref }}() {}\n\t{{- end }}\n{{- end}}\n\n{{ range $enum := .Enums }}\n\t{{with .Definition.GQLDefinition.Description }} {{.|prefixLines \"// \"}} {{end}}\n\ttype {{.Definition.GoType | ref }} string\n\tconst (\n\t{{- range $value := .Values}}\n\t\t{{- with .Description}}\n\t\t\t{{.|prefixLines \"// \"}}\n\t\t{{- end}}\n\t\t{{$enum.Definition.GoType | ref }}{{ .Name|toCamel }} {{$enum.Definition.GoType | ref }} = {{.Name|quote}}\n\t{{- end }}\n\t)\n\n\tvar All{{.Definition.GoType | ref }} = []{{.Definition.GoType | ref }}{\n\t{{- range $value := .Values}}\n\t\t{{$enum.Definition.GoType | ref }}{{ .Name|toCamel }},\n\t{{- end }}\n\t}\n\n\tfunc (e {{.Definition.GoType | ref }}) IsValid() bool {\n\t\tswitch e {\n\t\tcase {{ range $index, $element := .Values}}{{if $index}},{{end}}{{ $enum.Definition.GoType | ref }}{{ $element.Name|toCamel }}{{end}}:\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tfunc (e {{.Definition.GoType | ref }}) String() string {\n\t\treturn string(e)\n\t}\n\n\tfunc (e *{{.Definition.GoType | ref }}) 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 = {{.Definition.GoType | ref }}(str)\n\t\tif !e.IsValid() {\n\t\t\treturn fmt.Errorf(\"%s is not a valid {{.Definition.GQLDefinition.Name}}\", str)\n\t\t}\n\t\treturn nil\n\t}\n\n\tfunc (e {{.Definition.GoType | ref }}) 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.Definition.GQLDefinition.Name|lcFirst}}Implementors = {{$object.Implementors}}\n\n// nolint: gocyclo, errcheck, gas, goconst\n{{- if .Stream }}\nfunc (ec *executionContext) _{{$object.Definition.GQLDefinition.Name}}(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, {{$object.Definition.GQLDefinition.Name|lcFirst}}Implementors)\n\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\tObject: {{$object.Definition.GQLDefinition.Name|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.Definition.GQLDefinition.Name}}_{{$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.Definition.GQLDefinition.Name}}(ctx context.Context, sel ast.SelectionSet{{if not $object.Root}}, obj *{{$object.Definition.GoType | ref }} {{end}}) graphql.Marshaler {\n\tfields := graphql.CollectFields(ctx, sel, {{$object.Definition.GQLDefinition.Name|lcFirst}}Implementors)\n\t{{if $object.Root}}\n\t\tctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{\n\t\t\tObject: {{$object.Definition.GQLDefinition.Name|quote}},\n\t\t})\n\t{{end}}\n\n\tout := graphql.NewFieldSet(fields)\n\tinvalid := false\n\tfor i, field := range fields {\n\t\tswitch field.Name {\n\t\tcase \"__typename\":\n\t\t\tout.Values[i] = graphql.MarshalString({{$object.Definition.GQLDefinition.Name|quote}})\n\t\t{{- range $field := $object.Fields }}\n\t\tcase \"{{$field.GQLName}}\":\n\t\t\t{{- if $field.IsConcurrent }}\n\t\t\t\tfield := field\n\t\t\t\tout.Concurrently(i, func() (res graphql.Marshaler) {\n\t\t\t\t\tres = ec._{{$object.Definition.GQLDefinition.Name}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\t\tif res == graphql.Null {\n\t\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t\t}\n\t\t\t\t\t{{- end }}\n\t\t\t\t\treturn res\n\t\t\t\t})\n\t\t\t{{- else }}\n\t\t\t\tout.Values[i] = ec._{{$object.Definition.GQLDefinition.Name}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}})\n\t\t\t\t{{- if $field.ASTType.NonNull }}\n\t\t\t\t\tif out.Values[i] == graphql.Null {\n\t\t\t\t\t\tinvalid = true\n\t\t\t\t\t}\n\t\t\t\t{{- end }}\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\tout.Dispatch()\n\tif invalid { return graphql.Null }\n\treturn out\n}\n{{- end }}\n", - "resolver.gotpl": "package {{ .PackageName }}\n\nimport (\n\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"fmt\" }}\n\t{{ reserveImport \"io\" }}\n\t{{ reserveImport \"strconv\" }}\n\t{{ reserveImport \"time\" }}\n\t{{ reserveImport \"sync\" }}\n\t{{ reserveImport \"errors\" }}\n\t{{ reserveImport \"bytes\" }}\n\n\t{{ reserveImport \"github.com/99designs/gqlgen/handler\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser\" }}\n\t{{ reserveImport \"github.com/vektah/gqlparser/ast\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/graphql/introspection\" }}\n)\n\ntype {{.ResolverType}} struct {}\n\n{{ range $object := .Objects -}}\n\t{{- if $object.HasResolvers -}}\n\t\tfunc (r *{{$.ResolverType}}) {{$object.Definition.GQLDefinition.Name}}() {{ $object.ResolverInterface | ref }} {\n\t\t\treturn &{{lcFirst $object.Definition.GQLDefinition.Name}}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.Definition.GQLDefinition.Name}}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.Definition.GQLDefinition.Name}}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\t%%%IMPORTS%%%\n\n\t{{ reserveImport \"context\" }}\n\t{{ reserveImport \"log\" }}\n\t{{ reserveImport \"net/http\" }}\n\t{{ reserveImport \"os\" }}\n\t{{ reserveImport \"github.com/99designs/gqlgen/handler\" }}\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({{ lookupImport .ExecPackageName }}.NewExecutableSchema({{ lookupImport .ExecPackageName}}.Config{Resolvers: &{{ lookupImport .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/generated.gotpl b/codegen/templates/generated.gotpl index d275aac920c..fc84c820fbf 100644 --- a/codegen/templates/generated.gotpl +++ b/codegen/templates/generated.gotpl @@ -77,7 +77,7 @@ type ComplexityRoot struct { {{ range $field := $object.Fields -}} {{ if $field.Args }} func (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - {{ template "args.gotpl" $field.Args }} + {{ render "args.gotpl" $field.Args }} } {{ end }} {{ end }} @@ -86,7 +86,7 @@ type ComplexityRoot struct { {{ range $directive := .Directives }} {{ if $directive.Args }} func (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - {{ template "args.gotpl" $directive.Args }} + {{ render "args.gotpl" $directive.Args }} } {{ end }} {{ end }} @@ -210,19 +210,19 @@ type executionContext struct { } {{- range $object := .Objects }} - {{ template "object.gotpl" $object }} + {{ render "object.gotpl" $object }} {{- range $field := $object.Fields }} - {{ template "field.gotpl" $field }} + {{ render "field.gotpl" $field }} {{ end }} {{- end}} {{- range $interface := .Interfaces }} - {{ template "interface.gotpl" $interface }} + {{ render "interface.gotpl" $interface }} {{- end }} {{- range $input := .Inputs }} - {{ template "input.gotpl" $input }} + {{ render "input.gotpl" $input }} {{- end }} func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { diff --git a/codegen/templates/inliner/inliner.go b/codegen/templates/inliner/inliner.go deleted file mode 100644 index 3c5a0a81d01..00000000000 --- a/codegen/templates/inliner/inliner.go +++ /dev/null @@ -1,47 +0,0 @@ -package main - -import ( - "bytes" - "go/format" - "io/ioutil" - "strconv" - "strings" -) - -func main() { - dir := "./" - - files, err := ioutil.ReadDir(dir) - if err != nil { - panic(err) - } - - out := bytes.Buffer{} - out.WriteString("package templates\n\n") - out.WriteString("var data = map[string]string{\n") - - for _, f := range files { - if !strings.HasSuffix(f.Name(), ".gotpl") { - continue - } - - b, err := ioutil.ReadFile(dir + f.Name()) - if err != nil { - panic(err) - } - - out.WriteString(strconv.Quote(f.Name())) - out.WriteRune(':') - out.WriteString(strconv.Quote(string(b))) - out.WriteString(",\n") - } - - out.WriteString("}\n") - - formatted, err2 := format.Source(out.Bytes()) - if err2 != nil { - panic(err2) - } - - ioutil.WriteFile(dir+"data.go", formatted, 0644) -} diff --git a/codegen/templates/templates.go b/codegen/templates/templates.go index e45be8b7fba..770636598b5 100644 --- a/codegen/templates/templates.go +++ b/codegen/templates/templates.go @@ -1,22 +1,20 @@ -//go:generate go run ./inliner/inliner.go - package templates import ( "bytes" "fmt" + "go/types" "io/ioutil" "os" "path/filepath" "reflect" + "runtime" "sort" "strconv" "strings" "text/template" "unicode" - "go/types" - "github.com/99designs/gqlgen/internal/imports" "github.com/pkg/errors" ) @@ -24,6 +22,29 @@ import ( // this is done with a global because subtemplates currently get called in functions. Lets aim to remove this eventually. var CurrentImports *Imports +func RenderToFile(tpl string, destFile string, data interface{}) error { + if tpl == "" { + return fmt.Errorf("no template name given") + } + if CurrentImports != nil { + panic(fmt.Errorf("recursive or concurrent call to RenderToFile detected")) + } + CurrentImports = &Imports{destDir: filepath.Dir(destFile)} + + filename := resolveName(tpl, 1) + + var buf *bytes.Buffer + buf, err := render(filename, data) + if err != nil { + return errors.Wrap(err, destFile) + } + + b := bytes.Replace(buf.Bytes(), []byte("%%%IMPORTS%%%"), []byte(CurrentImports.String()), -1) + CurrentImports = nil + + return write(destFile, b) +} + func Funcs() template.FuncMap { return template.FuncMap{ "ucFirst": ucFirst, @@ -38,28 +59,12 @@ func Funcs() template.FuncMap { "notNil": notNil, "reserveImport": CurrentImports.Reserve, "lookupImport": CurrentImports.Lookup, + "render": func(filename string, tpldata interface{}) (*bytes.Buffer, error) { + return render(resolveName(filename, 0), tpldata) + }, } } -func Run(name string, tpldata interface{}) (*bytes.Buffer, error) { - t := template.New("").Funcs(Funcs()) - - for filename, data := range data { - _, err := t.New(filename).Parse(data) - if err != nil { - panic(err) - } - } - - buf := &bytes.Buffer{} - err := t.Lookup(name).Execute(buf, tpldata) - if err != nil { - return nil, err - } - - return buf, nil -} - func ucFirst(s string) string { if s == "" { return "" @@ -128,6 +133,126 @@ func ToCamel(s string) string { return string(buffer) } +func ToGo(name string) string { + return lintName(ToCamel(name)) +} + +func ToGoPrivate(name string) string { + return lintName(lcFirst(ToCamel(name))) +} + +// copy from https://github.com/golang/lint/blob/06c8688daad7faa9da5a0c2f163a3d14aac986ca/lint.go#L679 +func lintName(name string) string { + // Fast path for simple cases: "_" and all lowercase. + if name == "_" { + return name + } + allLower := true + for _, r := range name { + if !unicode.IsLower(r) { + allLower = false + break + } + } + if allLower { + return name + } + + // Split camelCase at any lower->upper transition, and split on underscores. + // Check each word for common initialisms. + runes := []rune(name) + w, i := 0, 0 // index of start of word, scan + for i+1 <= len(runes) { + eow := false // whether we hit the end of a word + if i+1 == len(runes) { + eow = true + } else if runes[i+1] == '_' { + // underscore; shift the remainder forward over any run of underscores + eow = true + n := 1 + for i+n+1 < len(runes) && runes[i+n+1] == '_' { + n++ + } + + // Leave at most one underscore if the underscore is between two digits + if i+n+1 < len(runes) && unicode.IsDigit(runes[i]) && unicode.IsDigit(runes[i+n+1]) { + n-- + } + + copy(runes[i+1:], runes[i+n+1:]) + runes = runes[:len(runes)-n] + } else if unicode.IsLower(runes[i]) && !unicode.IsLower(runes[i+1]) { + // lower->non-lower + eow = true + } + i++ + if !eow { + continue + } + + // [w,i) is a word. + word := string(runes[w:i]) + if u := strings.ToUpper(word); commonInitialisms[u] { + // Keep consistent case, which is lowercase only at the start. + if w == 0 && unicode.IsLower(runes[w]) { + u = strings.ToLower(u) + } + // All the common initialisms are ASCII, + // so we can replace the bytes exactly. + copy(runes[w:], []rune(u)) + } else if w > 0 && strings.ToLower(word) == word { + // already all lowercase, and not the first word, so uppercase the first character. + runes[w] = unicode.ToUpper(runes[w]) + } + w = i + } + return string(runes) +} + +// commonInitialisms is a set of common initialisms. +// Only add entries that are highly unlikely to be non-initialisms. +// For instance, "ID" is fine (Freudian code is rare), but "AND" is not. +var commonInitialisms = map[string]bool{ + "ACL": true, + "API": true, + "ASCII": true, + "CPU": true, + "CSS": true, + "DNS": true, + "EOF": true, + "GUID": true, + "HTML": true, + "HTTP": true, + "HTTPS": true, + "ID": true, + "IP": true, + "JSON": true, + "LHS": true, + "QPS": true, + "RAM": true, + "RHS": true, + "RPC": true, + "SLA": true, + "SMTP": true, + "SQL": true, + "SSH": true, + "TCP": true, + "TLS": true, + "TTL": true, + "UDP": true, + "UI": true, + "UID": true, + "UUID": true, + "URI": true, + "URL": true, + "UTF8": true, + "VM": true, + "XML": true, + "XMPP": true, + "XSRF": true, + "XSS": true, +} + func rawQuote(s string) string { return "`" + strings.Replace(s, "`", "`+\"`\"+`", -1) + "`" } @@ -194,22 +319,33 @@ func prefixLines(prefix, s string) string { return prefix + strings.Replace(s, "\n", "\n"+prefix, -1) } -func RenderToFile(tpl string, filename string, data interface{}) error { - if CurrentImports != nil { - panic(fmt.Errorf("recursive or concurrent call to RenderToFile detected")) +func resolveName(name string, skip int) string { + if name[0] == '.' { + // load path relative to calling source file + _, callerFile, _, _ := runtime.Caller(skip + 1) + return filepath.Join(filepath.Dir(callerFile), name[1:]) } - CurrentImports = &Imports{destDir: filepath.Dir(filename)} - var buf *bytes.Buffer - buf, err := Run(tpl, data) + // load path relative to this directory + _, callerFile, _, _ := runtime.Caller(0) + return filepath.Join(filepath.Dir(callerFile), name) +} + +func render(filename string, tpldata interface{}) (*bytes.Buffer, error) { + t := template.New("").Funcs(Funcs()) + + b, err := ioutil.ReadFile(filename) if err != nil { - return errors.Wrap(err, filename) + return nil, err } - b := bytes.Replace(buf.Bytes(), []byte("%%%IMPORTS%%%"), []byte(CurrentImports.String()), -1) - CurrentImports = nil + t, err = t.New(filepath.Base(filename)).Parse(string(b)) + if err != nil { + panic(err) + } - return write(filename, b) + buf := &bytes.Buffer{} + return buf, t.Execute(buf, tpldata) } func write(filename string, b []byte) error { diff --git a/codegen/util.go b/codegen/util.go index c06801cdbe9..a5529c81e3f 100644 --- a/codegen/util.go +++ b/codegen/util.go @@ -1,9 +1,7 @@ package codegen import ( - "go/build" "go/types" - "os" "strings" "github.com/pkg/errors" @@ -48,17 +46,6 @@ func equalFieldName(source, target string) bool { return strings.EqualFold(source, target) } -func resolvePkg(pkgName string) (string, error) { - cwd, _ := os.Getwd() - - pkg, err := build.Default.Import(pkgName, cwd, build.FindOnly) - if err != nil { - return "", err - } - - return pkg.ImportPath, nil -} - var keywords = []string{ "break", "default", diff --git a/example/todo/models_gen.go b/example/todo/models_gen.go index 6abc2273493..74a1c0da57b 100644 --- a/example/todo/models_gen.go +++ b/example/todo/models_gen.go @@ -10,8 +10,10 @@ import ( // Passed to createTodo to create a new todo type TodoInput struct { + // The body text Text string `json:"text"` - Done *bool `json:"done"` + // Is it done already? + Done *bool `json:"done"` } type Role string diff --git a/generate.go b/generate.go index b339fd7b380..c93dcbca634 100644 --- a/generate.go +++ b/generate.go @@ -6,24 +6,35 @@ import ( "github.com/99designs/gqlgen/codegen" "github.com/99designs/gqlgen/codegen/config" + "github.com/99designs/gqlgen/plugin" + "github.com/99designs/gqlgen/plugin/modelgen" "github.com/pkg/errors" + "golang.org/x/tools/go/loader" ) -func Generate(cfg *config.Config) error { +func Generate(cfg *config.Config, option ...Option) error { _ = syscall.Unlink(cfg.Exec.Filename) _ = syscall.Unlink(cfg.Model.Filename) - schema, err := codegen.NewSchema(cfg) - if err != nil { - return errors.Wrap(err, "merging failed") + plugins := []plugin.Plugin{ + modelgen.New(), } - if err = buildModels(schema); err != nil { - return errors.Wrap(err, "generating models failed") + for _, o := range option { + o(cfg, &plugins) + } + + for _, p := range plugins { + if mut, ok := p.(plugin.ConfigMutator); ok { + err := mut.MutateConfig(cfg) + if err != nil { + return errors.Wrap(err, p.Name()) + } + } } // Merge again now that the generated models have been injected into the typemap - schema, err = codegen.NewSchema(schema.Config) + schema, err := codegen.NewSchema(cfg) if err != nil { return errors.Wrap(err, "merging failed") } @@ -46,8 +57,18 @@ func Generate(cfg *config.Config) error { } func validate(cfg *config.Config) error { - progLoader := cfg.NewLoaderWithErrors() - _, err := progLoader.Load() + conf := loader.Config{} + + conf.Import(cfg.Exec.ImportPath()) + if cfg.Model.IsDefined() { + conf.Import(cfg.Model.ImportPath()) + } + + if cfg.Resolver.IsDefined() { + conf.Import(cfg.Resolver.ImportPath()) + } + + _, err := conf.Load() return err } diff --git a/model.go b/model.go deleted file mode 100644 index ec0dd65f677..00000000000 --- a/model.go +++ /dev/null @@ -1,66 +0,0 @@ -package gqlgen - -import ( - "sort" - - "go/types" - - "github.com/99designs/gqlgen/codegen" - "github.com/99designs/gqlgen/codegen/templates" -) - -type ModelBuild struct { - Interfaces []*codegen.Interface - Models codegen.Objects - Enums []codegen.Enum - PackageName string -} - -// Create a list of models that need to be generated -func buildModels(s *codegen.Schema) error { - b := &ModelBuild{ - PackageName: s.Config.Model.Package, - } - - for _, o := range s.Interfaces { - if !o.InTypemap { - b.Interfaces = append(b.Interfaces, o) - } - } - - for _, o := range append(s.Objects, s.Inputs...) { - if !o.InTypemap { - b.Models = append(b.Models, o) - } - } - - for _, e := range s.Enums { - if !e.InTypemap { - b.Enums = append(b.Enums, e) - } - } - - if len(b.Models) == 0 && len(b.Enums) == 0 { - return nil - } - - sort.Slice(b.Models, func(i, j int) bool { - return b.Models[i].Definition.GQLDefinition.Name < b.Models[j].Definition.GQLDefinition.Name - }) - - err := templates.RenderToFile("models.gotpl", s.Config.Model.Filename, b) - - for _, model := range b.Models { - modelCfg := s.Config.Models[model.Definition.GQLDefinition.Name] - modelCfg.Model = types.TypeString(model.Definition.GoType, nil) - s.Config.Models[model.Definition.GQLDefinition.Name] = modelCfg - } - - for _, enum := range b.Enums { - modelCfg := s.Config.Models[enum.Definition.GQLDefinition.Name] - modelCfg.Model = types.TypeString(enum.Definition.GoType, nil) - s.Config.Models[enum.Definition.GQLDefinition.Name] = modelCfg - } - - return err -} diff --git a/option.go b/option.go new file mode 100644 index 00000000000..0c173c7264e --- /dev/null +++ b/option.go @@ -0,0 +1,20 @@ +package gqlgen + +import ( + "github.com/99designs/gqlgen/codegen/config" + "github.com/99designs/gqlgen/plugin" +) + +type Option func(cfg *config.Config, plugins *[]plugin.Plugin) + +func NoPlugins() Option { + return func(cfg *config.Config, plugins *[]plugin.Plugin) { + *plugins = nil + } +} + +func AddPlugin(p plugin.Plugin) Option { + return func(cfg *config.Config, plugins *[]plugin.Plugin) { + *plugins = append(*plugins, p) + } +} diff --git a/plugin/modelgen/models.go b/plugin/modelgen/models.go new file mode 100644 index 00000000000..c6bfa329fd0 --- /dev/null +++ b/plugin/modelgen/models.go @@ -0,0 +1,193 @@ +package modelgen + +import ( + "go/types" + "sort" + + "github.com/99designs/gqlgen/codegen/config" + "github.com/99designs/gqlgen/codegen/templates" + "github.com/99designs/gqlgen/plugin" + "github.com/vektah/gqlparser/ast" +) + +type ModelBuild struct { + PackageName string + Interfaces []*Interface + Models []*Object + Enums []*Enum +} + +type Interface struct { + Description string + Name string +} + +type Object struct { + Description string + Name string + Fields []*Field + Implements []string +} + +type Field struct { + Description string + Name string + Type types.Type + Tag string +} + +type Enum struct { + Description string + Name string + Raw string + Values []*EnumValue +} + +type EnumValue struct { + Description string + Name string + Value string +} + +func New() plugin.Plugin { + return &Plugin{} +} + +type Plugin struct{} + +var _ plugin.ConfigMutator = &Plugin{} + +func (m *Plugin) Name() string { + return "modelgen" +} + +func (m *Plugin) MutateConfig(cfg *config.Config) error { + if err := cfg.Check(); err != nil { + return err + } + + schema, _, err := cfg.LoadSchema() + if err != nil { + return err + } + + binder, err := cfg.NewBinder() + if err != nil { + return err + } + + b := &ModelBuild{ + PackageName: cfg.Model.Package, + } + + for _, schemaType := range schema.Types { + if cfg.Models.UserDefined(schemaType.Name) { + continue + } + + switch schemaType.Kind { + case ast.Interface, ast.Union: + it := &Interface{ + Description: schemaType.Description, + Name: templates.ToGo(schemaType.Name), + } + + b.Interfaces = append(b.Interfaces, it) + case ast.Object, ast.InputObject: + if schemaType == schema.Query || schemaType == schema.Mutation || schemaType == schema.Subscription { + continue + } + it := &Object{ + Description: schemaType.Description, + Name: templates.ToGo(schemaType.Name), + } + + for _, implementor := range schema.GetImplements(schemaType) { + it.Implements = append(it.Implements, templates.ToGo(implementor.Name)) + } + + for _, field := range schemaType.Fields { + var typ types.Type + + if cfg.Models.UserDefined(field.Type.Name()) { + model := cfg.Models[field.Type.Name()] + pkg, typeName := model.PkgAndType() + typ, err = binder.FindType(pkg, typeName) + if err != nil { + return err + } + } else { + // no user defined model, must reference another generated model + typ = types.NewNamed( + types.NewTypeName(0, cfg.Model.Pkg(), templates.ToGo(field.Type.Name()), nil), + nil, + nil, + ) + } + + name := field.Name + if nameOveride := cfg.Models[schemaType.Name].Fields[field.Name].FieldName; nameOveride != "" { + name = nameOveride + } + + fd := schema.Types[field.Type.Name()] + it.Fields = append(it.Fields, &Field{ + Name: templates.ToGo(name), + Type: copyModifiersFromAst(field.Type, fd.Kind != ast.Interface, typ), + Description: field.Description, + Tag: `json:"` + field.Name + `"`, + }) + } + + b.Models = append(b.Models, it) + case ast.Enum: + it := &Enum{ + Name: templates.ToGo(schemaType.Name), + Raw: schemaType.Name, + Description: schemaType.Description, + } + + for _, v := range schemaType.EnumValues { + it.Values = append(it.Values, &EnumValue{ + Name: templates.ToGo(v.Name), + Value: v.Name, + Description: v.Description, + }) + } + + b.Enums = append(b.Enums, it) + } + } + + sort.Slice(b.Enums, func(i, j int) bool { return b.Enums[i].Name < b.Enums[j].Name }) + sort.Slice(b.Models, func(i, j int) bool { return b.Models[i].Name < b.Models[j].Name }) + sort.Slice(b.Interfaces, func(i, j int) bool { return b.Interfaces[i].Name < b.Interfaces[j].Name }) + + for _, it := range b.Enums { + cfg.Models.Add(it.Name, cfg.Model.ImportPath()+"."+it.Name) + } + for _, it := range b.Models { + cfg.Models.Add(it.Name, cfg.Model.ImportPath()+"."+it.Name) + } + for _, it := range b.Interfaces { + cfg.Models.Add(it.Name, cfg.Model.ImportPath()+"."+it.Name) + } + + if len(b.Models) == 0 && len(b.Enums) == 0 { + return nil + } + + return templates.RenderToFile("./models.gotpl", cfg.Model.Filename, b) +} + +func copyModifiersFromAst(t *ast.Type, usePtr bool, base types.Type) types.Type { + if t.Elem != nil { + return types.NewSlice(copyModifiersFromAst(t.Elem, usePtr, base)) + } + + if !t.NonNull && usePtr { + return types.NewPointer(base) + } + + return base +} diff --git a/codegen/templates/models.gotpl b/plugin/modelgen/models.gotpl similarity index 50% rename from codegen/templates/models.gotpl rename to plugin/modelgen/models.gotpl index 8e1071e8c55..a587b281f72 100644 --- a/codegen/templates/models.gotpl +++ b/plugin/modelgen/models.gotpl @@ -21,72 +21,72 @@ import ( ) {{- range $model := .Interfaces }} - {{with .Definition.GQLDefinition.Description }} {{.|prefixLines "// "}} {{end}} - type {{.Definition.GoType | ref }} interface { - Is{{.Definition.GoType | ref }}() + {{ with .Description }} {{.|prefixLines "// "}} {{ end }} + type {{.Name }} interface { + Is{{.Name }}() } {{- end }} {{ range $model := .Models }} - {{with .Definition.GQLDefinition.Description }} {{.|prefixLines "// "}} {{end}} - type {{.Definition.GoType | ref }} struct { + {{with .Description }} {{.|prefixLines "// "}} {{end}} + type {{ .Name }} struct { {{- range $field := .Fields }} - {{- with .Definition.GQLDefinition.Description }} + {{- with .Description }} {{.|prefixLines "// "}} {{- end}} - {{ $field.GoFieldName }} {{$field.GoType | ref}} `json:"{{$field.GQLName}}"` + {{ $field.Name }} {{$field.Type | ref}} `{{$field.Tag}}` {{- end }} } {{- range $iface := .Implements }} - func ({{$model.Definition.GoType | ref }}) Is{{$iface.GoType | ref }}() {} + func ({{ $model.Name }}) Is{{ $iface }}() {} {{- end }} {{- end}} {{ range $enum := .Enums }} - {{with .Definition.GQLDefinition.Description }} {{.|prefixLines "// "}} {{end}} - type {{.Definition.GoType | ref }} string + {{ with .Description }} {{.|prefixLines "// "}} {{end}} + type {{.Name }} string const ( {{- range $value := .Values}} {{- with .Description}} {{.|prefixLines "// "}} {{- end}} - {{$enum.Definition.GoType | ref }}{{ .Name|toCamel }} {{$enum.Definition.GoType | ref }} = {{.Name|quote}} + {{ $enum.Name }}{{ .Name }} {{$enum.Name }} = {{.Value|quote}} {{- end }} ) - var All{{.Definition.GoType | ref }} = []{{.Definition.GoType | ref }}{ + var All{{.Name }} = []{{ .Name }}{ {{- range $value := .Values}} - {{$enum.Definition.GoType | ref }}{{ .Name|toCamel }}, + {{$enum.Name }}{{ .Name }}, {{- end }} } - func (e {{.Definition.GoType | ref }}) IsValid() bool { + func (e {{.Name }}) IsValid() bool { switch e { - case {{ range $index, $element := .Values}}{{if $index}},{{end}}{{ $enum.Definition.GoType | ref }}{{ $element.Name|toCamel }}{{end}}: + case {{ range $index, $element := .Values}}{{if $index}},{{end}}{{ $enum.Name }}{{ $element.Name }}{{end}}: return true } return false } - func (e {{.Definition.GoType | ref }}) String() string { + func (e {{.Name }}) String() string { return string(e) } - func (e *{{.Definition.GoType | ref }}) UnmarshalGQL(v interface{}) error { + func (e *{{.Name }}) UnmarshalGQL(v interface{}) error { str, ok := v.(string) if !ok { return fmt.Errorf("enums must be strings") } - *e = {{.Definition.GoType | ref }}(str) + *e = {{ .Name }}(str) if !e.IsValid() { - return fmt.Errorf("%s is not a valid {{.Definition.GQLDefinition.Name}}", str) + return fmt.Errorf("%s is not a valid {{ .Raw }}", str) } return nil } - func (e {{.Definition.GoType | ref }}) MarshalGQL(w io.Writer) { + func (e {{.Name }}) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } diff --git a/plugin/modelgen/models_test.go b/plugin/modelgen/models_test.go new file mode 100644 index 00000000000..49ea8c16ac2 --- /dev/null +++ b/plugin/modelgen/models_test.go @@ -0,0 +1,20 @@ +package modelgen + +import ( + "testing" + + "github.com/99designs/gqlgen/codegen/config" + "github.com/stretchr/testify/require" +) + +func TestModelGeneration(t *testing.T) { + cfg, err := config.LoadConfig("testdata/gqlgen.yml") + require.NoError(t, err) + p := Plugin{} + require.NoError(t, p.MutateConfig(cfg)) + + require.True(t, cfg.Models.UserDefined("MissingType")) + require.True(t, cfg.Models.UserDefined("MissingEnum")) + require.True(t, cfg.Models.UserDefined("MissingUnion")) + require.True(t, cfg.Models.UserDefined("MissingInterface")) +} diff --git a/plugin/modelgen/out/existing.go b/plugin/modelgen/out/existing.go new file mode 100644 index 00000000000..6e91b1eeb8b --- /dev/null +++ b/plugin/modelgen/out/existing.go @@ -0,0 +1,23 @@ +package out + +type ExistingModel struct { + Name string + Enum ExistingEnum + Int ExistingInterface +} + +type ExistingInput struct { + Name string + Enum ExistingEnum + Int ExistingInterface +} + +type ExistingEnum string + +type ExistingInterface interface { + IsExistingInterface() +} + +type ExistingUnion interface { + IsExistingUnion() +} diff --git a/plugin/modelgen/out/generated.go b/plugin/modelgen/out/generated.go new file mode 100644 index 00000000000..a3f910516aa --- /dev/null +++ b/plugin/modelgen/out/generated.go @@ -0,0 +1,89 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + +package out + +import ( + "fmt" + "io" + "strconv" +) + +type MissingInterface interface { + IsMissingInterface() +} + +type MissingUnion interface { + IsMissingUnion() +} + +type ExistingType struct { + Name *string `json:"name"` + Enum *ExistingEnum `json:"enum"` + Int ExistingInterface `json:"int"` + Existing *MissingType `json:"existing"` +} + +func (ExistingType) IsMissingUnion() {} +func (ExistingType) IsMissingInterface() {} +func (ExistingType) IsExistingInterface() {} +func (ExistingType) IsExistingUnion() {} + +type MissingInput struct { + Name *string `json:"name"` + Enum *MissingEnum `json:"enum"` + Int MissingInterface `json:"int"` + Existing *ExistingType `json:"existing"` +} + +type MissingType struct { + Name *string `json:"name"` + Enum *MissingEnum `json:"enum"` + Int MissingInterface `json:"int"` + Existing *ExistingType `json:"existing"` +} + +func (MissingType) IsMissingInterface() {} +func (MissingType) IsExistingInterface() {} +func (MissingType) IsMissingUnion() {} +func (MissingType) IsExistingUnion() {} + +type MissingEnum string + +const ( + MissingEnumHello MissingEnum = "Hello" + MissingEnumGoodbye MissingEnum = "Goodbye" +) + +var AllMissingEnum = []MissingEnum{ + MissingEnumHello, + MissingEnumGoodbye, +} + +func (e MissingEnum) IsValid() bool { + switch e { + case MissingEnumHello, MissingEnumGoodbye: + return true + } + return false +} + +func (e MissingEnum) String() string { + return string(e) +} + +func (e *MissingEnum) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = MissingEnum(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid MissingEnum", str) + } + return nil +} + +func (e MissingEnum) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} diff --git a/plugin/modelgen/testdata/gqlgen.yml b/plugin/modelgen/testdata/gqlgen.yml new file mode 100644 index 00000000000..b32289be0d3 --- /dev/null +++ b/plugin/modelgen/testdata/gqlgen.yml @@ -0,0 +1,21 @@ +schema: + - "testdata/schema.graphql" + +exec: + filename: out/generated.go +model: + filename: out/generated.go + +models: + ExistingModel: + model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingModel + ExistingInput: + model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingInput + ExistingEnum: + model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingEnum + ExistingInterface: + model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingInterface + ExistingUnion: + model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingUnion + + diff --git a/plugin/modelgen/testdata/schema.graphql b/plugin/modelgen/testdata/schema.graphql new file mode 100644 index 00000000000..6be346bdbcc --- /dev/null +++ b/plugin/modelgen/testdata/schema.graphql @@ -0,0 +1,62 @@ +type Query { + thisShoudlntGetGenerated: Boolean +} + +type Mutation { + thisShoudlntGetGenerated: Boolean +} + +type Subscription { + thisShoudlntGetGenerated: Boolean +} + +type MissingType implements MissingInterface & ExistingInterface { + name: String + enum: MissingEnum + int: MissingInterface + existing: ExistingType +} + +input MissingInput { + name: String + enum: MissingEnum + int: MissingInterface + existing: ExistingType +} + +enum MissingEnum { + Hello + Goodbye +} + +interface MissingInterface { + name: String +} + +union MissingUnion = MissingType | ExistingType + +type ExistingType implements MissingInterface & ExistingInterface { + name: String + enum: ExistingEnum + int: ExistingInterface + existing: MissingType +} + +input ExistingInput { + name: String + enum: ExistingEnum + int: ExistingInterface + existing: MissingType +} + +enum ExistingEnum { + Hello + Goodbye +} + +interface ExistingInterface { + name: String +} + +union ExistingUnion = MissingType | ExistingType + diff --git a/plugin/plugin.go b/plugin/plugin.go new file mode 100644 index 00000000000..55492b1799f --- /dev/null +++ b/plugin/plugin.go @@ -0,0 +1,13 @@ +// plugin package interfaces are EXPERIMENTAL. + +package plugin + +import "github.com/99designs/gqlgen/codegen/config" + +type Plugin interface { + Name() string +} + +type ConfigMutator interface { + MutateConfig(cfg *config.Config) error +} From 0f8844932c526fa14dc81ed14b036537cd5eca35 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Mon, 21 Jan 2019 18:13:10 +1100 Subject: [PATCH 046/147] linting fixes --- cmd/root.go | 6 +++--- codegen/templates/input.gotpl | 4 ++-- codegen/testserver/generated.go | 4 ++-- example/scalars/model/model.go | 2 +- graphql/bool.go | 2 +- integration/integration-test.js | 2 +- integration/resolver.go | 2 +- internal/gopath/gopath.go | 4 ++-- internal/gopath/gopath_test.go | 4 ++-- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 519c2e1af51..6e6d6263512 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -25,11 +25,11 @@ func Execute() { app.Before = func(context *cli.Context) error { pwd, err := os.Getwd() if err != nil { - return fmt.Errorf("unable to determine current workding dir: %s\n", err.Error()) + return fmt.Errorf("unable to determine current workding dir: %s", err.Error()) } if !gopath.Contains(pwd) { - return fmt.Errorf("gqlgen must be run from inside your $GOPATH\n") + return fmt.Errorf("gqlgen must be run from inside your $GOPATH") } if context.Bool("verbose") { log.SetFlags(0) @@ -47,7 +47,7 @@ func Execute() { } if err := app.Run(os.Args); err != nil { - fmt.Fprintf(os.Stderr, err.Error()) + fmt.Fprint(os.Stderr, err.Error()) os.Exit(1) } } diff --git a/codegen/templates/input.gotpl b/codegen/templates/input.gotpl index 62df22eface..c225304ffd6 100644 --- a/codegen/templates/input.gotpl +++ b/codegen/templates/input.gotpl @@ -93,8 +93,8 @@ {{else}} if data, ok := c{{$field.GoFieldName}}.({{ $field.GoType | ref }}); ok{ obj.{{$field.GoFieldName}} = data - }else{ - return obj, errors.New("{{$field.GoFieldName}} expect {{$field.GoType | ref }}") + } else { + return obj, errors.New("expected {{$field.GoFieldName}} to be {{$field.GoType | ref }}") } {{ end }} diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index c0173077736..7dba7381acf 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -4670,7 +4670,7 @@ func (e *executableSchema) InnerDirectivesMiddleware(ctx context.Context, obj *I if data, ok := cMessage.(string); ok { obj.Message = data } else { - return obj, errors.New("Message expect string") + return obj, errors.New("expected Message to be string") } return obj, nil @@ -4753,7 +4753,7 @@ func (e *executableSchema) InputDirectivesMiddleware(ctx context.Context, obj *I if data, ok := cText.(string); ok { obj.Text = data } else { - return obj, errors.New("Text expect string") + return obj, errors.New("expected Text to be string") } mInnerDirectives1, err := e.InnerDirectivesMiddleware(ctx, &obj.Inner) diff --git a/example/scalars/model/model.go b/example/scalars/model/model.go index e779efaddbf..86038629b0e 100644 --- a/example/scalars/model/model.go +++ b/example/scalars/model/model.go @@ -25,7 +25,7 @@ func (b Banned) MarshalGQL(w io.Writer) { func (b *Banned) UnmarshalGQL(v interface{}) error { switch v := v.(type) { case string: - *b = "true" == strings.ToLower(v) + *b = strings.ToLower(v) == "true" return nil case bool: *b = Banned(v) diff --git a/graphql/bool.go b/graphql/bool.go index 7053bbcaa32..b175ca98628 100644 --- a/graphql/bool.go +++ b/graphql/bool.go @@ -19,7 +19,7 @@ func MarshalBoolean(b bool) Marshaler { func UnmarshalBoolean(v interface{}) (bool, error) { switch v := v.(type) { case string: - return "true" == strings.ToLower(v), nil + return strings.ToLower(v) == "true", nil case int: return v != 0, nil case bool: diff --git a/integration/integration-test.js b/integration/integration-test.js index e7bcc4871a6..43414ec17d0 100644 --- a/integration/integration-test.js +++ b/integration/integration-test.js @@ -68,6 +68,6 @@ describe('Errors', () => { query: gql`{ error(type: NORMAL) }`, }); - expect(res.errors[0].message).toEqual('Normal error'); + expect(res.errors[0].message).toEqual('normal error'); }); }); diff --git a/integration/resolver.go b/integration/resolver.go index 5f28e1d741f..787be65c828 100644 --- a/integration/resolver.go +++ b/integration/resolver.go @@ -58,7 +58,7 @@ func (r *queryResolver) Error(ctx context.Context, typeArg *models.ErrorType) (b return false, &CustomError{"User message", "Internal Message"} } - return false, fmt.Errorf("Normal error") + return false, fmt.Errorf("normal error") } func (r *queryResolver) Path(ctx context.Context) ([]*models.Element, error) { diff --git a/internal/gopath/gopath.go b/internal/gopath/gopath.go index c9b66167a3e..01cd5ba955e 100644 --- a/internal/gopath/gopath.go +++ b/internal/gopath/gopath.go @@ -7,7 +7,7 @@ import ( "strings" ) -var NotFound = fmt.Errorf("not on GOPATH") +var ErrNotFound = fmt.Errorf("not on GOPATH") // Contains returns true if the given directory is in the GOPATH func Contains(dir string) bool { @@ -24,7 +24,7 @@ func Dir2Import(dir string) (string, error) { return dir[len(gopath)+1:], nil } } - return "", NotFound + return "", ErrNotFound } // MustDir2Import takes an *absolute* path and returns a golang import path for the package, and panics if it isn't on the gopath diff --git a/internal/gopath/gopath_test.go b/internal/gopath/gopath_test.go index 847ad1e8567..ae48ab4fe95 100644 --- a/internal/gopath/gopath_test.go +++ b/internal/gopath/gopath_test.go @@ -46,7 +46,7 @@ func TestDir2Package(t *testing.T) { assert.Equal(t, "foo/bar", MustDir2Import("C:/b/src/foo/bar")) assert.Equal(t, "foo/bar", MustDir2Import(`C:\b\src\foo\bar`)) - assert.PanicsWithValue(t, NotFound, func() { + assert.PanicsWithValue(t, ErrNotFound, func() { MustDir2Import("C:/tmp/foo") }) } else { @@ -55,7 +55,7 @@ func TestDir2Package(t *testing.T) { assert.Equal(t, "foo/bar", MustDir2Import("/a/y/src/foo/bar")) assert.Equal(t, "foo/bar", MustDir2Import("/b/src/foo/bar")) - assert.PanicsWithValue(t, NotFound, func() { + assert.PanicsWithValue(t, ErrNotFound, func() { MustDir2Import("/tmp/foo") }) } From 251e8514d637b99bb0e52030dc25483f5e74085d Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Sat, 26 Jan 2019 02:39:51 +0000 Subject: [PATCH 047/147] Add support for go modules --- .circleci/golang.Dockerfile | 14 +- .circleci/test.sh | 2 +- .golangci.yml | 3 + .gometalinter.json | 14 - Gopkg.lock | 270 ------------------ Gopkg.toml | 29 -- client/websocket.go | 5 +- cmd/root.go | 9 - codegen/build_interface.go | 11 - codegen/build_typedef.go | 14 +- codegen/config/binder.go | 35 +-- codegen/config/config.go | 27 +- codegen/templates/import.go | 29 +- codegen/testserver/generated.go | 5 + codegen/testserver/generated_test.go | 6 +- codegen/testserver/models-gen.go | 47 +++ codegen/testserver/schema.graphql | 5 + codegen_test.go | 56 ---- example/dataloader/addressloader_gen.go | 21 ++ example/dataloader/dataloaders.go | 6 +- example/dataloader/itemsliceloader_gen.go | 21 ++ example/dataloader/ordersliceloader_gen.go | 21 ++ .../scalars/{vendor => }/external/model.go | 0 example/scalars/generated.go | 2 +- example/scalars/model/generated.go | 2 +- example/scalars/model/model.go | 2 +- example/scalars/resolvers.go | 2 +- example/scalars/vendor/readme.md | 1 - generate.go | 20 +- go.mod | 29 ++ go.sum | 68 +++++ handler/graphql_test.go | 2 +- integration/generated.go | 2 +- integration/gqlgen.yml | 2 +- integration/models-go/viewer.go | 2 +- integration/{vendor => }/remote_api/user.go | 0 integration/resolver.go | 6 +- internal/code/imports.go | 45 +++ internal/code/imports_test.go | 32 +++ internal/{gopath => code}/util.go | 9 +- internal/gopath/gopath.go | 37 --- internal/gopath/gopath_test.go | 62 ---- internal/imports/prune.go | 22 +- testdata/generateserver.graphqls | 11 - tools.go | 5 + 45 files changed, 389 insertions(+), 624 deletions(-) create mode 100644 .golangci.yml delete mode 100644 .gometalinter.json delete mode 100644 Gopkg.lock delete mode 100644 Gopkg.toml delete mode 100644 codegen_test.go rename example/scalars/{vendor => }/external/model.go (100%) delete mode 100644 example/scalars/vendor/readme.md create mode 100644 go.mod create mode 100644 go.sum rename integration/{vendor => }/remote_api/user.go (100%) create mode 100644 internal/code/imports.go create mode 100644 internal/code/imports_test.go rename internal/{gopath => code}/util.go (73%) delete mode 100644 internal/gopath/gopath.go delete mode 100644 internal/gopath/gopath_test.go delete mode 100644 testdata/generateserver.graphqls create mode 100644 tools.go diff --git a/.circleci/golang.Dockerfile b/.circleci/golang.Dockerfile index 7cc98dbcaf6..e5b6443ce97 100644 --- a/.circleci/golang.Dockerfile +++ b/.circleci/golang.Dockerfile @@ -1,12 +1,10 @@ -FROM golang:1.10 +FROM golang:1.11 -RUN curl -L -o /bin/dep https://github.com/golang/dep/releases/download/v0.4.1/dep-linux-amd64 && chmod +x /bin/dep -RUN go get -u github.com/alecthomas/gometalinter github.com/vektah/gorunpkg -RUN gometalinter --install +RUN curl -sL --fail https://github.com/golangci/golangci-lint/releases/download/v1.13/golangci-lint-1.13-linux-amd64.tar.gz | tar zxv --strip-components=1 --dir=/go/bin -WORKDIR /go/src/github.com/99designs/gqlgen +WORKDIR /projects/gqlgen -COPY Gopkg.* /go/src/github.com/99designs/gqlgen/ -RUN dep ensure -v --vendor-only +COPY go.* /projects/gqlgen/ +RUN go mod download -COPY . /go/src/github.com/99designs/gqlgen/ +COPY . /projects/gqlgen diff --git a/.circleci/test.sh b/.circleci/test.sh index 79c98f18f26..37b0e9dc6a9 100755 --- a/.circleci/test.sh +++ b/.circleci/test.sh @@ -18,4 +18,4 @@ echo "### running testsuite" go test -race ./... echo "### linting" -gometalinter --vendor ./... +golangci-lint run diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000000..2239d630a0f --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,3 @@ +linters-settings: + errcheck: + ignore: fmt:.*,[rR]ead|[wW]rite|[cC]lose,io:Copy diff --git a/.gometalinter.json b/.gometalinter.json deleted file mode 100644 index 07d6ff52339..00000000000 --- a/.gometalinter.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "sort": ["path"], - "Deadline": "5m", - "Linters": { - "errcheck": { - "Command": "errcheck -abspath -ignore '[rR]ead|[wW]rite|Close|[fF]print'", - "Pattern": "PATH:LINE:COL:MESSAGE", - "InstallFrom": "github.com/kisielk/errcheck", - "PartitionStrategy": "packages" - } - }, - "Skip": ["internal/imports/testdata"], - "Disable": ["gas","golint","gocyclo","goconst", "gotype", "maligned", "gosec"] -} diff --git a/Gopkg.lock b/Gopkg.lock deleted file mode 100644 index ba7c4bd22be..00000000000 --- a/Gopkg.lock +++ /dev/null @@ -1,270 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - branch = "master" - digest = "1:99b2e09d42b4d0929e9e6ac496922f5221baa79b60968576d5ce310b44640c3b" - name = "github.com/agnivade/levenshtein" - packages = ["."] - pruneopts = "UT" - revision = "1787a73e302ce294513cfab1982e186f5cf8985f" - -[[projects]] - digest = "1:a2c1d0e43bd3baaa071d1b9ed72c27d78169b2b269f71c105ac4ba34b1be4a39" - name = "github.com/davecgh/go-spew" - packages = ["spew"] - pruneopts = "UT" - revision = "346938d642f2ec3594ed81d874461961cd0faa76" - version = "v1.1.0" - -[[projects]] - digest = "1:66ddebb274faa160a4a23394a17ad3c8e15fee9bf5408d13f77d22b61bc7f072" - name = "github.com/go-chi/chi" - packages = ["."] - pruneopts = "UT" - revision = "e83ac2304db3c50cf03d96a2fcd39009d458bc35" - version = "v3.3.2" - -[[projects]] - digest = "1:f3df613325a793ffb3d0ce7644a3bb6f62db45ac744dafe20172fe999c61cdbf" - name = "github.com/gogo/protobuf" - packages = [ - "io", - "proto", - ] - pruneopts = "UT" - revision = "1adfc126b41513cc696b209667c8656ea7aac67c" - version = "v1.0.0" - -[[projects]] - digest = "1:160eabf7a69910fd74f29c692718bc2437c1c1c7d4c9dea9712357752a70e5df" - name = "github.com/gorilla/context" - packages = ["."] - pruneopts = "UT" - revision = "1ea25387ff6f684839d82767c1733ff4d4d15d0a" - version = "v1.1" - -[[projects]] - digest = "1:88aa9e326e2bd6045a46e00a922954b3e1a9ac5787109f49ac85366df370e1e5" - name = "github.com/gorilla/mux" - packages = ["."] - pruneopts = "UT" - revision = "53c1911da2b537f792e7cafcb446b05ffe33b996" - version = "v1.6.1" - -[[projects]] - digest = "1:43dd08a10854b2056e615d1b1d22ac94559d822e1f8b6fcc92c1a1057e85188e" - name = "github.com/gorilla/websocket" - packages = ["."] - pruneopts = "UT" - revision = "ea4d1f681babbce9545c9c5f3d5194a789c89f5b" - version = "v1.2.0" - -[[projects]] - branch = "master" - digest = "1:cf296baa185baae04a9a7004efee8511d08e2f5f51d4cbe5375da89722d681db" - name = "github.com/hashicorp/golang-lru" - packages = [ - ".", - "simplelru", - ] - pruneopts = "UT" - revision = "0fb14efe8c47ae851c0034ed7a448854d3d34cf3" - -[[projects]] - branch = "master" - digest = "1:ab9cfaf00fc5db5fd9d8e5f33da52e62bcc977d1976503dcc2a1492f391bd9ed" - name = "github.com/mitchellh/mapstructure" - packages = ["."] - pruneopts = "UT" - revision = "a4e142e9c047c904fa2f1e144d9a84e6133024bc" - -[[projects]] - digest = "1:d07bd28263c09c5d7f6502e8ddac63e027eca0eafcd07632790d958b50360317" - name = "github.com/opentracing/basictracer-go" - packages = [ - ".", - "wire", - ] - pruneopts = "UT" - revision = "1b32af207119a14b1b231d451df3ed04a72efebf" - version = "v1.0.0" - -[[projects]] - digest = "1:450b7623b185031f3a456801155c8320209f75d0d4c4e633c6b1e59d44d6e392" - name = "github.com/opentracing/opentracing-go" - packages = [ - ".", - "ext", - "log", - ] - pruneopts = "UT" - revision = "1949ddbfd147afd4d964a9f00b24eb291e0e7c38" - version = "v1.0.2" - -[[projects]] - digest = "1:40e195917a951a8bf867cd05de2a46aaf1806c50cf92eebf4c16f78cd196f747" - name = "github.com/pkg/errors" - packages = ["."] - pruneopts = "UT" - revision = "645ef00459ed84a119197bfb8d8205042c6df63d" - version = "v0.8.0" - -[[projects]] - digest = "1:0028cb19b2e4c3112225cd871870f2d9cf49b9b4276531f03438a88e94be86fe" - name = "github.com/pmezard/go-difflib" - packages = ["difflib"] - pruneopts = "UT" - revision = "792786c7400a136282c1664665ae0a8db921c6c2" - version = "v1.0.0" - -[[projects]] - digest = "1:b0c25f00bad20d783d259af2af8666969e2fc343fa0dc9efe52936bbd67fb758" - name = "github.com/rs/cors" - packages = ["."] - pruneopts = "UT" - revision = "9a47f48565a795472d43519dd49aac781f3034fb" - version = "v1.6.0" - -[[projects]] - branch = "master" - digest = "1:7ca2584fa7da0520cd2d1136a10194fe5a5b220bdb215074ab6f7b5ad91115f4" - name = "github.com/shurcooL/httpfs" - packages = ["vfsutil"] - pruneopts = "UT" - revision = "809beceb23714880abc4a382a00c05f89d13b1cc" - -[[projects]] - branch = "master" - digest = "1:a3f0c6930421c8a4c02aaf2a00c5e7b808204b15a47b1d8c285c1e9cbda886b5" - name = "github.com/shurcooL/vfsgen" - packages = ["."] - pruneopts = "UT" - revision = "ffb13db8def02f545acc58bd288ec6057c2bbfb9" - -[[projects]] - digest = "1:7e8d267900c7fa7f35129a2a37596e38ed0f11ca746d6d9ba727980ee138f9f6" - name = "github.com/stretchr/testify" - packages = [ - "assert", - "require", - ] - pruneopts = "UT" - revision = "12b6f73e6084dad08a7c6e575284b177ecafbc71" - version = "v1.2.1" - -[[projects]] - digest = "1:b24d38b282bacf9791408a080f606370efa3d364e4b5fd9ba0f7b87786d3b679" - name = "github.com/urfave/cli" - packages = ["."] - pruneopts = "UT" - revision = "cfb38830724cc34fedffe9a2a29fb54fa9169cd1" - version = "v1.20.0" - -[[projects]] - branch = "master" - digest = "1:3684f335059f8441260c3e949c0b99de97ea1057ecc493fdbd72ff3c27863277" - name = "github.com/vektah/dataloaden" - packages = ["."] - pruneopts = "UT" - revision = "314ac81052eedc03ac0a79bdc89d05a49a2a5814" - -[[projects]] - digest = "1:ed6a41de3eedd8d4868eea057837860453ebbe08c5e385fd50d4c24e5642ec18" - name = "github.com/vektah/gqlparser" - packages = [ - ".", - "ast", - "gqlerror", - "lexer", - "parser", - "validator", - "validator/rules", - ] - pruneopts = "UT" - revision = "e805d08bb209b1accdea76bd2327811858d81985" - version = "v1.0.0" - -[[projects]] - branch = "master" - digest = "1:76ee51c3f468493aff39dbacc401e8831fbb765104cbf613b89bef01cf4bad70" - name = "golang.org/x/net" - packages = ["context"] - pruneopts = "UT" - revision = "b3c676e531a6dc479fa1b35ac961c13f5e2b4d2e" - -[[projects]] - branch = "master" - digest = "1:3cbc05413b8aac22b1f6d4350ed696b5a83a8515a4136db8f1ec3a0aee3d76e1" - name = "golang.org/x/tools" - packages = [ - "go/ast/astutil", - "go/buildutil", - "go/loader", - "imports", - ] - pruneopts = "UT" - revision = "ce871d178848e3eea1e8795e5cfb74053dde4bb9" - -[[projects]] - digest = "1:342378ac4dcb378a5448dd723f0784ae519383532f5e70ade24132c4c8693202" - name = "gopkg.in/yaml.v2" - packages = ["."] - pruneopts = "UT" - revision = "5420a8b6744d3b0345ab293f6fcba19c978f1183" - version = "v2.2.1" - -[[projects]] - branch = "master" - digest = "1:741ebea9214cc226789d3003baeca9b169e04b5b336fb1a3b2c16e75bd296bb5" - name = "sourcegraph.com/sourcegraph/appdash" - packages = [ - ".", - "httptrace", - "internal/wire", - "opentracing", - "sqltrace", - "traceapp", - "traceapp/tmpl", - ] - pruneopts = "UT" - revision = "2cc67fd647551af94593ecaaa89fe4e5b2940a3e" - -[[projects]] - branch = "master" - digest = "1:8e0a2957fe342f22d70a543c3fcdf390f7627419c3d82d87ab4fd715a9ef5716" - name = "sourcegraph.com/sourcegraph/appdash-data" - packages = ["."] - pruneopts = "UT" - revision = "73f23eafcf67cad684fba328dd545a116ac273ff" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - input-imports = [ - "github.com/go-chi/chi", - "github.com/gorilla/websocket", - "github.com/hashicorp/golang-lru", - "github.com/mitchellh/mapstructure", - "github.com/opentracing/opentracing-go", - "github.com/pkg/errors", - "github.com/rs/cors", - "github.com/stretchr/testify/assert", - "github.com/stretchr/testify/require", - "github.com/urfave/cli", - "github.com/vektah/dataloaden", - "github.com/vektah/gqlparser", - "github.com/vektah/gqlparser/ast", - "github.com/vektah/gqlparser/gqlerror", - "github.com/vektah/gqlparser/parser", - "github.com/vektah/gqlparser/validator", - "golang.org/x/tools/go/ast/astutil", - "golang.org/x/tools/go/loader", - "golang.org/x/tools/imports", - "gopkg.in/yaml.v2", - "sourcegraph.com/sourcegraph/appdash", - "sourcegraph.com/sourcegraph/appdash/opentracing", - "sourcegraph.com/sourcegraph/appdash/traceapp", - ] - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml deleted file mode 100644 index 7876142a7ea..00000000000 --- a/Gopkg.toml +++ /dev/null @@ -1,29 +0,0 @@ -required = ["github.com/vektah/dataloaden"] - -[[constraint]] - branch = "master" - name = "github.com/mitchellh/mapstructure" - -[[constraint]] - name = "github.com/stretchr/testify" - version = "1.2.1" - -[[constraint]] - branch = "master" - name = "golang.org/x/tools" - -[[constraint]] - name = "github.com/vektah/gqlparser" - version = "^1.0.0" - -[prune] - go-tests = true - unused-packages = true - -[[constraint]] - name = "gopkg.in/yaml.v2" - version = "2.2.1" - -[[constraint]] - name = "github.com/rs/cors" - version = "1.6.0" diff --git a/client/websocket.go b/client/websocket.go index d66c872ca30..f7452b4c978 100644 --- a/client/websocket.go +++ b/client/websocket.go @@ -84,7 +84,10 @@ func (p *Client) WebsocketWithPayload(query string, initPayload map[string]inter Close: c.Close, Next: func(response interface{}) error { var op operationMessage - c.ReadJSON(&op) + err := c.ReadJSON(&op) + if err != nil { + return err + } if op.Type != dataMsg { if op.Type == errorMsg { return fmt.Errorf(string(op.Payload)) diff --git a/cmd/root.go b/cmd/root.go index 6e6d6263512..dc2970ac890 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -7,7 +7,6 @@ import ( "os" "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/internal/gopath" "github.com/urfave/cli" // Required since otherwise dep will prune away these unused packages before codegen has a chance to run @@ -23,14 +22,6 @@ func Execute() { app.Flags = genCmd.Flags app.Version = graphql.Version app.Before = func(context *cli.Context) error { - pwd, err := os.Getwd() - if err != nil { - return fmt.Errorf("unable to determine current workding dir: %s", err.Error()) - } - - if !gopath.Contains(pwd) { - return fmt.Errorf("gqlgen must be run from inside your $GOPATH") - } if context.Bool("verbose") { log.SetFlags(0) } else { diff --git a/codegen/build_interface.go b/codegen/build_interface.go index 173f4805cda..1e0578620a4 100644 --- a/codegen/build_interface.go +++ b/codegen/build_interface.go @@ -2,7 +2,6 @@ package codegen import ( "go/types" - "strings" "github.com/vektah/gqlparser/ast" ) @@ -38,13 +37,3 @@ func (b *builder) isValueReceiver(intf *TypeDefinition, implementor *TypeDefinit return types.Implements(implementorType, interfaceType) } - -// take a string in the form github.com/package/blah.TypeReference and split it into package and type -func pkgAndType(name string) (string, string) { - parts := strings.Split(name, ".") - if len(parts) == 1 { - return "", name - } - - return normalizeVendor(strings.Join(parts[:len(parts)-1], ".")), parts[len(parts)-1] -} diff --git a/codegen/build_typedef.go b/codegen/build_typedef.go index 9bfb272b7cd..e167ae416d3 100644 --- a/codegen/build_typedef.go +++ b/codegen/build_typedef.go @@ -4,6 +4,8 @@ import ( "fmt" "go/types" + "github.com/99designs/gqlgen/internal/code" + "github.com/99designs/gqlgen/codegen/templates" "github.com/pkg/errors" "github.com/vektah/gqlparser/ast" @@ -18,12 +20,16 @@ func (b *builder) buildTypeDef(schemaType *ast.Definition) (*TypeDefinition, err if userEntry, ok := b.Config.Models[t.GQLDefinition.Name]; ok && userEntry.Model != "" { // special case for maps if userEntry.Model == "map[string]interface{}" { - t.GoType = types.NewMap(types.Typ[types.String], types.NewInterface(nil, nil).Complete()) + t.GoType = types.NewMap(types.Typ[types.String], types.NewInterfaceType(nil, nil).Complete()) return t, nil } - pkgName, typeName = pkgAndType(userEntry.Model) + pkgName, typeName = code.PkgAndType(userEntry.Model) + if pkgName == "" { + return nil, fmt.Errorf("missing package name for %s", schemaType.Name) + } + } else if t.GQLDefinition.Kind == ast.Scalar { pkgName = "github.com/99designs/gqlgen/graphql" typeName = "String" @@ -39,10 +45,6 @@ func (b *builder) buildTypeDef(schemaType *ast.Definition) (*TypeDefinition, err return t, nil } - if pkgName == "" { - return nil, fmt.Errorf("missing package name for %s", schemaType.Name) - } - // External marshal functions def, err := b.Binder.FindObject(pkgName, typeName) if err != nil { diff --git a/codegen/config/binder.go b/codegen/config/binder.go index 9adb868e8cb..03974ab2552 100644 --- a/codegen/config/binder.go +++ b/codegen/config/binder.go @@ -7,35 +7,24 @@ import ( "strings" "github.com/pkg/errors" - "golang.org/x/tools/go/loader" + "golang.org/x/tools/go/packages" ) // Binder connects graphql types to golang types using static analysis type Binder struct { - program *loader.Program - types TypeMap + pkgs []*packages.Package + types TypeMap } func (c *Config) NewBinder() (*Binder, error) { - conf := loader.Config{ - AllowErrors: true, - TypeChecker: types.Config{ - Error: func(e error) {}, - }, - } - - for _, pkg := range c.Models.ReferencedPackages() { - conf.Import(pkg) - } - - prog, err := conf.Load() + pkgs, err := packages.Load(&packages.Config{Mode: packages.LoadTypes | packages.LoadSyntax}, c.Models.ReferencedPackages()...) if err != nil { - return nil, errors.Wrap(err, "loading program") + return nil, err } return &Binder{ - program: prog, - types: c.Models, + pkgs: pkgs, + types: c.Models, }, nil } @@ -51,9 +40,9 @@ func (b *Binder) FindType(pkgName string, typeName string) (types.Type, error) { return obj.Type(), nil } -func (b *Binder) getPkg(find string) *loader.PackageInfo { - for n, p := range b.program.Imported { - if normalizeVendor(find) == normalizeVendor(n) { +func (b *Binder) getPkg(find string) *packages.Package { + for _, p := range b.pkgs { + if normalizeVendor(find) == normalizeVendor(p.PkgPath) { return p } } @@ -74,9 +63,9 @@ func (b *Binder) FindObject(pkgName string, typeName string) (types.Object, erro return nil, errors.Errorf("required package was not loaded: %s", fullName) } - for astNode, def := range pkg.Defs { + for astNode, def := range pkg.TypesInfo.Defs { // only look at defs in the top scope - if def == nil || def.Parent() == nil || def.Parent() != pkg.Pkg.Scope() { + if def == nil || def.Parent() == nil || def.Parent() != pkg.Types.Scope() { continue } diff --git a/codegen/config/config.go b/codegen/config/config.go index 1c05fcf3186..688763d5843 100644 --- a/codegen/config/config.go +++ b/codegen/config/config.go @@ -2,21 +2,19 @@ package config import ( "fmt" - "go/build" "io/ioutil" "os" "path/filepath" - "regexp" "sort" "strings" "go/types" - "github.com/99designs/gqlgen/internal/gopath" + "github.com/99designs/gqlgen/internal/code" "github.com/pkg/errors" "github.com/vektah/gqlparser" "github.com/vektah/gqlparser/ast" - "gopkg.in/yaml.v2" + yaml "gopkg.in/yaml.v2" ) type Config struct { @@ -139,20 +137,14 @@ func (c *PackageConfig) normalize() error { // If Package is not set, first attempt to load the package at the output dir. If that fails // fallback to just the base dir name of the output filename. if c.Package == "" { - cwd, _ := os.Getwd() - pkg, _ := build.Default.Import(c.ImportPath(), cwd, 0) - if pkg.Name != "" { - c.Package = pkg.Name - } else { - c.Package = filepath.Base(c.Dir()) - } + c.Package = code.NameForPackage(c.ImportPath()) } - c.Package = sanitizePackageName(c.Package) + return nil } func (c *PackageConfig) ImportPath() string { - return gopath.MustDir2Import(c.Dir()) + return code.ImportPathForDir(c.Dir()) } func (c *PackageConfig) Dir() string { @@ -225,7 +217,7 @@ func (tm TypeMap) ReferencedPackages() []string { if typ.Model == "map[string]interface{}" { continue } - pkg, _ := gopath.PkgAndType(typ.Model) + pkg, _ := code.PkgAndType(typ.Model) if pkg == "" || inStrSlice(pkgs, pkg) { continue } @@ -346,6 +338,7 @@ func (c *Config) LoadSchema() (*ast.Schema, map[string]string, error) { var sources []*ast.Source for _, filename := range c.SchemaFilename { + filename = filepath.ToSlash(filename) var err error var schemaRaw []byte schemaRaw, err = ioutil.ReadFile(filename) @@ -364,12 +357,6 @@ func (c *Config) LoadSchema() (*ast.Schema, map[string]string, error) { return schema, schemaStrings, nil } -var invalidPackageNameChar = regexp.MustCompile(`[^\w]`) - -func sanitizePackageName(pkg string) string { - return invalidPackageNameChar.ReplaceAllLiteralString(filepath.Base(pkg), "_") -} - func abs(path string) string { absPath, err := filepath.Abs(path) if err != nil { diff --git a/codegen/templates/import.go b/codegen/templates/import.go index c83f5672e52..7959e6a1c5d 100644 --- a/codegen/templates/import.go +++ b/codegen/templates/import.go @@ -2,12 +2,10 @@ package templates import ( "fmt" - "go/build" - "strconv" - "go/types" + "strconv" - "github.com/99designs/gqlgen/internal/gopath" + "github.com/99designs/gqlgen/internal/code" ) type Import struct { @@ -46,18 +44,14 @@ func (s *Imports) Reserve(path string, aliases ...string) string { } // if we are referencing our own package we dont need an import - if gopath.MustDir2Import(s.destDir) == path { + if code.ImportPathForDir(s.destDir) == path { return "" } - pkg, err := build.Default.Import(path, s.destDir, 0) - if err != nil { - panic(err) - } - + name := code.NameForPackage(path) var alias string if len(aliases) != 1 { - alias = pkg.Name + alias = name } else { alias = aliases[0] } @@ -71,7 +65,7 @@ func (s *Imports) Reserve(path string, aliases ...string) string { } s.imports = append(s.imports, &Import{ - Name: pkg.Name, + Name: name, Path: path, Alias: alias, }) @@ -84,10 +78,10 @@ func (s *Imports) Lookup(path string) string { return "" } - path = gopath.NormalizeVendor(path) + path = code.NormalizeVendor(path) // if we are referencing our own package we dont need an import - if gopath.MustDir2Import(s.destDir) == path { + if code.ImportPathForDir(s.destDir) == path { return "" } @@ -95,13 +89,8 @@ func (s *Imports) Lookup(path string) string { return existing.Alias } - pkg, err := build.Default.Import(path, s.destDir, 0) - if err != nil { - panic(err) - } - imp := &Import{ - Name: pkg.Name, + Name: code.NameForPackage(path), Path: path, } s.imports = append(s.imports, imp) diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 7dba7381acf..699427fba21 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -5239,6 +5239,11 @@ type EmbeddedPointer { directive @length(min: Int!, max: Int, message: String!) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION directive @range(min: Int = 0, max: Int, message: String) on ARGUMENT_DEFINITION + +enum Status { + OK + ERROR +} `}, ) diff --git a/codegen/testserver/generated_test.go b/codegen/testserver/generated_test.go index dab97398f44..4280c498e87 100644 --- a/codegen/testserver/generated_test.go +++ b/codegen/testserver/generated_test.go @@ -1,4 +1,3 @@ -//go:generate rm -f resolver.go //go:generate go run ../../testdata/gqlgen.go package testserver @@ -191,6 +190,11 @@ func TestGeneratedServer(t *testing.T) { require.Nil(t, err) require.Equal(t, "Ok", *resp.NullableArg) }) + + t.Run("list of enums", func(t *testing.T) { + require.Equal(t, StatusOk, AllStatus[0]) + require.Equal(t, StatusError, AllStatus[1]) + }) } func TestDirectives(t *testing.T) { diff --git a/codegen/testserver/models-gen.go b/codegen/testserver/models-gen.go index 7f4354ccdc9..b358d12a397 100644 --- a/codegen/testserver/models-gen.go +++ b/codegen/testserver/models-gen.go @@ -2,6 +2,12 @@ package testserver +import ( + "fmt" + "io" + "strconv" +) + type InnerDirectives struct { Message string `json:"message"` } @@ -60,3 +66,44 @@ type User struct { ID int `json:"id"` Friends []User `json:"friends"` } + +type Status string + +const ( + StatusOk Status = "OK" + StatusError Status = "ERROR" +) + +var AllStatus = []Status{ + StatusOk, + StatusError, +} + +func (e Status) IsValid() bool { + switch e { + case StatusOk, StatusError: + return true + } + return false +} + +func (e Status) String() string { + return string(e) +} + +func (e *Status) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("enums must be strings") + } + + *e = Status(str) + if !e.IsValid() { + return fmt.Errorf("%s is not a valid Status", str) + } + return nil +} + +func (e Status) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(e.String())) +} diff --git a/codegen/testserver/schema.graphql b/codegen/testserver/schema.graphql index 812d93b2372..d08a37d54c7 100644 --- a/codegen/testserver/schema.graphql +++ b/codegen/testserver/schema.graphql @@ -167,3 +167,8 @@ type EmbeddedPointer { directive @length(min: Int!, max: Int, message: String!) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION directive @range(min: Int = 0, max: Int, message: String) on ARGUMENT_DEFINITION + +enum Status { + OK + ERROR +} diff --git a/codegen_test.go b/codegen_test.go deleted file mode 100644 index 0d24de856f6..00000000000 --- a/codegen_test.go +++ /dev/null @@ -1,56 +0,0 @@ -package gqlgen - -import ( - "testing" - - "github.com/99designs/gqlgen/codegen/config" - "github.com/stretchr/testify/require" - "golang.org/x/tools/go/loader" -) - -func TestGenerateServer(t *testing.T) { - name := "graphserver" - - cfg := &config.Config{ - SchemaFilename: config.SchemaFilenames{"testdata/generateserver.graphqls"}, - Exec: config.PackageConfig{Filename: "gen/" + name + "/exec.go"}, - Model: config.PackageConfig{Filename: "gen/" + name + "/model.go"}, - Resolver: config.PackageConfig{Filename: "gen/" + name + "/resolver.go", Type: "Resolver"}, - } - serverFilename := "gen/" + name + "/server/server.go" - - require.NoError(t, Generate(cfg)) - require.NoError(t, GenerateServer(serverFilename, cfg)) - - conf := loader.Config{} - conf.CreateFromFilenames("gen/"+name, serverFilename) - - _, err := conf.Load() - require.NoError(t, err) - - t.Run("list of enums", func(t *testing.T) { - conf = loader.Config{} - conf.CreateFromFilenames("gen/"+name, "gen/"+name+"/model.go") - - program, err := conf.Load() - require.NoError(t, err) - - found := false - - for _, c := range program.Created { - for ident := range c.Defs { - if ident.Name == "AllStatus" { - found = true - break - } - } - if found { - break - } - } - - if !found { - t.Fail() - } - }) -} diff --git a/example/dataloader/addressloader_gen.go b/example/dataloader/addressloader_gen.go index b99ad3635d3..90e1d433fc5 100644 --- a/example/dataloader/addressloader_gen.go +++ b/example/dataloader/addressloader_gen.go @@ -7,6 +7,27 @@ import ( "time" ) +// AddressLoaderConfig captures the config to create a new AddressLoader +type AddressLoaderConfig struct { + // Fetch is a method that provides the data for the loader + Fetch func(keys []int) ([]*Address, []error) + + // Wait is how long wait before sending a batch + Wait time.Duration + + // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit + MaxBatch int +} + +// NewAddressLoader creates a new AddressLoader given a fetch, wait, and maxBatch +func NewAddressLoader(config AddressLoaderConfig) *AddressLoader { + return &AddressLoader{ + fetch: config.Fetch, + wait: config.Wait, + maxBatch: config.MaxBatch, + } +} + // AddressLoader batches and caches requests type AddressLoader struct { // this method provides the data for the loader diff --git a/example/dataloader/dataloaders.go b/example/dataloader/dataloaders.go index 8e4efe56edd..05944e5d5e0 100644 --- a/example/dataloader/dataloaders.go +++ b/example/dataloader/dataloaders.go @@ -1,6 +1,6 @@ -//go:generate gorunpkg github.com/vektah/dataloaden -keys int github.com/99designs/gqlgen/example/dataloader.Address -//go:generate gorunpkg github.com/vektah/dataloaden -keys int -slice github.com/99designs/gqlgen/example/dataloader.Order -//go:generate gorunpkg github.com/vektah/dataloaden -keys int -slice github.com/99designs/gqlgen/example/dataloader.Item +//go:generate go run github.com/vektah/dataloaden -keys int github.com/99designs/gqlgen/example/dataloader.Address +//go:generate go run github.com/vektah/dataloaden -keys int -slice github.com/99designs/gqlgen/example/dataloader.Order +//go:generate go run github.com/vektah/dataloaden -keys int -slice github.com/99designs/gqlgen/example/dataloader.Item package dataloader diff --git a/example/dataloader/itemsliceloader_gen.go b/example/dataloader/itemsliceloader_gen.go index 55620a50560..5fa10078401 100644 --- a/example/dataloader/itemsliceloader_gen.go +++ b/example/dataloader/itemsliceloader_gen.go @@ -7,6 +7,27 @@ import ( "time" ) +// ItemSliceLoaderConfig captures the config to create a new ItemSliceLoader +type ItemSliceLoaderConfig struct { + // Fetch is a method that provides the data for the loader + Fetch func(keys []int) ([][]Item, []error) + + // Wait is how long wait before sending a batch + Wait time.Duration + + // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit + MaxBatch int +} + +// NewItemSliceLoader creates a new ItemSliceLoader given a fetch, wait, and maxBatch +func NewItemSliceLoader(config ItemSliceLoaderConfig) *ItemSliceLoader { + return &ItemSliceLoader{ + fetch: config.Fetch, + wait: config.Wait, + maxBatch: config.MaxBatch, + } +} + // ItemSliceLoader batches and caches requests type ItemSliceLoader struct { // this method provides the data for the loader diff --git a/example/dataloader/ordersliceloader_gen.go b/example/dataloader/ordersliceloader_gen.go index 432559040da..e76e24d31f0 100644 --- a/example/dataloader/ordersliceloader_gen.go +++ b/example/dataloader/ordersliceloader_gen.go @@ -7,6 +7,27 @@ import ( "time" ) +// OrderSliceLoaderConfig captures the config to create a new OrderSliceLoader +type OrderSliceLoaderConfig struct { + // Fetch is a method that provides the data for the loader + Fetch func(keys []int) ([][]Order, []error) + + // Wait is how long wait before sending a batch + Wait time.Duration + + // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit + MaxBatch int +} + +// NewOrderSliceLoader creates a new OrderSliceLoader given a fetch, wait, and maxBatch +func NewOrderSliceLoader(config OrderSliceLoaderConfig) *OrderSliceLoader { + return &OrderSliceLoader{ + fetch: config.Fetch, + wait: config.Wait, + maxBatch: config.MaxBatch, + } +} + // OrderSliceLoader batches and caches requests type OrderSliceLoader struct { // this method provides the data for the loader diff --git a/example/scalars/vendor/external/model.go b/example/scalars/external/model.go similarity index 100% rename from example/scalars/vendor/external/model.go rename to example/scalars/external/model.go diff --git a/example/scalars/generated.go b/example/scalars/generated.go index f6c8a2efc16..c2250131ccb 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -6,11 +6,11 @@ import ( "bytes" "context" "errors" - "external" "strconv" "sync" "time" + "github.com/99designs/gqlgen/example/scalars/external" "github.com/99designs/gqlgen/example/scalars/model" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" diff --git a/example/scalars/model/generated.go b/example/scalars/model/generated.go index a79b765819f..2ee63fc8aba 100644 --- a/example/scalars/model/generated.go +++ b/example/scalars/model/generated.go @@ -3,7 +3,7 @@ package model import ( - "external" + "github.com/99designs/gqlgen/example/scalars/external" ) type Address struct { diff --git a/example/scalars/model/model.go b/example/scalars/model/model.go index 86038629b0e..d95cb8ff393 100644 --- a/example/scalars/model/model.go +++ b/example/scalars/model/model.go @@ -2,13 +2,13 @@ package model import ( "errors" - "external" "fmt" "io" "strconv" "strings" "time" + "github.com/99designs/gqlgen/example/scalars/external" "github.com/99designs/gqlgen/graphql" ) diff --git a/example/scalars/resolvers.go b/example/scalars/resolvers.go index 3a89683fdbd..b2661121f83 100644 --- a/example/scalars/resolvers.go +++ b/example/scalars/resolvers.go @@ -4,10 +4,10 @@ package scalars import ( context "context" - "external" "fmt" time "time" + "github.com/99designs/gqlgen/example/scalars/external" "github.com/99designs/gqlgen/example/scalars/model" ) diff --git a/example/scalars/vendor/readme.md b/example/scalars/vendor/readme.md deleted file mode 100644 index a7ae70d827f..00000000000 --- a/example/scalars/vendor/readme.md +++ /dev/null @@ -1 +0,0 @@ -fake vendor directory for scalar tests. diff --git a/generate.go b/generate.go index c93dcbca634..8576aba0d36 100644 --- a/generate.go +++ b/generate.go @@ -4,12 +4,13 @@ import ( "path/filepath" "syscall" + "golang.org/x/tools/go/packages" + "github.com/99designs/gqlgen/codegen" "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/plugin" "github.com/99designs/gqlgen/plugin/modelgen" "github.com/pkg/errors" - "golang.org/x/tools/go/loader" ) func Generate(cfg *config.Config, option ...Option) error { @@ -32,7 +33,6 @@ func Generate(cfg *config.Config, option ...Option) error { } } } - // Merge again now that the generated models have been injected into the typemap schema, err := codegen.NewSchema(cfg) if err != nil { @@ -57,19 +57,19 @@ func Generate(cfg *config.Config, option ...Option) error { } func validate(cfg *config.Config) error { - conf := loader.Config{} - - conf.Import(cfg.Exec.ImportPath()) + roots := []string{cfg.Exec.ImportPath()} if cfg.Model.IsDefined() { - conf.Import(cfg.Model.ImportPath()) + roots = append(roots, cfg.Model.ImportPath()) } if cfg.Resolver.IsDefined() { - conf.Import(cfg.Resolver.ImportPath()) + roots = append(roots, cfg.Resolver.ImportPath()) } - - _, err := conf.Load() - return err + _, err := packages.Load(&packages.Config{Mode: packages.LoadTypes | packages.LoadSyntax}, roots...) + if err != nil { + return errors.Wrap(err, "validation failed") + } + return nil } func abs(path string) string { diff --git a/go.mod b/go.mod new file mode 100644 index 00000000000..efea31cea28 --- /dev/null +++ b/go.mod @@ -0,0 +1,29 @@ +module github.com/99designs/gqlgen + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/go-chi/chi v3.3.2+incompatible + github.com/gogo/protobuf v1.0.0 // indirect + github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f // indirect + github.com/gorilla/mux v1.6.1 // indirect + github.com/gorilla/websocket v1.2.0 + github.com/hashicorp/golang-lru v0.5.0 + github.com/kr/pretty v0.1.0 // indirect + github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047 + github.com/opentracing/basictracer-go v1.0.0 // indirect + github.com/opentracing/opentracing-go v1.0.2 + github.com/pkg/errors v0.8.1 + github.com/rs/cors v1.6.0 + github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371 // indirect + github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0 // indirect + github.com/stretchr/testify v1.3.0 + github.com/urfave/cli v1.20.0 + github.com/vektah/dataloaden v0.2.0 + github.com/vektah/gqlparser v1.1.0 + golang.org/x/net v0.0.0-20180404174746-b3c676e531a6 // indirect + golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6 + gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect + gopkg.in/yaml.v2 v2.2.2 + sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755 + sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 00000000000..161ab5ad278 --- /dev/null +++ b/go.sum @@ -0,0 +1,68 @@ +github.com/agnivade/levenshtein v1.0.1 h1:3oJU7J3FGFmyhn8KHjmVaZCN5hxTr7GxgRue+sxIXdQ= +github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= +github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= +github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-chi/chi v3.3.2+incompatible h1:uQNcQN3NsV1j4ANsPh42P4ew4t6rnRbJb8frvpp31qQ= +github.com/go-chi/chi v3.3.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= +github.com/gogo/protobuf v1.0.0 h1:2jyBKDKU/8v3v2xVR2PtiWQviFUyiaGk2rpfyFT8rTM= +github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f h1:9oNbS1z4rVpbnkHBdPZU4jo9bSmrLpII768arSyMFgk= +github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= +github.com/gorilla/mux v1.6.1 h1:KOwqsTYZdeuMacU7CxjMNYEKeBvLbxW+psodrbcEa3A= +github.com/gorilla/mux v1.6.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/websocket v1.2.0 h1:VJtLvh6VQym50czpZzx07z/kw9EgAxI3x1ZB8taTMQQ= +github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047 h1:zCoDWFD5nrJJVjbXiDZcVhOBSzKn3o9LgRLLMRNuru8= +github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/opentracing/basictracer-go v1.0.0 h1:YyUAhaEfjoWXclZVJ9sGoNct7j4TVk7lZWlQw5UXuoo= +github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= +github.com/opentracing/opentracing-go v1.0.2 h1:3jA2P6O1F9UOrWVpwrIo17pu01KWvNWg4X946/Y5Zwg= +github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rs/cors v1.6.0 h1:G9tHG9lebljV9mfp9SNPDL36nCDxmo3zTlAf1YgvzmI= +github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= +github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= +github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= +github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371 h1:SWV2fHctRpRrp49VXJ6UZja7gU9QLHwRpIPBN89SKEo= +github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= +github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0 h1:JJV9CsgM9EC9w2iVkwuz+sMx8yRFe89PJRUrv6hPCIA= +github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.1 h1:52QO5WkIUcHGIR7EnGagH88x1bUzqGXTC5/1bDTUQ7U= +github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= +github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= +github.com/vektah/dataloaden v0.2.0 h1:lhynDrG7c8mNLahboCo0Wq82tMjmu5yOUv2ds/tBmss= +github.com/vektah/dataloaden v0.2.0/go.mod h1:vxM6NuRlgiR0M6wbVTJeKp9vQIs81ZMfCYO+4yq/jbE= +github.com/vektah/gqlparser v1.1.0 h1:3668p2gUlO+PiS81x957Rpr3/FPRWG6cxgCXAvTS1hw= +github.com/vektah/gqlparser v1.1.0/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw= +golang.org/x/net v0.0.0-20180404174746-b3c676e531a6 h1:mge3qS/eMvcfyIAzTMOAy0XUzWG6Lk0N4M8zjuSmdco= +golang.org/x/net v0.0.0-20180404174746-b3c676e531a6/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6 h1:iZgcI2DDp6zW5v9Z/5+f0NuqoxNdmzg4hivjk2WLXpY= +golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755 h1:d2maSb13hr/ArmfK3rW+wNUKKfytCol7W1/vDHxMPiE= +sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= +sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67 h1:e1sMhtVq9AfcEy8AXNb8eSg6gbzfdpYhoNqnPJa+GzI= +sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:L5q+DGLGOQFpo1snNEkLOJT2d1YTW66rWNzatr3He1k= diff --git a/handler/graphql_test.go b/handler/graphql_test.go index 8dff6c182ed..377b773f901 100644 --- a/handler/graphql_test.go +++ b/handler/graphql_test.go @@ -112,7 +112,7 @@ func TestHandlerOptions(t *testing.T) { resp := doRequest(h, "OPTIONS", "/graphql?query={me{name}}", ``) assert.Equal(t, http.StatusOK, resp.Code) - assert.Equal(t, "OPTIONS, GET, POST", resp.HeaderMap.Get("Allow")) + assert.Equal(t, "OPTIONS, GET, POST", resp.Header().Get("Allow")) } func TestHandlerHead(t *testing.T) { diff --git a/integration/generated.go b/integration/generated.go index 6eca435adb2..8336654b9d7 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -6,13 +6,13 @@ import ( "bytes" "context" "errors" - "remote_api" "strconv" "sync" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" "github.com/99designs/gqlgen/integration/models-go" + "github.com/99designs/gqlgen/integration/remote_api" "github.com/vektah/gqlparser" "github.com/vektah/gqlparser/ast" ) diff --git a/integration/gqlgen.yml b/integration/gqlgen.yml index dcd0c0122c1..e3ca845f942 100644 --- a/integration/gqlgen.yml +++ b/integration/gqlgen.yml @@ -16,7 +16,7 @@ models: Viewer: model: github.com/99designs/gqlgen/integration/models-go.Viewer User: - model: remote_api.User + model: github.com/99designs/gqlgen/integration/remote_api.User fields: likes: resolver: true diff --git a/integration/models-go/viewer.go b/integration/models-go/viewer.go index 9b0c9811277..a0201a54e3d 100644 --- a/integration/models-go/viewer.go +++ b/integration/models-go/viewer.go @@ -1,6 +1,6 @@ package models -import "remote_api" +import "github.com/99designs/gqlgen/integration/remote_api" type Viewer struct { User *remote_api.User diff --git a/integration/vendor/remote_api/user.go b/integration/remote_api/user.go similarity index 100% rename from integration/vendor/remote_api/user.go rename to integration/remote_api/user.go diff --git a/integration/resolver.go b/integration/resolver.go index 787be65c828..2edb9941f6e 100644 --- a/integration/resolver.go +++ b/integration/resolver.go @@ -5,10 +5,10 @@ package integration import ( "context" "fmt" - "remote_api" "time" - "github.com/99designs/gqlgen/integration/models-go" + models "github.com/99designs/gqlgen/integration/models-go" + "github.com/99designs/gqlgen/integration/remote_api" ) type CustomError struct { @@ -62,7 +62,7 @@ func (r *queryResolver) Error(ctx context.Context, typeArg *models.ErrorType) (b } func (r *queryResolver) Path(ctx context.Context) ([]*models.Element, error) { - return []*models.Element{{1}, {2}, {3}, {4}}, nil + return []*models.Element{{ID: 1}, {ID: 2}, {ID: 3}, {ID: 4}}, nil } func (r *queryResolver) Date(ctx context.Context, filter models.DateFilter) (bool, error) { diff --git a/internal/code/imports.go b/internal/code/imports.go new file mode 100644 index 00000000000..27343212799 --- /dev/null +++ b/internal/code/imports.go @@ -0,0 +1,45 @@ +package code + +import ( + "path/filepath" + "sync" + + "golang.org/x/tools/go/packages" +) + +var pathForDirCache = sync.Map{} + +// ImportPathFromDir takes an *absolute* path and returns a golang import path for the package, and returns an error if it isn't on the gopath +func ImportPathForDir(dir string) string { + if v, ok := pathForDirCache.Load(dir); ok { + return v.(string) + } + p, _ := packages.Load(&packages.Config{ + Dir: dir, + }, ".") + + if len(p) != 1 { + return "" + } + + pathForDirCache.Store(dir, p[0].PkgPath) + + return p[0].PkgPath +} + +var nameForPackageCache = sync.Map{} + +func NameForPackage(importPath string) string { + if v, ok := nameForPackageCache.Load(importPath); ok { + return v.(string) + } + p, _ := packages.Load(nil, importPath) + + if len(p) != 1 || p[0].Name == "" { + return SanitizePackageName(filepath.Base(importPath)) + } + + nameForPackageCache.Store(importPath, p[0].Name) + + return p[0].Name +} diff --git a/internal/code/imports_test.go b/internal/code/imports_test.go new file mode 100644 index 00000000000..2612ffce5fb --- /dev/null +++ b/internal/code/imports_test.go @@ -0,0 +1,32 @@ +package code + +import ( + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestImportPathForDir(t *testing.T) { + wd, err := os.Getwd() + require.NoError(t, err) + + assert.Equal(t, "github.com/99designs/gqlgen/internal/code", ImportPathForDir(wd)) + assert.Equal(t, "github.com/99designs/gqlgen", ImportPathForDir(filepath.Join(wd, "..", ".."))) + + // doesnt contain go code, but should still give a valid import path + assert.Equal(t, "github.com/99designs/gqlgen/docs", ImportPathForDir(filepath.Join(wd, "..", "..", "docs"))) + + // directory does not exist + assert.Equal(t, "", ImportPathForDir(filepath.Join(wd, "..", "..", "dos"))) +} + +func TestNameForPackage(t *testing.T) { + assert.Equal(t, "gqlgen", NameForPackage("github.com/99designs/gqlgen")) + + // does not contain go code, should still give a valid name + assert.Equal(t, "docs", NameForPackage("github.com/99designs/gqlgen/docs")) + assert.Equal(t, "github_com", NameForPackage("github.com")) +} diff --git a/internal/gopath/util.go b/internal/code/util.go similarity index 73% rename from internal/gopath/util.go rename to internal/code/util.go index 5d0babe3f12..6e06e4cc187 100644 --- a/internal/gopath/util.go +++ b/internal/code/util.go @@ -1,6 +1,7 @@ -package gopath +package code import ( + "path/filepath" "regexp" "strings" ) @@ -23,3 +24,9 @@ func NormalizeVendor(pkg string) string { parts := strings.Split(pkg, "/vendor/") return modifiers + parts[len(parts)-1] } + +var invalidPackageNameChar = regexp.MustCompile(`[^\w]`) + +func SanitizePackageName(pkg string) string { + return invalidPackageNameChar.ReplaceAllLiteralString(filepath.Base(pkg), "_") +} diff --git a/internal/gopath/gopath.go b/internal/gopath/gopath.go deleted file mode 100644 index 01cd5ba955e..00000000000 --- a/internal/gopath/gopath.go +++ /dev/null @@ -1,37 +0,0 @@ -package gopath - -import ( - "fmt" - "go/build" - "path/filepath" - "strings" -) - -var ErrNotFound = fmt.Errorf("not on GOPATH") - -// Contains returns true if the given directory is in the GOPATH -func Contains(dir string) bool { - _, err := Dir2Import(dir) - return err == nil -} - -// Dir2Import takes an *absolute* path and returns a golang import path for the package, and returns an error if it isn't on the gopath -func Dir2Import(dir string) (string, error) { - dir = filepath.ToSlash(dir) - for _, gopath := range filepath.SplitList(build.Default.GOPATH) { - gopath = filepath.ToSlash(filepath.Join(gopath, "src")) - if len(gopath) < len(dir) && strings.EqualFold(gopath, dir[0:len(gopath)]) { - return dir[len(gopath)+1:], nil - } - } - return "", ErrNotFound -} - -// MustDir2Import takes an *absolute* path and returns a golang import path for the package, and panics if it isn't on the gopath -func MustDir2Import(dir string) string { - pkg, err := Dir2Import(dir) - if err != nil { - panic(err) - } - return pkg -} diff --git a/internal/gopath/gopath_test.go b/internal/gopath/gopath_test.go deleted file mode 100644 index ae48ab4fe95..00000000000 --- a/internal/gopath/gopath_test.go +++ /dev/null @@ -1,62 +0,0 @@ -package gopath - -import ( - "go/build" - "runtime" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestContains(t *testing.T) { - origBuildContext := build.Default - defer func() { build.Default = origBuildContext }() - - if runtime.GOOS == "windows" { - build.Default.GOPATH = `C:\go;C:\Users\user\go` - - assert.True(t, Contains(`C:\go\src\github.com\vektah\gqlgen`)) - assert.True(t, Contains(`C:\go\src\fpp`)) - assert.True(t, Contains(`C:/go/src/github.com/vektah/gqlgen`)) - assert.True(t, Contains(`C:\Users\user\go\src\foo`)) - assert.False(t, Contains(`C:\tmp`)) - assert.False(t, Contains(`C:\Users\user`)) - assert.False(t, Contains(`C:\Users\another\go`)) - } else { - build.Default.GOPATH = "/go:/home/user/go" - - assert.True(t, Contains("/go/src/github.com/vektah/gqlgen")) - assert.True(t, Contains("/go/src/foo")) - assert.True(t, Contains("/home/user/go/src/foo")) - assert.False(t, Contains("/tmp")) - assert.False(t, Contains("/home/user")) - assert.False(t, Contains("/home/another/go")) - } -} - -func TestDir2Package(t *testing.T) { - origBuildContext := build.Default - defer func() { build.Default = origBuildContext }() - - if runtime.GOOS == "windows" { - build.Default.GOPATH = "C:/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx;C:/a/y;C:/b/" - - assert.Equal(t, "foo/bar", MustDir2Import("C:/a/y/src/foo/bar")) - assert.Equal(t, "foo/bar", MustDir2Import(`C:\a\y\src\foo\bar`)) - assert.Equal(t, "foo/bar", MustDir2Import("C:/b/src/foo/bar")) - assert.Equal(t, "foo/bar", MustDir2Import(`C:\b\src\foo\bar`)) - - assert.PanicsWithValue(t, ErrNotFound, func() { - MustDir2Import("C:/tmp/foo") - }) - } else { - build.Default.GOPATH = "/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:/a/y:/b/" - - assert.Equal(t, "foo/bar", MustDir2Import("/a/y/src/foo/bar")) - assert.Equal(t, "foo/bar", MustDir2Import("/b/src/foo/bar")) - - assert.PanicsWithValue(t, ErrNotFound, func() { - MustDir2Import("/tmp/foo") - }) - } -} diff --git a/internal/imports/prune.go b/internal/imports/prune.go index d2469e83703..d678870efa7 100644 --- a/internal/imports/prune.go +++ b/internal/imports/prune.go @@ -5,16 +5,15 @@ package imports import ( "bytes" "go/ast" - "go/build" "go/parser" "go/printer" "go/token" - "path/filepath" "strings" - "golang.org/x/tools/imports" + "github.com/99designs/gqlgen/internal/code" "golang.org/x/tools/go/ast/astutil" + "golang.org/x/tools/imports" ) type visitFn func(node ast.Node) @@ -54,12 +53,6 @@ func getUnusedImports(file ast.Node, filename string) (map[string]string, error) imported := map[string]*ast.ImportSpec{} used := map[string]bool{} - abs, err := filepath.Abs(filename) - if err != nil { - return nil, err - } - srcDir := filepath.Dir(abs) - ast.Walk(visitFn(func(node ast.Node) { if node == nil { return @@ -75,7 +68,7 @@ func getUnusedImports(file ast.Node, filename string) (map[string]string, error) break } - local := importPathToName(ipath, srcDir) + local := code.NameForPackage(ipath) imported[local] = v case *ast.SelectorExpr: @@ -108,12 +101,3 @@ func getUnusedImports(file ast.Node, filename string) (map[string]string, error) return unusedImport, nil } - -func importPathToName(importPath, srcDir string) (packageName string) { - pkg, err := build.Default.Import(importPath, srcDir, 0) - if err != nil { - return "" - } - - return pkg.Name -} diff --git a/testdata/generateserver.graphqls b/testdata/generateserver.graphqls deleted file mode 100644 index bcb0a83a375..00000000000 --- a/testdata/generateserver.graphqls +++ /dev/null @@ -1,11 +0,0 @@ -type Query { - user: User -} -type User { - id: Int - fist_name: String -} -enum Status { - OK - ERROR -} diff --git a/tools.go b/tools.go new file mode 100644 index 00000000000..912fc0d6354 --- /dev/null +++ b/tools.go @@ -0,0 +1,5 @@ +// +build tools + +package main + +import _ "github.com/vektah/dataloaden" From 9e02a977daaba56f7c189a54bcc13f2d53e0d2f2 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Sat, 26 Jan 2019 07:17:30 +0000 Subject: [PATCH 048/147] fix integration test --- .circleci/config.yml | 2 +- .circleci/golang.Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ef4a8afd24b..26e594fb29d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -34,7 +34,7 @@ jobs: gqlgen/golang go run ./integration/server/server.go \ ) - sleep 2 + sleep 20 docker run \ -e SERVER_URL=http://integration_server:1234/query \ diff --git a/.circleci/golang.Dockerfile b/.circleci/golang.Dockerfile index e5b6443ce97..a0ceb286bf9 100644 --- a/.circleci/golang.Dockerfile +++ b/.circleci/golang.Dockerfile @@ -7,4 +7,4 @@ WORKDIR /projects/gqlgen COPY go.* /projects/gqlgen/ RUN go mod download -COPY . /projects/gqlgen +COPY . /projects/gqlgen/ From 48eb6c521259c1b6f80c3849318d7878f1223bf6 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Sat, 26 Jan 2019 07:26:24 +0000 Subject: [PATCH 049/147] Update appveyor --- appveyor.yml | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 142446a2534..db475111488 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,18 +3,15 @@ version: "{build}" # Source Config skip_branch_with_pr: true -clone_folder: c:\gopath\src\github.com\99designs\gqlgen +clone_folder: c:\projects\gqlgen # Build host environment: GOPATH: c:\gopath - GOVERSION: 1.10 + GOVERSION: 1.11.5 PATH: '%PATH%;c:\gopath\bin' -branches: - only: ["master", "next"] - init: - git config --global core.autocrlf input @@ -31,28 +28,5 @@ build: false deploy: false test_script: - - go get -u github.com/vektah/gorunpkg github.com/golang/dep/cmd/dep - - dep ensure -vendor-only - go generate ./... - go test -timeout 20m ./... - - - echo "testing init" - - rd /s /q vendor - - go get ./... - - go install - - cd c:\gopath\src\github.com\99designs\ - - mkdir init-project - - cd init-project - - ps: | - Set-Content -Value @" - // +build ignore - - package main - - import "github.com/99designs/gqlgen/cmd" - - func main() { - cmd.Execute() - } - "@ -Path .\gqlgen.go - - go run gqlgen.go init From 1bc51010eb895d675573cae4243207ea3aa6477e Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Wed, 30 Jan 2019 09:05:26 +0000 Subject: [PATCH 050/147] Everything is a plugin --- cmd/init.go | 11 +- codegen/{templates/args.gotpl => _args.gotpl} | 0 codegen/build_directive.go | 4 +- codegen/build_object.go | 2 +- codegen/config/binder.go | 42 + codegen/{build.go => data.go} | 37 +- codegen/field.go | 240 + codegen/{templates => }/field.gotpl | 5 +- codegen/fieldarg.go | 16 + codegen/generate.go | 15 + codegen/{templates => }/generated.gotpl | 54 +- codegen/{templates => }/input.gotpl | 2 + codegen/{templates => }/interface.gotpl | 4 +- codegen/object.go | 246 - codegen/{templates => }/object.gotpl | 4 +- codegen/schema.go | 21 - codegen/schema_test.go | 2 +- codegen/templates/import.go | 13 +- codegen/templates/templates.go | 131 +- codegen/templates/templates_test.go | 6 + codegen/testdata/gqlgen.yml | 21 + codegen/testdata/schema.graphql | 174 + codegen/testserver/generated.go | 8306 +++++++++-------- codegen/testserver/generated_test.go | 1 + codegen/testserver/models-gen.go | 2 - codegen/testserver/resolver.go | 2 + codegen/util.go | 38 - example/chat/generated.go | 2804 +++--- example/chat/models_gen.go | 2 - example/config/generated.go | 2718 +++--- example/config/models_gen.go | 2 - example/dataloader/generated.go | 3374 +++---- example/dataloader/models_gen.go | 2 - example/scalars/generated.go | 2700 +++--- example/scalars/model/generated.go | 2 - example/selection/generated.go | 1356 +-- example/selection/models_gen.go | 2 - example/starwars/generated.go | 6004 ++++++------ example/starwars/models_gen.go | 2 - example/todo/generated.go | 2590 ++--- example/todo/models_gen.go | 2 - example/type-system-extension/generated.go | 2220 ++--- example/type-system-extension/models_gen.go | 2 - exec.go | 42 - generate.go | 20 +- integration/generated.go | 2232 ++--- integration/models-go/generated.go | 2 - plugin/modelgen/models.go | 20 +- plugin/modelgen/models.gotpl | 32 +- plugin/plugin.go | 9 +- plugin/resolvergen/resolver.go | 53 + .../resolvergen}/resolver.gotpl | 32 +- plugin/servergen/server.go | 49 + .../servergen}/server.gotpl | 16 +- resolver.go | 43 - server.go | 42 - 56 files changed, 18124 insertions(+), 17649 deletions(-) rename codegen/{templates/args.gotpl => _args.gotpl} (100%) rename codegen/{build.go => data.go} (79%) create mode 100644 codegen/field.go rename codegen/{templates => }/field.gotpl (97%) create mode 100644 codegen/fieldarg.go create mode 100644 codegen/generate.go rename codegen/{templates => }/generated.gotpl (88%) rename codegen/{templates => }/input.gotpl (98%) rename codegen/{templates => }/interface.gotpl (93%) rename codegen/{templates => }/object.gotpl (98%) create mode 100644 codegen/testdata/gqlgen.yml create mode 100644 codegen/testdata/schema.graphql delete mode 100644 exec.go create mode 100644 plugin/resolvergen/resolver.go rename {codegen/templates => plugin/resolvergen}/resolver.gotpl (54%) create mode 100644 plugin/servergen/server.go rename {codegen/templates => plugin/servergen}/server.gotpl (70%) delete mode 100644 resolver.go delete mode 100644 server.go diff --git a/cmd/init.go b/cmd/init.go index aad42ad5d67..076d7d20a11 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -7,12 +7,14 @@ import ( "os" "strings" + "github.com/99designs/gqlgen/plugin/servergen" + "github.com/99designs/gqlgen" "github.com/99designs/gqlgen/codegen/config" "github.com/pkg/errors" "github.com/urfave/cli" - "gopkg.in/yaml.v2" + yaml "gopkg.in/yaml.v2" ) var configComment = ` @@ -71,16 +73,11 @@ var initCmd = cli.Command{ } func GenerateGraphServer(cfg *config.Config, serverFilename string) { - err := gqlgen.Generate(cfg) + err := gqlgen.Generate(cfg, gqlgen.AddPlugin(servergen.New(serverFilename))) if err != nil { fmt.Fprintln(os.Stderr, err.Error()) } - if err := gqlgen.GenerateServer(serverFilename, cfg); err != nil { - fmt.Fprintln(os.Stderr, err.Error()) - os.Exit(1) - } - fmt.Fprintf(os.Stdout, "Exec \"go run ./%s\" to start GraphQL server\n", serverFilename) } diff --git a/codegen/templates/args.gotpl b/codegen/_args.gotpl similarity index 100% rename from codegen/templates/args.gotpl rename to codegen/_args.gotpl diff --git a/codegen/build_directive.go b/codegen/build_directive.go index 9edb653f4a3..9790bddfa38 100644 --- a/codegen/build_directive.go +++ b/codegen/build_directive.go @@ -3,6 +3,8 @@ package codegen import ( "fmt" + "github.com/99designs/gqlgen/codegen/templates" + "github.com/pkg/errors" "github.com/vektah/gqlparser/ast" ) @@ -24,7 +26,7 @@ func (b *builder) buildDirectives() (map[string]*Directive, error) { newArg := FieldArgument{ GQLName: arg.Name, TypeReference: b.NamedTypes.getType(arg.Type), - GoVarName: sanitizeArgName(arg.Name), + GoVarName: templates.ToGoPrivate(arg.Name), } if !newArg.TypeReference.Definition.GQLDefinition.IsInputType() { diff --git a/codegen/build_object.go b/codegen/build_object.go index 2a66a2fc8dc..75a0bf8c567 100644 --- a/codegen/build_object.go +++ b/codegen/build_object.go @@ -125,7 +125,7 @@ func (b *builder) buildArg(obj *Object, arg *ast.ArgumentDefinition) (*FieldArgu GQLName: arg.Name, TypeReference: b.NamedTypes.getType(arg.Type), Object: obj, - GoVarName: sanitizeArgName(arg.Name), + GoVarName: templates.ToGoPrivate(arg.Name), Directives: argDirs, } diff --git a/codegen/config/binder.go b/codegen/config/binder.go index 03974ab2552..2b8e6af31f2 100644 --- a/codegen/config/binder.go +++ b/codegen/config/binder.go @@ -6,6 +6,9 @@ import ( "regexp" "strings" + "github.com/99designs/gqlgen/internal/code" + "github.com/vektah/gqlparser/ast" + "github.com/pkg/errors" "golang.org/x/tools/go/packages" ) @@ -85,3 +88,42 @@ func normalizeVendor(pkg string) string { parts := strings.Split(pkg, "/vendor/") return modifiers + parts[len(parts)-1] } + +func (b *Binder) FindBackingType(schemaType *ast.Type) (types.Type, error) { + var pkgName, typeName string + + if userEntry, ok := b.types[schemaType.Name()]; ok && userEntry.Model != "" { + // special case for maps + if userEntry.Model == "map[string]interface{}" { + return types.NewMap(types.Typ[types.String], types.NewInterfaceType(nil, nil).Complete()), nil + } + + pkgName, typeName = code.PkgAndType(userEntry.Model) + if pkgName == "" { + return nil, fmt.Errorf("missing package name for %s", schemaType.Name) + } + + } else { + pkgName = "github.com/99designs/gqlgen/graphql" + typeName = "String" + } + + t, err := b.FindType(pkgName, typeName) + if err != nil { + return nil, err + } + + return b.CopyModifiersFromAst(schemaType, true, t), nil +} + +func (b *Binder) CopyModifiersFromAst(t *ast.Type, usePtr bool, base types.Type) types.Type { + if t.Elem != nil { + return types.NewSlice(b.CopyModifiersFromAst(t.Elem, usePtr, base)) + } + + if !t.NonNull && usePtr { + return types.NewPointer(base) + } + + return base +} diff --git a/codegen/build.go b/codegen/data.go similarity index 79% rename from codegen/build.go rename to codegen/data.go index 82ee4da7dcd..43866c7a8d7 100644 --- a/codegen/build.go +++ b/codegen/data.go @@ -10,6 +10,23 @@ import ( "github.com/vektah/gqlparser/ast" ) +// Data is a unified model of the code to be generated. Plugins may modify this structure to do things like implement +// resolvers or directives automatically (eg grpc, validation) +type Data struct { + Config *config.Config + Schema *ast.Schema + SchemaStr map[string]string + Directives map[string]*Directive + Objects Objects + Inputs Objects + Interfaces []*Interface + Enums []Enum + + QueryRoot *Object + MutationRoot *Object + SubscriptionRoot *Object +} + type builder struct { Config *config.Config Schema *ast.Schema @@ -19,7 +36,7 @@ type builder struct { NamedTypes NamedTypes } -func buildSchema(cfg *config.Config) (*Schema, error) { +func BuildData(cfg *config.Config) (*Data, error) { b := builder{ Config: cfg, } @@ -54,7 +71,7 @@ func buildSchema(cfg *config.Config) (*Schema, error) { return nil, err } - s := Schema{ + s := Data{ Config: cfg, Directives: b.Directives, Schema: b.Schema, @@ -88,6 +105,20 @@ func buildSchema(cfg *config.Config) (*Schema, error) { } } + if s.Schema.Query != nil { + s.QueryRoot = s.Objects.ByName(s.Schema.Query.Name) + } else { + return nil, fmt.Errorf("query entry point missing") + } + + if s.Schema.Mutation != nil { + s.MutationRoot = s.Objects.ByName(s.Schema.Mutation.Name) + } + + if s.Schema.Subscription != nil { + s.SubscriptionRoot = s.Objects.ByName(s.Schema.Subscription.Name) + } + if err := b.injectIntrospectionRoots(&s); err != nil { return nil, err } @@ -111,7 +142,7 @@ func buildSchema(cfg *config.Config) (*Schema, error) { return &s, nil } -func (b *builder) injectIntrospectionRoots(s *Schema) error { +func (b *builder) injectIntrospectionRoots(s *Data) error { obj := s.Objects.ByName(b.Schema.Query.Name) if obj == nil { return fmt.Errorf("root query type must be defined") diff --git a/codegen/field.go b/codegen/field.go new file mode 100644 index 00000000000..e2763bf0d3b --- /dev/null +++ b/codegen/field.go @@ -0,0 +1,240 @@ +package codegen + +import ( + "fmt" + "go/types" + "strconv" + "strings" + + "github.com/99designs/gqlgen/codegen/templates" + "github.com/vektah/gqlparser/ast" +) + +type Field struct { + *TypeReference + GQLName string // The name of the field in graphql + GoFieldType GoFieldType // The field type in go, if any + GoReceiverName string // The name of method & var receiver in go, if any + GoFieldName string // The name of the method or var in go, if any + IsResolver bool // Does this field need a resolver + Args []*FieldArgument // A list of arguments to be passed to this field + MethodHasContext bool // If this is bound to a go method, does the method also take a context + NoErr bool // If this is bound to a go method, does that method have an error as the second argument + Object *Object // A link back to the parent object + Default interface{} // The default value + Directives []*Directive +} + +func (f *Field) HasDirectives() bool { + return len(f.Directives) > 0 +} + +func (f *Field) IsReserved() bool { + return strings.HasPrefix(f.GQLName, "__") +} + +func (f *Field) IsMethod() bool { + return f.GoFieldType == GoFieldMethod +} + +func (f *Field) IsVariable() bool { + return f.GoFieldType == GoFieldVariable +} + +func (f *Field) IsConcurrent() bool { + if f.Object.DisableConcurrency { + return false + } + return f.MethodHasContext || f.IsResolver +} + +func (f *Field) GoNameUnexported() string { + return templates.ToGoPrivate(f.GQLName) +} + +func (f *Field) ShortInvocation() string { + return fmt.Sprintf("%s().%s(%s)", f.Object.Definition.GQLDefinition.Name, f.GoFieldName, f.CallArgs()) +} + +func (f *Field) ArgsFunc() string { + if len(f.Args) == 0 { + return "" + } + + return "field_" + f.Object.Definition.GQLDefinition.Name + "_" + f.GQLName + "_args" +} + +func (f *Field) ResolverType() string { + if !f.IsResolver { + return "" + } + + return fmt.Sprintf("%s().%s(%s)", f.Object.Definition.GQLDefinition.Name, f.GoFieldName, f.CallArgs()) +} + +func (f *Field) ShortResolverDeclaration() string { + if !f.IsResolver { + return "" + } + res := fmt.Sprintf("%s(ctx context.Context", f.GoFieldName) + + if !f.Object.Root { + res += fmt.Sprintf(", obj *%s", templates.CurrentImports.LookupType(f.Object.Definition.GoType)) + } + for _, arg := range f.Args { + res += fmt.Sprintf(", %s %s", arg.GoVarName, templates.CurrentImports.LookupType(arg.GoType)) + } + + result := templates.CurrentImports.LookupType(f.GoType) + if f.Object.Stream { + result = "<-chan " + result + } + + res += fmt.Sprintf(") (%s, error)", result) + return res +} + +func (f *Field) ComplexitySignature() string { + res := fmt.Sprintf("func(childComplexity int") + for _, arg := range f.Args { + res += fmt.Sprintf(", %s %s", arg.GoVarName, templates.CurrentImports.LookupType(arg.GoType)) + } + res += ") int" + return res +} + +func (f *Field) ComplexityArgs() string { + var args []string + for _, arg := range f.Args { + args = append(args, "args["+strconv.Quote(arg.GQLName)+"].("+templates.CurrentImports.LookupType(arg.GoType)+")") + } + + return strings.Join(args, ", ") +} + +func (f *Field) CallArgs() string { + var args []string + + if f.IsResolver { + args = append(args, "rctx") + + if !f.Object.Root { + args = append(args, "obj") + } + } else { + if f.MethodHasContext { + args = append(args, "ctx") + } + } + + for _, arg := range f.Args { + args = append(args, "args["+strconv.Quote(arg.GQLName)+"].("+templates.CurrentImports.LookupType(arg.GoType)+")") + } + + return strings.Join(args, ", ") +} + +// should be in the template, but its recursive and has a bunch of args +func (f *Field) WriteJson() string { + return f.doWriteJson("res", f.GoType, f.ASTType, false, 1) +} + +func (f *Field) doWriteJson(val string, destType types.Type, astType *ast.Type, isPtr bool, depth int) string { + switch destType := destType.(type) { + case *types.Pointer: + return tpl(` + if {{.val}} == nil { + {{- if .nonNull }} + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + {{- end }} + return graphql.Null + } + {{.next }}`, map[string]interface{}{ + "val": val, + "nonNull": astType.NonNull, + "next": f.doWriteJson(val, destType.Elem(), astType, true, depth+1), + }) + + case *types.Slice: + if isPtr { + val = "*" + val + } + var arr = "arr" + strconv.Itoa(depth) + var index = "idx" + strconv.Itoa(depth) + var usePtr bool + if !isPtr { + switch destType.Elem().(type) { + case *types.Pointer, *types.Array: + default: + usePtr = true + } + } + + return tpl(` + {{.arr}} := make(graphql.Array, len({{.val}})) + {{ if and .top (not .isScalar) }} var wg sync.WaitGroup {{ end }} + {{ if not .isScalar }} + isLen1 := len({{.val}}) == 1 + if !isLen1 { + wg.Add(len({{.val}})) + } + {{ end }} + for {{.index}} := range {{.val}} { + {{- if not .isScalar }} + {{.index}} := {{.index}} + rctx := &graphql.ResolverContext{ + Index: &{{.index}}, + Result: {{ if .usePtr }}&{{end}}{{.val}}[{{.index}}], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func({{.index}} int) { + if !isLen1 { + defer wg.Done() + } + {{.arr}}[{{.index}}] = func() graphql.Marshaler { + {{ .next }} + }() + } + if isLen1 { + f({{.index}}) + } else { + go f({{.index}}) + } + {{ else }} + {{.arr}}[{{.index}}] = func() graphql.Marshaler { + {{ .next }} + }() + {{- end}} + } + {{ if and .top (not .isScalar) }} wg.Wait() {{ end }} + return {{.arr}}`, map[string]interface{}{ + "val": val, + "arr": arr, + "index": index, + "top": depth == 1, + "arrayLen": len(val), + "isScalar": f.Definition.GQLDefinition.Kind == ast.Scalar || f.Definition.GQLDefinition.Kind == ast.Enum, + "usePtr": usePtr, + "next": f.doWriteJson(val+"["+index+"]", destType.Elem(), astType.Elem, false, depth+1), + }) + + default: + if f.Definition.GQLDefinition.Kind == ast.Scalar || f.Definition.GQLDefinition.Kind == ast.Enum { + if isPtr { + val = "*" + val + } + return f.Marshal(val) + } + + if !isPtr { + val = "&" + val + } + return tpl(` + return ec._{{.type}}(ctx, field.Selections, {{.val}})`, map[string]interface{}{ + "type": f.Definition.GQLDefinition.Name, + "val": val, + }) + } +} diff --git a/codegen/templates/field.gotpl b/codegen/field.gotpl similarity index 97% rename from codegen/templates/field.gotpl rename to codegen/field.gotpl index 6856d791558..7b88c4a047e 100644 --- a/codegen/templates/field.gotpl +++ b/codegen/field.gotpl @@ -1,5 +1,4 @@ -{{ $field := . }} -{{ $object := $field.Object }} +{{- range $object := .Objects }}{{- range $field := $object.Fields }} {{- if $object.Stream }} func (ec *executionContext) _{{$object.Definition.GQLDefinition.Name}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { @@ -88,3 +87,5 @@ {{ $field.WriteJson }} } {{ end }} + +{{- end }}{{- end}} diff --git a/codegen/fieldarg.go b/codegen/fieldarg.go new file mode 100644 index 00000000000..d85feb3dd63 --- /dev/null +++ b/codegen/fieldarg.go @@ -0,0 +1,16 @@ +package codegen + +type FieldArgument struct { + *TypeReference + + GQLName string // The name of the argument in graphql + GoVarName string // The name of the var in go + Object *Object // A link back to the parent object + Default interface{} // The default value + Directives []*Directive + Value interface{} // value set in Data +} + +func (f *FieldArgument) Stream() bool { + return f.Object != nil && f.Object.Stream +} diff --git a/codegen/generate.go b/codegen/generate.go new file mode 100644 index 00000000000..eafa3f87434 --- /dev/null +++ b/codegen/generate.go @@ -0,0 +1,15 @@ +package codegen + +import ( + "github.com/99designs/gqlgen/codegen/templates" +) + +func GenerateCode(data *Data) error { + return templates.Render(templates.Options{ + PackageName: data.Config.Exec.Package, + Filename: data.Config.Exec.Filename, + Data: data, + RegionTags: true, + GeneratedHeader: true, + }) +} diff --git a/codegen/templates/generated.gotpl b/codegen/generated.gotpl similarity index 88% rename from codegen/templates/generated.gotpl rename to codegen/generated.gotpl index fc84c820fbf..cbc6f307060 100644 --- a/codegen/templates/generated.gotpl +++ b/codegen/generated.gotpl @@ -1,24 +1,16 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - -package {{ .PackageName }} - -import ( - %%%IMPORTS%%% - - {{ reserveImport "context" }} - {{ reserveImport "fmt" }} - {{ reserveImport "io" }} - {{ reserveImport "strconv" }} - {{ reserveImport "time" }} - {{ reserveImport "sync" }} - {{ reserveImport "errors" }} - {{ reserveImport "bytes" }} - - {{ reserveImport "github.com/vektah/gqlparser" }} - {{ reserveImport "github.com/vektah/gqlparser/ast" }} - {{ reserveImport "github.com/99designs/gqlgen/graphql" }} - {{ reserveImport "github.com/99designs/gqlgen/graphql/introspection" }} -) +{{ reserveImport "context" }} +{{ reserveImport "fmt" }} +{{ reserveImport "io" }} +{{ reserveImport "strconv" }} +{{ reserveImport "time" }} +{{ reserveImport "sync" }} +{{ reserveImport "errors" }} +{{ reserveImport "bytes" }} + +{{ reserveImport "github.com/vektah/gqlparser" }} +{{ reserveImport "github.com/vektah/gqlparser/ast" }} +{{ reserveImport "github.com/99designs/gqlgen/graphql" }} + // NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { @@ -77,7 +69,7 @@ type ComplexityRoot struct { {{ range $field := $object.Fields -}} {{ if $field.Args }} func (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - {{ render "args.gotpl" $field.Args }} + {{ template "_args.gotpl" $field.Args }} } {{ end }} {{ end }} @@ -86,7 +78,7 @@ type ComplexityRoot struct { {{ range $directive := .Directives }} {{ if $directive.Args }} func (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - {{ render "args.gotpl" $directive.Args }} + {{ template "_args.gotpl" $directive.Args }} } {{ end }} {{ end }} @@ -209,22 +201,6 @@ type executionContext struct { *executableSchema } -{{- range $object := .Objects }} - {{ render "object.gotpl" $object }} - - {{- range $field := $object.Fields }} - {{ render "field.gotpl" $field }} - {{ end }} -{{- end}} - -{{- range $interface := .Interfaces }} - {{ render "interface.gotpl" $interface }} -{{- end }} - -{{- range $input := .Inputs }} - {{ render "input.gotpl" $input }} -{{- end }} - func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { defer func() { if r := recover(); r != nil { diff --git a/codegen/templates/input.gotpl b/codegen/input.gotpl similarity index 98% rename from codegen/templates/input.gotpl rename to codegen/input.gotpl index c225304ffd6..f74c199f38e 100644 --- a/codegen/templates/input.gotpl +++ b/codegen/input.gotpl @@ -1,3 +1,4 @@ +{{- range $input := .Inputs }} {{- if .Definition.IsMarshaled }} func Unmarshal{{ .Definition.GQLDefinition.Name }}(v interface{}) ({{.Definition.GoType | ref}}, error) { var it {{.Definition.GoType | ref}} @@ -106,3 +107,4 @@ {{- end }} return obj, nil } +{{ end }} diff --git a/codegen/templates/interface.gotpl b/codegen/interface.gotpl similarity index 93% rename from codegen/templates/interface.gotpl rename to codegen/interface.gotpl index 8d6ba51691a..57d6c6f06ed 100644 --- a/codegen/templates/interface.gotpl +++ b/codegen/interface.gotpl @@ -1,4 +1,4 @@ -{{- $interface := . }} +{{- range $interface := .Interfaces }} func (ec *executionContext) _{{$interface.Definition.GQLDefinition.Name}}(ctx context.Context, sel ast.SelectionSet, obj *{{$interface.Definition.GoType | ref}}) graphql.Marshaler { switch obj := (*obj).(type) { @@ -16,3 +16,5 @@ func (ec *executionContext) _{{$interface.Definition.GQLDefinition.Name}}(ctx co panic(fmt.Errorf("unexpected type %T", obj)) } } + +{{- end }} diff --git a/codegen/object.go b/codegen/object.go index 67c04c7915c..ef0a7964032 100644 --- a/codegen/object.go +++ b/codegen/object.go @@ -2,7 +2,6 @@ package codegen import ( "bytes" - "fmt" "strconv" "strings" "text/template" @@ -11,7 +10,6 @@ import ( "go/types" "github.com/99designs/gqlgen/codegen/templates" - "github.com/vektah/gqlparser/ast" ) type GoFieldType int @@ -34,32 +32,6 @@ type Object struct { InTypemap bool } -type Field struct { - *TypeReference - GQLName string // The name of the field in graphql - GoFieldType GoFieldType // The field type in go, if any - GoReceiverName string // The name of method & var receiver in go, if any - GoFieldName string // The name of the method or var in go, if any - IsResolver bool // Does this field need a resolver - Args []*FieldArgument // A list of arguments to be passed to this field - MethodHasContext bool // If this is bound to a go method, does the method also take a context - NoErr bool // If this is bound to a go method, does that method have an error as the second argument - Object *Object // A link back to the parent object - Default interface{} // The default value - Directives []*Directive -} - -type FieldArgument struct { - *TypeReference - - GQLName string // The name of the argument in graphql - GoVarName string // The name of the var in go - Object *Object // A link back to the parent object - Default interface{} // The default value - Directives []*Directive - Value interface{} // value set in Schema -} - type Objects []*Object func (o *Object) Implementors() string { @@ -108,224 +80,6 @@ func (o *Object) Description() string { return o.Definition.GQLDefinition.Description } -func (f *Field) HasDirectives() bool { - return len(f.Directives) > 0 -} - -func (f *Field) IsReserved() bool { - return strings.HasPrefix(f.GQLName, "__") -} - -func (f *Field) IsMethod() bool { - return f.GoFieldType == GoFieldMethod -} - -func (f *Field) IsVariable() bool { - return f.GoFieldType == GoFieldVariable -} - -func (f *Field) IsConcurrent() bool { - if f.Object.DisableConcurrency { - return false - } - return f.MethodHasContext || f.IsResolver -} - -func (f *Field) GoNameUnexported() string { - return templates.ToGoPrivate(f.GQLName) -} - -func (f *Field) ShortInvocation() string { - return fmt.Sprintf("%s().%s(%s)", f.Object.Definition.GQLDefinition.Name, f.GoFieldName, f.CallArgs()) -} - -func (f *Field) ArgsFunc() string { - if len(f.Args) == 0 { - return "" - } - - return "field_" + f.Object.Definition.GQLDefinition.Name + "_" + f.GQLName + "_args" -} - -func (f *Field) ResolverType() string { - if !f.IsResolver { - return "" - } - - return fmt.Sprintf("%s().%s(%s)", f.Object.Definition.GQLDefinition.Name, f.GoFieldName, f.CallArgs()) -} - -func (f *Field) ShortResolverDeclaration() string { - if !f.IsResolver { - return "" - } - res := fmt.Sprintf("%s(ctx context.Context", f.GoFieldName) - - if !f.Object.Root { - res += fmt.Sprintf(", obj *%s", templates.CurrentImports.LookupType(f.Object.Definition.GoType)) - } - for _, arg := range f.Args { - res += fmt.Sprintf(", %s %s", arg.GoVarName, templates.CurrentImports.LookupType(arg.GoType)) - } - - result := templates.CurrentImports.LookupType(f.GoType) - if f.Object.Stream { - result = "<-chan " + result - } - - res += fmt.Sprintf(") (%s, error)", result) - return res -} - -func (f *Field) ComplexitySignature() string { - res := fmt.Sprintf("func(childComplexity int") - for _, arg := range f.Args { - res += fmt.Sprintf(", %s %s", arg.GoVarName, templates.CurrentImports.LookupType(arg.GoType)) - } - res += ") int" - return res -} - -func (f *Field) ComplexityArgs() string { - var args []string - for _, arg := range f.Args { - args = append(args, "args["+strconv.Quote(arg.GQLName)+"].("+templates.CurrentImports.LookupType(arg.GoType)+")") - } - - return strings.Join(args, ", ") -} - -func (f *Field) CallArgs() string { - var args []string - - if f.IsResolver { - args = append(args, "rctx") - - if !f.Object.Root { - args = append(args, "obj") - } - } else { - if f.MethodHasContext { - args = append(args, "ctx") - } - } - - for _, arg := range f.Args { - args = append(args, "args["+strconv.Quote(arg.GQLName)+"].("+templates.CurrentImports.LookupType(arg.GoType)+")") - } - - return strings.Join(args, ", ") -} - -// should be in the template, but its recursive and has a bunch of args -func (f *Field) WriteJson() string { - return f.doWriteJson("res", f.GoType, f.ASTType, false, 1) -} - -func (f *Field) doWriteJson(val string, destType types.Type, astType *ast.Type, isPtr bool, depth int) string { - switch destType := destType.(type) { - case *types.Pointer: - return tpl(` - if {{.val}} == nil { - {{- if .nonNull }} - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - {{- end }} - return graphql.Null - } - {{.next }}`, map[string]interface{}{ - "val": val, - "nonNull": astType.NonNull, - "next": f.doWriteJson(val, destType.Elem(), astType, true, depth+1), - }) - - case *types.Slice: - if isPtr { - val = "*" + val - } - var arr = "arr" + strconv.Itoa(depth) - var index = "idx" + strconv.Itoa(depth) - var usePtr bool - if !isPtr { - switch destType.Elem().(type) { - case *types.Pointer, *types.Array: - default: - usePtr = true - } - } - - return tpl(` - {{.arr}} := make(graphql.Array, len({{.val}})) - {{ if and .top (not .isScalar) }} var wg sync.WaitGroup {{ end }} - {{ if not .isScalar }} - isLen1 := len({{.val}}) == 1 - if !isLen1 { - wg.Add(len({{.val}})) - } - {{ end }} - for {{.index}} := range {{.val}} { - {{- if not .isScalar }} - {{.index}} := {{.index}} - rctx := &graphql.ResolverContext{ - Index: &{{.index}}, - Result: {{ if .usePtr }}&{{end}}{{.val}}[{{.index}}], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func({{.index}} int) { - if !isLen1 { - defer wg.Done() - } - {{.arr}}[{{.index}}] = func() graphql.Marshaler { - {{ .next }} - }() - } - if isLen1 { - f({{.index}}) - } else { - go f({{.index}}) - } - {{ else }} - {{.arr}}[{{.index}}] = func() graphql.Marshaler { - {{ .next }} - }() - {{- end}} - } - {{ if and .top (not .isScalar) }} wg.Wait() {{ end }} - return {{.arr}}`, map[string]interface{}{ - "val": val, - "arr": arr, - "index": index, - "top": depth == 1, - "arrayLen": len(val), - "isScalar": f.Definition.GQLDefinition.Kind == ast.Scalar || f.Definition.GQLDefinition.Kind == ast.Enum, - "usePtr": usePtr, - "next": f.doWriteJson(val+"["+index+"]", destType.Elem(), astType.Elem, false, depth+1), - }) - - default: - if f.Definition.GQLDefinition.Kind == ast.Scalar || f.Definition.GQLDefinition.Kind == ast.Enum { - if isPtr { - val = "*" + val - } - return f.Marshal(val) - } - - if !isPtr { - val = "&" + val - } - return tpl(` - return ec._{{.type}}(ctx, field.Selections, {{.val}})`, map[string]interface{}{ - "type": f.Definition.GQLDefinition.Name, - "val": val, - }) - } -} - -func (f *FieldArgument) Stream() bool { - return f.Object != nil && f.Object.Stream -} - func (os Objects) ByName(name string) *Object { for i, o := range os { if strings.EqualFold(o.Definition.GQLDefinition.Name, name) { diff --git a/codegen/templates/object.gotpl b/codegen/object.gotpl similarity index 98% rename from codegen/templates/object.gotpl rename to codegen/object.gotpl index d7eaf51f26a..7babd8c4cc6 100644 --- a/codegen/templates/object.gotpl +++ b/codegen/object.gotpl @@ -1,4 +1,4 @@ -{{ $object := . }} +{{- range $object := .Objects }} var {{ $object.Definition.GQLDefinition.Name|lcFirst}}Implementors = {{$object.Implementors}} @@ -69,3 +69,5 @@ func (ec *executionContext) _{{$object.Definition.GQLDefinition.Name}}(ctx conte return out } {{- end }} + +{{- end }} diff --git a/codegen/schema.go b/codegen/schema.go index d9956d221b2..c4d47b51af4 100644 --- a/codegen/schema.go +++ b/codegen/schema.go @@ -1,22 +1 @@ package codegen - -import ( - "github.com/99designs/gqlgen/codegen/config" - "github.com/vektah/gqlparser/ast" -) - -// Schema is the result of merging the GraphQL Schema with the existing go code -type Schema struct { - Config *config.Config - Schema *ast.Schema - SchemaStr map[string]string - Directives map[string]*Directive - Objects Objects - Inputs Objects - Interfaces []*Interface - Enums []Enum -} - -func NewSchema(cfg *config.Config) (*Schema, error) { - return buildSchema(cfg) -} diff --git a/codegen/schema_test.go b/codegen/schema_test.go index 072500dd226..1cb9f9a481d 100644 --- a/codegen/schema_test.go +++ b/codegen/schema_test.go @@ -20,7 +20,7 @@ func TestTypeInInput(t *testing.T) { } func generate(name string, schemaFilename string) error { - _, err := NewSchema(&config.Config{ + _, err := BuildData(&config.Config{ SchemaFilename: config.SchemaFilenames{schemaFilename}, Exec: config.PackageConfig{Filename: "gen/" + name + "/exec.go"}, Model: config.PackageConfig{Filename: "gen/" + name + "/model.go"}, diff --git a/codegen/templates/import.go b/codegen/templates/import.go index 7959e6a1c5d..effe9a0dfb5 100644 --- a/codegen/templates/import.go +++ b/codegen/templates/import.go @@ -38,14 +38,14 @@ func (s *Imports) String() string { return res } -func (s *Imports) Reserve(path string, aliases ...string) string { +func (s *Imports) Reserve(path string, aliases ...string) (string, error) { if path == "" { panic("empty ambient import") } // if we are referencing our own package we dont need an import if code.ImportPathForDir(s.destDir) == path { - return "" + return "", nil } name := code.NameForPackage(path) @@ -57,11 +57,14 @@ func (s *Imports) Reserve(path string, aliases ...string) string { } if existing := s.findByPath(path); existing != nil { - panic("ambient import already exists") + if existing.Alias == alias { + return "", nil + } + return "", fmt.Errorf("ambient import already exists") } if alias := s.findByAlias(alias); alias != nil { - panic("ambient import collides on an alias") + return "", fmt.Errorf("ambient import collides on an alias") } s.imports = append(s.imports, &Import{ @@ -70,7 +73,7 @@ func (s *Imports) Reserve(path string, aliases ...string) string { Alias: alias, }) - return "" + return "", nil } func (s *Imports) Lookup(path string) string { diff --git a/codegen/templates/templates.go b/codegen/templates/templates.go index 770636598b5..e6ffdcfda64 100644 --- a/codegen/templates/templates.go +++ b/codegen/templates/templates.go @@ -22,27 +22,94 @@ import ( // this is done with a global because subtemplates currently get called in functions. Lets aim to remove this eventually. var CurrentImports *Imports -func RenderToFile(tpl string, destFile string, data interface{}) error { - if tpl == "" { - return fmt.Errorf("no template name given") - } +type Options struct { + PackageName string + Filename string + RegionTags bool + GeneratedHeader bool + Data interface{} +} + +func Render(cfg Options) error { if CurrentImports != nil { panic(fmt.Errorf("recursive or concurrent call to RenderToFile detected")) } - CurrentImports = &Imports{destDir: filepath.Dir(destFile)} + CurrentImports = &Imports{destDir: filepath.Dir(cfg.Filename)} + + // load path relative to calling source file + _, callerFile, _, _ := runtime.Caller(1) + rootDir := filepath.Dir(callerFile) + + t := template.New("").Funcs(Funcs()) + + var roots []string + // load all the templates in the directory + err := filepath.Walk(rootDir, func(path string, info os.FileInfo, err error) error { + name := filepath.ToSlash(strings.TrimPrefix(path, rootDir+string(os.PathSeparator))) + if !strings.HasSuffix(info.Name(), ".gotpl") { + return nil + } + b, err := ioutil.ReadFile(path) + if err != nil { + return err + } - filename := resolveName(tpl, 1) + t, err = t.New(name).Parse(string(b)) + if err != nil { + return errors.Wrap(err, cfg.Filename) + } - var buf *bytes.Buffer - buf, err := render(filename, data) + if !strings.HasPrefix(info.Name(), "_") { + roots = append(roots, name) + } + return nil + }) if err != nil { - return errors.Wrap(err, destFile) + return errors.Wrap(err, "locating templates") + } + + // then execute all the important looking ones in order, adding them to the same file + sort.Slice(roots, func(i, j int) bool { return roots[i] < roots[j] }) + var buf bytes.Buffer + for _, root := range roots { + if cfg.RegionTags { + buf.WriteString("\n// region " + center(70, "*", " "+root+" ") + "\n") + } + err = t.Lookup(root).Execute(&buf, cfg.Data) + if err != nil { + return errors.Wrap(err, root) + } + if cfg.RegionTags { + buf.WriteString("\n// endregion " + center(70, "*", " "+root+" ") + "\n") + } } - b := bytes.Replace(buf.Bytes(), []byte("%%%IMPORTS%%%"), []byte(CurrentImports.String()), -1) + var result bytes.Buffer + if cfg.GeneratedHeader { + result.WriteString("// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.\n\n") + } + result.WriteString("package ") + result.WriteString(cfg.PackageName) + result.WriteString("\n\n") + result.WriteString("import (\n") + result.WriteString(CurrentImports.String()) + result.WriteString(")\n") + _, err = buf.WriteTo(&result) + if err != nil { + return err + } CurrentImports = nil - return write(destFile, b) + return write(cfg.Filename, result.Bytes()) +} + +func center(width int, pad string, s string) string { + if len(s)+2 > width { + return s + } + lpad := (width - len(s)) / 2 + rpad := width - (lpad + len(s)) + return strings.Repeat(pad, lpad) + s + strings.Repeat(pad, rpad) } func Funcs() template.FuncMap { @@ -59,6 +126,8 @@ func Funcs() template.FuncMap { "notNil": notNil, "reserveImport": CurrentImports.Reserve, "lookupImport": CurrentImports.Lookup, + "go": ToGo, + "goPrivate": ToGoPrivate, "render": func(filename string, tpldata interface{}) (*bytes.Buffer, error) { return render(resolveName(filename, 0), tpldata) }, @@ -138,7 +207,45 @@ func ToGo(name string) string { } func ToGoPrivate(name string) string { - return lintName(lcFirst(ToCamel(name))) + return lintName(sanitizeKeywords(lcFirst(ToCamel(name)))) +} + +var keywords = []string{ + "break", + "default", + "func", + "interface", + "select", + "case", + "defer", + "go", + "map", + "struct", + "chan", + "else", + "goto", + "package", + "switch", + "const", + "fallthrough", + "if", + "range", + "type", + "continue", + "for", + "import", + "return", + "var", +} + +// sanitizeKeywords prevents collisions with go keywords for arguments to resolver functions +func sanitizeKeywords(name string) string { + for _, k := range keywords { + if name == k { + return name + "Arg" + } + } + return name } // copy from https://github.com/golang/lint/blob/06c8688daad7faa9da5a0c2f163a3d14aac986ca/lint.go#L679 diff --git a/codegen/templates/templates_test.go b/codegen/templates/templates_test.go index dce5fffd6b0..31f518b4bcc 100644 --- a/codegen/templates/templates_test.go +++ b/codegen/templates/templates_test.go @@ -13,3 +13,9 @@ func TestToUpper(t *testing.T) { require.Equal(t, "ToCamel", ToCamel("ToCamel")) require.Equal(t, "ToCamel", ToCamel("to-camel")) } + +func TestCenter(t *testing.T) { + require.Equal(t, "fffff", center(3, "#", "fffff")) + require.Equal(t, "##fffff###", center(10, "#", "fffff")) + require.Equal(t, "###fffff###", center(11, "#", "fffff")) +} diff --git a/codegen/testdata/gqlgen.yml b/codegen/testdata/gqlgen.yml new file mode 100644 index 00000000000..b32289be0d3 --- /dev/null +++ b/codegen/testdata/gqlgen.yml @@ -0,0 +1,21 @@ +schema: + - "testdata/schema.graphql" + +exec: + filename: out/generated.go +model: + filename: out/generated.go + +models: + ExistingModel: + model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingModel + ExistingInput: + model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingInput + ExistingEnum: + model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingEnum + ExistingInterface: + model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingInterface + ExistingUnion: + model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingUnion + + diff --git a/codegen/testdata/schema.graphql b/codegen/testdata/schema.graphql new file mode 100644 index 00000000000..d08a37d54c7 --- /dev/null +++ b/codegen/testdata/schema.graphql @@ -0,0 +1,174 @@ +type Query { + invalidIdentifier: InvalidIdentifier + collision: It + mapInput(input: Changes): Boolean + recursive(input: RecursiveInputSlice): Boolean + nestedInputs(input: [[OuterInput]] = [[{inner: {id: 1}}]]): Boolean + nestedOutputs: [[OuterObject]] + keywords(input: Keywords): Boolean! + shapes: [Shape] + errorBubble: Error + modelMethods: ModelMethods + valid: String! + user(id: Int!): User! + nullableArg(arg: Int = 123): String + directiveArg(arg: String! @length(min:1, max: 255, message: "invalid length")): String + directiveNullableArg(arg: Int @range(min:0), arg2: Int @range): String + directiveInputNullable(arg: InputDirectives): String + directiveInput(arg: InputDirectives!): String +} + +type Subscription { + updated: String! + initPayload: String! +} + +type User { + id: Int! + friends: [User!]! +} + +type Error { + id: ID! + errorOnNonRequiredField: String + errorOnRequiredField: String! + nilOnRequiredField: String! +} + +type ModelMethods { + resolverField: Boolean! + noContext: Boolean! + withContext: Boolean! +} + +type InvalidIdentifier { + id: Int! +} + +type It { + id: ID! +} + +input Changes { + a: Int + b: Int +} + +input RecursiveInputSlice { + self: [RecursiveInputSlice!] +} + +input InnerInput { + id:Int! +} + +input OuterInput { + inner: InnerInput! +} + +input InputDirectives { + text: String! @length(min: 0, max: 7, message: "not valid") + inner: InnerDirectives! + innerNullable: InnerDirectives +} + +input InnerDirectives { + message: String! @length(min: 1, message: "not valid") +} + +type OuterObject { + inner: InnerObject! +} + +type InnerObject { + id: Int! +} + +input Keywords { + break: String! + default: String! + func: String! + interface: String! + select: String! + case: String! + defer: String! + go: String! + map: String! + struct: String! + chan: String! + else: String! + goto: String! + package: String! + switch: String! + const: String! + fallthrough: String! + if: String! + range: String! + type: String! + continue: String! + for: String! + import: String! + return: String! + var: String! +} + +extend type Query { + keywordArgs( + break: String!, + default: String!, + func: String!, + interface: String!, + select: String!, + case: String!, + defer: String!, + go: String!, + map: String!, + struct: String!, + chan: String!, + else: String!, + goto: String!, + package: String!, + switch: String!, + const: String!, + fallthrough: String!, + if: String!, + range: String!, + type: String!, + continue: String!, + for: String!, + import: String!, + return: String!, + var: String!, + ): Boolean! +} + +interface Shape { + area: Float +} +type Circle implements Shape { + radius: Float + area: Float +} +type Rectangle implements Shape { + length: Float + width: Float + area: Float +} +union ShapeUnion = Circle | Rectangle + +type ForcedResolver { + field: Circle +} + +type EmbeddedPointer { + ID: String + Title: String +} + +directive @length(min: Int!, max: Int, message: String!) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION +directive @range(min: Int = 0, max: Int, message: String) on ARGUMENT_DEFINITION + +enum Status { + OK + ERROR +} diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 699427fba21..3fed5f6781d 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -11,1289 +11,2036 @@ import ( "strconv" "sync" - introspection1 "github.com/99designs/gqlgen/codegen/testserver/introspection" + "github.com/99designs/gqlgen/codegen/testserver/introspection" "github.com/99designs/gqlgen/codegen/testserver/invalid-packagename" "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/graphql/introspection" + introspection1 "github.com/99designs/gqlgen/graphql/introspection" "github.com/vektah/gqlparser" "github.com/vektah/gqlparser/ast" ) -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, +// region **************************** field.gotpl ***************************** + +// nolint: vetshadow +func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.CollectedField, obj *Circle) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Circle", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Radius, nil + }) + if resTmp == nil { + return graphql.Null } + res := resTmp.(float64) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalFloat(res) } -type Config struct { - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot +// nolint: vetshadow +func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.CollectedField, obj *Circle) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Circle", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Area(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(float64) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalFloat(res) } -type ResolverRoot interface { - ForcedResolver() ForcedResolverResolver - ModelMethods() ModelMethodsResolver - Query() QueryResolver - Subscription() SubscriptionResolver - User() UserResolver +// nolint: vetshadow +func (ec *executionContext) _EmbeddedPointer_ID(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "EmbeddedPointer", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } -type DirectiveRoot struct { - Length func(ctx context.Context, obj interface{}, next graphql.Resolver, min int, max *int, message string) (res interface{}, err error) - - Range func(ctx context.Context, obj interface{}, next graphql.Resolver, min *int, max *int, message *string) (res interface{}, err error) +// nolint: vetshadow +func (ec *executionContext) _EmbeddedPointer_Title(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "EmbeddedPointer", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Title, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } -type ComplexityRoot struct { - Circle struct { - Radius func(childComplexity int) int - Area func(childComplexity int) int +// nolint: vetshadow +func (ec *executionContext) _Error_id(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Error", + Field: field, + Args: nil, } - - EmbeddedPointer struct { - Id func(childComplexity int) int - Title func(childComplexity int) int + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalID(res) +} - Error struct { - Id func(childComplexity int) int - ErrorOnNonRequiredField func(childComplexity int) int - ErrorOnRequiredField func(childComplexity int) int - NilOnRequiredField func(childComplexity int) int +// nolint: vetshadow +func (ec *executionContext) _Error_errorOnNonRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Error", + Field: field, + Args: nil, } - - ForcedResolver struct { - Field func(childComplexity int) int + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ErrorOnNonRequiredField() + }) + if resTmp == nil { + return graphql.Null } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - InnerObject struct { - Id func(childComplexity int) int +// nolint: vetshadow +func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Error", + Field: field, + Args: nil, } - - InvalidIdentifier struct { - Id func(childComplexity int) int + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ErrorOnRequiredField() + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - It struct { - Id func(childComplexity int) int +// nolint: vetshadow +func (ec *executionContext) _Error_nilOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Error", + Field: field, + Args: nil, } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.NilOnRequiredField(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - ModelMethods struct { - ResolverField func(childComplexity int) int - NoContext func(childComplexity int) int - WithContext func(childComplexity int) int + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null } + return graphql.MarshalString(*res) +} - OuterObject struct { - Inner func(childComplexity int) int +// nolint: vetshadow +func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field graphql.CollectedField, obj *ForcedResolver) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "ForcedResolver", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.ForcedResolver().Field(rctx, obj) + }) + if resTmp == nil { + return graphql.Null } + res := resTmp.(*Circle) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - Query struct { - InvalidIdentifier func(childComplexity int) int - Collision func(childComplexity int) int - MapInput func(childComplexity int, input *map[string]interface{}) int - Recursive func(childComplexity int, input *RecursiveInputSlice) int - NestedInputs func(childComplexity int, input [][]*OuterInput) int - NestedOutputs func(childComplexity int) int - Keywords func(childComplexity int, input *Keywords) int - Shapes func(childComplexity int) int - ErrorBubble func(childComplexity int) int - ModelMethods func(childComplexity int) int - Valid func(childComplexity int) int - User func(childComplexity int, id int) int - NullableArg func(childComplexity int, arg *int) int - DirectiveArg func(childComplexity int, arg string) int - DirectiveNullableArg func(childComplexity int, arg *int, arg2 *int) int - DirectiveInputNullable func(childComplexity int, arg *InputDirectives) int - DirectiveInput func(childComplexity int, arg InputDirectives) int - KeywordArgs func(childComplexity int, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) int + if res == nil { + return graphql.Null } - Rectangle struct { - Length func(childComplexity int) int - Width func(childComplexity int) int - Area func(childComplexity int) int - } + return ec._Circle(ctx, field.Selections, res) +} - Subscription struct { - Updated func(childComplexity int) int - InitPayload func(childComplexity int) int +// nolint: vetshadow +func (ec *executionContext) _InnerObject_id(ctx context.Context, field graphql.CollectedField, obj *InnerObject) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "InnerObject", + Field: field, + Args: nil, } - - User struct { - Id func(childComplexity int) int - Friends func(childComplexity int) int + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null } + res := resTmp.(int) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalInt(res) } -type ForcedResolverResolver interface { - Field(ctx context.Context, obj *ForcedResolver) (*Circle, error) -} -type ModelMethodsResolver interface { - ResolverField(ctx context.Context, obj *ModelMethods) (bool, error) -} -type QueryResolver interface { - InvalidIdentifier(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) - Collision(ctx context.Context) (*introspection1.It, error) - MapInput(ctx context.Context, input *map[string]interface{}) (*bool, error) - Recursive(ctx context.Context, input *RecursiveInputSlice) (*bool, error) - NestedInputs(ctx context.Context, input [][]*OuterInput) (*bool, error) - NestedOutputs(ctx context.Context) ([][]*OuterObject, error) - Keywords(ctx context.Context, input *Keywords) (bool, error) - Shapes(ctx context.Context) ([]Shape, error) - ErrorBubble(ctx context.Context) (*Error, error) - ModelMethods(ctx context.Context) (*ModelMethods, error) - Valid(ctx context.Context) (string, error) - User(ctx context.Context, id int) (User, error) - NullableArg(ctx context.Context, arg *int) (*string, error) - DirectiveArg(ctx context.Context, arg string) (*string, error) - DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int) (*string, error) - DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) - DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) - KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) -} -type SubscriptionResolver interface { - Updated(ctx context.Context) (<-chan string, error) - InitPayload(ctx context.Context) (<-chan string, error) -} -type UserResolver interface { - Friends(ctx context.Context, obj *User) ([]User, error) -} - -func (e *executableSchema) field_Query_mapInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *map[string]interface{} - if tmp, ok := rawArgs["input"]; ok { - var err error - var ptr1 map[string]interface{} - if tmp != nil { - ptr1 = tmp.(map[string]interface{}) - arg0 = &ptr1 - } - - if err != nil { - return nil, err +// nolint: vetshadow +func (ec *executionContext) _InvalidIdentifier_id(ctx context.Context, field graphql.CollectedField, obj *invalid_packagename.InvalidIdentifier) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "InvalidIdentifier", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(int) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalInt(res) +} - if arg0 != nil { - var err error - arg0, err = e.ChangesMiddleware(ctx, arg0) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedField, obj *introspection.It) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "It", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["input"] = arg0 - return args, nil - + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalID(res) } -func (e *executableSchema) field_Query_recursive_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *RecursiveInputSlice - if tmp, ok := rawArgs["input"]; ok { - var err error - var ptr1 RecursiveInputSlice - if tmp != nil { - ptr1, err = UnmarshalRecursiveInputSlice(tmp) - arg0 = &ptr1 +// nolint: vetshadow +func (ec *executionContext) _ModelMethods_resolverField(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "ModelMethods", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.ModelMethods().ResolverField(rctx, obj) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) +} - if err != nil { - return nil, err +// nolint: vetshadow +func (ec *executionContext) _ModelMethods_noContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "ModelMethods", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.NoContext(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) +} - if arg0 != nil { - var err error - arg0, err = e.RecursiveInputSliceMiddleware(ctx, arg0) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _ModelMethods_withContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "ModelMethods", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.WithContext(ctx), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["input"] = arg0 - return args, nil - + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) } -func (e *executableSchema) field_Query_nestedInputs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 [][]*OuterInput - if tmp, ok := rawArgs["input"]; ok { - var err error - var rawIf1 []interface{} - if tmp != nil { - if tmp1, ok := tmp.([]interface{}); ok { - rawIf1 = tmp1 - } else { - rawIf1 = []interface{}{tmp} - } - } - arg0 = make([][]*OuterInput, len(rawIf1)) - for idx1 := range rawIf1 { - var rawIf2 []interface{} - if rawIf1[idx1] != nil { - if tmp1, ok := rawIf1[idx1].([]interface{}); ok { - rawIf2 = tmp1 - } else { - rawIf2 = []interface{}{rawIf1[idx1]} - } - } - arg0[idx1] = make([]*OuterInput, len(rawIf2)) - for idx2 := range rawIf2 { - var ptr3 OuterInput - if rawIf2[idx2] != nil { - ptr3, err = UnmarshalOuterInput(rawIf2[idx2]) - arg0[idx1][idx2] = &ptr3 - } - } - } - if err != nil { - return nil, err - } - for idx1 := range arg0 { - for idx2 := range arg0[idx1] { - - if arg0[idx1][idx2] != nil { - var err error - arg0[idx1][idx2], err = e.OuterInputMiddleware(ctx, arg0[idx1][idx2]) - if err != nil { - return nil, err - } - } - } +// nolint: vetshadow +func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphql.CollectedField, obj *OuterObject) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "OuterObject", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Inner, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["input"] = arg0 - return args, nil + res := resTmp.(InnerObject) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec._InnerObject(ctx, field.Selections, &res) } -func (e *executableSchema) field_Query_keywords_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *Keywords - if tmp, ok := rawArgs["input"]; ok { - var err error - var ptr1 Keywords - if tmp != nil { - ptr1, err = UnmarshalKeywords(tmp) - arg0 = &ptr1 - } - - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().InvalidIdentifier(rctx) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*invalid_packagename.InvalidIdentifier) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - if arg0 != nil { - var err error - arg0, err = e.KeywordsMiddleware(ctx, arg0) - if err != nil { - return nil, err - } - } + if res == nil { + return graphql.Null } - args["input"] = arg0 - return args, nil + return ec._InvalidIdentifier(ctx, field.Selections, res) } -func (e *executableSchema) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 int - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalInt(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Query_collision(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["id"] = arg0 - return args, nil + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Collision(rctx) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.It) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -} + if res == nil { + return graphql.Null + } -func (e *executableSchema) field_Query_nullableArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *int - if tmp, ok := rawArgs["arg"]; ok { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg0 = &ptr1 - } + return ec._It(ctx, field.Selections, res) +} - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["arg"] = arg0 - return args, nil + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_mapInput_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().MapInput(rctx, args["input"].(*map[string]interface{})) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + if res == nil { + return graphql.Null + } + return graphql.MarshalBoolean(*res) } -func (e *executableSchema) field_Query_directiveArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["arg"]; ok { - argm0, err := chainFieldMiddleware([]graphql.FieldMiddleware{ - func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { - max := 255 - return e.directives.Length(ctx, tmp, n, 1, &max, "invalid length") - }, - }...)(ctx, func(ctx2 context.Context) (interface{}, error) { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - return arg0, nil - }) - if err != nil { - return nil, err - } - if data, ok := argm0.(string); ok { - arg0 = data - } else { - return nil, errors.New("expect string") - } +// nolint: vetshadow +func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["arg"] = arg0 - return args, nil + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_recursive_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Recursive(rctx, args["input"].(*RecursiveInputSlice)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + if res == nil { + return graphql.Null + } + return graphql.MarshalBoolean(*res) } -func (e *executableSchema) field_Query_directiveNullableArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *int - if tmp, ok := rawArgs["arg"]; ok { - argm0, err := chainFieldMiddleware([]graphql.FieldMiddleware{ - func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { - min := 0 - return e.directives.Range(ctx, tmp, n, &min, nil, nil) - }, - }...)(ctx, func(ctx2 context.Context) (interface{}, error) { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg0 = &ptr1 - } +// nolint: vetshadow +func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_nestedInputs_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().NestedInputs(rctx, args["input"].([][]*OuterInput)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - if err != nil { - return nil, err - } - return arg0, nil - }) - if err != nil { - return nil, err - } - if data, ok := argm0.(*int); ok { - arg0 = data - } else { - return nil, errors.New("expect *int") - } + if res == nil { + return graphql.Null } - args["arg"] = arg0 - var arg1 *int - if tmp, ok := rawArgs["arg2"]; ok { - argm1, err := chainFieldMiddleware([]graphql.FieldMiddleware{ - func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { - min := 0 - return e.directives.Range(ctx, tmp, n, &min, nil, nil) - }, - }...)(ctx, func(ctx2 context.Context) (interface{}, error) { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg1 = &ptr1 - } + return graphql.MarshalBoolean(*res) +} - if err != nil { - return nil, err - } - return arg1, nil - }) - if err != nil { - return nil, err - } - if data, ok := argm1.(*int); ok { - arg1 = data - } else { - return nil, errors.New("expect *int") - } +// nolint: vetshadow +func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["arg2"] = arg1 - return args, nil + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().NestedOutputs(rctx) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([][]*OuterObject) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -func (e *executableSchema) field_Query_directiveInputNullable_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *InputDirectives - if tmp, ok := rawArgs["arg"]; ok { - var err error - var ptr1 InputDirectives - if tmp != nil { - ptr1, err = UnmarshalInputDirectives(tmp) - arg0 = &ptr1 - } + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - if err != nil { - return nil, err + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } - - if arg0 != nil { - var err error - arg0, err = e.InputDirectivesMiddleware(ctx, arg0) - if err != nil { - return nil, err + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() } - } - } - args["arg"] = arg0 - return args, nil + arr1[idx1] = func() graphql.Marshaler { -} + arr2 := make(graphql.Array, len(res[idx1])) -func (e *executableSchema) field_Query_directiveInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 InputDirectives - if tmp, ok := rawArgs["arg"]; ok { - var err error - arg0, err = UnmarshalInputDirectives(tmp) - if err != nil { - return nil, err - } + isLen1 := len(res[idx1]) == 1 + if !isLen1 { + wg.Add(len(res[idx1])) + } - mInputDirectives1, err := e.InputDirectivesMiddleware(ctx, &arg0) - if err != nil { - return nil, err - } - arg0 = *mInputDirectives1 - } - args["arg"] = arg0 - return args, nil + for idx2 := range res[idx1] { + idx2 := idx2 + rctx := &graphql.ResolverContext{ + Index: &idx2, + Result: res[idx1][idx2], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx2 int) { + if !isLen1 { + defer wg.Done() + } + arr2[idx2] = func() graphql.Marshaler { -} + if res[idx1][idx2] == nil { + return graphql.Null + } -func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["break"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err + return ec._OuterObject(ctx, field.Selections, res[idx1][idx2]) + }() + } + if isLen1 { + f(idx2) + } else { + go f(idx2) + } + + } + + return arr2 + }() } - } - args["break"] = arg0 - var arg1 string - if tmp, ok := rawArgs["default"]; ok { - var err error - arg1, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err + if isLen1 { + f(idx1) + } else { + go f(idx1) } + } - args["default"] = arg1 - var arg2 string - if tmp, ok := rawArgs["func"]; ok { - var err error - arg2, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + wg.Wait() + return arr1 +} + +// nolint: vetshadow +func (ec *executionContext) _Query_keywords(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["func"] = arg2 - var arg3 string - if tmp, ok := rawArgs["interface"]; ok { - var err error - arg3, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_keywords_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["interface"] = arg3 - var arg4 string - if tmp, ok := rawArgs["select"]; ok { - var err error - arg4, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Keywords(rctx, args["input"].(*Keywords)) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["select"] = arg4 - var arg5 string - if tmp, ok := rawArgs["case"]; ok { - var err error - arg5, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) +} + +// nolint: vetshadow +func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["case"] = arg5 - var arg6 string - if tmp, ok := rawArgs["defer"]; ok { - var err error - arg6, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Shapes(rctx) + }) + if resTmp == nil { + return graphql.Null } - args["defer"] = arg6 - var arg7 string - if tmp, ok := rawArgs["go"]; ok { - var err error - arg7, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + res := resTmp.([]Shape) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - args["go"] = arg7 - var arg8 string - if tmp, ok := rawArgs["map"]; ok { - var err error - arg8, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err + + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } - } - args["map"] = arg8 - var arg9 string - if tmp, ok := rawArgs["struct"]; ok { - var err error - arg9, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec._Shape(ctx, field.Selections, &res[idx1]) + }() } - } - args["struct"] = arg9 - var arg10 string - if tmp, ok := rawArgs["chan"]; ok { - var err error - arg10, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err + if isLen1 { + f(idx1) + } else { + go f(idx1) } + } - args["chan"] = arg10 - var arg11 string - if tmp, ok := rawArgs["else"]; ok { - var err error - arg11, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + wg.Wait() + return arr1 +} + +// nolint: vetshadow +func (ec *executionContext) _Query_errorBubble(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["else"] = arg11 - var arg12 string - if tmp, ok := rawArgs["goto"]; ok { - var err error - arg12, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().ErrorBubble(rctx) + }) + if resTmp == nil { + return graphql.Null } - args["goto"] = arg12 - var arg13 string - if tmp, ok := rawArgs["package"]; ok { - var err error - arg13, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + res := resTmp.(*Error) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { + return graphql.Null } - args["package"] = arg13 - var arg14 string - if tmp, ok := rawArgs["switch"]; ok { - var err error - arg14, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + + return ec._Error(ctx, field.Selections, res) +} + +// nolint: vetshadow +func (ec *executionContext) _Query_modelMethods(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["switch"] = arg14 - var arg15 string - if tmp, ok := rawArgs["const"]; ok { - var err error - arg15, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().ModelMethods(rctx) + }) + if resTmp == nil { + return graphql.Null } - args["const"] = arg15 - var arg16 string - if tmp, ok := rawArgs["fallthrough"]; ok { - var err error - arg16, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + res := resTmp.(*ModelMethods) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { + return graphql.Null } - args["fallthrough"] = arg16 - var arg17 string - if tmp, ok := rawArgs["if"]; ok { - var err error - arg17, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + + return ec._ModelMethods(ctx, field.Selections, res) +} + +// nolint: vetshadow +func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["if"] = arg17 - var arg18 string - if tmp, ok := rawArgs["range"]; ok { - var err error - arg18, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Valid(rctx) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["range"] = arg18 - var arg19 string - if tmp, ok := rawArgs["type"]; ok { - var err error - arg19, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} + +// nolint: vetshadow +func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["type"] = arg19 - var arg20 string - if tmp, ok := rawArgs["continue"]; ok { - var err error - arg20, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_user_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["continue"] = arg20 - var arg21 string - if tmp, ok := rawArgs["for"]; ok { - var err error - arg21, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().User(rctx, args["id"].(int)) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["for"] = arg21 - var arg22 string - if tmp, ok := rawArgs["import"]; ok { - var err error - arg22, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + res := resTmp.(User) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + return ec._User(ctx, field.Selections, &res) +} + +// nolint: vetshadow +func (ec *executionContext) _Query_nullableArg(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["import"] = arg22 - var arg23 string - if tmp, ok := rawArgs["return"]; ok { - var err error - arg23, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_nullableArg_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["return"] = arg23 - var arg24 string - if tmp, ok := rawArgs["var"]; ok { - var err error - arg24, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().NullableArg(rctx, args["arg"].(*int)) + }) + if resTmp == nil { + return graphql.Null } - args["var"] = arg24 - return args, nil + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } -func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Query_directiveArg(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["name"] = arg0 - return args, nil + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_directiveArg_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().DirectiveArg(rctx, args["arg"].(string)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Query_directiveNullableArg(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["includeDeprecated"] = arg0 - return args, nil + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_directiveNullableArg_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().DirectiveNullableArg(rctx, args["arg"].(*int), args["arg2"].(*int)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Query_directiveInputNullable(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["includeDeprecated"] = arg0 - return args, nil + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_directiveInputNullable_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().DirectiveInputNullable(rctx, args["arg"].(*InputDirectives)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } -func (e *executableSchema) dir_length_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 int - if tmp, ok := rawArgs["min"]; ok { - var err error - arg0, err = graphql.UnmarshalInt(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Query_directiveInput(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["min"] = arg0 - var arg1 *int - if tmp, ok := rawArgs["max"]; ok { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg1 = &ptr1 - } - - if err != nil { - return nil, err - } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_directiveInput_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["max"] = arg1 - var arg2 string - if tmp, ok := rawArgs["message"]; ok { - var err error - arg2, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().DirectiveInput(rctx, args["arg"].(InputDirectives)) + }) + if resTmp == nil { + return graphql.Null } - args["message"] = arg2 - return args, nil + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } -func (e *executableSchema) dir_range_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *int - if tmp, ok := rawArgs["min"]; ok { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg0 = &ptr1 - } - - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Query_keywordArgs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["min"] = arg0 - var arg1 *int - if tmp, ok := rawArgs["max"]; ok { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg1 = &ptr1 + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_keywordArgs_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().KeywordArgs(rctx, args["break"].(string), args["default"].(string), args["func"].(string), args["interface"].(string), args["select"].(string), args["case"].(string), args["defer"].(string), args["go"].(string), args["map"].(string), args["struct"].(string), args["chan"].(string), args["else"].(string), args["goto"].(string), args["package"].(string), args["switch"].(string), args["const"].(string), args["fallthrough"].(string), args["if"].(string), args["range"].(string), args["type"].(string), args["continue"].(string), args["for"].(string), args["import"].(string), args["return"].(string), args["var"].(string)) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) +} - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["max"] = arg1 - var arg2 *string - if tmp, ok := rawArgs["message"]; ok { - var err error - var ptr1 string - if tmp != nil { - ptr1, err = graphql.UnmarshalString(tmp) - arg2 = &ptr1 - } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query___type_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(args["name"].(string)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection1.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - if err != nil { - return nil, err - } + if res == nil { + return graphql.Null } - args["message"] = arg2 - return args, nil + return ec.___Type(ctx, field.Selections, res) } -type executableSchema struct { - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot -} +// nolint: vetshadow +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection1.Schema) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -func (e *executableSchema) Schema() *ast.Schema { - return parsedSchema -} + if res == nil { + return graphql.Null + } -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - switch typeName + "." + field { + return ec.___Schema(ctx, field.Selections, res) +} - case "Circle.radius": - if e.complexity.Circle.Radius == nil { - break - } +// nolint: vetshadow +func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Rectangle", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Length, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(float64) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalFloat(res) +} - return e.complexity.Circle.Radius(childComplexity), true +// nolint: vetshadow +func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Rectangle", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Width, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(float64) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalFloat(res) +} - case "Circle.area": - if e.complexity.Circle.Area == nil { - break - } +// nolint: vetshadow +func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Rectangle", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Area(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(float64) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalFloat(res) +} - return e.complexity.Circle.Area(childComplexity), true - - case "EmbeddedPointer.ID": - if e.complexity.EmbeddedPointer.Id == nil { - break +func (ec *executionContext) _Subscription_updated(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Field: field, + Args: nil, + }) + // FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259 + // and Tracer stack + rctx := ctx + results, err := ec.resolvers.Subscription().Updated(rctx) + if err != nil { + ec.Error(ctx, err) + return nil + } + return func() graphql.Marshaler { + res, ok := <-results + if !ok { + return nil } + return graphql.WriterFunc(func(w io.Writer) { + w.Write([]byte{'{'}) + graphql.MarshalString(field.Alias).MarshalGQL(w) + w.Write([]byte{':'}) + func() graphql.Marshaler { + return graphql.MarshalString(res) + }().MarshalGQL(w) + w.Write([]byte{'}'}) + }) + } +} - return e.complexity.EmbeddedPointer.Id(childComplexity), true - - case "EmbeddedPointer.Title": - if e.complexity.EmbeddedPointer.Title == nil { - break +func (ec *executionContext) _Subscription_initPayload(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Field: field, + Args: nil, + }) + // FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259 + // and Tracer stack + rctx := ctx + results, err := ec.resolvers.Subscription().InitPayload(rctx) + if err != nil { + ec.Error(ctx, err) + return nil + } + return func() graphql.Marshaler { + res, ok := <-results + if !ok { + return nil } + return graphql.WriterFunc(func(w io.Writer) { + w.Write([]byte{'{'}) + graphql.MarshalString(field.Alias).MarshalGQL(w) + w.Write([]byte{':'}) + func() graphql.Marshaler { + return graphql.MarshalString(res) + }().MarshalGQL(w) + w.Write([]byte{'}'}) + }) + } +} - return e.complexity.EmbeddedPointer.Title(childComplexity), true - - case "Error.id": - if e.complexity.Error.Id == nil { - break +// nolint: vetshadow +func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "User", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(int) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalInt(res) +} - return e.complexity.Error.Id(childComplexity), true - - case "Error.errorOnNonRequiredField": - if e.complexity.Error.ErrorOnNonRequiredField == nil { - break +// nolint: vetshadow +func (ec *executionContext) _User_friends(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "User", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.User().Friends(rctx, obj) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.([]User) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.Error.ErrorOnNonRequiredField(childComplexity), true - - case "Error.errorOnRequiredField": - if e.complexity.Error.ErrorOnRequiredField == nil { - break - } + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - return e.complexity.Error.ErrorOnRequiredField(childComplexity), true + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - case "Error.nilOnRequiredField": - if e.complexity.Error.NilOnRequiredField == nil { - break + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.Error.NilOnRequiredField(childComplexity), true - - case "ForcedResolver.field": - if e.complexity.ForcedResolver.Field == nil { - break + return ec._User(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.ForcedResolver.Field(childComplexity), true + } + wg.Wait() + return arr1 +} - case "InnerObject.id": - if e.complexity.InnerObject.Id == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection1.Directive) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - return e.complexity.InnerObject.Id(childComplexity), true +// nolint: vetshadow +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection1.Directive) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - case "InvalidIdentifier.id": - if e.complexity.InvalidIdentifier.Id == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection1.Directive) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.([]string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.InvalidIdentifier.Id(childComplexity), true + arr1 := make(graphql.Array, len(res)) - case "It.id": - if e.complexity.It.Id == nil { - break - } + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { + return graphql.MarshalString(res[idx1]) + }() + } - return e.complexity.It.Id(childComplexity), true + return arr1 +} - case "ModelMethods.resolverField": - if e.complexity.ModelMethods.ResolverField == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection1.Directive) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.([]introspection1.InputValue) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.ModelMethods.ResolverField(childComplexity), true - - case "ModelMethods.noContext": - if e.complexity.ModelMethods.NoContext == nil { - break - } + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - return e.complexity.ModelMethods.NoContext(childComplexity), true + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - case "ModelMethods.withContext": - if e.complexity.ModelMethods.WithContext == nil { - break + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.ModelMethods.WithContext(childComplexity), true - - case "OuterObject.inner": - if e.complexity.OuterObject.Inner == nil { - break + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.OuterObject.Inner(childComplexity), true + } + wg.Wait() + return arr1 +} - case "Query.invalidIdentifier": - if e.complexity.Query.InvalidIdentifier == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection1.EnumValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - return e.complexity.Query.InvalidIdentifier(childComplexity), true +// nolint: vetshadow +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection1.EnumValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - case "Query.collision": - if e.complexity.Query.Collision == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection1.EnumValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) +} - return e.complexity.Query.Collision(childComplexity), true +// nolint: vetshadow +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection1.EnumValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - case "Query.mapInput": - if e.complexity.Query.MapInput == nil { - break - } + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) +} - args, err := e.field_Query_mapInput_args(context.TODO(), rawArgs) - if err != nil { - return 0, false +// nolint: vetshadow +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection1.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - return e.complexity.Query.MapInput(childComplexity, args["input"].(*map[string]interface{})), true +// nolint: vetshadow +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection1.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - case "Query.recursive": - if e.complexity.Query.Recursive == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection1.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.([]introspection1.InputValue) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - args, err := e.field_Query_recursive_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - return e.complexity.Query.Recursive(childComplexity, args["input"].(*RecursiveInputSlice)), true + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - case "Query.nestedInputs": - if e.complexity.Query.NestedInputs == nil { - break + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - args, err := e.field_Query_nestedInputs_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }() } - - return e.complexity.Query.NestedInputs(childComplexity, args["input"].([][]*OuterInput)), true - - case "Query.nestedOutputs": - if e.complexity.Query.NestedOutputs == nil { - break + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.Query.NestedOutputs(childComplexity), true + } + wg.Wait() + return arr1 +} - case "Query.keywords": - if e.complexity.Query.Keywords == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection1.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(*introspection1.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - args, err := e.field_Query_keywords_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } - return e.complexity.Query.Keywords(childComplexity, args["input"].(*Keywords)), true + return ec.___Type(ctx, field.Selections, res) +} - case "Query.shapes": - if e.complexity.Query.Shapes == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection1.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) +} - return e.complexity.Query.Shapes(childComplexity), true - - case "Query.errorBubble": - if e.complexity.Query.ErrorBubble == nil { - break - } +// nolint: vetshadow +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection1.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.Query.ErrorBubble(childComplexity), true + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) +} - case "Query.modelMethods": - if e.complexity.Query.ModelMethods == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection1.InputValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - return e.complexity.Query.ModelMethods(childComplexity), true +// nolint: vetshadow +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection1.InputValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - case "Query.valid": - if e.complexity.Query.Valid == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection1.InputValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(*introspection1.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.Query.Valid(childComplexity), true - - case "Query.user": - if e.complexity.Query.User == nil { - break + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } - args, err := e.field_Query_user_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } + return ec.___Type(ctx, field.Selections, res) +} - return e.complexity.Query.User(childComplexity, args["id"].(int)), true +// nolint: vetshadow +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection1.InputValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - case "Query.nullableArg": - if e.complexity.Query.NullableArg == nil { - break - } - - args, err := e.field_Query_nullableArg_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.NullableArg(childComplexity, args["arg"].(*int)), true - - case "Query.directiveArg": - if e.complexity.Query.DirectiveArg == nil { - break - } - - args, err := e.field_Query_directiveArg_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.DirectiveArg(childComplexity, args["arg"].(string)), true - - case "Query.directiveNullableArg": - if e.complexity.Query.DirectiveNullableArg == nil { - break - } - - args, err := e.field_Query_directiveNullableArg_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.DirectiveNullableArg(childComplexity, args["arg"].(*int), args["arg2"].(*int)), true - - case "Query.directiveInputNullable": - if e.complexity.Query.DirectiveInputNullable == nil { - break - } - - args, err := e.field_Query_directiveInputNullable_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.DirectiveInputNullable(childComplexity, args["arg"].(*InputDirectives)), true - - case "Query.directiveInput": - if e.complexity.Query.DirectiveInput == nil { - break - } - - args, err := e.field_Query_directiveInput_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.DirectiveInput(childComplexity, args["arg"].(InputDirectives)), true - - case "Query.keywordArgs": - if e.complexity.Query.KeywordArgs == nil { - break - } - - args, err := e.field_Query_keywordArgs_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.KeywordArgs(childComplexity, 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)), true - - case "Rectangle.length": - if e.complexity.Rectangle.Length == nil { - break - } - - return e.complexity.Rectangle.Length(childComplexity), true - - case "Rectangle.width": - if e.complexity.Rectangle.Width == nil { - break - } - - return e.complexity.Rectangle.Width(childComplexity), true - - case "Rectangle.area": - if e.complexity.Rectangle.Area == nil { - break - } - - return e.complexity.Rectangle.Area(childComplexity), true - - case "Subscription.updated": - if e.complexity.Subscription.Updated == nil { - break - } - - return e.complexity.Subscription.Updated(childComplexity), true - - case "Subscription.initPayload": - if e.complexity.Subscription.InitPayload == nil { - break - } - - return e.complexity.Subscription.InitPayload(childComplexity), true - - case "User.id": - if e.complexity.User.Id == nil { - break - } - - return e.complexity.User.Id(childComplexity), true - - case "User.friends": - if e.complexity.User.Friends == nil { - break - } - - return e.complexity.User.Friends(childComplexity), true + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) +} +// nolint: vetshadow +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection1.Schema) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Field: field, + Args: nil, } - return 0, false -} - -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), nil }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]introspection1.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions} -} - -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - return graphql.ErrorResponse(ctx, "mutations are not supported") -} - -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - next := ec._Subscription(ctx, op.SelectionSet) - if ec.Errors != nil { - return graphql.OneShot(&graphql.Response{Data: []byte("null"), Errors: ec.Errors}) + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - var buf bytes.Buffer - return func() *graphql.Response { - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - buf.Reset() - data := next() - - if data == nil { - return nil + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() } - data.MarshalGQL(&buf) - return buf.Bytes() - }) + arr1[idx1] = func() graphql.Marshaler { - if buf == nil { - return nil + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() } - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, + if isLen1 { + f(idx1) + } else { + go f(idx1) } - } -} - -type executionContext struct { - *graphql.RequestContext - *executableSchema -} - -var circleImplementors = []string{"Circle", "Shape"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Circle(ctx context.Context, sel ast.SelectionSet, obj *Circle) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, circleImplementors) - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Circle") - case "radius": - out.Values[i] = ec._Circle_radius(ctx, field, obj) - case "area": - out.Values[i] = ec._Circle_area(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.CollectedField, obj *Circle) graphql.Marshaler { +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection1.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Circle", + Object: "__Schema", Field: field, Args: nil, } @@ -1301,23 +2048,34 @@ func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Radius, nil + return obj.QueryType(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(float64) + res := resTmp.(*introspection1.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) + + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.CollectedField, obj *Circle) graphql.Marshaler { +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection1.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Circle", + Object: "__Schema", Field: field, Args: nil, } @@ -1325,50 +2083,28 @@ func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Area(), nil + return obj.MutationType(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(float64) + res := resTmp.(*introspection1.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) -} - -var embeddedPointerImplementors = []string{"EmbeddedPointer"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _EmbeddedPointer(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedPointerModel) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, embeddedPointerImplementors) - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("EmbeddedPointer") - case "ID": - out.Values[i] = ec._EmbeddedPointer_ID(ctx, field, obj) - case "Title": - out.Values[i] = ec._EmbeddedPointer_Title(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { + if res == nil { return graphql.Null } - return out + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) _EmbeddedPointer_ID(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) graphql.Marshaler { +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection1.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "EmbeddedPointer", + Object: "__Schema", Field: field, Args: nil, } @@ -1376,23 +2112,28 @@ func (ec *executionContext) _EmbeddedPointer_ID(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.SubscriptionType(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*introspection1.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) _EmbeddedPointer_Title(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) graphql.Marshaler { +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection1.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "EmbeddedPointer", + Object: "__Schema", Field: field, Args: nil, } @@ -1400,63 +2141,59 @@ func (ec *executionContext) _EmbeddedPointer_Title(ctx context.Context, field gr ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Title, nil + return obj.Directives(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]introspection1.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} -var errorImplementors = []string{"Error"} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Error(ctx context.Context, sel ast.SelectionSet, obj *Error) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, errorImplementors) + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Error") - case "id": - out.Values[i] = ec._Error_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "errorOnNonRequiredField": - out.Values[i] = ec._Error_errorOnNonRequiredField(ctx, field, obj) - case "errorOnRequiredField": - out.Values[i] = ec._Error_errorOnRequiredField(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "nilOnRequiredField": - out.Values[i] = ec._Error_nilOnRequiredField(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() } - default: - panic("unknown field " + strconv.Quote(field.Name)) + arr1[idx1] = func() graphql.Marshaler { + + return ec.___Directive(ctx, field.Selections, &res[idx1]) + }() } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) _Error_id(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Error", + Object: "__Type", Field: field, Args: nil, } @@ -1464,7 +2201,7 @@ func (ec *executionContext) _Error_id(ctx context.Context, field graphql.Collect ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.Kind(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1475,15 +2212,15 @@ func (ec *executionContext) _Error_id(ctx context.Context, field graphql.Collect res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _Error_errorOnNonRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Error", + Object: "__Type", Field: field, Args: nil, } @@ -1491,23 +2228,27 @@ func (ec *executionContext) _Error_errorOnNonRequiredField(ctx context.Context, ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ErrorOnNonRequiredField() + return obj.Name(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Error", + Object: "__Type", Field: field, Args: nil, } @@ -1515,12 +2256,9 @@ func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, fie ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ErrorOnRequiredField() + return obj.Description(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } res := resTmp.(string) @@ -1530,74 +2268,75 @@ func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, fie } // nolint: vetshadow -func (ec *executionContext) _Error_nilOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Error", + Object: "__Type", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_fields_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.NilOnRequiredField(), nil + return obj.Fields(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*string) + res := resTmp.([]introspection1.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return graphql.MarshalString(*res) -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -var forcedResolverImplementors = []string{"ForcedResolver"} + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _ForcedResolver(ctx context.Context, sel ast.SelectionSet, obj *ForcedResolver) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, forcedResolverImplementors) + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("ForcedResolver") - case "field": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._ForcedResolver_field(ctx, field, obj) - return res - }) - default: - panic("unknown field " + strconv.Quote(field.Name)) + return ec.___Field(ctx, field.Selections, &res[idx1]) + }() } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field graphql.CollectedField, obj *ForcedResolver) graphql.Marshaler { +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "ForcedResolver", + Object: "__Type", Field: field, Args: nil, } @@ -1605,56 +2344,56 @@ func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field gra ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.ForcedResolver().Field(rctx, obj) + return obj.Interfaces(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*Circle) + res := resTmp.([]introspection1.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - return ec._Circle(ctx, field.Selections, res) -} + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { -var innerObjectImplementors = []string{"InnerObject"} + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _InnerObject(ctx context.Context, sel ast.SelectionSet, obj *InnerObject) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, innerObjectImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("InnerObject") - case "id": - out.Values[i] = ec._InnerObject_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null } - return out + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) _InnerObject_id(ctx context.Context, field graphql.CollectedField, obj *InnerObject) graphql.Marshaler { +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "InnerObject", + Object: "__Type", Field: field, Args: nil, } @@ -1662,109 +2401,120 @@ func (ec *executionContext) _InnerObject_id(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.PossibleTypes(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(int) + res := resTmp.([]introspection1.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) -} -var invalidIdentifierImplementors = []string{"InvalidIdentifier"} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _InvalidIdentifier(ctx context.Context, sel ast.SelectionSet, obj *invalid_packagename.InvalidIdentifier) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, invalidIdentifierImplementors) + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("InvalidIdentifier") - case "id": - out.Values[i] = ec._InvalidIdentifier_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() } - default: - panic("unknown field " + strconv.Quote(field.Name)) + arr1[idx1] = func() graphql.Marshaler { + + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) _InvalidIdentifier_id(ctx context.Context, field graphql.CollectedField, obj *invalid_packagename.InvalidIdentifier) graphql.Marshaler { +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "InvalidIdentifier", + Object: "__Type", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(int) + res := resTmp.([]introspection1.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) -} -var itImplementors = []string{"It"} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _It(ctx context.Context, sel ast.SelectionSet, obj *introspection1.It) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, itImplementors) + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("It") - case "id": - out.Values[i] = ec._It_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() } - default: - panic("unknown field " + strconv.Quote(field.Name)) + arr1[idx1] = func() graphql.Marshaler { + + return ec.___EnumValue(ctx, field.Selections, &res[idx1]) + }() } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedField, obj *introspection1.It) graphql.Marshaler { +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "It", + Object: "__Type", Field: field, Args: nil, } @@ -1772,72 +2522,56 @@ func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedF ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.InputFields(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]introspection1.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) -} -var modelMethodsImplementors = []string{"ModelMethods"} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _ModelMethods(ctx context.Context, sel ast.SelectionSet, obj *ModelMethods) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, modelMethodsImplementors) + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("ModelMethods") - case "resolverField": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._ModelMethods_resolverField(ctx, field, obj) - if res == graphql.Null { - invalid = true - } - return res - }) - case "noContext": - out.Values[i] = ec._ModelMethods_noContext(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() } - case "withContext": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._ModelMethods_withContext(ctx, field, obj) - if res == graphql.Null { - invalid = true - } - return res - }) - default: - panic("unknown field " + strconv.Quote(field.Name)) + arr1[idx1] = func() graphql.Marshaler { + + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }() } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) _ModelMethods_resolverField(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) graphql.Marshaler { +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "ModelMethods", + Object: "__Type", Field: field, Args: nil, } @@ -1845,2859 +2579,1614 @@ func (ec *executionContext) _ModelMethods_resolverField(ctx context.Context, fie ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.ModelMethods().ResolverField(rctx, obj) + return obj.OfType(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*introspection1.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) -} -// nolint: vetshadow -func (ec *executionContext) _ModelMethods_noContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "ModelMethods", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.NoContext(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } + if res == nil { return graphql.Null } - res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + + return ec.___Type(ctx, field.Selections, res) } -// nolint: vetshadow -func (ec *executionContext) _ModelMethods_withContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "ModelMethods", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.WithContext(ctx), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null +// endregion **************************** field.gotpl ***************************** + +// region ************************** generated.gotpl *************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, } - res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) } -var outerObjectImplementors = []string{"OuterObject"} +type Config struct { + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _OuterObject(ctx context.Context, sel ast.SelectionSet, obj *OuterObject) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, outerObjectImplementors) +type ResolverRoot interface { + ForcedResolver() ForcedResolverResolver + ModelMethods() ModelMethodsResolver + Query() QueryResolver + Subscription() SubscriptionResolver + User() UserResolver +} - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("OuterObject") - case "inner": - out.Values[i] = ec._OuterObject_inner(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } +type DirectiveRoot struct { + Length func(ctx context.Context, obj interface{}, next graphql.Resolver, min int, max *int, message string) (res interface{}, err error) + + Range func(ctx context.Context, obj interface{}, next graphql.Resolver, min *int, max *int, message *string) (res interface{}, err error) +} + +type ComplexityRoot struct { + Circle struct { + Radius func(childComplexity int) int + Area func(childComplexity int) int } - out.Dispatch() - if invalid { - return graphql.Null + + EmbeddedPointer struct { + Id func(childComplexity int) int + Title func(childComplexity int) int } - return out -} -// nolint: vetshadow -func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphql.CollectedField, obj *OuterObject) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "OuterObject", - Field: field, - Args: nil, + Error struct { + Id func(childComplexity int) int + ErrorOnNonRequiredField func(childComplexity int) int + ErrorOnRequiredField func(childComplexity int) int + NilOnRequiredField func(childComplexity int) int } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Inner, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null + + ForcedResolver struct { + Field func(childComplexity int) int } - res := resTmp.(InnerObject) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec._InnerObject(ctx, field.Selections, &res) + InnerObject struct { + Id func(childComplexity int) int + } + + InvalidIdentifier struct { + Id func(childComplexity int) int + } + + It struct { + Id func(childComplexity int) int + } + + ModelMethods struct { + ResolverField func(childComplexity int) int + NoContext func(childComplexity int) int + WithContext func(childComplexity int) int + } + + OuterObject struct { + Inner func(childComplexity int) int + } + + Query struct { + InvalidIdentifier func(childComplexity int) int + Collision func(childComplexity int) int + MapInput func(childComplexity int, input *map[string]interface{}) int + Recursive func(childComplexity int, input *RecursiveInputSlice) int + NestedInputs func(childComplexity int, input [][]*OuterInput) int + NestedOutputs func(childComplexity int) int + Keywords func(childComplexity int, input *Keywords) int + Shapes func(childComplexity int) int + ErrorBubble func(childComplexity int) int + ModelMethods func(childComplexity int) int + Valid func(childComplexity int) int + User func(childComplexity int, id int) int + NullableArg func(childComplexity int, arg *int) int + DirectiveArg func(childComplexity int, arg string) int + DirectiveNullableArg func(childComplexity int, arg *int, arg2 *int) int + DirectiveInputNullable func(childComplexity int, arg *InputDirectives) int + DirectiveInput func(childComplexity int, arg InputDirectives) int + KeywordArgs func(childComplexity int, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) int + } + + Rectangle struct { + Length func(childComplexity int) int + Width func(childComplexity int) int + Area func(childComplexity int) int + } + + Subscription struct { + Updated func(childComplexity int) int + InitPayload func(childComplexity int) int + } + + User struct { + Id func(childComplexity int) int + Friends func(childComplexity int) int + } } -var queryImplementors = []string{"Query"} +type ForcedResolverResolver interface { + Field(ctx context.Context, obj *ForcedResolver) (*Circle, error) +} +type ModelMethodsResolver interface { + ResolverField(ctx context.Context, obj *ModelMethods) (bool, error) +} +type QueryResolver interface { + InvalidIdentifier(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) + Collision(ctx context.Context) (*introspection.It, error) + MapInput(ctx context.Context, input *map[string]interface{}) (*bool, error) + Recursive(ctx context.Context, input *RecursiveInputSlice) (*bool, error) + NestedInputs(ctx context.Context, input [][]*OuterInput) (*bool, error) + NestedOutputs(ctx context.Context) ([][]*OuterObject, error) + Keywords(ctx context.Context, input *Keywords) (bool, error) + Shapes(ctx context.Context) ([]Shape, error) + ErrorBubble(ctx context.Context) (*Error, error) + ModelMethods(ctx context.Context) (*ModelMethods, error) + Valid(ctx context.Context) (string, error) + User(ctx context.Context, id int) (User, error) + NullableArg(ctx context.Context, arg *int) (*string, error) + DirectiveArg(ctx context.Context, arg string) (*string, error) + DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int) (*string, error) + DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) + DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) + KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) +} +type SubscriptionResolver interface { + Updated(ctx context.Context) (<-chan string, error) + InitPayload(ctx context.Context) (<-chan string, error) +} +type UserResolver interface { + Friends(ctx context.Context, obj *User) ([]User, error) +} -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, queryImplementors) +func (e *executableSchema) field_Query_mapInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *map[string]interface{} + if tmp, ok := rawArgs["input"]; ok { + var err error + var ptr1 map[string]interface{} + if tmp != nil { + ptr1 = tmp.(map[string]interface{}) + arg0 = &ptr1 + } - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: "Query", - }) + if err != nil { + return nil, err + } - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Query") - case "invalidIdentifier": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_invalidIdentifier(ctx, field) - return res - }) - case "collision": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_collision(ctx, field) - return res - }) - case "mapInput": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_mapInput(ctx, field) - return res - }) - case "recursive": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_recursive(ctx, field) - return res - }) - case "nestedInputs": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_nestedInputs(ctx, field) - return res - }) - case "nestedOutputs": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_nestedOutputs(ctx, field) - return res - }) - case "keywords": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_keywords(ctx, field) - if res == graphql.Null { - invalid = true - } - return res - }) - case "shapes": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_shapes(ctx, field) - return res - }) - case "errorBubble": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_errorBubble(ctx, field) - return res - }) - case "modelMethods": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_modelMethods(ctx, field) - return res - }) - case "valid": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_valid(ctx, field) - if res == graphql.Null { - invalid = true - } - return res - }) - case "user": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_user(ctx, field) - if res == graphql.Null { - invalid = true - } - return res - }) - case "nullableArg": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_nullableArg(ctx, field) - return res - }) - case "directiveArg": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_directiveArg(ctx, field) - return res - }) - case "directiveNullableArg": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_directiveNullableArg(ctx, field) - return res - }) - case "directiveInputNullable": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_directiveInputNullable(ctx, field) - return res - }) - case "directiveInput": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_directiveInput(ctx, field) - return res - }) - case "keywordArgs": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_keywordArgs(ctx, field) - if res == graphql.Null { - invalid = true - } - return res - }) - case "__type": - out.Values[i] = ec._Query___type(ctx, field) - case "__schema": - out.Values[i] = ec._Query___schema(ctx, field) - default: - panic("unknown field " + strconv.Quote(field.Name)) + if arg0 != nil { + var err error + arg0, err = e.ChangesMiddleware(ctx, arg0) + if err != nil { + return nil, err + } } } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + args["input"] = arg0 + return args, nil + } -// nolint: vetshadow -func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().InvalidIdentifier(rctx) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*invalid_packagename.InvalidIdentifier) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +func (e *executableSchema) field_Query_recursive_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *RecursiveInputSlice + if tmp, ok := rawArgs["input"]; ok { + var err error + var ptr1 RecursiveInputSlice + if tmp != nil { + ptr1, err = UnmarshalRecursiveInputSlice(tmp) + arg0 = &ptr1 + } - if res == nil { - return graphql.Null + if err != nil { + return nil, err + } + + if arg0 != nil { + var err error + arg0, err = e.RecursiveInputSliceMiddleware(ctx, arg0) + if err != nil { + return nil, err + } + } } + args["input"] = arg0 + return args, nil - return ec._InvalidIdentifier(ctx, field.Selections, res) } -// nolint: vetshadow -func (ec *executionContext) _Query_collision(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Collision(rctx) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection1.It) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +func (e *executableSchema) field_Query_nestedInputs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 [][]*OuterInput + if tmp, ok := rawArgs["input"]; ok { + var err error + var rawIf1 []interface{} + if tmp != nil { + if tmp1, ok := tmp.([]interface{}); ok { + rawIf1 = tmp1 + } else { + rawIf1 = []interface{}{tmp} + } + } + arg0 = make([][]*OuterInput, len(rawIf1)) + for idx1 := range rawIf1 { + var rawIf2 []interface{} + if rawIf1[idx1] != nil { + if tmp1, ok := rawIf1[idx1].([]interface{}); ok { + rawIf2 = tmp1 + } else { + rawIf2 = []interface{}{rawIf1[idx1]} + } + } + arg0[idx1] = make([]*OuterInput, len(rawIf2)) + for idx2 := range rawIf2 { + var ptr3 OuterInput + if rawIf2[idx2] != nil { + ptr3, err = UnmarshalOuterInput(rawIf2[idx2]) + arg0[idx1][idx2] = &ptr3 + } + } + } + if err != nil { + return nil, err + } + for idx1 := range arg0 { + for idx2 := range arg0[idx1] { - if res == nil { - return graphql.Null + if arg0[idx1][idx2] != nil { + var err error + arg0[idx1][idx2], err = e.OuterInputMiddleware(ctx, arg0[idx1][idx2]) + if err != nil { + return nil, err + } + } + } + } } + args["input"] = arg0 + return args, nil - return ec._It(ctx, field.Selections, res) } -// nolint: vetshadow -func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_mapInput_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().MapInput(rctx, args["input"].(*map[string]interface{})) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +func (e *executableSchema) field_Query_keywords_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *Keywords + if tmp, ok := rawArgs["input"]; ok { + var err error + var ptr1 Keywords + if tmp != nil { + ptr1, err = UnmarshalKeywords(tmp) + arg0 = &ptr1 + } - if res == nil { - return graphql.Null - } - return graphql.MarshalBoolean(*res) -} + if err != nil { + return nil, err + } -// nolint: vetshadow -func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_recursive_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Recursive(rctx, args["input"].(*RecursiveInputSlice)) - }) - if resTmp == nil { - return graphql.Null + if arg0 != nil { + var err error + arg0, err = e.KeywordsMiddleware(ctx, arg0) + if err != nil { + return nil, err + } + } } - res := resTmp.(*bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + args["input"] = arg0 + return args, nil - if res == nil { - return graphql.Null - } - return graphql.MarshalBoolean(*res) } -// nolint: vetshadow -func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_nestedInputs_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().NestedInputs(rctx, args["input"].([][]*OuterInput)) - }) - if resTmp == nil { - return graphql.Null +func (e *executableSchema) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 int + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = graphql.UnmarshalInt(tmp) + if err != nil { + return nil, err + } } - res := resTmp.(*bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + args["id"] = arg0 + return args, nil - if res == nil { - return graphql.Null - } - return graphql.MarshalBoolean(*res) } -// nolint: vetshadow -func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().NestedOutputs(rctx) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([][]*OuterObject) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], +func (e *executableSchema) field_Query_nullableArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *int + if tmp, ok := rawArgs["arg"]; ok { + var err error + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + arg0 = &ptr1 } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - arr2 := make(graphql.Array, len(res[idx1])) - isLen1 := len(res[idx1]) == 1 - if !isLen1 { - wg.Add(len(res[idx1])) - } + if err != nil { + return nil, err + } + } + args["arg"] = arg0 + return args, nil - for idx2 := range res[idx1] { - idx2 := idx2 - rctx := &graphql.ResolverContext{ - Index: &idx2, - Result: res[idx1][idx2], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx2 int) { - if !isLen1 { - defer wg.Done() - } - arr2[idx2] = func() graphql.Marshaler { +} - if res[idx1][idx2] == nil { - return graphql.Null - } +func (e *executableSchema) field_Query_directiveArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["arg"]; ok { + argm0, err := chainFieldMiddleware([]graphql.FieldMiddleware{ + func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { + max := 255 + return e.directives.Length(ctx, tmp, n, 1, &max, "invalid length") + }, + }...)(ctx, func(ctx2 context.Context) (interface{}, error) { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + return arg0, nil + }) + if err != nil { + return nil, err + } + if data, ok := argm0.(string); ok { + arg0 = data + } else { + return nil, errors.New("expect string") + } + } + args["arg"] = arg0 + return args, nil - return ec._OuterObject(ctx, field.Selections, res[idx1][idx2]) - }() - } - if isLen1 { - f(idx2) - } else { - go f(idx2) - } +} - } +func (e *executableSchema) field_Query_directiveNullableArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *int + if tmp, ok := rawArgs["arg"]; ok { + argm0, err := chainFieldMiddleware([]graphql.FieldMiddleware{ + func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { + min := 0 + return e.directives.Range(ctx, tmp, n, &min, nil, nil) + }, + }...)(ctx, func(ctx2 context.Context) (interface{}, error) { + var err error + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + arg0 = &ptr1 + } - return arr2 - }() + if err != nil { + return nil, err + } + return arg0, nil + }) + if err != nil { + return nil, err } - if isLen1 { - f(idx1) + if data, ok := argm0.(*int); ok { + arg0 = data } else { - go f(idx1) + return nil, errors.New("expect *int") } - } - wg.Wait() - return arr1 -} + args["arg"] = arg0 + var arg1 *int + if tmp, ok := rawArgs["arg2"]; ok { + argm1, err := chainFieldMiddleware([]graphql.FieldMiddleware{ + func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { + min := 0 + return e.directives.Range(ctx, tmp, n, &min, nil, nil) + }, + }...)(ctx, func(ctx2 context.Context) (interface{}, error) { + var err error + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + arg1 = &ptr1 + } -// nolint: vetshadow -func (ec *executionContext) _Query_keywords(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_keywords_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Keywords(rctx, args["input"].(*Keywords)) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + if err != nil { + return nil, err + } + return arg1, nil + }) + if err != nil { + return nil, err + } + if data, ok := argm1.(*int); ok { + arg1 = data + } else { + return nil, errors.New("expect *int") } - return graphql.Null - } - res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) -} - -// nolint: vetshadow -func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Shapes(rctx) - }) - if resTmp == nil { - return graphql.Null } - res := resTmp.([]Shape) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + args["arg2"] = arg1 + return args, nil - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } +} - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], +func (e *executableSchema) field_Query_directiveInputNullable_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *InputDirectives + if tmp, ok := rawArgs["arg"]; ok { + var err error + var ptr1 InputDirectives + if tmp != nil { + ptr1, err = UnmarshalInputDirectives(tmp) + arg0 = &ptr1 } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec._Shape(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) + if err != nil { + return nil, err } + if arg0 != nil { + var err error + arg0, err = e.InputDirectivesMiddleware(ctx, arg0) + if err != nil { + return nil, err + } + } } - wg.Wait() - return arr1 + args["arg"] = arg0 + return args, nil + } -// nolint: vetshadow -func (ec *executionContext) _Query_errorBubble(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().ErrorBubble(rctx) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*Error) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +func (e *executableSchema) field_Query_directiveInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 InputDirectives + if tmp, ok := rawArgs["arg"]; ok { + var err error + arg0, err = UnmarshalInputDirectives(tmp) + if err != nil { + return nil, err + } - if res == nil { - return graphql.Null + mInputDirectives1, err := e.InputDirectivesMiddleware(ctx, &arg0) + if err != nil { + return nil, err + } + arg0 = *mInputDirectives1 } + args["arg"] = arg0 + return args, nil - return ec._Error(ctx, field.Selections, res) } -// nolint: vetshadow -func (ec *executionContext) _Query_modelMethods(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().ModelMethods(rctx) - }) - if resTmp == nil { - return graphql.Null +func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["break"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - res := resTmp.(*ModelMethods) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null + args["break"] = arg0 + var arg1 string + if tmp, ok := rawArgs["default"]; ok { + var err error + arg1, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - - return ec._ModelMethods(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + args["default"] = arg1 + var arg2 string + if tmp, ok := rawArgs["func"]; ok { + var err error + arg2, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Valid(rctx) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + args["func"] = arg2 + var arg3 string + if tmp, ok := rawArgs["interface"]; ok { + var err error + arg3, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_user_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null + args["interface"] = arg3 + var arg4 string + if tmp, ok := rawArgs["select"]; ok { + var err error + arg4, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().User(rctx, args["id"].(int)) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + args["select"] = arg4 + var arg5 string + if tmp, ok := rawArgs["case"]; ok { + var err error + arg5, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(User) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._User(ctx, field.Selections, &res) -} - -// nolint: vetshadow -func (ec *executionContext) _Query_nullableArg(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + args["case"] = arg5 + var arg6 string + if tmp, ok := rawArgs["defer"]; ok { + var err error + arg6, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_nullableArg_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null + args["defer"] = arg6 + var arg7 string + if tmp, ok := rawArgs["go"]; ok { + var err error + arg7, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().NullableArg(rctx, args["arg"].(*int)) - }) - if resTmp == nil { - return graphql.Null + args["go"] = arg7 + var arg8 string + if tmp, ok := rawArgs["map"]; ok { + var err error + arg8, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null + args["map"] = arg8 + var arg9 string + if tmp, ok := rawArgs["struct"]; ok { + var err error + arg9, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - return graphql.MarshalString(*res) -} - -// nolint: vetshadow -func (ec *executionContext) _Query_directiveArg(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + args["struct"] = arg9 + var arg10 string + if tmp, ok := rawArgs["chan"]; ok { + var err error + arg10, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_directiveArg_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null + args["chan"] = arg10 + var arg11 string + if tmp, ok := rawArgs["else"]; ok { + var err error + arg11, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().DirectiveArg(rctx, args["arg"].(string)) - }) - if resTmp == nil { - return graphql.Null + args["else"] = arg11 + var arg12 string + if tmp, ok := rawArgs["goto"]; ok { + var err error + arg12, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null + args["goto"] = arg12 + var arg13 string + if tmp, ok := rawArgs["package"]; ok { + var err error + arg13, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - return graphql.MarshalString(*res) -} - -// nolint: vetshadow -func (ec *executionContext) _Query_directiveNullableArg(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + args["package"] = arg13 + var arg14 string + if tmp, ok := rawArgs["switch"]; ok { + var err error + arg14, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_directiveNullableArg_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null + args["switch"] = arg14 + var arg15 string + if tmp, ok := rawArgs["const"]; ok { + var err error + arg15, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().DirectiveNullableArg(rctx, args["arg"].(*int), args["arg2"].(*int)) - }) - if resTmp == nil { - return graphql.Null + args["const"] = arg15 + var arg16 string + if tmp, ok := rawArgs["fallthrough"]; ok { + var err error + arg16, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null + args["fallthrough"] = arg16 + var arg17 string + if tmp, ok := rawArgs["if"]; ok { + var err error + arg17, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - return graphql.MarshalString(*res) -} - -// nolint: vetshadow -func (ec *executionContext) _Query_directiveInputNullable(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + args["if"] = arg17 + var arg18 string + if tmp, ok := rawArgs["range"]; ok { + var err error + arg18, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_directiveInputNullable_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null + args["range"] = arg18 + var arg19 string + if tmp, ok := rawArgs["type"]; ok { + var err error + arg19, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().DirectiveInputNullable(rctx, args["arg"].(*InputDirectives)) - }) - if resTmp == nil { - return graphql.Null + args["type"] = arg19 + var arg20 string + if tmp, ok := rawArgs["continue"]; ok { + var err error + arg20, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null + args["continue"] = arg20 + var arg21 string + if tmp, ok := rawArgs["for"]; ok { + var err error + arg21, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - return graphql.MarshalString(*res) -} - -// nolint: vetshadow -func (ec *executionContext) _Query_directiveInput(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + args["for"] = arg21 + var arg22 string + if tmp, ok := rawArgs["import"]; ok { + var err error + arg22, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_directiveInput_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null + args["import"] = arg22 + var arg23 string + if tmp, ok := rawArgs["return"]; ok { + var err error + arg23, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().DirectiveInput(rctx, args["arg"].(InputDirectives)) - }) - if resTmp == nil { - return graphql.Null + args["return"] = arg23 + var arg24 string + if tmp, ok := rawArgs["var"]; ok { + var err error + arg24, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + args["var"] = arg24 + return args, nil - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) } -// nolint: vetshadow -func (ec *executionContext) _Query_keywordArgs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_keywordArgs_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().KeywordArgs(rctx, args["break"].(string), args["default"].(string), args["func"].(string), args["interface"].(string), args["select"].(string), args["case"].(string), args["defer"].(string), args["go"].(string), args["map"].(string), args["struct"].(string), args["chan"].(string), args["else"].(string), args["goto"].(string), args["package"].(string), args["switch"].(string), args["const"].(string), args["fallthrough"].(string), args["if"].(string), args["range"].(string), args["type"].(string), args["continue"].(string), args["for"].(string), args["import"].(string), args["return"].(string), args["var"].(string)) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + args["name"] = arg0 + return args, nil + } -// nolint: vetshadow -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query___type_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectType(args["name"].(string)) - }) - if resTmp == nil { - return graphql.Null +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + args["includeDeprecated"] = arg0 + return args, nil - if res == nil { - return graphql.Null +} + +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } } + args["includeDeprecated"] = arg0 + return args, nil - return ec.___Type(ctx, field.Selections, res) } -// nolint: vetshadow -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() - }) - if resTmp == nil { - return graphql.Null +func (e *executableSchema) dir_length_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 int + if tmp, ok := rawArgs["min"]; ok { + var err error + arg0, err = graphql.UnmarshalInt(tmp) + if err != nil { + return nil, err + } } - res := resTmp.(*introspection.Schema) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + args["min"] = arg0 + var arg1 *int + if tmp, ok := rawArgs["max"]; ok { + var err error + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + arg1 = &ptr1 + } - if res == nil { - return graphql.Null + if err != nil { + return nil, err + } + } + args["max"] = arg1 + var arg2 string + if tmp, ok := rawArgs["message"]; ok { + var err error + arg2, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } + args["message"] = arg2 + return args, nil - return ec.___Schema(ctx, field.Selections, res) } -var rectangleImplementors = []string{"Rectangle", "Shape"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Rectangle(ctx context.Context, sel ast.SelectionSet, obj *Rectangle) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, rectangleImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Rectangle") - case "length": - out.Values[i] = ec._Rectangle_length(ctx, field, obj) - case "width": - out.Values[i] = ec._Rectangle_width(ctx, field, obj) - case "area": - out.Values[i] = ec._Rectangle_area(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) +func (e *executableSchema) dir_range_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *int + if tmp, ok := rawArgs["min"]; ok { + var err error + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + arg0 = &ptr1 + } + + if err != nil { + return nil, err } } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} + args["min"] = arg0 + var arg1 *int + if tmp, ok := rawArgs["max"]; ok { + var err error + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + arg1 = &ptr1 + } -// nolint: vetshadow -func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Rectangle", - Field: field, - Args: nil, + if err != nil { + return nil, err + } } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Length, nil - }) - if resTmp == nil { - return graphql.Null + args["max"] = arg1 + var arg2 *string + if tmp, ok := rawArgs["message"]; ok { + var err error + var ptr1 string + if tmp != nil { + ptr1, err = graphql.UnmarshalString(tmp) + arg2 = &ptr1 + } + + if err != nil { + return nil, err + } } - res := resTmp.(float64) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) + args["message"] = arg2 + return args, nil + } -// nolint: vetshadow -func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Rectangle", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Width, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(float64) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) +type executableSchema struct { + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot } -// nolint: vetshadow -func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Rectangle", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Area(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(float64) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) +func (e *executableSchema) Schema() *ast.Schema { + return parsedSchema } -var subscriptionImplementors = []string{"Subscription"} +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + switch typeName + "." + field { -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Subscription(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, subscriptionImplementors) - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: "Subscription", - }) - if len(fields) != 1 { - ec.Errorf(ctx, "must subscribe to exactly one stream") - return nil - } + case "Circle.radius": + if e.complexity.Circle.Radius == nil { + break + } - switch fields[0].Name { - case "updated": - return ec._Subscription_updated(ctx, fields[0]) - case "initPayload": - return ec._Subscription_initPayload(ctx, fields[0]) - default: - panic("unknown field " + strconv.Quote(fields[0].Name)) - } -} + return e.complexity.Circle.Radius(childComplexity), true -func (ec *executionContext) _Subscription_updated(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Field: field, - Args: nil, - }) - // FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259 - // and Tracer stack - rctx := ctx - results, err := ec.resolvers.Subscription().Updated(rctx) - if err != nil { - ec.Error(ctx, err) - return nil - } - return func() graphql.Marshaler { - res, ok := <-results - if !ok { - return nil + case "Circle.area": + if e.complexity.Circle.Area == nil { + break } - return graphql.WriterFunc(func(w io.Writer) { - w.Write([]byte{'{'}) - graphql.MarshalString(field.Alias).MarshalGQL(w) - w.Write([]byte{':'}) - func() graphql.Marshaler { - return graphql.MarshalString(res) - }().MarshalGQL(w) - w.Write([]byte{'}'}) - }) - } -} -func (ec *executionContext) _Subscription_initPayload(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Field: field, - Args: nil, - }) - // FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259 - // and Tracer stack - rctx := ctx - results, err := ec.resolvers.Subscription().InitPayload(rctx) - if err != nil { - ec.Error(ctx, err) - return nil - } - return func() graphql.Marshaler { - res, ok := <-results - if !ok { - return nil + return e.complexity.Circle.Area(childComplexity), true + + case "EmbeddedPointer.ID": + if e.complexity.EmbeddedPointer.Id == nil { + break } - return graphql.WriterFunc(func(w io.Writer) { - w.Write([]byte{'{'}) - graphql.MarshalString(field.Alias).MarshalGQL(w) - w.Write([]byte{':'}) - func() graphql.Marshaler { - return graphql.MarshalString(res) - }().MarshalGQL(w) - w.Write([]byte{'}'}) - }) - } -} -var userImplementors = []string{"User"} + return e.complexity.EmbeddedPointer.Id(childComplexity), true -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *User) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, userImplementors) + case "EmbeddedPointer.Title": + if e.complexity.EmbeddedPointer.Title == nil { + break + } - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("User") - case "id": - out.Values[i] = ec._User_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "friends": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._User_friends(ctx, field, obj) - if res == graphql.Null { - invalid = true - } - return res - }) - default: - panic("unknown field " + strconv.Quote(field.Name)) + return e.complexity.EmbeddedPointer.Title(childComplexity), true + + case "Error.id": + if e.complexity.Error.Id == nil { + break } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} -// nolint: vetshadow -func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + return e.complexity.Error.Id(childComplexity), true + + case "Error.errorOnNonRequiredField": + if e.complexity.Error.ErrorOnNonRequiredField == nil { + break } - return graphql.Null - } - res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) -} -// nolint: vetshadow -func (ec *executionContext) _User_friends(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.User().Friends(rctx, obj) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + return e.complexity.Error.ErrorOnNonRequiredField(childComplexity), true + + case "Error.errorOnRequiredField": + if e.complexity.Error.ErrorOnRequiredField == nil { + break } - return graphql.Null - } - res := resTmp.([]User) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + return e.complexity.Error.ErrorOnRequiredField(childComplexity), true - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } + case "Error.nilOnRequiredField": + if e.complexity.Error.NilOnRequiredField == nil { + break + } - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + return e.complexity.Error.NilOnRequiredField(childComplexity), true + + case "ForcedResolver.field": + if e.complexity.ForcedResolver.Field == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec._User(ctx, field.Selections, &res[idx1]) - }() + return e.complexity.ForcedResolver.Field(childComplexity), true + + case "InnerObject.id": + if e.complexity.InnerObject.Id == nil { + break } - if isLen1 { - f(idx1) - } else { - go f(idx1) + + return e.complexity.InnerObject.Id(childComplexity), true + + case "InvalidIdentifier.id": + if e.complexity.InvalidIdentifier.Id == nil { + break } - } - wg.Wait() - return arr1 -} + return e.complexity.InvalidIdentifier.Id(childComplexity), true -var __DirectiveImplementors = []string{"__Directive"} + case "It.id": + if e.complexity.It.Id == nil { + break + } -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) + return e.complexity.It.Id(childComplexity), true - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Directive") - case "name": - out.Values[i] = ec.___Directive_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___Directive_description(ctx, field, obj) - case "locations": - out.Values[i] = ec.___Directive_locations(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "args": - out.Values[i] = ec.___Directive_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) + case "ModelMethods.resolverField": + if e.complexity.ModelMethods.ResolverField == nil { + break } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} -// nolint: vetshadow -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + return e.complexity.ModelMethods.ResolverField(childComplexity), true + + case "ModelMethods.noContext": + if e.complexity.ModelMethods.NoContext == nil { + break } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} -// nolint: vetshadow -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} + return e.complexity.ModelMethods.NoContext(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Locations, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + case "ModelMethods.withContext": + if e.complexity.ModelMethods.WithContext == nil { + break } - return graphql.Null - } - res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) + return e.complexity.ModelMethods.WithContext(childComplexity), true - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } + case "OuterObject.inner": + if e.complexity.OuterObject.Inner == nil { + break + } - return arr1 -} + return e.complexity.OuterObject.Inner(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Args, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + case "Query.invalidIdentifier": + if e.complexity.Query.InvalidIdentifier == nil { + break } - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } + return e.complexity.Query.InvalidIdentifier(childComplexity), true - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + case "Query.collision": + if e.complexity.Query.Collision == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() + return e.complexity.Query.Collision(childComplexity), true + + case "Query.mapInput": + if e.complexity.Query.MapInput == nil { + break } - if isLen1 { - f(idx1) - } else { - go f(idx1) + + args, err := e.field_Query_mapInput_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - } - wg.Wait() - return arr1 -} + return e.complexity.Query.MapInput(childComplexity, args["input"].(*map[string]interface{})), true -var __EnumValueImplementors = []string{"__EnumValue"} + case "Query.recursive": + if e.complexity.Query.Recursive == nil { + break + } -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) + args, err := e.field_Query_recursive_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__EnumValue") - case "name": - out.Values[i] = ec.___EnumValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___EnumValue_description(ctx, field, obj) - case "isDeprecated": - out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "deprecationReason": - out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) + return e.complexity.Query.Recursive(childComplexity, args["input"].(*RecursiveInputSlice)), true + + case "Query.nestedInputs": + if e.complexity.Query.NestedInputs == nil { + break } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} -// nolint: vetshadow -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + args, err := e.field_Query_nestedInputs_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} -// nolint: vetshadow -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} + return e.complexity.Query.NestedInputs(childComplexity, args["input"].([][]*OuterInput)), true -// nolint: vetshadow -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + case "Query.nestedOutputs": + if e.complexity.Query.NestedOutputs == nil { + break } - return graphql.Null - } - res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) -} -// nolint: vetshadow -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return e.complexity.Query.NestedOutputs(childComplexity), true - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) -} + case "Query.keywords": + if e.complexity.Query.Keywords == nil { + break + } -var __FieldImplementors = []string{"__Field"} + args, err := e.field_Query_keywords_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __FieldImplementors) + return e.complexity.Query.Keywords(childComplexity, args["input"].(*Keywords)), true - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Field") - case "name": - out.Values[i] = ec.___Field_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___Field_description(ctx, field, obj) - case "args": - out.Values[i] = ec.___Field_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "type": - out.Values[i] = ec.___Field_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "isDeprecated": - out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "deprecationReason": - out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) + case "Query.shapes": + if e.complexity.Query.Shapes == nil { + break } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} -// nolint: vetshadow -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + return e.complexity.Query.Shapes(childComplexity), true + + case "Query.errorBubble": + if e.complexity.Query.ErrorBubble == nil { + break } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} -// nolint: vetshadow -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} + return e.complexity.Query.ErrorBubble(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Args, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + case "Query.modelMethods": + if e.complexity.Query.ModelMethods == nil { + break } - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } + return e.complexity.Query.ModelMethods(childComplexity), true - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + case "Query.valid": + if e.complexity.Query.Valid == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() + return e.complexity.Query.Valid(childComplexity), true + + case "Query.user": + if e.complexity.Query.User == nil { + break } - if isLen1 { - f(idx1) - } else { - go f(idx1) + + args, err := e.field_Query_user_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - } - wg.Wait() - return arr1 -} + return e.complexity.Query.User(childComplexity, args["id"].(int)), true -// nolint: vetshadow -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Type, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + case "Query.nullableArg": + if e.complexity.Query.NullableArg == nil { + break } - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + args, err := e.field_Query_nullableArg_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - return graphql.Null - } - return ec.___Type(ctx, field.Selections, res) -} + return e.complexity.Query.NullableArg(childComplexity, args["arg"].(*int)), true -// nolint: vetshadow -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + case "Query.directiveArg": + if e.complexity.Query.DirectiveArg == nil { + break } - return graphql.Null - } - res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) -} + args, err := e.field_Query_directiveArg_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } -var __InputValueImplementors = []string{"__InputValue"} + return e.complexity.Query.DirectiveArg(childComplexity, args["arg"].(string)), true -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) + case "Query.directiveNullableArg": + if e.complexity.Query.DirectiveNullableArg == nil { + break + } - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__InputValue") - case "name": - out.Values[i] = ec.___InputValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___InputValue_description(ctx, field, obj) - case "type": - out.Values[i] = ec.___InputValue_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "defaultValue": - out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) + args, err := e.field_Query_directiveNullableArg_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} -// nolint: vetshadow -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + return e.complexity.Query.DirectiveNullableArg(childComplexity, args["arg"].(*int), args["arg2"].(*int)), true + + case "Query.directiveInputNullable": + if e.complexity.Query.DirectiveInputNullable == nil { + break } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} -// nolint: vetshadow -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} + args, err := e.field_Query_directiveInputNullable_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } -// nolint: vetshadow -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Type, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + return e.complexity.Query.DirectiveInputNullable(childComplexity, args["arg"].(*InputDirectives)), true + + case "Query.directiveInput": + if e.complexity.Query.DirectiveInput == nil { + break } - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + args, err := e.field_Query_directiveInput_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - return graphql.Null - } - return ec.___Type(ctx, field.Selections, res) -} + return e.complexity.Query.DirectiveInput(childComplexity, args["arg"].(InputDirectives)), true -// nolint: vetshadow -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + case "Query.keywordArgs": + if e.complexity.Query.KeywordArgs == nil { + break + } - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) -} + args, err := e.field_Query_keywordArgs_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } -var __SchemaImplementors = []string{"__Schema"} + return e.complexity.Query.KeywordArgs(childComplexity, 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)), true -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) + case "Rectangle.length": + if e.complexity.Rectangle.Length == nil { + break + } - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Schema") - case "types": - out.Values[i] = ec.___Schema_types(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "queryType": - out.Values[i] = ec.___Schema_queryType(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "mutationType": - out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) - case "subscriptionType": - out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) - case "directives": - out.Values[i] = ec.___Schema_directives(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) + return e.complexity.Rectangle.Length(childComplexity), true + + case "Rectangle.width": + if e.complexity.Rectangle.Width == nil { + break } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} -// nolint: vetshadow -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Types(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + return e.complexity.Rectangle.Width(childComplexity), true + + case "Rectangle.area": + if e.complexity.Rectangle.Area == nil { + break } - return graphql.Null - } - res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + return e.complexity.Rectangle.Area(childComplexity), true - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } + case "Subscription.updated": + if e.complexity.Subscription.Updated == nil { + break + } - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + return e.complexity.Subscription.Updated(childComplexity), true + + case "Subscription.initPayload": + if e.complexity.Subscription.InitPayload == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() + return e.complexity.Subscription.InitPayload(childComplexity), true + + case "User.id": + if e.complexity.User.Id == nil { + break } - if isLen1 { - f(idx1) - } else { - go f(idx1) + + return e.complexity.User.Id(childComplexity), true + + case "User.friends": + if e.complexity.User.Friends == nil { + break } + return e.complexity.User.Friends(childComplexity), true + } - wg.Wait() - return arr1 + return 0, false } -// nolint: vetshadow -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil +func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._Query(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions} +} - return ec.___Type(ctx, field.Selections, res) +func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + return graphql.ErrorResponse(ctx, "mutations are not supported") } -// nolint: vetshadow -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil - }) - if resTmp == nil { - return graphql.Null +func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + next := ec._Subscription(ctx, op.SelectionSet) + if ec.Errors != nil { + return graphql.OneShot(&graphql.Response{Data: []byte("null"), Errors: ec.Errors}) } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null + var buf bytes.Buffer + return func() *graphql.Response { + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + buf.Reset() + data := next() + + if data == nil { + return nil + } + data.MarshalGQL(&buf) + return buf.Bytes() + }) + + if buf == nil { + return nil + } + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions, + } } +} - return ec.___Type(ctx, field.Selections, res) +type executionContext struct { + *graphql.RequestContext + *executableSchema } -// nolint: vetshadow -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + rctx := graphql.GetResolverContext(ctx) + for _, d := range rctx.Field.Definition.Directives { + switch d.Name { + case "length": + if ec.directives.Length != nil { + rawArgs := d.ArgumentMap(ec.Variables) + args, err := ec.dir_length_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return nil + } + n := next + next = func(ctx context.Context) (interface{}, error) { + return ec.directives.Length(ctx, obj, n, args["min"].(int), args["max"].(*int), args["message"].(string)) + } + } + case "range": + if ec.directives.Range != nil { + rawArgs := d.ArgumentMap(ec.Variables) + args, err := ec.dir_range_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return nil + } + n := next + next = func(ctx context.Context) (interface{}, error) { + return ec.directives.Range(ctx, obj, n, args["min"].(*int), args["max"].(*int), args["message"].(*string)) + } + } + } } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil - }) - if resTmp == nil { - return graphql.Null + res, err := ec.ResolverMiddleware(ctx, next) + if err != nil { + ec.Error(ctx, err) + return nil } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return res +} - if res == nil { - return graphql.Null +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") } - - return ec.___Type(ctx, field.Selections, res) + return introspection.WrapSchema(parsedSchema), nil } -// nolint: vetshadow -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") } - res := resTmp.([]introspection.Directive) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil +} - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup +var parsedSchema = gqlparser.MustLoadSchema( + &ast.Source{Name: "schema.graphql", Input: `type Query { + invalidIdentifier: InvalidIdentifier + collision: It + mapInput(input: Changes): Boolean + recursive(input: RecursiveInputSlice): Boolean + nestedInputs(input: [[OuterInput]] = [[{inner: {id: 1}}]]): Boolean + nestedOutputs: [[OuterObject]] + keywords(input: Keywords): Boolean! + shapes: [Shape] + errorBubble: Error + modelMethods: ModelMethods + valid: String! + user(id: Int!): User! + nullableArg(arg: Int = 123): String + directiveArg(arg: String! @length(min:1, max: 255, message: "invalid length")): String + directiveNullableArg(arg: Int @range(min:0), arg2: Int @range): String + directiveInputNullable(arg: InputDirectives): String + directiveInput(arg: InputDirectives!): String +} - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } +type Subscription { + updated: String! + initPayload: String! +} - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { +type User { + id: Int! + friends: [User!]! +} - return ec.___Directive(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } +type Error { + id: ID! + errorOnNonRequiredField: String + errorOnRequiredField: String! + nilOnRequiredField: String! +} - } - wg.Wait() - return arr1 +type ModelMethods { + resolverField: Boolean! + noContext: Boolean! + withContext: Boolean! } -var __TypeImplementors = []string{"__Type"} +type InvalidIdentifier { + id: Int! +} -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __TypeImplementors) +type It { + id: ID! +} - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Type") - case "kind": - out.Values[i] = ec.___Type_kind(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "name": - out.Values[i] = ec.___Type_name(ctx, field, obj) - case "description": - out.Values[i] = ec.___Type_description(ctx, field, obj) - case "fields": - out.Values[i] = ec.___Type_fields(ctx, field, obj) - case "interfaces": - out.Values[i] = ec.___Type_interfaces(ctx, field, obj) - case "possibleTypes": - out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) - case "enumValues": - out.Values[i] = ec.___Type_enumValues(ctx, field, obj) - case "inputFields": - out.Values[i] = ec.___Type_inputFields(ctx, field, obj) - case "ofType": - out.Values[i] = ec.___Type_ofType(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out +input Changes { + a: Int + b: Int } -// nolint: vetshadow -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) +input RecursiveInputSlice { + self: [RecursiveInputSlice!] } -// nolint: vetshadow -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +input InnerInput { + id:Int! +} - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) +input OuterInput { + inner: InnerInput! } -// nolint: vetshadow -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) +input InputDirectives { + text: String! @length(min: 0, max: 7, message: "not valid") + inner: InnerDirectives! + innerNullable: InnerDirectives } -// nolint: vetshadow -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_fields_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Fields(args["includeDeprecated"].(bool)), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Field) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +input InnerDirectives { + message: String! @length(min: 1, message: "not valid") +} - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup +type OuterObject { + inner: InnerObject! +} - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } +type InnerObject { + id: Int! +} - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { +input Keywords { + break: String! + default: String! + func: String! + interface: String! + select: String! + case: String! + defer: String! + go: String! + map: String! + struct: String! + chan: String! + else: String! + goto: String! + package: String! + switch: String! + const: String! + fallthrough: String! + if: String! + range: String! + type: String! + continue: String! + for: String! + import: String! + return: String! + var: String! +} - return ec.___Field(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } +extend type Query { + keywordArgs( + break: String!, + default: String!, + func: String!, + interface: String!, + select: String!, + case: String!, + defer: String!, + go: String!, + map: String!, + struct: String!, + chan: String!, + else: String!, + goto: String!, + package: String!, + switch: String!, + const: String!, + fallthrough: String!, + if: String!, + range: String!, + type: String!, + continue: String!, + for: String!, + import: String!, + return: String!, + var: String!, + ): Boolean! +} - } - wg.Wait() - return arr1 +interface Shape { + area: Float +} +type Circle implements Shape { + radius: Float + area: Float +} +type Rectangle implements Shape { + length: Float + width: Float + area: Float } +union ShapeUnion = Circle | Rectangle -// nolint: vetshadow -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +type ForcedResolver { + field: Circle +} - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup +type EmbeddedPointer { + ID: String + Title: String +} - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } +directive @length(min: Int!, max: Int, message: String!) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION +directive @range(min: Int = 0, max: Int, message: String) on ARGUMENT_DEFINITION - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { +enum Status { + OK + ERROR +} +`}, +) - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } +// ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + } + return handleFunc[0](ctx, chainHandler) + } } - wg.Wait() - return arr1 -} -// nolint: vetshadow -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + if n == 1 { + return handleFunc[0] } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil - }) - if resTmp == nil { - return graphql.Null + + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) } - res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +} - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup +// endregion ************************** generated.gotpl *************************** - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } +// region **************************** input.gotpl ***************************** - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { +func (e *executableSchema) ChangesMiddleware(ctx context.Context, obj *map[string]interface{}) (*map[string]interface{}, error) { - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } + return obj, nil +} + +func UnmarshalInnerDirectives(v interface{}) (InnerDirectives, error) { + var it InnerDirectives + var asMap = v.(map[string]interface{}) + for k, v := range asMap { + switch k { + case "message": + var err error + it.Message, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + } } - wg.Wait() - return arr1 + + return it, nil } -// nolint: vetshadow -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_enumValues_args(ctx, rawArgs) +func (e *executableSchema) InnerDirectivesMiddleware(ctx context.Context, obj *InnerDirectives) (*InnerDirectives, error) { + + cMessage, err := chainFieldMiddleware( + []graphql.FieldMiddleware{ + func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { + return e.directives.Length(ctx, obj.Message, n, 1, nil, "not valid") + }, + }..., + )(ctx, func(ctx context.Context) (interface{}, error) { + return obj.Message, nil + }) if err != nil { - ec.Error(ctx, err) - return graphql.Null + return obj, err } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.EnumValues(args["includeDeprecated"].(bool)), nil - }) - if resTmp == nil { - return graphql.Null + + if data, ok := cMessage.(string); ok { + obj.Message = data + } else { + return obj, errors.New("expected Message to be string") } - res := resTmp.([]introspection.EnumValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + return obj, nil +} - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } +func UnmarshalInnerInput(v interface{}) (InnerInput, error) { + var it InnerInput + var asMap = v.(map[string]interface{}) - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() + for k, v := range asMap { + switch k { + case "id": + var err error + it.ID, err = graphql.UnmarshalInt(v) + if err != nil { + return it, err } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) } - } - wg.Wait() - return arr1 + + return it, nil } -// nolint: vetshadow -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +func (e *executableSchema) InnerInputMiddleware(ctx context.Context, obj *InnerInput) (*InnerInput, error) { - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -func (ec *executionContext) _Shape(ctx context.Context, sel ast.SelectionSet, obj *Shape) graphql.Marshaler { - switch obj := (*obj).(type) { - case nil: - return graphql.Null - case *Circle: - return ec._Circle(ctx, sel, obj) - case *Rectangle: - return ec._Rectangle(ctx, sel, obj) - default: - panic(fmt.Errorf("unexpected type %T", obj)) - } -} - -func (ec *executionContext) _ShapeUnion(ctx context.Context, sel ast.SelectionSet, obj *ShapeUnion) graphql.Marshaler { - switch obj := (*obj).(type) { - case nil: - return graphql.Null - case *Circle: - return ec._Circle(ctx, sel, obj) - case *Rectangle: - return ec._Rectangle(ctx, sel, obj) - default: - panic(fmt.Errorf("unexpected type %T", obj)) - } -} - -func (e *executableSchema) ChangesMiddleware(ctx context.Context, obj *map[string]interface{}) (*map[string]interface{}, error) { - - return obj, nil -} - -func UnmarshalInnerDirectives(v interface{}) (InnerDirectives, error) { - var it InnerDirectives - var asMap = v.(map[string]interface{}) - - for k, v := range asMap { - switch k { - case "message": - var err error - it.Message, err = graphql.UnmarshalString(v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -func (e *executableSchema) InnerDirectivesMiddleware(ctx context.Context, obj *InnerDirectives) (*InnerDirectives, error) { - - cMessage, err := chainFieldMiddleware( - []graphql.FieldMiddleware{ - func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { - return e.directives.Length(ctx, obj.Message, n, 1, nil, "not valid") - }, - }..., - )(ctx, func(ctx context.Context) (interface{}, error) { - return obj.Message, nil - }) - if err != nil { - return obj, err - } - - if data, ok := cMessage.(string); ok { - obj.Message = data - } else { - return obj, errors.New("expected Message to be string") - } - - return obj, nil -} - -func UnmarshalInnerInput(v interface{}) (InnerInput, error) { - var it InnerInput - var asMap = v.(map[string]interface{}) - - for k, v := range asMap { - switch k { - case "id": - var err error - it.ID, err = graphql.UnmarshalInt(v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -func (e *executableSchema) InnerInputMiddleware(ctx context.Context, obj *InnerInput) (*InnerInput, error) { - - return obj, nil -} + return obj, nil +} func UnmarshalInputDirectives(v interface{}) (InputDirectives, error) { var it InputDirectives @@ -4930,354 +4419,885 @@ func UnmarshalKeywords(v interface{}) (Keywords, error) { } } } - - return it, nil + + return it, nil +} + +func (e *executableSchema) KeywordsMiddleware(ctx context.Context, obj *Keywords) (*Keywords, error) { + + return obj, nil +} + +func UnmarshalOuterInput(v interface{}) (OuterInput, error) { + var it OuterInput + var asMap = v.(map[string]interface{}) + + for k, v := range asMap { + switch k { + case "inner": + var err error + it.Inner, err = UnmarshalInnerInput(v) + if err != nil { + return it, err + } + } + } + + return it, nil +} + +func (e *executableSchema) OuterInputMiddleware(ctx context.Context, obj *OuterInput) (*OuterInput, error) { + + mInnerInput1, err := e.InnerInputMiddleware(ctx, &obj.Inner) + if err != nil { + return nil, err + } + obj.Inner = *mInnerInput1 + return obj, nil +} + +func UnmarshalRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { + var it RecursiveInputSlice + var asMap = v.(map[string]interface{}) + + for k, v := range asMap { + switch k { + case "self": + var err error + var rawIf1 []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + rawIf1 = tmp1 + } else { + rawIf1 = []interface{}{v} + } + } + it.Self = make([]RecursiveInputSlice, len(rawIf1)) + for idx1 := range rawIf1 { + it.Self[idx1], err = UnmarshalRecursiveInputSlice(rawIf1[idx1]) + } + if err != nil { + return it, err + } + } + } + + return it, nil +} + +func (e *executableSchema) RecursiveInputSliceMiddleware(ctx context.Context, obj *RecursiveInputSlice) (*RecursiveInputSlice, error) { + + for idx1 := range obj.Self { + + mRecursiveInputSlice2, err := e.RecursiveInputSliceMiddleware(ctx, &obj.Self[idx1]) + if err != nil { + return nil, err + } + obj.Self[idx1] = *mRecursiveInputSlice2 + } + return obj, nil +} + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +func (ec *executionContext) _Shape(ctx context.Context, sel ast.SelectionSet, obj *Shape) graphql.Marshaler { + switch obj := (*obj).(type) { + case nil: + return graphql.Null + case *Circle: + return ec._Circle(ctx, sel, obj) + case *Rectangle: + return ec._Rectangle(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +func (ec *executionContext) _ShapeUnion(ctx context.Context, sel ast.SelectionSet, obj *ShapeUnion) graphql.Marshaler { + switch obj := (*obj).(type) { + case nil: + return graphql.Null + case *Circle: + return ec._Circle(ctx, sel, obj) + case *Rectangle: + return ec._Rectangle(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +var circleImplementors = []string{"Circle", "Shape"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Circle(ctx context.Context, sel ast.SelectionSet, obj *Circle) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, circleImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Circle") + case "radius": + out.Values[i] = ec._Circle_radius(ctx, field, obj) + case "area": + out.Values[i] = ec._Circle_area(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var embeddedPointerImplementors = []string{"EmbeddedPointer"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _EmbeddedPointer(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedPointerModel) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, embeddedPointerImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("EmbeddedPointer") + case "ID": + out.Values[i] = ec._EmbeddedPointer_ID(ctx, field, obj) + case "Title": + out.Values[i] = ec._EmbeddedPointer_Title(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var errorImplementors = []string{"Error"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Error(ctx context.Context, sel ast.SelectionSet, obj *Error) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, errorImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Error") + case "id": + out.Values[i] = ec._Error_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "errorOnNonRequiredField": + out.Values[i] = ec._Error_errorOnNonRequiredField(ctx, field, obj) + case "errorOnRequiredField": + out.Values[i] = ec._Error_errorOnRequiredField(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "nilOnRequiredField": + out.Values[i] = ec._Error_nilOnRequiredField(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var forcedResolverImplementors = []string{"ForcedResolver"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _ForcedResolver(ctx context.Context, sel ast.SelectionSet, obj *ForcedResolver) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, forcedResolverImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("ForcedResolver") + case "field": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._ForcedResolver_field(ctx, field, obj) + return res + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var innerObjectImplementors = []string{"InnerObject"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _InnerObject(ctx context.Context, sel ast.SelectionSet, obj *InnerObject) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, innerObjectImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("InnerObject") + case "id": + out.Values[i] = ec._InnerObject_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var invalidIdentifierImplementors = []string{"InvalidIdentifier"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _InvalidIdentifier(ctx context.Context, sel ast.SelectionSet, obj *invalid_packagename.InvalidIdentifier) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, invalidIdentifierImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("InvalidIdentifier") + case "id": + out.Values[i] = ec._InvalidIdentifier_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var itImplementors = []string{"It"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _It(ctx context.Context, sel ast.SelectionSet, obj *introspection.It) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, itImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("It") + case "id": + out.Values[i] = ec._It_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var modelMethodsImplementors = []string{"ModelMethods"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _ModelMethods(ctx context.Context, sel ast.SelectionSet, obj *ModelMethods) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, modelMethodsImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("ModelMethods") + case "resolverField": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._ModelMethods_resolverField(ctx, field, obj) + if res == graphql.Null { + invalid = true + } + return res + }) + case "noContext": + out.Values[i] = ec._ModelMethods_noContext(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "withContext": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._ModelMethods_withContext(ctx, field, obj) + if res == graphql.Null { + invalid = true + } + return res + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out } -func (e *executableSchema) KeywordsMiddleware(ctx context.Context, obj *Keywords) (*Keywords, error) { - - return obj, nil -} +var outerObjectImplementors = []string{"OuterObject"} -func UnmarshalOuterInput(v interface{}) (OuterInput, error) { - var it OuterInput - var asMap = v.(map[string]interface{}) +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _OuterObject(ctx context.Context, sel ast.SelectionSet, obj *OuterObject) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, outerObjectImplementors) - for k, v := range asMap { - switch k { + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("OuterObject") case "inner": - var err error - it.Inner, err = UnmarshalInnerInput(v) - if err != nil { - return it, err + out.Values[i] = ec._OuterObject_inner(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true } + default: + panic("unknown field " + strconv.Quote(field.Name)) } } - - return it, nil -} - -func (e *executableSchema) OuterInputMiddleware(ctx context.Context, obj *OuterInput) (*OuterInput, error) { - - mInnerInput1, err := e.InnerInputMiddleware(ctx, &obj.Inner) - if err != nil { - return nil, err - } - obj.Inner = *mInnerInput1 - return obj, nil -} - -func UnmarshalRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { - var it RecursiveInputSlice - var asMap = v.(map[string]interface{}) - - for k, v := range asMap { - switch k { - case "self": - var err error - var rawIf1 []interface{} - if v != nil { - if tmp1, ok := v.([]interface{}); ok { - rawIf1 = tmp1 - } else { - rawIf1 = []interface{}{v} - } - } - it.Self = make([]RecursiveInputSlice, len(rawIf1)) - for idx1 := range rawIf1 { - it.Self[idx1], err = UnmarshalRecursiveInputSlice(rawIf1[idx1]) - } - if err != nil { - return it, err - } - } + out.Dispatch() + if invalid { + return graphql.Null } - - return it, nil + return out } -func (e *executableSchema) RecursiveInputSliceMiddleware(ctx context.Context, obj *RecursiveInputSlice) (*RecursiveInputSlice, error) { +var queryImplementors = []string{"Query"} - for idx1 := range obj.Self { +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, queryImplementors) - mRecursiveInputSlice2, err := e.RecursiveInputSliceMiddleware(ctx, &obj.Self[idx1]) - if err != nil { - return nil, err - } - obj.Self[idx1] = *mRecursiveInputSlice2 - } - return obj, nil -} + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "Query", + }) -func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - rctx := graphql.GetResolverContext(ctx) - for _, d := range rctx.Field.Definition.Directives { - switch d.Name { - case "length": - if ec.directives.Length != nil { - rawArgs := d.ArgumentMap(ec.Variables) - args, err := ec.dir_length_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return nil + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Query") + case "invalidIdentifier": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_invalidIdentifier(ctx, field) + return res + }) + case "collision": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_collision(ctx, field) + return res + }) + case "mapInput": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_mapInput(ctx, field) + return res + }) + case "recursive": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_recursive(ctx, field) + return res + }) + case "nestedInputs": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_nestedInputs(ctx, field) + return res + }) + case "nestedOutputs": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_nestedOutputs(ctx, field) + return res + }) + case "keywords": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_keywords(ctx, field) + if res == graphql.Null { + invalid = true } - n := next - next = func(ctx context.Context) (interface{}, error) { - return ec.directives.Length(ctx, obj, n, args["min"].(int), args["max"].(*int), args["message"].(string)) + return res + }) + case "shapes": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_shapes(ctx, field) + return res + }) + case "errorBubble": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_errorBubble(ctx, field) + return res + }) + case "modelMethods": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_modelMethods(ctx, field) + return res + }) + case "valid": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_valid(ctx, field) + if res == graphql.Null { + invalid = true } - } - case "range": - if ec.directives.Range != nil { - rawArgs := d.ArgumentMap(ec.Variables) - args, err := ec.dir_range_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return nil + return res + }) + case "user": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_user(ctx, field) + if res == graphql.Null { + invalid = true } - n := next - next = func(ctx context.Context) (interface{}, error) { - return ec.directives.Range(ctx, obj, n, args["min"].(*int), args["max"].(*int), args["message"].(*string)) + return res + }) + case "nullableArg": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_nullableArg(ctx, field) + return res + }) + case "directiveArg": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_directiveArg(ctx, field) + return res + }) + case "directiveNullableArg": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_directiveNullableArg(ctx, field) + return res + }) + case "directiveInputNullable": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_directiveInputNullable(ctx, field) + return res + }) + case "directiveInput": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_directiveInput(ctx, field) + return res + }) + case "keywordArgs": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_keywordArgs(ctx, field) + if res == graphql.Null { + invalid = true } - } + return res + }) + case "__type": + out.Values[i] = ec._Query___type(ctx, field) + case "__schema": + out.Values[i] = ec._Query___schema(ctx, field) + default: + panic("unknown field " + strconv.Quote(field.Name)) } } - res, err := ec.ResolverMiddleware(ctx, next) - if err != nil { - ec.Error(ctx, err) - return nil - } - return res -} - -func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") - } - return introspection.WrapSchema(parsedSchema), nil -} - -func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") + out.Dispatch() + if invalid { + return graphql.Null } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil -} - -var parsedSchema = gqlparser.MustLoadSchema( - &ast.Source{Name: "schema.graphql", Input: `type Query { - invalidIdentifier: InvalidIdentifier - collision: It - mapInput(input: Changes): Boolean - recursive(input: RecursiveInputSlice): Boolean - nestedInputs(input: [[OuterInput]] = [[{inner: {id: 1}}]]): Boolean - nestedOutputs: [[OuterObject]] - keywords(input: Keywords): Boolean! - shapes: [Shape] - errorBubble: Error - modelMethods: ModelMethods - valid: String! - user(id: Int!): User! - nullableArg(arg: Int = 123): String - directiveArg(arg: String! @length(min:1, max: 255, message: "invalid length")): String - directiveNullableArg(arg: Int @range(min:0), arg2: Int @range): String - directiveInputNullable(arg: InputDirectives): String - directiveInput(arg: InputDirectives!): String -} - -type Subscription { - updated: String! - initPayload: String! -} - -type User { - id: Int! - friends: [User!]! -} - -type Error { - id: ID! - errorOnNonRequiredField: String - errorOnRequiredField: String! - nilOnRequiredField: String! -} - -type ModelMethods { - resolverField: Boolean! - noContext: Boolean! - withContext: Boolean! + return out } -type InvalidIdentifier { - id: Int! -} +var rectangleImplementors = []string{"Rectangle", "Shape"} -type It { - id: ID! -} +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Rectangle(ctx context.Context, sel ast.SelectionSet, obj *Rectangle) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, rectangleImplementors) -input Changes { - a: Int - b: Int + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Rectangle") + case "length": + out.Values[i] = ec._Rectangle_length(ctx, field, obj) + case "width": + out.Values[i] = ec._Rectangle_width(ctx, field, obj) + case "area": + out.Values[i] = ec._Rectangle_area(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out } -input RecursiveInputSlice { - self: [RecursiveInputSlice!] -} +var subscriptionImplementors = []string{"Subscription"} -input InnerInput { - id:Int! -} +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Subscription(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, subscriptionImplementors) + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "Subscription", + }) + if len(fields) != 1 { + ec.Errorf(ctx, "must subscribe to exactly one stream") + return nil + } -input OuterInput { - inner: InnerInput! + switch fields[0].Name { + case "updated": + return ec._Subscription_updated(ctx, fields[0]) + case "initPayload": + return ec._Subscription_initPayload(ctx, fields[0]) + default: + panic("unknown field " + strconv.Quote(fields[0].Name)) + } } -input InputDirectives { - text: String! @length(min: 0, max: 7, message: "not valid") - inner: InnerDirectives! - innerNullable: InnerDirectives -} +var userImplementors = []string{"User"} -input InnerDirectives { - message: String! @length(min: 1, message: "not valid") -} +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *User) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, userImplementors) -type OuterObject { - inner: InnerObject! + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("User") + case "id": + out.Values[i] = ec._User_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "friends": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._User_friends(ctx, field, obj) + if res == graphql.Null { + invalid = true + } + return res + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out } -type InnerObject { - id: Int! -} +var __DirectiveImplementors = []string{"__Directive"} -input Keywords { - break: String! - default: String! - func: String! - interface: String! - select: String! - case: String! - defer: String! - go: String! - map: String! - struct: String! - chan: String! - else: String! - goto: String! - package: String! - switch: String! - const: String! - fallthrough: String! - if: String! - range: String! - type: String! - continue: String! - for: String! - import: String! - return: String! - var: String! -} +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection1.Directive) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) -extend type Query { - keywordArgs( - break: String!, - default: String!, - func: String!, - interface: String!, - select: String!, - case: String!, - defer: String!, - go: String!, - map: String!, - struct: String!, - chan: String!, - else: String!, - goto: String!, - package: String!, - switch: String!, - const: String!, - fallthrough: String!, - if: String!, - range: String!, - type: String!, - continue: String!, - for: String!, - import: String!, - return: String!, - var: String!, - ): Boolean! + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out } -interface Shape { - area: Float -} -type Circle implements Shape { - radius: Float - area: Float -} -type Rectangle implements Shape { - length: Float - width: Float - area: Float -} -union ShapeUnion = Circle | Rectangle +var __EnumValueImplementors = []string{"__EnumValue"} -type ForcedResolver { - field: Circle -} +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection1.EnumValue) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) -type EmbeddedPointer { - ID: String - Title: String + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out } -directive @length(min: Int!, max: Int, message: String!) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION -directive @range(min: Int = 0, max: Int, message: String) on ARGUMENT_DEFINITION +var __FieldImplementors = []string{"__Field"} -enum Status { - OK - ERROR +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection1.Field) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __FieldImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out } -`}, -) -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) +var __InputValueImplementors = []string{"__InputValue"} - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection1.InputValue) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true } - return handleFunc[0](ctx, chainHandler) + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) } } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} - if n == 1 { - return handleFunc[0] +var __SchemaImplementors = []string{"__Schema"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection1.Schema) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null } + return out +} - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) +var __TypeImplementors = []string{"__Type"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection1.Type) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __TypeImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null } + return out } + +// endregion **************************** object.gotpl **************************** diff --git a/codegen/testserver/generated_test.go b/codegen/testserver/generated_test.go index 4280c498e87..2f60be2300e 100644 --- a/codegen/testserver/generated_test.go +++ b/codegen/testserver/generated_test.go @@ -1,3 +1,4 @@ +//go:generate rm -f resolver.go //go:generate go run ../../testdata/gqlgen.go package testserver diff --git a/codegen/testserver/models-gen.go b/codegen/testserver/models-gen.go index b358d12a397..c82c28a435d 100644 --- a/codegen/testserver/models-gen.go +++ b/codegen/testserver/models-gen.go @@ -1,5 +1,3 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - package testserver import ( diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index 99f5e3b860f..9e0bf4b3d63 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -7,6 +7,8 @@ import ( "github.com/99designs/gqlgen/codegen/testserver/invalid-packagename" ) +// THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES. + type Resolver struct{} func (r *Resolver) ForcedResolver() ForcedResolverResolver { diff --git a/codegen/util.go b/codegen/util.go index a5529c81e3f..cf9304e0fbd 100644 --- a/codegen/util.go +++ b/codegen/util.go @@ -46,44 +46,6 @@ func equalFieldName(source, target string) bool { return strings.EqualFold(source, target) } -var keywords = []string{ - "break", - "default", - "func", - "interface", - "select", - "case", - "defer", - "go", - "map", - "struct", - "chan", - "else", - "goto", - "package", - "switch", - "const", - "fallthrough", - "if", - "range", - "type", - "continue", - "for", - "import", - "return", - "var", -} - -// sanitizeArgName prevents collisions with go keywords for arguments to resolver functions -func sanitizeArgName(name string) string { - for _, k := range keywords { - if name == k { - return name + "Arg" - } - } - return name -} - func isMap(t types.Type) bool { _, isMap := t.(*types.Map) return isMap diff --git a/example/chat/generated.go b/example/chat/generated.go index 315d0b5889d..bbd5ab5cf5e 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -17,379 +17,182 @@ import ( "github.com/vektah/gqlparser/ast" ) -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } -} - -type Config struct { - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot -} - -type ResolverRoot interface { - Mutation() MutationResolver - Query() QueryResolver - Subscription() SubscriptionResolver -} +// region **************************** field.gotpl ***************************** -type DirectiveRoot struct { -} - -type ComplexityRoot struct { - Chatroom struct { - Name func(childComplexity int) int - Messages func(childComplexity int) int +// nolint: vetshadow +func (ec *executionContext) _Chatroom_name(ctx context.Context, field graphql.CollectedField, obj *Chatroom) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Chatroom", + Field: field, + Args: nil, } - - Message struct { - Id func(childComplexity int) int - Text func(childComplexity int) int - CreatedBy func(childComplexity int) int - CreatedAt func(childComplexity int) int + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - Mutation struct { - Post func(childComplexity int, text string, username string, roomName string) int +// nolint: vetshadow +func (ec *executionContext) _Chatroom_messages(ctx context.Context, field graphql.CollectedField, obj *Chatroom) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Chatroom", + Field: field, + Args: nil, } - - Query struct { - Room func(childComplexity int, name string) int + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Messages, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null } + res := resTmp.([]Message) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - Subscription struct { - MessageAdded func(childComplexity int, roomName string) int - } -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -type MutationResolver interface { - Post(ctx context.Context, text string, username string, roomName string) (Message, error) -} -type QueryResolver interface { - Room(ctx context.Context, name string) (*Chatroom, error) -} -type SubscriptionResolver interface { - MessageAdded(ctx context.Context, roomName string) (<-chan Message, error) -} + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } -func (e *executableSchema) field_Mutation_post_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["text"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } - } - args["text"] = arg0 - var arg1 string - if tmp, ok := rawArgs["username"]; ok { - var err error - arg1, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec._Message(ctx, field.Selections, &res[idx1]) + }() } - } - args["username"] = arg1 - var arg2 string - if tmp, ok := rawArgs["roomName"]; ok { - var err error - arg2, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err + if isLen1 { + f(idx1) + } else { + go f(idx1) } - } - args["roomName"] = arg2 - return args, nil + } + wg.Wait() + return arr1 } -func (e *executableSchema) field_Query_room_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err +// nolint: vetshadow +func (ec *executionContext) _Message_id(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Message", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["name"] = arg0 - return args, nil - + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalID(res) } -func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err +// nolint: vetshadow +func (ec *executionContext) _Message_text(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Message", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Text, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["name"] = arg0 - return args, nil - + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } -func (e *executableSchema) field_Subscription_messageAdded_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["roomName"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err +// nolint: vetshadow +func (ec *executionContext) _Message_createdBy(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Message", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.CreatedBy, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["roomName"] = arg0 - return args, nil - -} - -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil - -} - -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil - -} - -type executableSchema struct { - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot -} - -func (e *executableSchema) Schema() *ast.Schema { - return parsedSchema -} - -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - switch typeName + "." + field { - - case "Chatroom.name": - if e.complexity.Chatroom.Name == nil { - break - } - - return e.complexity.Chatroom.Name(childComplexity), true - - case "Chatroom.messages": - if e.complexity.Chatroom.Messages == nil { - break - } - - return e.complexity.Chatroom.Messages(childComplexity), true - - case "Message.id": - if e.complexity.Message.Id == nil { - break - } - - return e.complexity.Message.Id(childComplexity), true - - case "Message.text": - if e.complexity.Message.Text == nil { - break - } - - return e.complexity.Message.Text(childComplexity), true - - case "Message.createdBy": - if e.complexity.Message.CreatedBy == nil { - break - } - - return e.complexity.Message.CreatedBy(childComplexity), true - - case "Message.createdAt": - if e.complexity.Message.CreatedAt == nil { - break - } - - return e.complexity.Message.CreatedAt(childComplexity), true - - case "Mutation.post": - if e.complexity.Mutation.Post == nil { - break - } - - args, err := e.field_Mutation_post_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.Post(childComplexity, args["text"].(string), args["username"].(string), args["roomName"].(string)), true - - case "Query.room": - if e.complexity.Query.Room == nil { - break - } - - args, err := e.field_Query_room_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.Room(childComplexity, args["name"].(string)), true - - case "Subscription.messageAdded": - if e.complexity.Subscription.MessageAdded == nil { - break - } - - args, err := e.field_Subscription_messageAdded_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Subscription.MessageAdded(childComplexity, args["roomName"].(string)), true - - } - return 0, false -} - -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions} -} - -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Mutation(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, - } -} - -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - next := ec._Subscription(ctx, op.SelectionSet) - if ec.Errors != nil { - return graphql.OneShot(&graphql.Response{Data: []byte("null"), Errors: ec.Errors}) - } - - var buf bytes.Buffer - return func() *graphql.Response { - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - buf.Reset() - data := next() - - if data == nil { - return nil - } - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - if buf == nil { - return nil - } - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, - } - } -} - -type executionContext struct { - *graphql.RequestContext - *executableSchema -} - -var chatroomImplementors = []string{"Chatroom"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Chatroom(ctx context.Context, sel ast.SelectionSet, obj *Chatroom) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, chatroomImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Chatroom") - case "name": - out.Values[i] = ec._Chatroom_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "messages": - out.Values[i] = ec._Chatroom_messages(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _Chatroom_name(ctx context.Context, field graphql.CollectedField, obj *Chatroom) graphql.Marshaler { +func (ec *executionContext) _Message_createdAt(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Chatroom", + Object: "Message", Field: field, Args: nil, } @@ -397,7 +200,7 @@ func (ec *executionContext) _Chatroom_name(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.CreatedAt, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -405,26 +208,33 @@ func (ec *executionContext) _Chatroom_name(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.(string) + res := resTmp.(time.Time) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return graphql.MarshalTime(res) } // nolint: vetshadow -func (ec *executionContext) _Chatroom_messages(ctx context.Context, field graphql.CollectedField, obj *Chatroom) graphql.Marshaler { +func (ec *executionContext) _Mutation_post(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Chatroom", + Object: "Mutation", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_post_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Messages, nil + return ec.resolvers.Mutation().Post(rctx, args["text"].(string), args["username"].(string), args["roomName"].(string)) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -432,148 +242,157 @@ func (ec *executionContext) _Chatroom_messages(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.([]Message) + res := resTmp.(Message) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._Message(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec._Message(ctx, field.Selections, &res) } -var messageImplementors = []string{"Message"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Message(ctx context.Context, sel ast.SelectionSet, obj *Message) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, messageImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Message") - case "id": - out.Values[i] = ec._Message_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "text": - out.Values[i] = ec._Message_text(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "createdBy": - out.Values[i] = ec._Message_createdBy(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "createdAt": - out.Values[i] = ec._Message_createdAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } +// nolint: vetshadow +func (ec *executionContext) _Query_room(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - out.Dispatch() - if invalid { + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_room_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) return graphql.Null } - return out + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Room(rctx, args["name"].(string)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Chatroom) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { + return graphql.Null + } + + return ec._Chatroom(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) _Message_id(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Message", + Object: "Query", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query___type_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return ec.introspectType(args["name"].(string)) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + + if res == nil { + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) _Message_text(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Message", + Object: "Query", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Text, nil + return ec.introspectSchema() }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + + return ec.___Schema(ctx, field.Selections, res) +} + +func (ec *executionContext) _Subscription_messageAdded(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Field: field, + Args: nil, + }) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Subscription_messageAdded_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return nil + } + // FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259 + // and Tracer stack + rctx := ctx + results, err := ec.resolvers.Subscription().MessageAdded(rctx, args["roomName"].(string)) + if err != nil { + ec.Error(ctx, err) + return nil + } + return func() graphql.Marshaler { + res, ok := <-results + if !ok { + return nil + } + return graphql.WriterFunc(func(w io.Writer) { + w.Write([]byte{'{'}) + graphql.MarshalString(field.Alias).MarshalGQL(w) + w.Write([]byte{':'}) + func() graphql.Marshaler { + + return ec._Message(ctx, field.Selections, &res) + }().MarshalGQL(w) + w.Write([]byte{'}'}) + }) + } } // nolint: vetshadow -func (ec *executionContext) _Message_createdBy(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Message", + Object: "__Directive", Field: field, Args: nil, } @@ -581,7 +400,7 @@ func (ec *executionContext) _Message_createdBy(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.CreatedBy, nil + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -596,11 +415,11 @@ func (ec *executionContext) _Message_createdBy(ctx context.Context, field graphq } // nolint: vetshadow -func (ec *executionContext) _Message_createdAt(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Message", + Object: "__Directive", Field: field, Args: nil, } @@ -608,73 +427,31 @@ func (ec *executionContext) _Message_createdAt(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.CreatedAt, nil + return obj.Description, nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(time.Time) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalTime(res) -} - -var mutationImplementors = []string{"Mutation"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, mutationImplementors) - - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: "Mutation", - }) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Mutation") - case "post": - out.Values[i] = ec._Mutation_post(ctx, field) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _Mutation_post(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Mutation", + Object: "__Directive", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_post_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().Post(rctx, args["text"].(string), args["username"].(string), args["roomName"].(string)) + return obj.Locations, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -682,255 +459,138 @@ func (ec *executionContext) _Mutation_post(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.(Message) + res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec._Message(ctx, field.Selections, &res) -} + arr1 := make(graphql.Array, len(res)) -var queryImplementors = []string{"Query"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, queryImplementors) - - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: "Query", - }) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Query") - case "room": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_room(ctx, field) - return res - }) - case "__type": - out.Values[i] = ec._Query___type(ctx, field) - case "__schema": - out.Values[i] = ec._Query___schema(ctx, field) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { + return graphql.MarshalString(res[idx1]) + }() } - return out + + return arr1 } // nolint: vetshadow -func (ec *executionContext) _Query_room(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "__Directive", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_room_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Room(rctx, args["name"].(string)) + return obj.Args, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*Chatroom) + res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - return ec._Chatroom(ctx, field.Selections, res) + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "__EnumValue", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query___type_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectType(args["name"].(string)) + return obj.Name, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "__EnumValue", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() + return obj.Description, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Schema) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Schema(ctx, field.Selections, res) -} - -var subscriptionImplementors = []string{"Subscription"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Subscription(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, subscriptionImplementors) - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: "Subscription", - }) - if len(fields) != 1 { - ec.Errorf(ctx, "must subscribe to exactly one stream") - return nil - } - - switch fields[0].Name { - case "messageAdded": - return ec._Subscription_messageAdded(ctx, fields[0]) - default: - panic("unknown field " + strconv.Quote(fields[0].Name)) - } -} - -func (ec *executionContext) _Subscription_messageAdded(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Field: field, - Args: nil, - }) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Subscription_messageAdded_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return nil - } - // FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259 - // and Tracer stack - rctx := ctx - results, err := ec.resolvers.Subscription().MessageAdded(rctx, args["roomName"].(string)) - if err != nil { - ec.Error(ctx, err) - return nil - } - return func() graphql.Marshaler { - res, ok := <-results - if !ok { - return nil - } - return graphql.WriterFunc(func(w io.Writer) { - w.Write([]byte{'{'}) - graphql.MarshalString(field.Alias).MarshalGQL(w) - w.Write([]byte{':'}) - func() graphql.Marshaler { - - return ec._Message(ctx, field.Selections, &res) - }().MarshalGQL(w) - w.Write([]byte{'}'}) - }) - } -} - -var __DirectiveImplementors = []string{"__Directive"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Directive") - case "name": - out.Values[i] = ec.___Directive_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___Directive_description(ctx, field, obj) - case "locations": - out.Values[i] = ec.___Directive_locations(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "args": - out.Values[i] = ec.___Directive_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "__EnumValue", Field: field, Args: nil, } @@ -938,7 +598,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.IsDeprecated(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -946,18 +606,18 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(string) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "__EnumValue", Field: field, Args: nil, } @@ -965,23 +625,27 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.DeprecationReason(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} -// nolint: vetshadow -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) +} + +// nolint: vetshadow +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "__Field", Field: field, Args: nil, } @@ -989,7 +653,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Locations, nil + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -997,27 +661,42 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr } return graphql.Null } - res := resTmp.([]string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() +// nolint: vetshadow +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, } - - return arr1 + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "__Field", Field: field, Args: nil, } @@ -1072,49 +751,47 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql return arr1 } -var __EnumValueImplementors = []string{"__EnumValue"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__EnumValue") - case "name": - out.Values[i] = ec.___EnumValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___EnumValue_description(ctx, field, obj) - case "isDeprecated": - out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "deprecationReason": - out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) +// nolint: vetshadow +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - out.Dispatch() - if invalid { + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - return out + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "__Field", Field: field, Args: nil, } @@ -1122,7 +799,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.IsDeprecated(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1130,18 +807,18 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(string) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "__Field", Field: field, Args: nil, } @@ -1149,23 +826,27 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.DeprecationReason(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "__InputValue", Field: field, Args: nil, } @@ -1173,7 +854,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1181,18 +862,18 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "__InputValue", Field: field, Args: nil, } @@ -1200,74 +881,23 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.Description, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) -} - -var __FieldImplementors = []string{"__Field"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __FieldImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Field") - case "name": - out.Values[i] = ec.___Field_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___Field_description(ctx, field, obj) - case "args": - out.Values[i] = ec.___Field_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "type": - out.Values[i] = ec.___Field_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "isDeprecated": - out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "deprecationReason": - out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__InputValue", Field: field, Args: nil, } @@ -1275,7 +905,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Type, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1283,18 +913,26 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__InputValue", Field: field, Args: nil, } @@ -1302,23 +940,27 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.DefaultValue, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Schema", Field: field, Args: nil, } @@ -1326,7 +968,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Args, nil + return obj.Types(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1334,7 +976,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1359,7 +1001,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } arr1[idx1] = func() graphql.Marshaler { - return ec.___InputValue(ctx, field.Selections, &res[idx1]) + return ec.___Type(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1374,11 +1016,11 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Schema", Field: field, Args: nil, } @@ -1386,7 +1028,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.QueryType(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1409,11 +1051,11 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Schema", Field: field, Args: nil, } @@ -1421,26 +1063,28 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.MutationType(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + + if res == nil { + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Schema", Field: field, Args: nil, } @@ -1448,64 +1092,28 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.SubscriptionType(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { return graphql.Null } - return graphql.MarshalString(*res) -} - -var __InputValueImplementors = []string{"__InputValue"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__InputValue") - case "name": - out.Values[i] = ec.___InputValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___InputValue_description(ctx, field, obj) - case "type": - out.Values[i] = ec.___InputValue_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "defaultValue": - out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Schema", Field: field, Args: nil, } @@ -1513,7 +1121,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Directives(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1521,18 +1129,51 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___Directive(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Type", Field: field, Args: nil, } @@ -1540,9 +1181,12 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.Kind(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(string) @@ -1552,11 +1196,11 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field } // nolint: vetshadow -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Type", Field: field, Args: nil, } @@ -1564,34 +1208,27 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.Name(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Type", Field: field, Args: nil, } @@ -1599,69 +1236,87 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil + return obj.Description(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - if res == nil { +// nolint: vetshadow +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_fields_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) return graphql.Null } - return graphql.MarshalString(*res) -} + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(args["includeDeprecated"].(bool)), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -var __SchemaImplementors = []string{"__Schema"} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Schema") - case "types": - out.Values[i] = ec.___Schema_types(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "queryType": - out.Values[i] = ec.___Schema_queryType(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "mutationType": - out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) - case "subscriptionType": - out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) - case "directives": - out.Values[i] = ec.___Schema_directives(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() } - default: - panic("unknown field " + strconv.Quote(field.Name)) + arr1[idx1] = func() graphql.Marshaler { + + return ec.___Field(ctx, field.Selections, &res[idx1]) + }() } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Type", Field: field, Args: nil, } @@ -1669,12 +1324,9 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Types(), nil + return obj.Interfaces(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } res := resTmp.([]introspection.Type) @@ -1717,11 +1369,11 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } // nolint: vetshadow -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Type", Field: field, Args: nil, } @@ -1729,108 +1381,12 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil + return obj.PossibleTypes(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.Directive) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1855,7 +1411,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap } arr1[idx1] = func() graphql.Marshaler { - return ec.___Directive(ctx, field.Selections, &res[idx1]) + return ec.___Type(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1869,131 +1425,8 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap return arr1 } -var __TypeImplementors = []string{"__Type"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __TypeImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Type") - case "kind": - out.Values[i] = ec.___Type_kind(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "name": - out.Values[i] = ec.___Type_name(ctx, field, obj) - case "description": - out.Values[i] = ec.___Type_description(ctx, field, obj) - case "fields": - out.Values[i] = ec.___Type_fields(ctx, field, obj) - case "interfaces": - out.Values[i] = ec.___Type_interfaces(ctx, field, obj) - case "possibleTypes": - out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) - case "enumValues": - out.Values[i] = ec.___Type_enumValues(ctx, field, obj) - case "inputFields": - out.Values[i] = ec.___Type_inputFields(ctx, field, obj) - case "ofType": - out.Values[i] = ec.___Type_ofType(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - // nolint: vetshadow -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -2003,7 +1436,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_fields_args(ctx, rawArgs) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -2012,12 +1445,12 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Fields(args["includeDeprecated"].(bool)), nil + return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.Field) + res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -2042,7 +1475,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } arr1[idx1] = func() graphql.Marshaler { - return ec.___Field(ctx, field.Selections, &res[idx1]) + return ec.___EnumValue(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -2057,7 +1490,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } // nolint: vetshadow -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -2069,12 +1502,12 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil + return obj.InputFields(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -2099,7 +1532,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq } arr1[idx1] = func() graphql.Marshaler { - return ec.___Type(ctx, field.Selections, &res[idx1]) + return ec.___InputValue(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -2114,7 +1547,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq } // nolint: vetshadow -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -2126,289 +1559,876 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil + return obj.OfType(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) + if res == nil { + return graphql.Null } - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { + return ec.___Type(ctx, field.Selections, res) +} - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } +// endregion **************************** field.gotpl ***************************** +// region ************************** generated.gotpl *************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, } - wg.Wait() - return arr1 } -// nolint: vetshadow -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, +type Config struct { + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Mutation() MutationResolver + Query() QueryResolver + Subscription() SubscriptionResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + Chatroom struct { + Name func(childComplexity int) int + Messages func(childComplexity int) int } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_enumValues_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null + + Message struct { + Id func(childComplexity int) int + Text func(childComplexity int) int + CreatedBy func(childComplexity int) int + CreatedAt func(childComplexity int) int } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.EnumValues(args["includeDeprecated"].(bool)), nil - }) - if resTmp == nil { - return graphql.Null + + Mutation struct { + Post func(childComplexity int, text string, username string, roomName string) int } - res := resTmp.([]introspection.EnumValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + Query struct { + Room func(childComplexity int, name string) int + } - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) + Subscription struct { + MessageAdded func(childComplexity int, roomName string) int } +} - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { +type MutationResolver interface { + Post(ctx context.Context, text string, username string, roomName string) (Message, error) +} +type QueryResolver interface { + Room(ctx context.Context, name string) (*Chatroom, error) +} +type SubscriptionResolver interface { + MessageAdded(ctx context.Context, roomName string) (<-chan Message, error) +} - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) - }() +func (e *executableSchema) field_Mutation_post_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["text"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } - if isLen1 { - f(idx1) - } else { - go f(idx1) + } + args["text"] = arg0 + var arg1 string + if tmp, ok := rawArgs["username"]; ok { + var err error + arg1, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } - } - wg.Wait() - return arr1 + args["username"] = arg1 + var arg2 string + if tmp, ok := rawArgs["roomName"]; ok { + var err error + arg2, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["roomName"] = arg2 + return args, nil + } -// nolint: vetshadow -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, +func (e *executableSchema) field_Query_room_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil - }) - if resTmp == nil { - return graphql.Null + args["name"] = arg0 + return args, nil + +} + +func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + args["name"] = arg0 + return args, nil - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup +} - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) +func (e *executableSchema) field_Subscription_messageAdded_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["roomName"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } + args["roomName"] = arg0 + return args, nil - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], +} + +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { + } + args["includeDeprecated"] = arg0 + return args, nil - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() +} + +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err } - if isLen1 { - f(idx1) - } else { - go f(idx1) + } + args["includeDeprecated"] = arg0 + return args, nil + +} + +type executableSchema struct { + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + switch typeName + "." + field { + + case "Chatroom.name": + if e.complexity.Chatroom.Name == nil { + break + } + + return e.complexity.Chatroom.Name(childComplexity), true + + case "Chatroom.messages": + if e.complexity.Chatroom.Messages == nil { + break + } + + return e.complexity.Chatroom.Messages(childComplexity), true + + case "Message.id": + if e.complexity.Message.Id == nil { + break + } + + return e.complexity.Message.Id(childComplexity), true + + case "Message.text": + if e.complexity.Message.Text == nil { + break + } + + return e.complexity.Message.Text(childComplexity), true + + case "Message.createdBy": + if e.complexity.Message.CreatedBy == nil { + break + } + + return e.complexity.Message.CreatedBy(childComplexity), true + + case "Message.createdAt": + if e.complexity.Message.CreatedAt == nil { + break + } + + return e.complexity.Message.CreatedAt(childComplexity), true + + case "Mutation.post": + if e.complexity.Mutation.Post == nil { + break + } + + args, err := e.field_Mutation_post_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.Post(childComplexity, args["text"].(string), args["username"].(string), args["roomName"].(string)), true + + case "Query.room": + if e.complexity.Query.Room == nil { + break + } + + args, err := e.field_Query_room_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Room(childComplexity, args["name"].(string)), true + + case "Subscription.messageAdded": + if e.complexity.Subscription.MessageAdded == nil { + break + } + + args, err := e.field_Subscription_messageAdded_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Subscription.MessageAdded(childComplexity, args["roomName"].(string)), true + + } + return 0, false +} + +func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._Query(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() + }) + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions} +} + +func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._Mutation(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() + }) + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions, + } +} + +func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + next := ec._Subscription(ctx, op.SelectionSet) + if ec.Errors != nil { + return graphql.OneShot(&graphql.Response{Data: []byte("null"), Errors: ec.Errors}) + } + + var buf bytes.Buffer + return func() *graphql.Response { + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + buf.Reset() + data := next() + + if data == nil { + return nil + } + data.MarshalGQL(&buf) + return buf.Bytes() + }) + + if buf == nil { + return nil + } + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions, + } + } +} + +type executionContext struct { + *graphql.RequestContext + *executableSchema +} + +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + res, err := ec.ResolverMiddleware(ctx, next) + if err != nil { + ec.Error(ctx, err) + return nil + } + return res +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(parsedSchema), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil +} + +var parsedSchema = gqlparser.MustLoadSchema( + &ast.Source{Name: "schema.graphql", Input: `type Chatroom { + name: String! + messages: [Message!]! +} + +type Message { + id: ID! + text: String! + createdBy: String! + createdAt: Time! +} + +type Query { + room(name:String!): Chatroom +} + +type Mutation { + post(text: String!, username: String!, roomName: String!): Message! +} + +type Subscription { + messageAdded(roomName: String!): Message! +} + +scalar Time +`}, +) + +// ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + + } + return handleFunc[0](ctx, chainHandler) + } + } + + if n == 1 { + return handleFunc[0] + } + + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) + } +} + +// endregion ************************** generated.gotpl *************************** + +// region **************************** input.gotpl ***************************** + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +var chatroomImplementors = []string{"Chatroom"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Chatroom(ctx context.Context, sel ast.SelectionSet, obj *Chatroom) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, chatroomImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Chatroom") + case "name": + out.Values[i] = ec._Chatroom_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "messages": + out.Values[i] = ec._Chatroom_messages(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var messageImplementors = []string{"Message"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Message(ctx context.Context, sel ast.SelectionSet, obj *Message) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, messageImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Message") + case "id": + out.Values[i] = ec._Message_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "text": + out.Values[i] = ec._Message_text(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "createdBy": + out.Values[i] = ec._Message_createdBy(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "createdAt": + out.Values[i] = ec._Message_createdAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var mutationImplementors = []string{"Mutation"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, mutationImplementors) + + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "Mutation", + }) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Mutation") + case "post": + out.Values[i] = ec._Mutation_post(ctx, field) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var queryImplementors = []string{"Query"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, queryImplementors) + + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "Query", + }) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Query") + case "room": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_room(ctx, field) + return res + }) + case "__type": + out.Values[i] = ec._Query___type(ctx, field) + case "__schema": + out.Values[i] = ec._Query___schema(ctx, field) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var subscriptionImplementors = []string{"Subscription"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Subscription(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, subscriptionImplementors) + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "Subscription", + }) + if len(fields) != 1 { + ec.Errorf(ctx, "must subscribe to exactly one stream") + return nil + } + + switch fields[0].Name { + case "messageAdded": + return ec._Subscription_messageAdded(ctx, fields[0]) + default: + panic("unknown field " + strconv.Quote(fields[0].Name)) + } +} + +var __DirectiveImplementors = []string{"__Directive"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __EnumValueImplementors = []string{"__EnumValue"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) } - - } - wg.Wait() - return arr1 -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil - }) - if resTmp == nil { + out.Dispatch() + if invalid { return graphql.Null } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return out +} - if res == nil { - return graphql.Null - } +var __FieldImplementors = []string{"__Field"} - return ec.___Type(ctx, field.Selections, res) -} +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __FieldImplementors) -func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) } - }() - res, err := ec.ResolverMiddleware(ctx, next) - if err != nil { - ec.Error(ctx, err) - return nil } - return res -} - -func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") + out.Dispatch() + if invalid { + return graphql.Null } - return introspection.WrapSchema(parsedSchema), nil + return out } -func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") - } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil -} +var __InputValueImplementors = []string{"__InputValue"} -var parsedSchema = gqlparser.MustLoadSchema( - &ast.Source{Name: "schema.graphql", Input: `type Chatroom { - name: String! - messages: [Message!]! -} +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) -type Message { - id: ID! - text: String! - createdBy: String! - createdAt: Time! + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out } -type Query { - room(name:String!): Chatroom -} +var __SchemaImplementors = []string{"__Schema"} -type Mutation { - post(text: String!, username: String!, roomName: String!): Message! -} +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) -type Subscription { - messageAdded(roomName: String!): Message! + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out } -scalar Time -`}, -) - -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) +var __TypeImplementors = []string{"__Type"} - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __TypeImplementors) + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true } - return handleFunc[0](ctx, chainHandler) + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) } } - - if n == 1 { - return handleFunc[0] - } - - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) + out.Dispatch() + if invalid { + return graphql.Null } + return out } + +// endregion **************************** object.gotpl **************************** diff --git a/example/chat/models_gen.go b/example/chat/models_gen.go index 27fbb4a9223..b35be48c938 100644 --- a/example/chat/models_gen.go +++ b/example/chat/models_gen.go @@ -1,5 +1,3 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - package chat import ( diff --git a/example/config/generated.go b/example/config/generated.go index 8c5d2bedc37..994710ed14c 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -15,309 +15,236 @@ import ( "github.com/vektah/gqlparser/ast" ) -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } -} +// region **************************** field.gotpl ***************************** -type Config struct { - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot -} - -type ResolverRoot interface { - Mutation() MutationResolver - Query() QueryResolver - Todo() TodoResolver -} +// nolint: vetshadow +func (ec *executionContext) _Mutation_createTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Mutation", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_createTodo_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateTodo(rctx, args["input"].(NewTodo)) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(Todo) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -type DirectiveRoot struct { + return ec._Todo(ctx, field.Selections, &res) } -type ComplexityRoot struct { - Mutation struct { - CreateTodo func(childComplexity int, input NewTodo) int +// nolint: vetshadow +func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - - Query struct { - Todos func(childComplexity int) int + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Todos(rctx) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null } + res := resTmp.([]Todo) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - Todo struct { - Id func(childComplexity int) int - DatabaseId func(childComplexity int) int - Text func(childComplexity int) int - Done func(childComplexity int) int - User func(childComplexity int) int - } + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - User struct { - Id func(childComplexity int) int - Name func(childComplexity int) int + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } -} -type MutationResolver interface { - CreateTodo(ctx context.Context, input NewTodo) (Todo, error) -} -type QueryResolver interface { - Todos(ctx context.Context) ([]Todo, error) -} -type TodoResolver interface { - ID(ctx context.Context, obj *Todo) (string, error) -} - -func (e *executableSchema) field_Mutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 NewTodo - if tmp, ok := rawArgs["input"]; ok { - var err error - arg0, err = UnmarshalNewTodo(tmp) - if err != nil { - return nil, err + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - mNewTodo1, err := e.NewTodoMiddleware(ctx, &arg0) - if err != nil { - return nil, err + return ec._Todo(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) } - arg0 = *mNewTodo1 - } - args["input"] = arg0 - return args, nil + } + wg.Wait() + return arr1 } -func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query___type_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(args["name"].(string)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { + return graphql.Null } - args["name"] = arg0 - return args, nil + return ec.___Type(ctx, field.Selections, res) } -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["includeDeprecated"] = arg0 - return args, nil + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + if res == nil { + return graphql.Null + } + + return ec.___Schema(ctx, field.Selections, res) } -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err +// nolint: vetshadow +func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Todo", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Todo().ID(rctx, obj) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["includeDeprecated"] = arg0 - return args, nil - + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalID(res) } -type executableSchema struct { - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot -} - -func (e *executableSchema) Schema() *ast.Schema { - return parsedSchema -} - -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - switch typeName + "." + field { - - case "Mutation.createTodo": - if e.complexity.Mutation.CreateTodo == nil { - break - } - - args, err := e.field_Mutation_createTodo_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.CreateTodo(childComplexity, args["input"].(NewTodo)), true - - case "Query.todos": - if e.complexity.Query.Todos == nil { - break - } - - return e.complexity.Query.Todos(childComplexity), true - - case "Todo.id": - if e.complexity.Todo.Id == nil { - break - } - - return e.complexity.Todo.Id(childComplexity), true - - case "Todo.databaseId": - if e.complexity.Todo.DatabaseId == nil { - break - } - - return e.complexity.Todo.DatabaseId(childComplexity), true - - case "Todo.text": - if e.complexity.Todo.Text == nil { - break - } - - return e.complexity.Todo.Text(childComplexity), true - - case "Todo.done": - if e.complexity.Todo.Done == nil { - break - } - - return e.complexity.Todo.Done(childComplexity), true - - case "Todo.user": - if e.complexity.Todo.User == nil { - break - } - - return e.complexity.Todo.User(childComplexity), true - - case "User.id": - if e.complexity.User.Id == nil { - break - } - - return e.complexity.User.Id(childComplexity), true - - case "User.name": - if e.complexity.User.Name == nil { - break - } - - return e.complexity.User.Name(childComplexity), true - - } - return 0, false -} - -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions} -} - -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Mutation(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, +// nolint: vetshadow +func (ec *executionContext) _Todo_databaseId(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Todo", + Field: field, + Args: nil, } -} - -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) -} - -type executionContext struct { - *graphql.RequestContext - *executableSchema -} - -var mutationImplementors = []string{"Mutation"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, mutationImplementors) - - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: "Mutation", + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DatabaseID, nil }) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Mutation") - case "createTodo": - out.Values[i] = ec._Mutation_createTodo(ctx, field) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } - } - out.Dispatch() - if invalid { return graphql.Null } - return out + res := resTmp.(int) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalInt(res) } // nolint: vetshadow -func (ec *executionContext) _Mutation_createTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Mutation", + Object: "Todo", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_createTodo_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateTodo(rctx, args["input"].(NewTodo)) + return obj.Description, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -325,67 +252,53 @@ func (ec *executionContext) _Mutation_createTodo(ctx context.Context, field grap } return graphql.Null } - res := resTmp.(Todo) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._Todo(ctx, field.Selections, &res) + return graphql.MarshalString(res) } -var queryImplementors = []string{"Query"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, queryImplementors) - - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: "Query", +// nolint: vetshadow +func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Todo", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Done, nil }) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Query") - case "todos": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_todos(ctx, field) - if res == graphql.Null { - invalid = true - } - return res - }) - case "__type": - out.Values[i] = ec._Query___type(ctx, field) - case "__schema": - out.Values[i] = ec._Query___schema(ctx, field) - default: - panic("unknown field " + strconv.Quote(field.Name)) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } - } - out.Dispatch() - if invalid { return graphql.Null } - return out + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "Todo", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Todos(rctx) + return obj.User, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -393,168 +306,124 @@ func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.([]Todo) + res := resTmp.(User) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + return ec._User(ctx, field.Selections, &res) +} - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) +// nolint: vetshadow +func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "User", + Field: field, + Args: nil, } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._Todo(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } - + return graphql.Null } - wg.Wait() - return arr1 + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalID(res) } // nolint: vetshadow -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "User", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query___type_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectType(args["name"].(string)) + return obj.FullName(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "__Directive", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() + return obj.Name, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Schema) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Schema(ctx, field.Selections, res) + return graphql.MarshalString(res) } -var todoImplementors = []string{"Todo"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, todoImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Todo") - case "id": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Todo_id(ctx, field, obj) - if res == graphql.Null { - invalid = true - } - return res - }) - case "databaseId": - out.Values[i] = ec._Todo_databaseId(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "text": - out.Values[i] = ec._Todo_text(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "done": - out.Values[i] = ec._Todo_done(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "user": - out.Values[i] = ec._Todo_user(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } +// nolint: vetshadow +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Field: field, + Args: nil, } - out.Dispatch() - if invalid { + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if resTmp == nil { return graphql.Null } - return out + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Todo", + Object: "__Directive", Field: field, Args: nil, } @@ -562,7 +431,7 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Todo().ID(rctx, obj) + return obj.Locations, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -570,18 +439,27 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + + arr1 := make(graphql.Array, len(res)) + + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { + return graphql.MarshalString(res[idx1]) + }() + } + + return arr1 } // nolint: vetshadow -func (ec *executionContext) _Todo_databaseId(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Todo", + Object: "__Directive", Field: field, Args: nil, } @@ -589,7 +467,7 @@ func (ec *executionContext) _Todo_databaseId(ctx context.Context, field graphql. ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DatabaseID, nil + return obj.Args, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -597,18 +475,51 @@ func (ec *executionContext) _Todo_databaseId(ctx context.Context, field graphql. } return graphql.Null } - res := resTmp.(int) + res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) + + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Todo", + Object: "__EnumValue", Field: field, Args: nil, } @@ -616,7 +527,7 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -631,11 +542,11 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec } // nolint: vetshadow -func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Todo", + Object: "__EnumValue", Field: field, Args: nil, } @@ -643,26 +554,23 @@ func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.Collec ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Done, nil + return obj.Description, nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Todo", + Object: "__EnumValue", Field: field, Args: nil, } @@ -670,7 +578,7 @@ func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.Collec ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.User, nil + return obj.IsDeprecated(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -678,79 +586,18 @@ func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.Collec } return graphql.Null } - res := resTmp.(User) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._User(ctx, field.Selections, &res) -} - -var userImplementors = []string{"User"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *User) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, userImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("User") - case "id": - out.Values[i] = ec._User_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "name": - out.Values[i] = ec._User_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - -// nolint: vetshadow -func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "User", + Object: "__EnumValue", Field: field, Args: nil, } @@ -758,66 +605,27 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.FullName(), nil + return obj.DeprecationReason(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -var __DirectiveImplementors = []string{"__Directive"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Directive") - case "name": - out.Values[i] = ec.___Directive_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___Directive_description(ctx, field, obj) - case "locations": - out.Values[i] = ec.___Directive_locations(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "args": - out.Values[i] = ec.___Directive_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { + if res == nil { return graphql.Null } - return out + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "__Field", Field: field, Args: nil, } @@ -840,11 +648,11 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql } // nolint: vetshadow -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "__Field", Field: field, Args: nil, } @@ -864,47 +672,11 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field } // nolint: vetshadow -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Locations, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 -} - -// nolint: vetshadow -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "__Field", Field: field, Args: nil, } @@ -959,49 +731,12 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql return arr1 } -var __EnumValueImplementors = []string{"__EnumValue"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__EnumValue") - case "name": - out.Values[i] = ec.___EnumValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___EnumValue_description(ctx, field, obj) - case "isDeprecated": - out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "deprecationReason": - out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - // nolint: vetshadow -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "__Field", Field: field, Args: nil, } @@ -1009,7 +744,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Type, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1017,42 +752,26 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} -// nolint: vetshadow -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "__Field", Field: field, Args: nil, } @@ -1075,11 +794,11 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "__Field", Field: field, Args: nil, } @@ -1102,59 +821,12 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, return graphql.MarshalString(*res) } -var __FieldImplementors = []string{"__Field"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __FieldImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Field") - case "name": - out.Values[i] = ec.___Field_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___Field_description(ctx, field, obj) - case "args": - out.Values[i] = ec.___Field_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "type": - out.Values[i] = ec.___Field_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "isDeprecated": - out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "deprecationReason": - out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - // nolint: vetshadow -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__InputValue", Field: field, Args: nil, } @@ -1177,11 +849,11 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__InputValue", Field: field, Args: nil, } @@ -1201,11 +873,11 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap } // nolint: vetshadow -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__InputValue", Field: field, Args: nil, } @@ -1213,7 +885,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Args, nil + return obj.Type, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1221,7 +893,70 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) +} + +// nolint: vetshadow +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) +} + +// nolint: vetshadow +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1246,7 +981,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } arr1[idx1] = func() graphql.Marshaler { - return ec.___InputValue(ctx, field.Selections, &res[idx1]) + return ec.___Type(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1261,11 +996,11 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Schema", Field: field, Args: nil, } @@ -1273,7 +1008,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.QueryType(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1296,11 +1031,11 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Schema", Field: field, Args: nil, } @@ -1308,26 +1043,28 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.MutationType(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + + if res == nil { + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Schema", Field: field, Args: nil, } @@ -1335,64 +1072,28 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.SubscriptionType(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { return graphql.Null } - return graphql.MarshalString(*res) -} - -var __InputValueImplementors = []string{"__InputValue"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__InputValue") - case "name": - out.Values[i] = ec.___InputValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___InputValue_description(ctx, field, obj) - case "type": - out.Values[i] = ec.___InputValue_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "defaultValue": - out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Schema", Field: field, Args: nil, } @@ -1400,7 +1101,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Directives(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1408,18 +1109,51 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___Directive(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Type", Field: field, Args: nil, } @@ -1427,9 +1161,12 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.Kind(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(string) @@ -1439,11 +1176,11 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field } // nolint: vetshadow -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Type", Field: field, Args: nil, } @@ -1451,34 +1188,27 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.Name(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Type", Field: field, Args: nil, } @@ -1486,85 +1216,43 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil + return obj.Description(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) -} - -var __SchemaImplementors = []string{"__Schema"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Schema") - case "types": - out.Values[i] = ec.___Schema_types(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "queryType": - out.Values[i] = ec.___Schema_queryType(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "mutationType": - out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) - case "subscriptionType": - out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) - case "directives": - out.Values[i] = ec.___Schema_directives(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Type", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_fields_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Types(), nil + return obj.Fields(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1589,7 +1277,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } arr1[idx1] = func() graphql.Marshaler { - return ec.___Type(ctx, field.Selections, &res[idx1]) + return ec.___Field(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1604,11 +1292,11 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } // nolint: vetshadow -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Type", Field: field, Args: nil, } @@ -1616,34 +1304,56 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil + return obj.Interfaces(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - return ec.___Type(ctx, field.Selections, res) + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Type", Field: field, Args: nil, } @@ -1651,57 +1361,120 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil + return obj.PossibleTypes(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - return ec.___Type(ctx, field.Selections, res) + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Type", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil + return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - return ec.___Type(ctx, field.Selections, res) + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___EnumValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Type", Field: field, Args: nil, } @@ -1709,15 +1482,12 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil + return obj.InputFields(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]introspection.Directive) + res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1742,7 +1512,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap } arr1[idx1] = func() graphql.Marshaler { - return ec.___Directive(ctx, field.Selections, &res[idx1]) + return ec.___InputValue(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1756,576 +1526,826 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap return arr1 } -var __TypeImplementors = []string{"__Type"} +// nolint: vetshadow +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __TypeImplementors) + if res == nil { + return graphql.Null + } - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Type") - case "kind": - out.Values[i] = ec.___Type_kind(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "name": - out.Values[i] = ec.___Type_name(ctx, field, obj) - case "description": - out.Values[i] = ec.___Type_description(ctx, field, obj) - case "fields": - out.Values[i] = ec.___Type_fields(ctx, field, obj) - case "interfaces": - out.Values[i] = ec.___Type_interfaces(ctx, field, obj) - case "possibleTypes": - out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) - case "enumValues": - out.Values[i] = ec.___Type_enumValues(ctx, field, obj) - case "inputFields": - out.Values[i] = ec.___Type_inputFields(ctx, field, obj) - case "ofType": - out.Values[i] = ec.___Type_ofType(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + return ec.___Type(ctx, field.Selections, res) } -// nolint: vetshadow -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null +// endregion **************************** field.gotpl ***************************** + +// region ************************** generated.gotpl *************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) } -// nolint: vetshadow -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +type Config struct { + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) +type ResolverRoot interface { + Mutation() MutationResolver + Query() QueryResolver + Todo() TodoResolver } -// nolint: vetshadow -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) +type DirectiveRoot struct { } -// nolint: vetshadow -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_fields_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null +type ComplexityRoot struct { + Mutation struct { + CreateTodo func(childComplexity int, input NewTodo) int } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Fields(args["includeDeprecated"].(bool)), nil - }) - if resTmp == nil { - return graphql.Null + + Query struct { + Todos func(childComplexity int) int } - res := resTmp.([]introspection.Field) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + Todo struct { + Id func(childComplexity int) int + DatabaseId func(childComplexity int) int + Text func(childComplexity int) int + Done func(childComplexity int) int + User func(childComplexity int) int + } - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) + User struct { + Id func(childComplexity int) int + Name func(childComplexity int) int } +} - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { +type MutationResolver interface { + CreateTodo(ctx context.Context, input NewTodo) (Todo, error) +} +type QueryResolver interface { + Todos(ctx context.Context) ([]Todo, error) +} +type TodoResolver interface { + ID(ctx context.Context, obj *Todo) (string, error) +} - return ec.___Field(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) +func (e *executableSchema) field_Mutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 NewTodo + if tmp, ok := rawArgs["input"]; ok { + var err error + arg0, err = UnmarshalNewTodo(tmp) + if err != nil { + return nil, err } + mNewTodo1, err := e.NewTodoMiddleware(ctx, &arg0) + if err != nil { + return nil, err + } + arg0 = *mNewTodo1 } - wg.Wait() - return arr1 + args["input"] = arg0 + return args, nil + } -// nolint: vetshadow -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil - }) - if resTmp == nil { - return graphql.Null +func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + args["name"] = arg0 + return args, nil - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } +} - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { + } + args["includeDeprecated"] = arg0 + return args, nil - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } +} +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } } - wg.Wait() - return arr1 + args["includeDeprecated"] = arg0 + return args, nil + } -// nolint: vetshadow -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +type executableSchema struct { + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup +func (e *executableSchema) Schema() *ast.Schema { + return parsedSchema +} - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + switch typeName + "." + field { - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + case "Mutation.createTodo": + if e.complexity.Mutation.CreateTodo == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) + args, err := e.field_Mutation_createTodo_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - } - wg.Wait() - return arr1 -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_enumValues_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.EnumValues(args["includeDeprecated"].(bool)), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.EnumValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return e.complexity.Mutation.CreateTodo(childComplexity, args["input"].(NewTodo)), true - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + case "Query.todos": + if e.complexity.Query.Todos == nil { + break + } - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } + return e.complexity.Query.Todos(childComplexity), true - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + case "Todo.id": + if e.complexity.Todo.Id == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) + return e.complexity.Todo.Id(childComplexity), true + + case "Todo.databaseId": + if e.complexity.Todo.DatabaseId == nil { + break } - } - wg.Wait() - return arr1 -} + return e.complexity.Todo.DatabaseId(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + case "Todo.text": + if e.complexity.Todo.Text == nil { + break + } - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + return e.complexity.Todo.Text(childComplexity), true - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } + case "Todo.done": + if e.complexity.Todo.Done == nil { + break + } - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + return e.complexity.Todo.Done(childComplexity), true + + case "Todo.user": + if e.complexity.Todo.User == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() + return e.complexity.Todo.User(childComplexity), true + + case "User.id": + if e.complexity.User.Id == nil { + break } - if isLen1 { - f(idx1) - } else { - go f(idx1) + + return e.complexity.User.Id(childComplexity), true + + case "User.name": + if e.complexity.User.Name == nil { + break } + return e.complexity.User.Name(childComplexity), true + } - wg.Wait() - return arr1 + return 0, false } -// nolint: vetshadow -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, +func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._Query(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() + }) + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions} +} + +func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._Mutation(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() + }) + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil +} + +func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { + return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) +} + +type executionContext struct { + *graphql.RequestContext + *executableSchema +} + +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + res, err := ec.ResolverMiddleware(ctx, next) + if err != nil { + ec.Error(ctx, err) + return nil + } + return res +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(parsedSchema), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil +} + +var parsedSchema = gqlparser.MustLoadSchema( + &ast.Source{Name: "schema.graphql", Input: `type Query { + todos: [Todo!]! +} + +type Mutation { + createTodo(input: NewTodo!): Todo! +} +`}, + &ast.Source{Name: "todo.graphql", Input: `type Todo { + id: ID! + databaseId: Int! + text: String! + done: Boolean! + user: User! +} + +input NewTodo { + text: String! + userId: String! +} + +`}, + &ast.Source{Name: "user.graphql", Input: `type User { + id: ID! + name: String! +} +`}, +) + +// ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + + } + return handleFunc[0](ctx, chainHandler) + } + } + + if n == 1 { + return handleFunc[0] + } + + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) + } +} + +// endregion ************************** generated.gotpl *************************** + +// region **************************** input.gotpl ***************************** + +func UnmarshalNewTodo(v interface{}) (NewTodo, error) { + var it NewTodo + var asMap = v.(map[string]interface{}) + + for k, v := range asMap { + switch k { + case "text": + var err error + it.Text, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "userId": + var err error + it.UserID, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + } + } + + return it, nil +} + +func (e *executableSchema) NewTodoMiddleware(ctx context.Context, obj *NewTodo) (*NewTodo, error) { + + return obj, nil +} + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +var mutationImplementors = []string{"Mutation"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, mutationImplementors) + + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "Mutation", }) - if resTmp == nil { + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Mutation") + case "createTodo": + out.Values[i] = ec._Mutation_createTodo(ctx, field) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var queryImplementors = []string{"Query"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, queryImplementors) + + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "Query", + }) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Query") + case "todos": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_todos(ctx, field) + if res == graphql.Null { + invalid = true + } + return res + }) + case "__type": + out.Values[i] = ec._Query___type(ctx, field) + case "__schema": + out.Values[i] = ec._Query___schema(ctx, field) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var todoImplementors = []string{"Todo"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, todoImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Todo") + case "id": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Todo_id(ctx, field, obj) + if res == graphql.Null { + invalid = true + } + return res + }) + case "databaseId": + out.Values[i] = ec._Todo_databaseId(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "text": + out.Values[i] = ec._Todo_text(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "done": + out.Values[i] = ec._Todo_done(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "user": + out.Values[i] = ec._Todo_user(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var userImplementors = []string{"User"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *User) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, userImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("User") + case "id": + out.Values[i] = ec._User_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "name": + out.Values[i] = ec._User_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { return graphql.Null } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { + return out +} + +var __DirectiveImplementors = []string{"__Directive"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __EnumValueImplementors = []string{"__EnumValue"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { return graphql.Null } - - return ec.___Type(ctx, field.Selections, res) + return out } -func UnmarshalNewTodo(v interface{}) (NewTodo, error) { - var it NewTodo - var asMap = v.(map[string]interface{}) +var __FieldImplementors = []string{"__Field"} - for k, v := range asMap { - switch k { - case "text": - var err error - it.Text, err = graphql.UnmarshalString(v) - if err != nil { - return it, err +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __FieldImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true } - case "userId": - var err error - it.UserID, err = graphql.UnmarshalString(v) - if err != nil { - return it, err + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) } } - - return it, nil + out.Dispatch() + if invalid { + return graphql.Null + } + return out } -func (e *executableSchema) NewTodoMiddleware(ctx context.Context, obj *NewTodo) (*NewTodo, error) { +var __InputValueImplementors = []string{"__InputValue"} - return obj, nil -} +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) -func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) } - }() - res, err := ec.ResolverMiddleware(ctx, next) - if err != nil { - ec.Error(ctx, err) - return nil - } - return res -} - -func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") } - return introspection.WrapSchema(parsedSchema), nil -} - -func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") + out.Dispatch() + if invalid { + return graphql.Null } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil -} - -var parsedSchema = gqlparser.MustLoadSchema( - &ast.Source{Name: "schema.graphql", Input: `type Query { - todos: [Todo!]! + return out } -type Mutation { - createTodo(input: NewTodo!): Todo! -} -`}, - &ast.Source{Name: "todo.graphql", Input: `type Todo { - id: ID! - databaseId: Int! - text: String! - done: Boolean! - user: User! -} +var __SchemaImplementors = []string{"__Schema"} -input NewTodo { - text: String! - userId: String! -} +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) -`}, - &ast.Source{Name: "user.graphql", Input: `type User { - id: ID! - name: String! + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out } -`}, -) -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) +var __TypeImplementors = []string{"__Type"} - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __TypeImplementors) + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true } - return handleFunc[0](ctx, chainHandler) + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) } } - - if n == 1 { - return handleFunc[0] - } - - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) + out.Dispatch() + if invalid { + return graphql.Null } + return out } + +// endregion **************************** object.gotpl **************************** diff --git a/example/config/models_gen.go b/example/config/models_gen.go index 056757da9f4..c749821922e 100644 --- a/example/config/models_gen.go +++ b/example/config/models_gen.go @@ -1,5 +1,3 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - package config type NewTodo struct { diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index 046d597b4cb..0bb2142832f 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -16,388 +16,262 @@ import ( "github.com/vektah/gqlparser/ast" ) -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } -} - -type Config struct { - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot -} - -type ResolverRoot interface { - Customer() CustomerResolver - Order() OrderResolver - Query() QueryResolver -} - -type DirectiveRoot struct { -} - -type ComplexityRoot struct { - Address struct { - Id func(childComplexity int) int - Street func(childComplexity int) int - Country func(childComplexity int) int - } - - Customer struct { - Id func(childComplexity int) int - Name func(childComplexity int) int - Address func(childComplexity int) int - Orders func(childComplexity int) int - } +// region **************************** field.gotpl ***************************** - Item struct { - Name func(childComplexity int) int - } - - Order struct { - Id func(childComplexity int) int - Date func(childComplexity int) int - Amount func(childComplexity int) int - Items func(childComplexity int) int - } - - Query struct { - Customers func(childComplexity int) int - Torture1d func(childComplexity int, customerIds []int) int - Torture2d func(childComplexity int, customerIds [][]int) int - } -} - -type CustomerResolver interface { - Address(ctx context.Context, obj *Customer) (*Address, error) - Orders(ctx context.Context, obj *Customer) ([]Order, error) -} -type OrderResolver interface { - Items(ctx context.Context, obj *Order) ([]Item, error) -} -type QueryResolver interface { - Customers(ctx context.Context) ([]Customer, error) - Torture1d(ctx context.Context, customerIds []int) ([]Customer, error) - Torture2d(ctx context.Context, customerIds [][]int) ([][]Customer, error) -} - -func (e *executableSchema) field_Query_torture1d_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 []int - if tmp, ok := rawArgs["customerIds"]; ok { - var err error - var rawIf1 []interface{} - if tmp != nil { - if tmp1, ok := tmp.([]interface{}); ok { - rawIf1 = tmp1 - } else { - rawIf1 = []interface{}{tmp} - } - } - arg0 = make([]int, len(rawIf1)) - for idx1 := range rawIf1 { - arg0[idx1], err = graphql.UnmarshalInt(rawIf1[idx1]) - } - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Address_id(ctx context.Context, field graphql.CollectedField, obj *Address) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Address", + Field: field, + Args: nil, } - args["customerIds"] = arg0 - return args, nil - -} - -func (e *executableSchema) field_Query_torture2d_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 [][]int - if tmp, ok := rawArgs["customerIds"]; ok { - var err error - var rawIf1 []interface{} - if tmp != nil { - if tmp1, ok := tmp.([]interface{}); ok { - rawIf1 = tmp1 - } else { - rawIf1 = []interface{}{tmp} - } - } - arg0 = make([][]int, len(rawIf1)) - for idx1 := range rawIf1 { - var rawIf2 []interface{} - if rawIf1[idx1] != nil { - if tmp1, ok := rawIf1[idx1].([]interface{}); ok { - rawIf2 = tmp1 - } else { - rawIf2 = []interface{}{rawIf1[idx1]} - } - } - arg0[idx1] = make([]int, len(rawIf2)) - for idx2 := range rawIf2 { - arg0[idx1][idx2], err = graphql.UnmarshalInt(rawIf2[idx2]) - } - } - if err != nil { - return nil, err + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["customerIds"] = arg0 - return args, nil - + res := resTmp.(int) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalInt(res) } -func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Address_street(ctx context.Context, field graphql.CollectedField, obj *Address) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Address", + Field: field, + Args: nil, } - args["name"] = arg0 - return args, nil - -} - -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Street, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["includeDeprecated"] = arg0 - return args, nil - + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Address_country(ctx context.Context, field graphql.CollectedField, obj *Address) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Address", + Field: field, + Args: nil, } - args["includeDeprecated"] = arg0 - return args, nil - -} - -type executableSchema struct { - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot -} - -func (e *executableSchema) Schema() *ast.Schema { - return parsedSchema -} - -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - switch typeName + "." + field { - - case "Address.id": - if e.complexity.Address.Id == nil { - break - } - - return e.complexity.Address.Id(childComplexity), true - - case "Address.street": - if e.complexity.Address.Street == nil { - break - } - - return e.complexity.Address.Street(childComplexity), true - - case "Address.country": - if e.complexity.Address.Country == nil { - break - } - - return e.complexity.Address.Country(childComplexity), true - - case "Customer.id": - if e.complexity.Customer.Id == nil { - break - } - - return e.complexity.Customer.Id(childComplexity), true - - case "Customer.name": - if e.complexity.Customer.Name == nil { - break - } - - return e.complexity.Customer.Name(childComplexity), true - - case "Customer.address": - if e.complexity.Customer.Address == nil { - break - } - - return e.complexity.Customer.Address(childComplexity), true - - case "Customer.orders": - if e.complexity.Customer.Orders == nil { - break - } - - return e.complexity.Customer.Orders(childComplexity), true - - case "Item.name": - if e.complexity.Item.Name == nil { - break - } - - return e.complexity.Item.Name(childComplexity), true - - case "Order.id": - if e.complexity.Order.Id == nil { - break + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Country, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - return e.complexity.Order.Id(childComplexity), true - - case "Order.date": - if e.complexity.Order.Date == nil { - break +// nolint: vetshadow +func (ec *executionContext) _Customer_id(ctx context.Context, field graphql.CollectedField, obj *Customer) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Customer", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(int) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalInt(res) +} - return e.complexity.Order.Date(childComplexity), true - - case "Order.amount": - if e.complexity.Order.Amount == nil { - break +// nolint: vetshadow +func (ec *executionContext) _Customer_name(ctx context.Context, field graphql.CollectedField, obj *Customer) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Customer", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - return e.complexity.Order.Amount(childComplexity), true +// nolint: vetshadow +func (ec *executionContext) _Customer_address(ctx context.Context, field graphql.CollectedField, obj *Customer) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Customer", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Customer().Address(rctx, obj) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Address) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - case "Order.items": - if e.complexity.Order.Items == nil { - break - } + if res == nil { + return graphql.Null + } - return e.complexity.Order.Items(childComplexity), true + return ec._Address(ctx, field.Selections, res) +} - case "Query.customers": - if e.complexity.Query.Customers == nil { - break - } +// nolint: vetshadow +func (ec *executionContext) _Customer_orders(ctx context.Context, field graphql.CollectedField, obj *Customer) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Customer", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Customer().Orders(rctx, obj) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]Order) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.Query.Customers(childComplexity), true + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - case "Query.torture1d": - if e.complexity.Query.Torture1d == nil { - break - } + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - args, err := e.field_Query_torture1d_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.Query.Torture1d(childComplexity, args["customerIds"].([]int)), true - - case "Query.torture2d": - if e.complexity.Query.Torture2d == nil { - break + return ec._Order(ctx, field.Selections, &res[idx1]) + }() } - - args, err := e.field_Query_torture2d_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.Query.Torture2d(childComplexity, args["customerIds"].([][]int)), true - } - return 0, false + wg.Wait() + return arr1 } -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() +// nolint: vetshadow +func (ec *executionContext) _Item_name(ctx context.Context, field graphql.CollectedField, obj *Item) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Item", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions} -} - -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - return graphql.ErrorResponse(ctx, "mutations are not supported") -} - -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) -} - -type executionContext struct { - *graphql.RequestContext - *executableSchema -} - -var addressImplementors = []string{"Address"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, obj *Address) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, addressImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Address") - case "id": - out.Values[i] = ec._Address_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "street": - out.Values[i] = ec._Address_street(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "country": - out.Values[i] = ec._Address_country(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } - } - out.Dispatch() - if invalid { return graphql.Null } - return out + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _Address_id(ctx context.Context, field graphql.CollectedField, obj *Address) graphql.Marshaler { +func (ec *executionContext) _Order_id(ctx context.Context, field graphql.CollectedField, obj *Order) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Address", + Object: "Order", Field: field, Args: nil, } @@ -420,11 +294,11 @@ func (ec *executionContext) _Address_id(ctx context.Context, field graphql.Colle } // nolint: vetshadow -func (ec *executionContext) _Address_street(ctx context.Context, field graphql.CollectedField, obj *Address) graphql.Marshaler { +func (ec *executionContext) _Order_date(ctx context.Context, field graphql.CollectedField, obj *Order) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Address", + Object: "Order", Field: field, Args: nil, } @@ -432,7 +306,7 @@ func (ec *executionContext) _Address_street(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Street, nil + return obj.Date, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -440,18 +314,18 @@ func (ec *executionContext) _Address_street(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.(string) + res := resTmp.(time.Time) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return graphql.MarshalTime(res) } // nolint: vetshadow -func (ec *executionContext) _Address_country(ctx context.Context, field graphql.CollectedField, obj *Address) graphql.Marshaler { +func (ec *executionContext) _Order_amount(ctx context.Context, field graphql.CollectedField, obj *Order) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Address", + Object: "Order", Field: field, Args: nil, } @@ -459,7 +333,7 @@ func (ec *executionContext) _Address_country(ctx context.Context, field graphql. ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Country, nil + return obj.Amount, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -467,63 +341,18 @@ func (ec *executionContext) _Address_country(ctx context.Context, field graphql. } return graphql.Null } - res := resTmp.(string) + res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -var customerImplementors = []string{"Customer"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Customer(ctx context.Context, sel ast.SelectionSet, obj *Customer) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, customerImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Customer") - case "id": - out.Values[i] = ec._Customer_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "name": - out.Values[i] = ec._Customer_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "address": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Customer_address(ctx, field, obj) - return res - }) - case "orders": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Customer_orders(ctx, field, obj) - return res - }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + return graphql.MarshalFloat(res) } // nolint: vetshadow -func (ec *executionContext) _Customer_id(ctx context.Context, field graphql.CollectedField, obj *Customer) graphql.Marshaler { +func (ec *executionContext) _Order_items(ctx context.Context, field graphql.CollectedField, obj *Order) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Customer", + Object: "Order", Field: field, Args: nil, } @@ -531,95 +360,197 @@ func (ec *executionContext) _Customer_id(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return ec.resolvers.Order().Items(rctx, obj) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(int) + res := resTmp.([]Item) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) + + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec._Item(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) _Customer_name(ctx context.Context, field graphql.CollectedField, obj *Customer) graphql.Marshaler { +func (ec *executionContext) _Query_customers(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Customer", + Object: "Query", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return ec.resolvers.Query().Customers(rctx) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]Customer) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec._Customer(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) _Customer_address(ctx context.Context, field graphql.CollectedField, obj *Customer) graphql.Marshaler { +func (ec *executionContext) _Query_torture1d(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Customer", + Object: "Query", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_torture1d_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Customer().Address(rctx, obj) + return ec.resolvers.Query().Torture1d(rctx, args["customerIds"].([]int)) }) if resTmp == nil { return graphql.Null } - res := resTmp.(*Address) + res := resTmp.([]Customer) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - return ec._Address(ctx, field.Selections, res) + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec._Customer(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) _Customer_orders(ctx context.Context, field graphql.CollectedField, obj *Customer) graphql.Marshaler { +func (ec *executionContext) _Query_torture2d(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Customer", + Object: "Query", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_torture2d_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Customer().Orders(rctx, obj) + return ec.resolvers.Query().Torture2d(rctx, args["customerIds"].([][]int)) }) if resTmp == nil { return graphql.Null } - res := resTmp.([]Order) + res := resTmp.([][]Customer) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -644,7 +575,38 @@ func (ec *executionContext) _Customer_orders(ctx context.Context, field graphql. } arr1[idx1] = func() graphql.Marshaler { - return ec._Order(ctx, field.Selections, &res[idx1]) + arr2 := make(graphql.Array, len(res[idx1])) + + isLen1 := len(res[idx1]) == 1 + if !isLen1 { + wg.Add(len(res[idx1])) + } + + for idx2 := range res[idx1] { + idx2 := idx2 + rctx := &graphql.ResolverContext{ + Index: &idx2, + Result: &res[idx1][idx2], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx2 int) { + if !isLen1 { + defer wg.Done() + } + arr2[idx2] = func() graphql.Marshaler { + + return ec._Customer(ctx, field.Selections, &res[idx1][idx2]) + }() + } + if isLen1 { + f(idx2) + } else { + go f(idx2) + } + + } + + return arr2 }() } if isLen1 { @@ -658,111 +620,77 @@ func (ec *executionContext) _Customer_orders(ctx context.Context, field graphql. return arr1 } -var itemImplementors = []string{"Item"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Item(ctx context.Context, sel ast.SelectionSet, obj *Item) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, itemImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Item") - case "name": - out.Values[i] = ec._Item_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } +// nolint: vetshadow +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - out.Dispatch() - if invalid { + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query___type_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) return graphql.Null } - return out + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(args["name"].(string)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) _Item_name(ctx context.Context, field graphql.CollectedField, obj *Item) graphql.Marshaler { +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Item", + Object: "Query", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return ec.introspectSchema() }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -var orderImplementors = []string{"Order"} -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Order(ctx context.Context, sel ast.SelectionSet, obj *Order) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, orderImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Order") - case "id": - out.Values[i] = ec._Order_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "date": - out.Values[i] = ec._Order_date(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "amount": - out.Values[i] = ec._Order_amount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "items": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Order_items(ctx, field, obj) - return res - }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { + if res == nil { return graphql.Null } - return out + + return ec.___Schema(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) _Order_id(ctx context.Context, field graphql.CollectedField, obj *Order) graphql.Marshaler { +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Order", + Object: "__Directive", Field: field, Args: nil, } @@ -770,7 +698,7 @@ func (ec *executionContext) _Order_id(ctx context.Context, field graphql.Collect ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -778,18 +706,18 @@ func (ec *executionContext) _Order_id(ctx context.Context, field graphql.Collect } return graphql.Null } - res := resTmp.(int) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _Order_date(ctx context.Context, field graphql.CollectedField, obj *Order) graphql.Marshaler { +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Order", + Object: "__Directive", Field: field, Args: nil, } @@ -797,26 +725,23 @@ func (ec *executionContext) _Order_date(ctx context.Context, field graphql.Colle ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Date, nil + return obj.Description, nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(time.Time) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalTime(res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _Order_amount(ctx context.Context, field graphql.CollectedField, obj *Order) graphql.Marshaler { +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Order", + Object: "__Directive", Field: field, Args: nil, } @@ -824,7 +749,7 @@ func (ec *executionContext) _Order_amount(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Amount, nil + return obj.Locations, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -832,18 +757,27 @@ func (ec *executionContext) _Order_amount(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(float64) + res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) + + arr1 := make(graphql.Array, len(res)) + + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { + return graphql.MarshalString(res[idx1]) + }() + } + + return arr1 } // nolint: vetshadow -func (ec *executionContext) _Order_items(ctx context.Context, field graphql.CollectedField, obj *Order) graphql.Marshaler { +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Order", + Object: "__Directive", Field: field, Args: nil, } @@ -851,12 +785,15 @@ func (ec *executionContext) _Order_items(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Order().Items(rctx, obj) + return obj.Args, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]Item) + res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -881,7 +818,7 @@ func (ec *executionContext) _Order_items(ctx context.Context, field graphql.Coll } arr1[idx1] = func() graphql.Marshaler { - return ec._Item(ctx, field.Selections, &res[idx1]) + return ec.___InputValue(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -895,202 +832,185 @@ func (ec *executionContext) _Order_items(ctx context.Context, field graphql.Coll return arr1 } -var queryImplementors = []string{"Query"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, queryImplementors) - - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: "Query", +// nolint: vetshadow +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil }) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Query") - case "customers": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_customers(ctx, field) - return res - }) - case "torture1d": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_torture1d(ctx, field) - return res - }) - case "torture2d": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_torture2d(ctx, field) - return res - }) - case "__type": - out.Values[i] = ec._Query___type(ctx, field) - case "__schema": - out.Values[i] = ec._Query___schema(ctx, field) - default: - panic("unknown field " + strconv.Quote(field.Name)) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - out.Dispatch() - if invalid { + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} + +// nolint: vetshadow +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if resTmp == nil { return graphql.Null } - return out + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _Query_customers(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "__EnumValue", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Customers(rctx) + return obj.IsDeprecated(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]Customer) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._Customer(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) _Query_torture1d(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "__EnumValue", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_torture1d_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Torture1d(rctx, args["customerIds"].([]int)) + return obj.DeprecationReason(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.([]Customer) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) + if res == nil { + return graphql.Null } + return graphql.MarshalString(*res) +} - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._Customer(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) +// nolint: vetshadow +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } - + return graphql.Null } - wg.Wait() - return arr1 + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _Query_torture2d(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "__Field", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_torture2d_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if resTmp == nil { return graphql.Null } - rctx.Args = args + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} + +// nolint: vetshadow +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Torture2d(rctx, args["customerIds"].([][]int)) + return obj.Args, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([][]Customer) + res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1115,38 +1035,7 @@ func (ec *executionContext) _Query_torture2d(ctx context.Context, field graphql. } arr1[idx1] = func() graphql.Marshaler { - arr2 := make(graphql.Array, len(res[idx1])) - - isLen1 := len(res[idx1]) == 1 - if !isLen1 { - wg.Add(len(res[idx1])) - } - - for idx2 := range res[idx1] { - idx2 := idx2 - rctx := &graphql.ResolverContext{ - Index: &idx2, - Result: &res[idx1][idx2], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx2 int) { - if !isLen1 { - defer wg.Done() - } - arr2[idx2] = func() graphql.Marshaler { - - return ec._Customer(ctx, field.Selections, &res[idx1][idx2]) - }() - } - if isLen1 { - f(idx2) - } else { - go f(idx2) - } - - } - - return arr2 + return ec.___InputValue(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1161,28 +1050,24 @@ func (ec *executionContext) _Query_torture2d(ctx context.Context, field graphql. } // nolint: vetshadow -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "__Field", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query___type_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectType(args["name"].(string)) + return obj.Type, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(*introspection.Type) @@ -1190,6 +1075,9 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } @@ -1197,80 +1085,66 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "__Field", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() + return obj.IsDeprecated(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) +} + +// nolint: vetshadow +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Schema) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { return graphql.Null } - - return ec.___Schema(ctx, field.Selections, res) -} - -var __DirectiveImplementors = []string{"__Directive"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Directive") - case "name": - out.Values[i] = ec.___Directive_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___Directive_description(ctx, field, obj) - case "locations": - out.Values[i] = ec.___Directive_locations(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "args": - out.Values[i] = ec.___Directive_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "__InputValue", Field: field, Args: nil, } @@ -1293,11 +1167,11 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql } // nolint: vetshadow -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "__InputValue", Field: field, Args: nil, } @@ -1317,11 +1191,11 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field } // nolint: vetshadow -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "__InputValue", Field: field, Args: nil, } @@ -1329,7 +1203,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Locations, nil + return obj.Type, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1337,27 +1211,54 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr } return graphql.Null } - res := resTmp.([]string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() + return ec.___Type(ctx, field.Selections, res) +} + +// nolint: vetshadow +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if resTmp == nil { + return graphql.Null } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return arr1 + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "__Schema", Field: field, Args: nil, } @@ -1365,7 +1266,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Args, nil + return obj.Types(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1373,7 +1274,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1398,7 +1299,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql } arr1[idx1] = func() graphql.Marshaler { - return ec.___InputValue(ctx, field.Selections, &res[idx1]) + return ec.___Type(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1412,49 +1313,12 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql return arr1 } -var __EnumValueImplementors = []string{"__EnumValue"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__EnumValue") - case "name": - out.Values[i] = ec.___EnumValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___EnumValue_description(ctx, field, obj) - case "isDeprecated": - out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "deprecationReason": - out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - // nolint: vetshadow -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "__Schema", Field: field, Args: nil, } @@ -1462,7 +1326,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.QueryType(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1470,18 +1334,26 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "__Schema", Field: field, Args: nil, } @@ -1489,23 +1361,28 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.MutationType(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "__Schema", Field: field, Args: nil, } @@ -1513,26 +1390,28 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.SubscriptionType(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + + if res == nil { + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "__Schema", Field: field, Args: nil, } @@ -1540,74 +1419,59 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.Directives(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) -} - -var __FieldImplementors = []string{"__Field"} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __FieldImplementors) + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Field") - case "name": - out.Values[i] = ec.___Field_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___Field_description(ctx, field, obj) - case "args": - out.Values[i] = ec.___Field_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "type": - out.Values[i] = ec.___Field_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "isDeprecated": - out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() } - case "deprecationReason": - out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) + arr1[idx1] = func() graphql.Marshaler { + + return ec.___Directive(ctx, field.Selections, &res[idx1]) + }() } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Type", Field: field, Args: nil, } @@ -1615,7 +1479,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Kind(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1630,11 +1494,11 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Type", Field: field, Args: nil, } @@ -1642,7 +1506,35 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.Name(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) +} + +// nolint: vetshadow +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil }) if resTmp == nil { return graphql.Null @@ -1654,27 +1546,31 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap } // nolint: vetshadow -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Type", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_fields_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Args, nil + return obj.Fields(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1699,7 +1595,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } arr1[idx1] = func() graphql.Marshaler { - return ec.___InputValue(ctx, field.Selections, &res[idx1]) + return ec.___Field(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1714,11 +1610,11 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Type", Field: field, Args: nil, } @@ -1726,34 +1622,56 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.Interfaces(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - return ec.___Type(ctx, field.Selections, res) + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Type", Field: field, Args: nil, } @@ -1761,91 +1679,120 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.PossibleTypes(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Type", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) -} - -var __InputValueImplementors = []string{"__InputValue"} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__InputValue") - case "name": - out.Values[i] = ec.___InputValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___InputValue_description(ctx, field, obj) - case "type": - out.Values[i] = ec.___InputValue_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() } - case "defaultValue": - out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) + arr1[idx1] = func() graphql.Marshaler { + + return ec.___EnumValue(ctx, field.Selections, &res[idx1]) + }() } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Type", Field: field, Args: nil, } @@ -1853,50 +1800,56 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.InputFields(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} -// nolint: vetshadow -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { - return graphql.Null + + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Type", Field: field, Args: nil, } @@ -1904,12 +1857,9 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.OfType(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } res := resTmp.(*introspection.Type) @@ -1917,845 +1867,915 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } return ec.___Type(ctx, field.Selections, res) } -// nolint: vetshadow -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, +// endregion **************************** field.gotpl ***************************** + +// region ************************** generated.gotpl *************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil - }) - if resTmp == nil { - return graphql.Null +} + +type Config struct { + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Customer() CustomerResolver + Order() OrderResolver + Query() QueryResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + Address struct { + Id func(childComplexity int) int + Street func(childComplexity int) int + Country func(childComplexity int) int } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null + Customer struct { + Id func(childComplexity int) int + Name func(childComplexity int) int + Address func(childComplexity int) int + Orders func(childComplexity int) int + } + + Item struct { + Name func(childComplexity int) int + } + + Order struct { + Id func(childComplexity int) int + Date func(childComplexity int) int + Amount func(childComplexity int) int + Items func(childComplexity int) int + } + + Query struct { + Customers func(childComplexity int) int + Torture1d func(childComplexity int, customerIds []int) int + Torture2d func(childComplexity int, customerIds [][]int) int } - return graphql.MarshalString(*res) } -var __SchemaImplementors = []string{"__Schema"} +type CustomerResolver interface { + Address(ctx context.Context, obj *Customer) (*Address, error) + Orders(ctx context.Context, obj *Customer) ([]Order, error) +} +type OrderResolver interface { + Items(ctx context.Context, obj *Order) ([]Item, error) +} +type QueryResolver interface { + Customers(ctx context.Context) ([]Customer, error) + Torture1d(ctx context.Context, customerIds []int) ([]Customer, error) + Torture2d(ctx context.Context, customerIds [][]int) ([][]Customer, error) +} -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) +func (e *executableSchema) field_Query_torture1d_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 []int + if tmp, ok := rawArgs["customerIds"]; ok { + var err error + var rawIf1 []interface{} + if tmp != nil { + if tmp1, ok := tmp.([]interface{}); ok { + rawIf1 = tmp1 + } else { + rawIf1 = []interface{}{tmp} + } + } + arg0 = make([]int, len(rawIf1)) + for idx1 := range rawIf1 { + arg0[idx1], err = graphql.UnmarshalInt(rawIf1[idx1]) + } + if err != nil { + return nil, err + } + } + args["customerIds"] = arg0 + return args, nil - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Schema") - case "types": - out.Values[i] = ec.___Schema_types(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true +} + +func (e *executableSchema) field_Query_torture2d_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 [][]int + if tmp, ok := rawArgs["customerIds"]; ok { + var err error + var rawIf1 []interface{} + if tmp != nil { + if tmp1, ok := tmp.([]interface{}); ok { + rawIf1 = tmp1 + } else { + rawIf1 = []interface{}{tmp} } - case "queryType": - out.Values[i] = ec.___Schema_queryType(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true + } + arg0 = make([][]int, len(rawIf1)) + for idx1 := range rawIf1 { + var rawIf2 []interface{} + if rawIf1[idx1] != nil { + if tmp1, ok := rawIf1[idx1].([]interface{}); ok { + rawIf2 = tmp1 + } else { + rawIf2 = []interface{}{rawIf1[idx1]} + } } - case "mutationType": - out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) - case "subscriptionType": - out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) - case "directives": - out.Values[i] = ec.___Schema_directives(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true + arg0[idx1] = make([]int, len(rawIf2)) + for idx2 := range rawIf2 { + arg0[idx1][idx2], err = graphql.UnmarshalInt(rawIf2[idx2]) } - default: - panic("unknown field " + strconv.Quote(field.Name)) + } + if err != nil { + return nil, err + } + } + args["customerIds"] = arg0 + return args, nil + +} + +func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + args["name"] = arg0 + return args, nil + } -// nolint: vetshadow -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Types(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + args["includeDeprecated"] = arg0 + return args, nil - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup +} - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } } + args["includeDeprecated"] = arg0 + return args, nil - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], +} + +type executableSchema struct { + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + switch typeName + "." + field { + + case "Address.id": + if e.complexity.Address.Id == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() + return e.complexity.Address.Id(childComplexity), true + + case "Address.street": + if e.complexity.Address.Street == nil { + break } - if isLen1 { - f(idx1) - } else { - go f(idx1) + + return e.complexity.Address.Street(childComplexity), true + + case "Address.country": + if e.complexity.Address.Country == nil { + break } - } - wg.Wait() - return arr1 -} + return e.complexity.Address.Country(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + case "Customer.id": + if e.complexity.Customer.Id == nil { + break } - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + return e.complexity.Customer.Id(childComplexity), true + + case "Customer.name": + if e.complexity.Customer.Name == nil { + break } - return graphql.Null - } - return ec.___Type(ctx, field.Selections, res) -} + return e.complexity.Customer.Name(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + case "Customer.address": + if e.complexity.Customer.Address == nil { + break + } - if res == nil { - return graphql.Null - } + return e.complexity.Customer.Address(childComplexity), true - return ec.___Type(ctx, field.Selections, res) -} + case "Customer.orders": + if e.complexity.Customer.Orders == nil { + break + } -// nolint: vetshadow -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return e.complexity.Customer.Orders(childComplexity), true - if res == nil { - return graphql.Null - } + case "Item.name": + if e.complexity.Item.Name == nil { + break + } - return ec.___Type(ctx, field.Selections, res) -} + return e.complexity.Item.Name(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + case "Order.id": + if e.complexity.Order.Id == nil { + break } - return graphql.Null - } - res := resTmp.([]introspection.Directive) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + return e.complexity.Order.Id(childComplexity), true + + case "Order.date": + if e.complexity.Order.Date == nil { + break + } + + return e.complexity.Order.Date(childComplexity), true + + case "Order.amount": + if e.complexity.Order.Amount == nil { + break + } - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } + return e.complexity.Order.Amount(childComplexity), true - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + case "Order.items": + if e.complexity.Order.Items == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec.___Directive(ctx, field.Selections, &res[idx1]) - }() + return e.complexity.Order.Items(childComplexity), true + + case "Query.customers": + if e.complexity.Query.Customers == nil { + break } - if isLen1 { - f(idx1) - } else { - go f(idx1) + + return e.complexity.Query.Customers(childComplexity), true + + case "Query.torture1d": + if e.complexity.Query.Torture1d == nil { + break } - } - wg.Wait() - return arr1 -} + args, err := e.field_Query_torture1d_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } -var __TypeImplementors = []string{"__Type"} + return e.complexity.Query.Torture1d(childComplexity, args["customerIds"].([]int)), true -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __TypeImplementors) + case "Query.torture2d": + if e.complexity.Query.Torture2d == nil { + break + } - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Type") - case "kind": - out.Values[i] = ec.___Type_kind(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "name": - out.Values[i] = ec.___Type_name(ctx, field, obj) - case "description": - out.Values[i] = ec.___Type_description(ctx, field, obj) - case "fields": - out.Values[i] = ec.___Type_fields(ctx, field, obj) - case "interfaces": - out.Values[i] = ec.___Type_interfaces(ctx, field, obj) - case "possibleTypes": - out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) - case "enumValues": - out.Values[i] = ec.___Type_enumValues(ctx, field, obj) - case "inputFields": - out.Values[i] = ec.___Type_inputFields(ctx, field, obj) - case "ofType": - out.Values[i] = ec.___Type_ofType(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) + args, err := e.field_Query_torture2d_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } + + return e.complexity.Query.Torture2d(childComplexity, args["customerIds"].([][]int)), true + } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + return 0, false } -// nolint: vetshadow -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil +func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._Query(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions} } -// nolint: vetshadow -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + return graphql.ErrorResponse(ctx, "mutations are not supported") +} - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) +func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { + return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) } -// nolint: vetshadow -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) +type executionContext struct { + *graphql.RequestContext + *executableSchema } -// nolint: vetshadow -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_fields_args(ctx, rawArgs) +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + res, err := ec.ResolverMiddleware(ctx, next) if err != nil { ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Fields(args["includeDeprecated"].(bool)), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Field) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) + return nil } + return res +} - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Field(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") } - wg.Wait() - return arr1 + return introspection.WrapSchema(parsedSchema), nil } -// nolint: vetshadow -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil - }) - if resTmp == nil { - return graphql.Null +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") } - res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil +} - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup +var parsedSchema = gqlparser.MustLoadSchema( + &ast.Source{Name: "schema.graphql", Input: `type Query { + customers: [Customer!] - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } + # these methods are here to test code generation of nested arrays + torture1d(customerIds: [Int!]): [Customer!] + torture2d(customerIds: [[Int!]]): [[Customer!]] +} - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { +type Customer { + id: Int! + name: String! + address: Address + orders: [Order!] +} - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } +type Address { + id: Int! + street: String! + country: String! +} - } - wg.Wait() - return arr1 +type Order { + id: Int! + date: Time! + amount: Float! + items: [Item!] } -// nolint: vetshadow -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +type Item { + name: String! +} +scalar Time +`}, +) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup +// ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) + return handleFunc[0](ctx, chainHandler) } + } + if n == 1 { + return handleFunc[0] + } + + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) } - wg.Wait() - return arr1 } -// nolint: vetshadow -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, +// endregion ************************** generated.gotpl *************************** + +// region **************************** input.gotpl ***************************** + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +var addressImplementors = []string{"Address"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, obj *Address) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, addressImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Address") + case "id": + out.Values[i] = ec._Address_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "street": + out.Values[i] = ec._Address_street(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "country": + out.Values[i] = ec._Address_country(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_enumValues_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) + out.Dispatch() + if invalid { return graphql.Null } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.EnumValues(args["includeDeprecated"].(bool)), nil - }) - if resTmp == nil { + return out +} + +var customerImplementors = []string{"Customer"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Customer(ctx context.Context, sel ast.SelectionSet, obj *Customer) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, customerImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Customer") + case "id": + out.Values[i] = ec._Customer_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "name": + out.Values[i] = ec._Customer_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "address": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Customer_address(ctx, field, obj) + return res + }) + case "orders": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Customer_orders(ctx, field, obj) + return res + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { return graphql.Null } - res := resTmp.([]introspection.EnumValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return out +} - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup +var itemImplementors = []string{"Item"} - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Item(ctx context.Context, sel ast.SelectionSet, obj *Item) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, itemImplementors) - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Item") + case "name": + out.Values[i] = ec._Item_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) + default: + panic("unknown field " + strconv.Quote(field.Name)) } - } - wg.Wait() - return arr1 + out.Dispatch() + if invalid { + return graphql.Null + } + return out } -// nolint: vetshadow -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, +var orderImplementors = []string{"Order"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Order(ctx context.Context, sel ast.SelectionSet, obj *Order) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, orderImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Order") + case "id": + out.Values[i] = ec._Order_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "date": + out.Values[i] = ec._Order_date(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "amount": + out.Values[i] = ec._Order_amount(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "items": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Order_items(ctx, field, obj) + return res + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil - }) - if resTmp == nil { + out.Dispatch() + if invalid { return graphql.Null } - res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return out +} - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup +var queryImplementors = []string{"Query"} - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, queryImplementors) - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "Query", + }) - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Query") + case "customers": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_customers(ctx, field) + return res + }) + case "torture1d": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_torture1d(ctx, field) + return res + }) + case "torture2d": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_torture2d(ctx, field) + return res + }) + case "__type": + out.Values[i] = ec._Query___type(ctx, field) + case "__schema": + out.Values[i] = ec._Query___schema(ctx, field) + default: + panic("unknown field " + strconv.Quote(field.Name)) } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __DirectiveImplementors = []string{"__Directive"} +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } } - wg.Wait() - return arr1 + out.Dispatch() + if invalid { + return graphql.Null + } + return out } -// nolint: vetshadow -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, +var __EnumValueImplementors = []string{"__EnumValue"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil - }) - if resTmp == nil { + out.Dispatch() + if invalid { return graphql.Null } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return out +} - if res == nil { - return graphql.Null - } +var __FieldImplementors = []string{"__Field"} - return ec.___Type(ctx, field.Selections, res) -} +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __FieldImplementors) -func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) } - }() - res, err := ec.ResolverMiddleware(ctx, next) - if err != nil { - ec.Error(ctx, err) - return nil - } - return res -} - -func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") } - return introspection.WrapSchema(parsedSchema), nil -} - -func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") + out.Dispatch() + if invalid { + return graphql.Null } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil + return out } -var parsedSchema = gqlparser.MustLoadSchema( - &ast.Source{Name: "schema.graphql", Input: `type Query { - customers: [Customer!] +var __InputValueImplementors = []string{"__InputValue"} - # these methods are here to test code generation of nested arrays - torture1d(customerIds: [Int!]): [Customer!] - torture2d(customerIds: [[Int!]]): [[Customer!]] -} +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) -type Customer { - id: Int! - name: String! - address: Address - orders: [Order!] + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out } -type Address { - id: Int! - street: String! - country: String! -} +var __SchemaImplementors = []string{"__Schema"} -type Order { - id: Int! - date: Time! - amount: Float! - items: [Item!] -} +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) -type Item { - name: String! + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out } -scalar Time -`}, -) -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) +var __TypeImplementors = []string{"__Type"} - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __TypeImplementors) + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true } - return handleFunc[0](ctx, chainHandler) + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) } } - - if n == 1 { - return handleFunc[0] - } - - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) + out.Dispatch() + if invalid { + return graphql.Null } + return out } + +// endregion **************************** object.gotpl **************************** diff --git a/example/dataloader/models_gen.go b/example/dataloader/models_gen.go index fb141c173fb..c0ff90ce82b 100644 --- a/example/dataloader/models_gen.go +++ b/example/dataloader/models_gen.go @@ -1,5 +1,3 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - package dataloader type Address struct { diff --git a/example/scalars/generated.go b/example/scalars/generated.go index c2250131ccb..5e422d3e5f8 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -18,325 +18,237 @@ import ( "github.com/vektah/gqlparser/ast" ) -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } -} +// region **************************** field.gotpl ***************************** -type Config struct { - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot +// nolint: vetshadow +func (ec *executionContext) _Address_id(ctx context.Context, field graphql.CollectedField, obj *model.Address) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Address", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(external.ObjectID) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return model.MarshalID(res) } -type ResolverRoot interface { - Query() QueryResolver - User() UserResolver -} +// nolint: vetshadow +func (ec *executionContext) _Address_location(ctx context.Context, field graphql.CollectedField, obj *model.Address) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Address", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Location, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.Point) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -type DirectiveRoot struct { + if res == nil { + return graphql.Null + } + return *res } -type ComplexityRoot struct { - Address struct { - Id func(childComplexity int) int - Location func(childComplexity int) int +// nolint: vetshadow +func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - - Query struct { - User func(childComplexity int, id external.ObjectID) int - Search func(childComplexity int, input *model.SearchArgs) int + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_user_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().User(rctx, args["id"].(external.ObjectID)) + }) + if resTmp == nil { + return graphql.Null } + res := resTmp.(*model.User) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - User struct { - Id func(childComplexity int) int - Name func(childComplexity int) int - Created func(childComplexity int) int - IsBanned func(childComplexity int) int - PrimitiveResolver func(childComplexity int) int - CustomResolver func(childComplexity int) int - Address func(childComplexity int) int - Tier func(childComplexity int) int + if res == nil { + return graphql.Null } -} -type QueryResolver interface { - User(ctx context.Context, id external.ObjectID) (*model.User, error) - Search(ctx context.Context, input *model.SearchArgs) ([]model.User, error) -} -type UserResolver interface { - PrimitiveResolver(ctx context.Context, obj *model.User) (string, error) - CustomResolver(ctx context.Context, obj *model.User) (model.Point, error) + return ec._User(ctx, field.Selections, res) } -func (e *executableSchema) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 external.ObjectID - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = model.UnmarshalID(tmp) - if err != nil { - return nil, err +// nolint: vetshadow +func (ec *executionContext) _Query_search(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_search_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Search(rctx, args["input"].(*model.SearchArgs)) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["id"] = arg0 - return args, nil + res := resTmp.([]model.User) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -func (e *executableSchema) field_Query_search_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *model.SearchArgs - if tmp, ok := rawArgs["input"]; ok { - var err error - var ptr1 model.SearchArgs - if tmp != nil { - ptr1, err = UnmarshalSearchArgs(tmp) - arg0 = &ptr1 - } + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - if err != nil { - return nil, err + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } - - if arg0 != nil { - var err error - arg0, err = e.SearchArgsMiddleware(ctx, arg0) - if err != nil { - return nil, err + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() } + arr1[idx1] = func() graphql.Marshaler { + + return ec._User(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) } - } - args["input"] = arg0 - return args, nil + } + wg.Wait() + return arr1 } -func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query___type_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(args["name"].(string)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { + return graphql.Null } - args["name"] = arg0 - return args, nil + return ec.___Type(ctx, field.Selections, res) } -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil - -} - -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil - -} - -type executableSchema struct { - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot -} - -func (e *executableSchema) Schema() *ast.Schema { - return parsedSchema -} - -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - switch typeName + "." + field { - - case "Address.id": - if e.complexity.Address.Id == nil { - break - } - - return e.complexity.Address.Id(childComplexity), true - - case "Address.location": - if e.complexity.Address.Location == nil { - break - } - - return e.complexity.Address.Location(childComplexity), true - - case "Query.user": - if e.complexity.Query.User == nil { - break - } - - args, err := e.field_Query_user_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.User(childComplexity, args["id"].(external.ObjectID)), true - - case "Query.search": - if e.complexity.Query.Search == nil { - break - } - - args, err := e.field_Query_search_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.Search(childComplexity, args["input"].(*model.SearchArgs)), true - - case "User.id": - if e.complexity.User.Id == nil { - break - } - - return e.complexity.User.Id(childComplexity), true - - case "User.name": - if e.complexity.User.Name == nil { - break - } - - return e.complexity.User.Name(childComplexity), true - - case "User.created": - if e.complexity.User.Created == nil { - break - } - - return e.complexity.User.Created(childComplexity), true - - case "User.isBanned": - if e.complexity.User.IsBanned == nil { - break - } - - return e.complexity.User.IsBanned(childComplexity), true - - case "User.primitiveResolver": - if e.complexity.User.PrimitiveResolver == nil { - break - } - - return e.complexity.User.PrimitiveResolver(childComplexity), true - - case "User.customResolver": - if e.complexity.User.CustomResolver == nil { - break - } - - return e.complexity.User.CustomResolver(childComplexity), true - - case "User.address": - if e.complexity.User.Address == nil { - break - } - - return e.complexity.User.Address(childComplexity), true - - case "User.tier": - if e.complexity.User.Tier == nil { - break - } - - return e.complexity.User.Tier(childComplexity), true - +// nolint: vetshadow +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - return 0, false -} - -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions} -} - -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - return graphql.ErrorResponse(ctx, "mutations are not supported") -} - -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) -} - -type executionContext struct { - *graphql.RequestContext - *executableSchema -} - -var addressImplementors = []string{"Address"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, obj *model.Address) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, addressImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Address") - case "id": - out.Values[i] = ec._Address_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "location": - out.Values[i] = ec._Address_location(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } + if resTmp == nil { + return graphql.Null } - out.Dispatch() - if invalid { + res := resTmp.(*introspection.Schema) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { return graphql.Null } - return out + + return ec.___Schema(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) _Address_id(ctx context.Context, field graphql.CollectedField, obj *model.Address) graphql.Marshaler { +func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Address", + Object: "User", Field: field, Args: nil, } @@ -359,11 +271,11 @@ func (ec *executionContext) _Address_id(ctx context.Context, field graphql.Colle } // nolint: vetshadow -func (ec *executionContext) _Address_location(ctx context.Context, field graphql.CollectedField, obj *model.Address) graphql.Marshaler { +func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Address", + Object: "User", Field: field, Args: nil, } @@ -371,124 +283,85 @@ func (ec *executionContext) _Address_location(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Location, nil + return obj.Name, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*model.Point) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - if res == nil { +// nolint: vetshadow +func (ec *executionContext) _User_created(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "User", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Created, nil + }) + if resTmp == nil { return graphql.Null } - return *res -} - -var queryImplementors = []string{"Query"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, queryImplementors) - - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: "Query", - }) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Query") - case "user": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_user(ctx, field) - return res - }) - case "search": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_search(ctx, field) - if res == graphql.Null { - invalid = true - } - return res - }) - case "__type": - out.Values[i] = ec._Query___type(ctx, field) - case "__schema": - out.Values[i] = ec._Query___schema(ctx, field) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + res := resTmp.(time.Time) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return model.MarshalTimestamp(res) } // nolint: vetshadow -func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) _User_isBanned(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "User", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_user_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().User(rctx, args["id"].(external.ObjectID)) + return obj.IsBanned, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*model.User) + res := resTmp.(model.Banned) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec._User(ctx, field.Selections, res) + return res } // nolint: vetshadow -func (ec *executionContext) _Query_search(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) _User_primitiveResolver(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "User", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_search_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Search(rctx, args["input"].(*model.SearchArgs)) + return ec.resolvers.User().PrimitiveResolver(rctx, obj) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -496,174 +369,66 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.([]model.User) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._User(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) _User_customResolver(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "User", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query___type_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectType(args["name"].(string)) + return ec.resolvers.User().CustomResolver(rctx, obj) }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(model.Point) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return res } // nolint: vetshadow -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) _User_address(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "User", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() + return obj.Address, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Schema) + res := resTmp.(model.Address) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null - } - - return ec.___Schema(ctx, field.Selections, res) -} - -var userImplementors = []string{"User"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *model.User) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, userImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("User") - case "id": - out.Values[i] = ec._User_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "name": - out.Values[i] = ec._User_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "created": - out.Values[i] = ec._User_created(ctx, field, obj) - case "isBanned": - out.Values[i] = ec._User_isBanned(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "primitiveResolver": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._User_primitiveResolver(ctx, field, obj) - if res == graphql.Null { - invalid = true - } - return res - }) - case "customResolver": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._User_customResolver(ctx, field, obj) - if res == graphql.Null { - invalid = true - } - return res - }) - case "address": - out.Values[i] = ec._User_address(ctx, field, obj) - case "tier": - out.Values[i] = ec._User_tier(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + return ec._Address(ctx, field.Selections, &res) } // nolint: vetshadow -func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { +func (ec *executionContext) _User_tier(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -675,26 +440,23 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.Tier, nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(external.ObjectID) + res := resTmp.(model.Tier) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return model.MarshalID(res) + return res } // nolint: vetshadow -func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "User", + Object: "__Directive", Field: field, Args: nil, } @@ -717,11 +479,11 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec } // nolint: vetshadow -func (ec *executionContext) _User_created(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "User", + Object: "__Directive", Field: field, Args: nil, } @@ -729,23 +491,23 @@ func (ec *executionContext) _User_created(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Created, nil + return obj.Description, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(time.Time) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return model.MarshalTimestamp(res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _User_isBanned(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "User", + Object: "__Directive", Field: field, Args: nil, } @@ -753,7 +515,7 @@ func (ec *executionContext) _User_isBanned(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsBanned, nil + return obj.Locations, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -761,18 +523,27 @@ func (ec *executionContext) _User_isBanned(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.(model.Banned) + res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return res + + arr1 := make(graphql.Array, len(res)) + + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { + return graphql.MarshalString(res[idx1]) + }() + } + + return arr1 } // nolint: vetshadow -func (ec *executionContext) _User_primitiveResolver(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "User", + Object: "__Directive", Field: field, Args: nil, } @@ -780,7 +551,7 @@ func (ec *executionContext) _User_primitiveResolver(ctx context.Context, field g ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.User().PrimitiveResolver(rctx, obj) + return obj.Args, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -788,18 +559,51 @@ func (ec *executionContext) _User_primitiveResolver(ctx context.Context, field g } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) _User_customResolver(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "User", + Object: "__EnumValue", Field: field, Args: nil, } @@ -807,7 +611,7 @@ func (ec *executionContext) _User_customResolver(ctx context.Context, field grap ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.User().CustomResolver(rctx, obj) + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -815,18 +619,18 @@ func (ec *executionContext) _User_customResolver(ctx context.Context, field grap } return graphql.Null } - res := resTmp.(model.Point) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return res + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _User_address(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "User", + Object: "__EnumValue", Field: field, Args: nil, } @@ -834,24 +638,23 @@ func (ec *executionContext) _User_address(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Address, nil + return obj.Description, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(model.Address) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._Address(ctx, field.Selections, &res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _User_tier(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "User", + Object: "__EnumValue", Field: field, Args: nil, } @@ -859,63 +662,26 @@ func (ec *executionContext) _User_tier(ctx context.Context, field graphql.Collec ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Tier, nil + return obj.IsDeprecated(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(model.Tier) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return res -} - -var __DirectiveImplementors = []string{"__Directive"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Directive") - case "name": - out.Values[i] = ec.___Directive_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___Directive_description(ctx, field, obj) - case "locations": - out.Values[i] = ec.___Directive_locations(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "args": - out.Values[i] = ec.___Directive_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "__EnumValue", Field: field, Args: nil, } @@ -923,26 +689,27 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.DeprecationReason(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "__Field", Field: field, Args: nil, } @@ -950,9 +717,12 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.Name, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(string) @@ -962,11 +732,11 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field } // nolint: vetshadow -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "__Field", Field: field, Args: nil, } @@ -974,35 +744,23 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Locations, nil + return obj.Description, nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "__Field", Field: field, Args: nil, } @@ -1057,49 +815,12 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql return arr1 } -var __EnumValueImplementors = []string{"__EnumValue"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__EnumValue") - case "name": - out.Values[i] = ec.___EnumValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___EnumValue_description(ctx, field, obj) - case "isDeprecated": - out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "deprecationReason": - out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - // nolint: vetshadow -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "__Field", Field: field, Args: nil, } @@ -1107,7 +828,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Type, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1115,18 +836,26 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "__Field", Field: field, Args: nil, } @@ -1134,23 +863,26 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.IsDeprecated(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(string) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "__Field", Field: field, Args: nil, } @@ -1158,26 +890,27 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.DeprecationReason(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "__InputValue", Field: field, Args: nil, } @@ -1185,74 +918,50 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.Name, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return graphql.MarshalString(res) } -var __FieldImplementors = []string{"__Field"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __FieldImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Field") - case "name": - out.Values[i] = ec.___Field_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___Field_description(ctx, field, obj) - case "args": - out.Values[i] = ec.___Field_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "type": - out.Values[i] = ec.___Field_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "isDeprecated": - out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "deprecationReason": - out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } +// nolint: vetshadow +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Field: field, + Args: nil, } - out.Dispatch() - if invalid { + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if resTmp == nil { return graphql.Null } - return out + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__InputValue", Field: field, Args: nil, } @@ -1260,7 +969,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Type, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1268,18 +977,26 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__InputValue", Field: field, Args: nil, } @@ -1287,23 +1004,27 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.DefaultValue, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Schema", Field: field, Args: nil, } @@ -1311,7 +1032,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Args, nil + return obj.Types(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1319,7 +1040,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1344,7 +1065,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } arr1[idx1] = func() graphql.Marshaler { - return ec.___InputValue(ctx, field.Selections, &res[idx1]) + return ec.___Type(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1359,11 +1080,11 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Schema", Field: field, Args: nil, } @@ -1371,7 +1092,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.QueryType(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1394,11 +1115,11 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Schema", Field: field, Args: nil, } @@ -1406,26 +1127,28 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.MutationType(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + + if res == nil { + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Schema", Field: field, Args: nil, } @@ -1433,64 +1156,28 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.SubscriptionType(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { return graphql.Null } - return graphql.MarshalString(*res) -} - -var __InputValueImplementors = []string{"__InputValue"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__InputValue") - case "name": - out.Values[i] = ec.___InputValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___InputValue_description(ctx, field, obj) - case "type": - out.Values[i] = ec.___InputValue_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "defaultValue": - out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Schema", Field: field, Args: nil, } @@ -1498,7 +1185,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Directives(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1506,18 +1193,51 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___Directive(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Type", Field: field, Args: nil, } @@ -1525,9 +1245,12 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.Kind(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(string) @@ -1537,11 +1260,11 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field } // nolint: vetshadow -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Type", Field: field, Args: nil, } @@ -1549,34 +1272,27 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.Name(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Type", Field: field, Args: nil, } @@ -1584,85 +1300,43 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil + return obj.Description(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) -} - -var __SchemaImplementors = []string{"__Schema"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Schema") - case "types": - out.Values[i] = ec.___Schema_types(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "queryType": - out.Values[i] = ec.___Schema_queryType(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "mutationType": - out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) - case "subscriptionType": - out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) - case "directives": - out.Values[i] = ec.___Schema_directives(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Type", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_fields_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Types(), nil + return obj.Fields(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1687,7 +1361,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } arr1[idx1] = func() graphql.Marshaler { - return ec.___Type(ctx, field.Selections, &res[idx1]) + return ec.___Field(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1702,11 +1376,11 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } // nolint: vetshadow -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Type", Field: field, Args: nil, } @@ -1714,34 +1388,56 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil + return obj.Interfaces(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - return ec.___Type(ctx, field.Selections, res) + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Type", Field: field, Args: nil, } @@ -1749,57 +1445,120 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil + return obj.PossibleTypes(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - return ec.___Type(ctx, field.Selections, res) + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Type", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil + return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - return ec.___Type(ctx, field.Selections, res) + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___EnumValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Type", Field: field, Args: nil, } @@ -1807,15 +1566,12 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil + return obj.InputFields(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]introspection.Directive) + res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1840,7 +1596,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap } arr1[idx1] = func() graphql.Marshaler { - return ec.___Directive(ctx, field.Selections, &res[idx1]) + return ec.___InputValue(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1854,79 +1610,8 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap return arr1 } -var __TypeImplementors = []string{"__Type"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __TypeImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Type") - case "kind": - out.Values[i] = ec.___Type_kind(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "name": - out.Values[i] = ec.___Type_name(ctx, field, obj) - case "description": - out.Values[i] = ec.___Type_description(ctx, field, obj) - case "fields": - out.Values[i] = ec.___Type_fields(ctx, field, obj) - case "interfaces": - out.Values[i] = ec.___Type_interfaces(ctx, field, obj) - case "possibleTypes": - out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) - case "enumValues": - out.Values[i] = ec.___Type_enumValues(ctx, field, obj) - case "inputFields": - out.Values[i] = ec.___Type_inputFields(ctx, field, obj) - case "ofType": - out.Values[i] = ec.___Type_ofType(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - // nolint: vetshadow -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1938,373 +1623,417 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name(), nil + return obj.OfType(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { return graphql.Null } - return graphql.MarshalString(*res) + + return ec.___Type(ctx, field.Selections, res) } -// nolint: vetshadow -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if resTmp == nil { - return graphql.Null +// endregion **************************** field.gotpl ***************************** + +// region ************************** generated.gotpl *************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) } -// nolint: vetshadow -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, +type Config struct { + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Query() QueryResolver + User() UserResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + Address struct { + Id func(childComplexity int) int + Location func(childComplexity int) int } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_fields_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null + + Query struct { + User func(childComplexity int, id external.ObjectID) int + Search func(childComplexity int, input *model.SearchArgs) int } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Fields(args["includeDeprecated"].(bool)), nil - }) - if resTmp == nil { - return graphql.Null + + User struct { + Id func(childComplexity int) int + Name func(childComplexity int) int + Created func(childComplexity int) int + IsBanned func(childComplexity int) int + PrimitiveResolver func(childComplexity int) int + CustomResolver func(childComplexity int) int + Address func(childComplexity int) int + Tier func(childComplexity int) int } - res := resTmp.([]introspection.Field) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +} - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup +type QueryResolver interface { + User(ctx context.Context, id external.ObjectID) (*model.User, error) + Search(ctx context.Context, input *model.SearchArgs) ([]model.User, error) +} +type UserResolver interface { + PrimitiveResolver(ctx context.Context, obj *model.User) (string, error) + CustomResolver(ctx context.Context, obj *model.User) (model.Point, error) +} - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) +func (e *executableSchema) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 external.ObjectID + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = model.UnmarshalID(tmp) + if err != nil { + return nil, err + } } + args["id"] = arg0 + return args, nil - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { +} - return ec.___Field(ctx, field.Selections, &res[idx1]) - }() +func (e *executableSchema) field_Query_search_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *model.SearchArgs + if tmp, ok := rawArgs["input"]; ok { + var err error + var ptr1 model.SearchArgs + if tmp != nil { + ptr1, err = UnmarshalSearchArgs(tmp) + arg0 = &ptr1 } - if isLen1 { - f(idx1) - } else { - go f(idx1) + + if err != nil { + return nil, err } + if arg0 != nil { + var err error + arg0, err = e.SearchArgsMiddleware(ctx, arg0) + if err != nil { + return nil, err + } + } } - wg.Wait() - return arr1 + args["input"] = arg0 + return args, nil + } -// nolint: vetshadow -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil - }) - if resTmp == nil { - return graphql.Null +func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + args["name"] = arg0 + return args, nil - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup +} - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } } + args["includeDeprecated"] = arg0 + return args, nil - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], +} + +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { + } + args["includeDeprecated"] = arg0 + return args, nil - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() +} + +type executableSchema struct { + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + switch typeName + "." + field { + + case "Address.id": + if e.complexity.Address.Id == nil { + break } - if isLen1 { - f(idx1) - } else { - go f(idx1) + + return e.complexity.Address.Id(childComplexity), true + + case "Address.location": + if e.complexity.Address.Location == nil { + break } - } - wg.Wait() - return arr1 -} + return e.complexity.Address.Location(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + case "Query.user": + if e.complexity.Query.User == nil { + break + } - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + args, err := e.field_Query_user_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } + return e.complexity.Query.User(childComplexity, args["id"].(external.ObjectID)), true - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + case "Query.search": + if e.complexity.Query.Search == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() + args, err := e.field_Query_search_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - if isLen1 { - f(idx1) - } else { - go f(idx1) + + return e.complexity.Query.Search(childComplexity, args["input"].(*model.SearchArgs)), true + + case "User.id": + if e.complexity.User.Id == nil { + break } - } - wg.Wait() - return arr1 -} + return e.complexity.User.Id(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_enumValues_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.EnumValues(args["includeDeprecated"].(bool)), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.EnumValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + case "User.name": + if e.complexity.User.Name == nil { + break + } - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + return e.complexity.User.Name(childComplexity), true - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } + case "User.created": + if e.complexity.User.Created == nil { + break + } - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + return e.complexity.User.Created(childComplexity), true + + case "User.isBanned": + if e.complexity.User.IsBanned == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) - }() + return e.complexity.User.IsBanned(childComplexity), true + + case "User.primitiveResolver": + if e.complexity.User.PrimitiveResolver == nil { + break } - if isLen1 { - f(idx1) - } else { - go f(idx1) + + return e.complexity.User.PrimitiveResolver(childComplexity), true + + case "User.customResolver": + if e.complexity.User.CustomResolver == nil { + break } + return e.complexity.User.CustomResolver(childComplexity), true + + case "User.address": + if e.complexity.User.Address == nil { + break + } + + return e.complexity.User.Address(childComplexity), true + + case "User.tier": + if e.complexity.User.Tier == nil { + break + } + + return e.complexity.User.Tier(childComplexity), true + } - wg.Wait() - return arr1 + return 0, false } -// nolint: vetshadow -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil +func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._Query(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() }) - if resTmp == nil { - return graphql.Null + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions} +} + +func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + return graphql.ErrorResponse(ctx, "mutations are not supported") +} + +func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { + return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) +} + +type executionContext struct { + *graphql.RequestContext + *executableSchema +} + +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + res, err := ec.ResolverMiddleware(ctx, next) + if err != nil { + ec.Error(ctx, err) + return nil } - res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return res +} - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(parsedSchema), nil +} - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") } + return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil +} - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { +var parsedSchema = gqlparser.MustLoadSchema( + &ast.Source{Name: "schema.graphql", Input: `type Query { + user(id: ID!): User + search(input: SearchArgs = {location: "37,144", isBanned: false}): [User!]! +} - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } +type User { + id: ID! + name: String! + created: Timestamp + isBanned: Banned! + primitiveResolver: String! + customResolver: Point! + address: Address + tier: Tier +} + +type Address { + id: ID! + location: Point +} + +input SearchArgs { + location: Point + createdAfter: Timestamp + isBanned: Banned # TODO: This can be a Boolean again once multiple backing types are allowed +} + +enum Tier { + A + B + C +} + +scalar Timestamp +scalar Point +scalar Banned +`}, +) + +// ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + } + return handleFunc[0](ctx, chainHandler) + } } - wg.Wait() - return arr1 -} -// nolint: vetshadow -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil - }) - if resTmp == nil { - return graphql.Null + if n == 1 { + return handleFunc[0] } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) } - - return ec.___Type(ctx, field.Selections, res) } +// endregion ************************** generated.gotpl *************************** + +// region **************************** input.gotpl ***************************** + func UnmarshalSearchArgs(v interface{}) (model.SearchArgs, error) { var it model.SearchArgs var asMap = v.(map[string]interface{}) @@ -2333,123 +2062,414 @@ func UnmarshalSearchArgs(v interface{}) (model.SearchArgs, error) { if err != nil { return it, err } - case "isBanned": - var err error - err = (&it.IsBanned).UnmarshalGQL(v) - if err != nil { - return it, err + case "isBanned": + var err error + err = (&it.IsBanned).UnmarshalGQL(v) + if err != nil { + return it, err + } + } + } + + return it, nil +} + +func (e *executableSchema) SearchArgsMiddleware(ctx context.Context, obj *model.SearchArgs) (*model.SearchArgs, error) { + + return obj, nil +} + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +var addressImplementors = []string{"Address"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, obj *model.Address) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, addressImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Address") + case "id": + out.Values[i] = ec._Address_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "location": + out.Values[i] = ec._Address_location(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var queryImplementors = []string{"Query"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, queryImplementors) + + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "Query", + }) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Query") + case "user": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_user(ctx, field) + return res + }) + case "search": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_search(ctx, field) + if res == graphql.Null { + invalid = true + } + return res + }) + case "__type": + out.Values[i] = ec._Query___type(ctx, field) + case "__schema": + out.Values[i] = ec._Query___schema(ctx, field) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var userImplementors = []string{"User"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *model.User) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, userImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("User") + case "id": + out.Values[i] = ec._User_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "name": + out.Values[i] = ec._User_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "created": + out.Values[i] = ec._User_created(ctx, field, obj) + case "isBanned": + out.Values[i] = ec._User_isBanned(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "primitiveResolver": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._User_primitiveResolver(ctx, field, obj) + if res == graphql.Null { + invalid = true + } + return res + }) + case "customResolver": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._User_customResolver(ctx, field, obj) + if res == graphql.Null { + invalid = true + } + return res + }) + case "address": + out.Values[i] = ec._User_address(ctx, field, obj) + case "tier": + out.Values[i] = ec._User_tier(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __DirectiveImplementors = []string{"__Directive"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __EnumValueImplementors = []string{"__EnumValue"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) } } - - return it, nil + out.Dispatch() + if invalid { + return graphql.Null + } + return out } -func (e *executableSchema) SearchArgsMiddleware(ctx context.Context, obj *model.SearchArgs) (*model.SearchArgs, error) { +var __FieldImplementors = []string{"__Field"} - return obj, nil -} +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __FieldImplementors) -func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) } - }() - res, err := ec.ResolverMiddleware(ctx, next) - if err != nil { - ec.Error(ctx, err) - return nil } - return res -} - -func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") + out.Dispatch() + if invalid { + return graphql.Null } - return introspection.WrapSchema(parsedSchema), nil + return out } -func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") - } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil -} +var __InputValueImplementors = []string{"__InputValue"} -var parsedSchema = gqlparser.MustLoadSchema( - &ast.Source{Name: "schema.graphql", Input: `type Query { - user(id: ID!): User - search(input: SearchArgs = {location: "37,144", isBanned: false}): [User!]! -} +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) -type User { - id: ID! - name: String! - created: Timestamp - isBanned: Banned! - primitiveResolver: String! - customResolver: Point! - address: Address - tier: Tier + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out } -type Address { - id: ID! - location: Point -} +var __SchemaImplementors = []string{"__Schema"} -input SearchArgs { - location: Point - createdAfter: Timestamp - isBanned: Banned # TODO: This can be a Boolean again once multiple backing types are allowed -} +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) -enum Tier { - A - B - C + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out } -scalar Timestamp -scalar Point -scalar Banned -`}, -) - -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) +var __TypeImplementors = []string{"__Type"} - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __TypeImplementors) + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true } - return handleFunc[0](ctx, chainHandler) + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) } } - - if n == 1 { - return handleFunc[0] - } - - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) + out.Dispatch() + if invalid { + return graphql.Null } + return out } + +// endregion **************************** object.gotpl **************************** diff --git a/example/scalars/model/generated.go b/example/scalars/model/generated.go index 2ee63fc8aba..3330e525b55 100644 --- a/example/scalars/model/generated.go +++ b/example/scalars/model/generated.go @@ -1,5 +1,3 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - package model import ( diff --git a/example/selection/generated.go b/example/selection/generated.go index 72864263e58..a8040ac8e1d 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -17,242 +17,7 @@ import ( "github.com/vektah/gqlparser/ast" ) -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } -} - -type Config struct { - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot -} - -type ResolverRoot interface { - Query() QueryResolver -} - -type DirectiveRoot struct { -} - -type ComplexityRoot struct { - Like struct { - Reaction func(childComplexity int) int - Sent func(childComplexity int) int - Selection func(childComplexity int) int - Collected func(childComplexity int) int - } - - Post struct { - Message func(childComplexity int) int - Sent func(childComplexity int) int - Selection func(childComplexity int) int - Collected func(childComplexity int) int - } - - Query struct { - Events func(childComplexity int) int - } -} - -type QueryResolver interface { - Events(ctx context.Context) ([]Event, error) -} - -func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - } - args["name"] = arg0 - return args, nil - -} - -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil - -} - -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil - -} - -type executableSchema struct { - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot -} - -func (e *executableSchema) Schema() *ast.Schema { - return parsedSchema -} - -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - switch typeName + "." + field { - - case "Like.reaction": - if e.complexity.Like.Reaction == nil { - break - } - - return e.complexity.Like.Reaction(childComplexity), true - - case "Like.sent": - if e.complexity.Like.Sent == nil { - break - } - - return e.complexity.Like.Sent(childComplexity), true - - case "Like.selection": - if e.complexity.Like.Selection == nil { - break - } - - return e.complexity.Like.Selection(childComplexity), true - - case "Like.collected": - if e.complexity.Like.Collected == nil { - break - } - - return e.complexity.Like.Collected(childComplexity), true - - case "Post.message": - if e.complexity.Post.Message == nil { - break - } - - return e.complexity.Post.Message(childComplexity), true - - case "Post.sent": - if e.complexity.Post.Sent == nil { - break - } - - return e.complexity.Post.Sent(childComplexity), true - - case "Post.selection": - if e.complexity.Post.Selection == nil { - break - } - - return e.complexity.Post.Selection(childComplexity), true - - case "Post.collected": - if e.complexity.Post.Collected == nil { - break - } - - return e.complexity.Post.Collected(childComplexity), true - - case "Query.events": - if e.complexity.Query.Events == nil { - break - } - - return e.complexity.Query.Events(childComplexity), true - - } - return 0, false -} - -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions} -} - -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - return graphql.ErrorResponse(ctx, "mutations are not supported") -} - -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) -} - -type executionContext struct { - *graphql.RequestContext - *executableSchema -} - -var likeImplementors = []string{"Like", "Event"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Like(ctx context.Context, sel ast.SelectionSet, obj *Like) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, likeImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Like") - case "reaction": - out.Values[i] = ec._Like_reaction(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "sent": - out.Values[i] = ec._Like_sent(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "selection": - out.Values[i] = ec._Like_selection(ctx, field, obj) - case "collected": - out.Values[i] = ec._Like_collected(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} +// region **************************** field.gotpl ***************************** // nolint: vetshadow func (ec *executionContext) _Like_reaction(ctx context.Context, field graphql.CollectedField, obj *Like) graphql.Marshaler { @@ -374,43 +139,6 @@ func (ec *executionContext) _Like_collected(ctx context.Context, field graphql.C return arr1 } -var postImplementors = []string{"Post", "Event"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Post(ctx context.Context, sel ast.SelectionSet, obj *Post) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, postImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Post") - case "message": - out.Values[i] = ec._Post_message(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "sent": - out.Values[i] = ec._Post_sent(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "selection": - out.Values[i] = ec._Post_selection(ctx, field, obj) - case "collected": - out.Values[i] = ec._Post_collected(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - // nolint: vetshadow func (ec *executionContext) _Post_message(ctx context.Context, field graphql.CollectedField, obj *Post) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) @@ -531,43 +259,6 @@ func (ec *executionContext) _Post_collected(ctx context.Context, field graphql.C return arr1 } -var queryImplementors = []string{"Query"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, queryImplementors) - - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: "Query", - }) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Query") - case "events": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_events(ctx, field) - return res - }) - case "__type": - out.Values[i] = ec._Query___type(ctx, field) - case "__schema": - out.Values[i] = ec._Query___schema(ctx, field) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - // nolint: vetshadow func (ec *executionContext) _Query_events(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) @@ -690,46 +381,6 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C return ec.___Schema(ctx, field.Selections, res) } -var __DirectiveImplementors = []string{"__Directive"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Directive") - case "name": - out.Values[i] = ec.___Directive_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___Directive_description(ctx, field, obj) - case "locations": - out.Values[i] = ec.___Directive_locations(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "args": - out.Values[i] = ec.___Directive_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - // nolint: vetshadow func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) @@ -877,43 +528,6 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql return arr1 } -var __EnumValueImplementors = []string{"__EnumValue"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__EnumValue") - case "name": - out.Values[i] = ec.___EnumValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___EnumValue_description(ctx, field, obj) - case "isDeprecated": - out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "deprecationReason": - out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - // nolint: vetshadow func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) @@ -1020,53 +634,6 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, return graphql.MarshalString(*res) } -var __FieldImplementors = []string{"__Field"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __FieldImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Field") - case "name": - out.Values[i] = ec.___Field_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___Field_description(ctx, field, obj) - case "args": - out.Values[i] = ec.___Field_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "type": - out.Values[i] = ec.___Field_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "isDeprecated": - out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "deprecationReason": - out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - // nolint: vetshadow func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) @@ -1268,43 +835,6 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel return graphql.MarshalString(*res) } -var __InputValueImplementors = []string{"__InputValue"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__InputValue") - case "name": - out.Values[i] = ec.___InputValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___InputValue_description(ctx, field, obj) - case "type": - out.Values[i] = ec.___InputValue_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "defaultValue": - out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - // nolint: vetshadow func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) @@ -1419,75 +949,33 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel return graphql.MarshalString(*res) } -var __SchemaImplementors = []string{"__Schema"} +// nolint: vetshadow +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Schema") - case "types": - out.Values[i] = ec.___Schema_types(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "queryType": - out.Values[i] = ec.___Schema_queryType(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "mutationType": - out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) - case "subscriptionType": - out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) - case "directives": - out.Values[i] = ec.___Schema_directives(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - -// nolint: vetshadow -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Types(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup isLen1 := len(res) == 1 if !isLen1 { @@ -1674,50 +1162,6 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap return arr1 } -var __TypeImplementors = []string{"__Type"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __TypeImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Type") - case "kind": - out.Values[i] = ec.___Type_kind(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "name": - out.Values[i] = ec.___Type_name(ctx, field, obj) - case "description": - out.Values[i] = ec.___Type_description(ctx, field, obj) - case "fields": - out.Values[i] = ec.___Type_fields(ctx, field, obj) - case "interfaces": - out.Values[i] = ec.___Type_interfaces(ctx, field, obj) - case "possibleTypes": - out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) - case "enumValues": - out.Values[i] = ec.___Type_enumValues(ctx, field, obj) - case "inputFields": - out.Values[i] = ec.___Type_inputFields(ctx, field, obj) - case "ofType": - out.Values[i] = ec.___Type_ofType(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - // nolint: vetshadow func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) @@ -2125,111 +1569,687 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co return ec.___Type(ctx, field.Selections, res) } -func (ec *executionContext) _Event(ctx context.Context, sel ast.SelectionSet, obj *Event) graphql.Marshaler { - switch obj := (*obj).(type) { - case nil: - return graphql.Null - case Post: - return ec._Post(ctx, sel, &obj) - case *Post: - return ec._Post(ctx, sel, obj) - case Like: - return ec._Like(ctx, sel, &obj) - case *Like: - return ec._Like(ctx, sel, obj) - default: - panic(fmt.Errorf("unexpected type %T", obj)) - } -} +// endregion **************************** field.gotpl ***************************** -func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - res, err := ec.ResolverMiddleware(ctx, next) - if err != nil { - ec.Error(ctx, err) - return nil - } - return res -} +// region ************************** generated.gotpl *************************** -func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, } - return introspection.WrapSchema(parsedSchema), nil } -func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") - } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil +type Config struct { + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot } -var parsedSchema = gqlparser.MustLoadSchema( - &ast.Source{Name: "schema.graphql", Input: `interface Event { - selection: [String!] - collected: [String!] +type ResolverRoot interface { + Query() QueryResolver } -type Post implements Event { - message: String! - sent: Time! - selection: [String!] - collected: [String!] +type DirectiveRoot struct { } -type Like implements Event { - reaction: String! - sent: Time! - selection: [String!] - collected: [String!] -} +type ComplexityRoot struct { + Like struct { + Reaction func(childComplexity int) int + Sent func(childComplexity int) int + Selection func(childComplexity int) int + Collected func(childComplexity int) int + } -type Query { - events: [Event!] + Post struct { + Message func(childComplexity int) int + Sent func(childComplexity int) int + Selection func(childComplexity int) int + Collected func(childComplexity int) int + } + + Query struct { + Events func(childComplexity int) int + } } -scalar Time -`}, -) +type QueryResolver interface { + Events(ctx context.Context) ([]Event, error) +} -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) +func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg0 + return args, nil - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err +} - } - return handleFunc[0](ctx, chainHandler) +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err } } + args["includeDeprecated"] = arg0 + return args, nil - if n == 1 { - return handleFunc[0] - } +} - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } } + args["includeDeprecated"] = arg0 + return args, nil + } + +type executableSchema struct { + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + switch typeName + "." + field { + + case "Like.reaction": + if e.complexity.Like.Reaction == nil { + break + } + + return e.complexity.Like.Reaction(childComplexity), true + + case "Like.sent": + if e.complexity.Like.Sent == nil { + break + } + + return e.complexity.Like.Sent(childComplexity), true + + case "Like.selection": + if e.complexity.Like.Selection == nil { + break + } + + return e.complexity.Like.Selection(childComplexity), true + + case "Like.collected": + if e.complexity.Like.Collected == nil { + break + } + + return e.complexity.Like.Collected(childComplexity), true + + case "Post.message": + if e.complexity.Post.Message == nil { + break + } + + return e.complexity.Post.Message(childComplexity), true + + case "Post.sent": + if e.complexity.Post.Sent == nil { + break + } + + return e.complexity.Post.Sent(childComplexity), true + + case "Post.selection": + if e.complexity.Post.Selection == nil { + break + } + + return e.complexity.Post.Selection(childComplexity), true + + case "Post.collected": + if e.complexity.Post.Collected == nil { + break + } + + return e.complexity.Post.Collected(childComplexity), true + + case "Query.events": + if e.complexity.Query.Events == nil { + break + } + + return e.complexity.Query.Events(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._Query(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() + }) + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions} +} + +func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + return graphql.ErrorResponse(ctx, "mutations are not supported") +} + +func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { + return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) +} + +type executionContext struct { + *graphql.RequestContext + *executableSchema +} + +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + res, err := ec.ResolverMiddleware(ctx, next) + if err != nil { + ec.Error(ctx, err) + return nil + } + return res +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(parsedSchema), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil +} + +var parsedSchema = gqlparser.MustLoadSchema( + &ast.Source{Name: "schema.graphql", Input: `interface Event { + selection: [String!] + collected: [String!] +} + +type Post implements Event { + message: String! + sent: Time! + selection: [String!] + collected: [String!] +} + +type Like implements Event { + reaction: String! + sent: Time! + selection: [String!] + collected: [String!] +} + +type Query { + events: [Event!] +} + +scalar Time +`}, +) + +// ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + + } + return handleFunc[0](ctx, chainHandler) + } + } + + if n == 1 { + return handleFunc[0] + } + + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) + } +} + +// endregion ************************** generated.gotpl *************************** + +// region **************************** input.gotpl ***************************** + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +func (ec *executionContext) _Event(ctx context.Context, sel ast.SelectionSet, obj *Event) graphql.Marshaler { + switch obj := (*obj).(type) { + case nil: + return graphql.Null + case Post: + return ec._Post(ctx, sel, &obj) + case *Post: + return ec._Post(ctx, sel, obj) + case Like: + return ec._Like(ctx, sel, &obj) + case *Like: + return ec._Like(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +var likeImplementors = []string{"Like", "Event"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Like(ctx context.Context, sel ast.SelectionSet, obj *Like) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, likeImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Like") + case "reaction": + out.Values[i] = ec._Like_reaction(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "sent": + out.Values[i] = ec._Like_sent(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "selection": + out.Values[i] = ec._Like_selection(ctx, field, obj) + case "collected": + out.Values[i] = ec._Like_collected(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var postImplementors = []string{"Post", "Event"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Post(ctx context.Context, sel ast.SelectionSet, obj *Post) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, postImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Post") + case "message": + out.Values[i] = ec._Post_message(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "sent": + out.Values[i] = ec._Post_sent(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "selection": + out.Values[i] = ec._Post_selection(ctx, field, obj) + case "collected": + out.Values[i] = ec._Post_collected(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var queryImplementors = []string{"Query"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, queryImplementors) + + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "Query", + }) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Query") + case "events": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_events(ctx, field) + return res + }) + case "__type": + out.Values[i] = ec._Query___type(ctx, field) + case "__schema": + out.Values[i] = ec._Query___schema(ctx, field) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __DirectiveImplementors = []string{"__Directive"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __EnumValueImplementors = []string{"__EnumValue"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __FieldImplementors = []string{"__Field"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __FieldImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __InputValueImplementors = []string{"__InputValue"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __SchemaImplementors = []string{"__Schema"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __TypeImplementors = []string{"__Type"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __TypeImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +// endregion **************************** object.gotpl **************************** diff --git a/example/selection/models_gen.go b/example/selection/models_gen.go index a8183a3cbe0..4a194b0d638 100644 --- a/example/selection/models_gen.go +++ b/example/selection/models_gen.go @@ -1,5 +1,3 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - package selection import ( diff --git a/example/starwars/generated.go b/example/starwars/generated.go index de4f736ea44..13859be80e8 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -17,878 +17,1226 @@ import ( "github.com/vektah/gqlparser/ast" ) -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, +// region **************************** field.gotpl ***************************** + +// nolint: vetshadow +func (ec *executionContext) _Droid_id(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Droid", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalID(res) } -type Config struct { - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot +// nolint: vetshadow +func (ec *executionContext) _Droid_name(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Droid", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } -type ResolverRoot interface { - Droid() DroidResolver - FriendsConnection() FriendsConnectionResolver - Human() HumanResolver - Mutation() MutationResolver - Query() QueryResolver - Starship() StarshipResolver -} +// nolint: vetshadow +func (ec *executionContext) _Droid_friends(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Droid", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Droid().Friends(rctx, obj) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]Character) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -type DirectiveRoot struct { -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -type ComplexityRoot struct { - Droid struct { - Id func(childComplexity int) int - Name func(childComplexity int) int - Friends func(childComplexity int) int - FriendsConnection func(childComplexity int, first *int, after *string) int - AppearsIn func(childComplexity int) int - PrimaryFunction func(childComplexity int) int + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - FriendsConnection struct { - TotalCount func(childComplexity int) int - Edges func(childComplexity int) int - Friends func(childComplexity int) int - PageInfo func(childComplexity int) int - } + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - FriendsEdge struct { - Cursor func(childComplexity int) int - Node func(childComplexity int) int - } + return ec._Character(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } - Human struct { - Id func(childComplexity int) int - Name func(childComplexity int) int - Height func(childComplexity int, unit LengthUnit) int - Mass func(childComplexity int) int - Friends func(childComplexity int) int - FriendsConnection func(childComplexity int, first *int, after *string) int - AppearsIn func(childComplexity int) int - Starships func(childComplexity int) int } + wg.Wait() + return arr1 +} - Mutation struct { - CreateReview func(childComplexity int, episode Episode, review Review) int +// nolint: vetshadow +func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Droid", + Field: field, + Args: nil, } - - PageInfo struct { - StartCursor func(childComplexity int) int - EndCursor func(childComplexity int) int - HasNextPage func(childComplexity int) int + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Droid_friendsConnection_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - - Query struct { - Hero func(childComplexity int, episode *Episode) int - Reviews func(childComplexity int, episode Episode, since *time.Time) int - Search func(childComplexity int, text string) int - Character func(childComplexity int, id string) int - Droid func(childComplexity int, id string) int - Human func(childComplexity int, id string) int - Starship func(childComplexity int, id string) int + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Droid().FriendsConnection(rctx, obj, args["first"].(*int), args["after"].(*string)) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null } + res := resTmp.(FriendsConnection) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - Review struct { - Stars func(childComplexity int) int - Commentary func(childComplexity int) int - Time func(childComplexity int) int + return ec._FriendsConnection(ctx, field.Selections, &res) +} + +// nolint: vetshadow +func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Droid", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.AppearsIn, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null } + res := resTmp.([]Episode) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - Starship struct { - Id func(childComplexity int) int - Name func(childComplexity int) int - Length func(childComplexity int, unit *LengthUnit) int - History func(childComplexity int) int + arr1 := make(graphql.Array, len(res)) + + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { + return res[idx1] + }() } -} -type DroidResolver interface { - Friends(ctx context.Context, obj *Droid) ([]Character, error) - FriendsConnection(ctx context.Context, obj *Droid, first *int, after *string) (FriendsConnection, error) -} -type FriendsConnectionResolver interface { - Edges(ctx context.Context, obj *FriendsConnection) ([]FriendsEdge, error) - Friends(ctx context.Context, obj *FriendsConnection) ([]Character, error) + return arr1 } -type HumanResolver interface { - Friends(ctx context.Context, obj *Human) ([]Character, error) - FriendsConnection(ctx context.Context, obj *Human, first *int, after *string) (FriendsConnection, error) - Starships(ctx context.Context, obj *Human) ([]Starship, error) -} -type MutationResolver interface { - CreateReview(ctx context.Context, episode Episode, review Review) (*Review, error) -} -type QueryResolver interface { - Hero(ctx context.Context, episode *Episode) (Character, error) - Reviews(ctx context.Context, episode Episode, since *time.Time) ([]Review, error) - Search(ctx context.Context, text string) ([]SearchResult, error) - Character(ctx context.Context, id string) (Character, error) - Droid(ctx context.Context, id string) (*Droid, error) - Human(ctx context.Context, id string) (*Human, error) - Starship(ctx context.Context, id string) (*Starship, error) -} -type StarshipResolver interface { - Length(ctx context.Context, obj *Starship, unit *LengthUnit) (float64, error) +// nolint: vetshadow +func (ec *executionContext) _Droid_primaryFunction(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Droid", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PrimaryFunction, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } -func (e *executableSchema) field_Droid_friendsConnection_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *int - if tmp, ok := rawArgs["first"]; ok { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg0 = &ptr1 - } - - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _FriendsConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "FriendsConnection", + Field: field, + Args: nil, } - args["first"] = arg0 - var arg1 *string - if tmp, ok := rawArgs["after"]; ok { - var err error - var ptr1 string - if tmp != nil { - ptr1, err = graphql.UnmarshalID(tmp) - arg1 = &ptr1 - } - - if err != nil { - return nil, err + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["after"] = arg1 - return args, nil - + res := resTmp.(int) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalInt(res) } -func (e *executableSchema) field_Human_height_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 LengthUnit - if tmp, ok := rawArgs["unit"]; ok { - var err error - err = (&arg0).UnmarshalGQL(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _FriendsConnection_edges(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "FriendsConnection", + Field: field, + Args: nil, } - args["unit"] = arg0 - return args, nil + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.FriendsConnection().Edges(rctx, obj) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]FriendsEdge) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -func (e *executableSchema) field_Human_friendsConnection_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *int - if tmp, ok := rawArgs["first"]; ok { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg0 = &ptr1 + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - if err != nil { - return nil, err + return ec._FriendsEdge(ctx, field.Selections, &res[idx1]) + }() } - } - args["first"] = arg0 - var arg1 *string - if tmp, ok := rawArgs["after"]; ok { - var err error - var ptr1 string - if tmp != nil { - ptr1, err = graphql.UnmarshalID(tmp) - arg1 = &ptr1 + if isLen1 { + f(idx1) + } else { + go f(idx1) } - if err != nil { - return nil, err - } } - args["after"] = arg1 - return args, nil - + wg.Wait() + return arr1 } -func (e *executableSchema) field_Mutation_createReview_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 Episode - if tmp, ok := rawArgs["episode"]; ok { - var err error - err = (&arg0).UnmarshalGQL(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _FriendsConnection_friends(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "FriendsConnection", + Field: field, + Args: nil, } - args["episode"] = arg0 - var arg1 Review - if tmp, ok := rawArgs["review"]; ok { - var err error - arg1, err = UnmarshalReviewInput(tmp) - if err != nil { - return nil, err - } - - mReviewInput1, err := e.ReviewInputMiddleware(ctx, &arg1) - if err != nil { - return nil, err - } - arg1 = *mReviewInput1 + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.FriendsConnection().Friends(rctx, obj) + }) + if resTmp == nil { + return graphql.Null } - args["review"] = arg1 - return args, nil + res := resTmp.([]Character) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -func (e *executableSchema) field_Query_hero_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *Episode - if tmp, ok := rawArgs["episode"]; ok { - var err error - var ptr1 Episode - if tmp != nil { - err = (&ptr1).UnmarshalGQL(tmp) - arg0 = &ptr1 + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - if err != nil { - return nil, err + return ec._Character(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) } - } - args["episode"] = arg0 - return args, nil + } + wg.Wait() + return arr1 } -func (e *executableSchema) field_Query_reviews_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 Episode - if tmp, ok := rawArgs["episode"]; ok { - var err error - err = (&arg0).UnmarshalGQL(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _FriendsConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "FriendsConnection", + Field: field, + Args: nil, } - args["episode"] = arg0 - var arg1 *time.Time - if tmp, ok := rawArgs["since"]; ok { - var err error - var ptr1 time.Time - if tmp != nil { - ptr1, err = graphql.UnmarshalTime(tmp) - arg1 = &ptr1 - } - - if err != nil { - return nil, err + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["since"] = arg1 - return args, nil + res := resTmp.(PageInfo) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec._PageInfo(ctx, field.Selections, &res) } -func (e *executableSchema) field_Query_search_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["text"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _FriendsEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *FriendsEdge) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "FriendsEdge", + Field: field, + Args: nil, } - args["text"] = arg0 - return args, nil - -} - -func (e *executableSchema) field_Query_character_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalID(tmp) - if err != nil { - return nil, err + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["id"] = arg0 - return args, nil - + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalID(res) } -func (e *executableSchema) field_Query_droid_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalID(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _FriendsEdge_node(ctx context.Context, field graphql.CollectedField, obj *FriendsEdge) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "FriendsEdge", + Field: field, + Args: nil, } - args["id"] = arg0 - return args, nil - -} - -func (e *executableSchema) field_Query_human_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalID(tmp) - if err != nil { - return nil, err - } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + if resTmp == nil { + return graphql.Null } - args["id"] = arg0 - return args, nil + res := resTmp.(Character) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec._Character(ctx, field.Selections, &res) } -func (e *executableSchema) field_Query_starship_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalID(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Human_id(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Human", + Field: field, + Args: nil, } - args["id"] = arg0 - return args, nil - -} - -func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["name"] = arg0 - return args, nil - + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalID(res) } -func (e *executableSchema) field_Starship_length_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *LengthUnit - if tmp, ok := rawArgs["unit"]; ok { - var err error - var ptr1 LengthUnit - if tmp != nil { - err = (&ptr1).UnmarshalGQL(tmp) - arg0 = &ptr1 - } - - if err != nil { - return nil, err +// nolint: vetshadow +func (ec *executionContext) _Human_name(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Human", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["unit"] = arg0 - return args, nil - + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err +// nolint: vetshadow +func (ec *executionContext) _Human_height(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Human", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Human_height_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Height(args["unit"].(LengthUnit)), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["includeDeprecated"] = arg0 - return args, nil - + res := resTmp.(float64) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalFloat(res) } -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Human_mass(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Human", + Field: field, + Args: nil, } - args["includeDeprecated"] = arg0 - return args, nil - + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Mass, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(float64) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalFloat(res) } -type executableSchema struct { - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot -} +// nolint: vetshadow +func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Human", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Human().Friends(rctx, obj) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]Character) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -func (e *executableSchema) Schema() *ast.Schema { - return parsedSchema -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - switch typeName + "." + field { + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - case "Droid.id": - if e.complexity.Droid.Id == nil { - break + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.Droid.Id(childComplexity), true - - case "Droid.name": - if e.complexity.Droid.Name == nil { - break + return ec._Character(ctx, field.Selections, &res[idx1]) + }() } - - return e.complexity.Droid.Name(childComplexity), true - - case "Droid.friends": - if e.complexity.Droid.Friends == nil { - break + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.Droid.Friends(childComplexity), true - - case "Droid.friendsConnection": - if e.complexity.Droid.FriendsConnection == nil { - break - } + } + wg.Wait() + return arr1 +} - args, err := e.field_Droid_friendsConnection_args(context.TODO(), rawArgs) - if err != nil { - return 0, false +// nolint: vetshadow +func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Human", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Human_friendsConnection_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Human().FriendsConnection(rctx, obj, args["first"].(*int), args["after"].(*string)) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(FriendsConnection) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.Droid.FriendsConnection(childComplexity, args["first"].(*int), args["after"].(*string)), true + return ec._FriendsConnection(ctx, field.Selections, &res) +} - case "Droid.appearsIn": - if e.complexity.Droid.AppearsIn == nil { - break +// nolint: vetshadow +func (ec *executionContext) _Human_appearsIn(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Human", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.AppearsIn, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.([]Episode) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.Droid.AppearsIn(childComplexity), true - - case "Droid.primaryFunction": - if e.complexity.Droid.PrimaryFunction == nil { - break - } + arr1 := make(graphql.Array, len(res)) - return e.complexity.Droid.PrimaryFunction(childComplexity), true + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { + return res[idx1] + }() + } - case "FriendsConnection.totalCount": - if e.complexity.FriendsConnection.TotalCount == nil { - break - } + return arr1 +} - return e.complexity.FriendsConnection.TotalCount(childComplexity), true +// nolint: vetshadow +func (ec *executionContext) _Human_starships(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Human", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Human().Starships(rctx, obj) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]Starship) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - case "FriendsConnection.edges": - if e.complexity.FriendsConnection.Edges == nil { - break - } + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - return e.complexity.FriendsConnection.Edges(childComplexity), true + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - case "FriendsConnection.friends": - if e.complexity.FriendsConnection.Friends == nil { - break + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.FriendsConnection.Friends(childComplexity), true - - case "FriendsConnection.pageInfo": - if e.complexity.FriendsConnection.PageInfo == nil { - break + return ec._Starship(ctx, field.Selections, &res[idx1]) + }() } - - return e.complexity.FriendsConnection.PageInfo(childComplexity), true - - case "FriendsEdge.cursor": - if e.complexity.FriendsEdge.Cursor == nil { - break + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.FriendsEdge.Cursor(childComplexity), true - - case "FriendsEdge.node": - if e.complexity.FriendsEdge.Node == nil { - break - } + } + wg.Wait() + return arr1 +} - return e.complexity.FriendsEdge.Node(childComplexity), true +// nolint: vetshadow +func (ec *executionContext) _Mutation_createReview(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Mutation", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_createReview_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateReview(rctx, args["episode"].(Episode), args["review"].(Review)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Review) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - case "Human.id": - if e.complexity.Human.Id == nil { - break - } + if res == nil { + return graphql.Null + } - return e.complexity.Human.Id(childComplexity), true + return ec._Review(ctx, field.Selections, res) +} - case "Human.name": - if e.complexity.Human.Name == nil { - break +// nolint: vetshadow +func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *PageInfo) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "PageInfo", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.StartCursor, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalID(res) +} - return e.complexity.Human.Name(childComplexity), true - - case "Human.height": - if e.complexity.Human.Height == nil { - break +// nolint: vetshadow +func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *PageInfo) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "PageInfo", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EndCursor, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalID(res) +} - args, err := e.field_Human_height_args(context.TODO(), rawArgs) - if err != nil { - return 0, false +// nolint: vetshadow +func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *PageInfo) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "PageInfo", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.HasNextPage, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) +} - return e.complexity.Human.Height(childComplexity, args["unit"].(LengthUnit)), true - - case "Human.mass": - if e.complexity.Human.Mass == nil { - break - } +// nolint: vetshadow +func (ec *executionContext) _Query_hero(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_hero_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Hero(rctx, args["episode"].(*Episode)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(Character) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.Human.Mass(childComplexity), true + return ec._Character(ctx, field.Selections, &res) +} - case "Human.friends": - if e.complexity.Human.Friends == nil { - break +// nolint: vetshadow +func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_reviews_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Reviews(rctx, args["episode"].(Episode), args["since"].(*time.Time)) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.([]Review) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.Human.Friends(childComplexity), true + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - case "Human.friendsConnection": - if e.complexity.Human.FriendsConnection == nil { - break - } + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - args, err := e.field_Human_friendsConnection_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.Human.FriendsConnection(childComplexity, args["first"].(*int), args["after"].(*string)), true - - case "Human.appearsIn": - if e.complexity.Human.AppearsIn == nil { - break + return ec._Review(ctx, field.Selections, &res[idx1]) + }() } - - return e.complexity.Human.AppearsIn(childComplexity), true - - case "Human.starships": - if e.complexity.Human.Starships == nil { - break + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.Human.Starships(childComplexity), true - - case "Mutation.createReview": - if e.complexity.Mutation.CreateReview == nil { - break - } + } + wg.Wait() + return arr1 +} - args, err := e.field_Mutation_createReview_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.CreateReview(childComplexity, args["episode"].(Episode), args["review"].(Review)), true - - case "PageInfo.startCursor": - if e.complexity.PageInfo.StartCursor == nil { - break +// nolint: vetshadow +func (ec *executionContext) _Query_search(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_search_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Search(rctx, args["text"].(string)) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.([]SearchResult) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.PageInfo.StartCursor(childComplexity), true - - case "PageInfo.endCursor": - if e.complexity.PageInfo.EndCursor == nil { - break - } + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - return e.complexity.PageInfo.EndCursor(childComplexity), true + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - case "PageInfo.hasNextPage": - if e.complexity.PageInfo.HasNextPage == nil { - break + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.PageInfo.HasNextPage(childComplexity), true - - case "Query.hero": - if e.complexity.Query.Hero == nil { - break + return ec._SearchResult(ctx, field.Selections, &res[idx1]) + }() } - - args, err := e.field_Query_hero_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.Query.Hero(childComplexity, args["episode"].(*Episode)), true - - case "Query.reviews": - if e.complexity.Query.Reviews == nil { - break - } + } + wg.Wait() + return arr1 +} - args, err := e.field_Query_reviews_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } +// nolint: vetshadow +func (ec *executionContext) _Query_character(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_character_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Character(rctx, args["id"].(string)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(Character) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.Query.Reviews(childComplexity, args["episode"].(Episode), args["since"].(*time.Time)), true + return ec._Character(ctx, field.Selections, &res) +} - case "Query.search": - if e.complexity.Query.Search == nil { - break - } +// nolint: vetshadow +func (ec *executionContext) _Query_droid(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_droid_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Droid(rctx, args["id"].(string)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Droid) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - args, err := e.field_Query_search_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } + if res == nil { + return graphql.Null + } - return e.complexity.Query.Search(childComplexity, args["text"].(string)), true + return ec._Droid(ctx, field.Selections, res) +} - case "Query.character": - if e.complexity.Query.Character == nil { - break - } +// nolint: vetshadow +func (ec *executionContext) _Query_human(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_human_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Human(rctx, args["id"].(string)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Human) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - args, err := e.field_Query_character_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } + if res == nil { + return graphql.Null + } - return e.complexity.Query.Character(childComplexity, args["id"].(string)), true + return ec._Human(ctx, field.Selections, res) +} - case "Query.droid": - if e.complexity.Query.Droid == nil { - break - } +// nolint: vetshadow +func (ec *executionContext) _Query_starship(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_starship_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Starship(rctx, args["id"].(string)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Starship) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - args, err := e.field_Query_droid_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } + if res == nil { + return graphql.Null + } - return e.complexity.Query.Droid(childComplexity, args["id"].(string)), true - - case "Query.human": - if e.complexity.Query.Human == nil { - break - } - - args, err := e.field_Query_human_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.Human(childComplexity, args["id"].(string)), true - - case "Query.starship": - if e.complexity.Query.Starship == nil { - break - } - - args, err := e.field_Query_starship_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.Starship(childComplexity, args["id"].(string)), true - - case "Review.stars": - if e.complexity.Review.Stars == nil { - break - } - - return e.complexity.Review.Stars(childComplexity), true - - case "Review.commentary": - if e.complexity.Review.Commentary == nil { - break - } - - return e.complexity.Review.Commentary(childComplexity), true - - case "Review.time": - if e.complexity.Review.Time == nil { - break - } - - return e.complexity.Review.Time(childComplexity), true - - case "Starship.id": - if e.complexity.Starship.Id == nil { - break - } - - return e.complexity.Starship.Id(childComplexity), true - - case "Starship.name": - if e.complexity.Starship.Name == nil { - break - } - - return e.complexity.Starship.Name(childComplexity), true - - case "Starship.length": - if e.complexity.Starship.Length == nil { - break - } - - args, err := e.field_Starship_length_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Starship.Length(childComplexity, args["unit"].(*LengthUnit)), true - - case "Starship.history": - if e.complexity.Starship.History == nil { - break - } - - return e.complexity.Starship.History(childComplexity), true + return ec._Starship(ctx, field.Selections, res) +} +// nolint: vetshadow +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - return 0, false -} - -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions} -} - -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Mutation(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query___type_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(args["name"].(string)) }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, + if resTmp == nil { + return graphql.Null } -} + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) -} + if res == nil { + return graphql.Null + } -type executionContext struct { - *graphql.RequestContext - *executableSchema + return ec.___Type(ctx, field.Selections, res) } -var droidImplementors = []string{"Droid", "Character"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Droid(ctx context.Context, sel ast.SelectionSet, obj *Droid) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, droidImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Droid") - case "id": - out.Values[i] = ec._Droid_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "name": - out.Values[i] = ec._Droid_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "friends": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Droid_friends(ctx, field, obj) - return res - }) - case "friendsConnection": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Droid_friendsConnection(ctx, field, obj) - if res == graphql.Null { - invalid = true - } - return res - }) - case "appearsIn": - out.Values[i] = ec._Droid_appearsIn(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "primaryFunction": - out.Values[i] = ec._Droid_primaryFunction(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } +// nolint: vetshadow +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - out.Dispatch() - if invalid { + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if resTmp == nil { return graphql.Null } - return out + res := resTmp.(*introspection.Schema) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { + return graphql.Null + } + + return ec.___Schema(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) _Droid_id(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { +func (ec *executionContext) _Review_stars(ctx context.Context, field graphql.CollectedField, obj *Review) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Droid", + Object: "Review", Field: field, Args: nil, } @@ -896,7 +1244,7 @@ func (ec *executionContext) _Droid_id(ctx context.Context, field graphql.Collect ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.Stars, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -904,18 +1252,18 @@ func (ec *executionContext) _Droid_id(ctx context.Context, field graphql.Collect } return graphql.Null } - res := resTmp.(string) + res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + return graphql.MarshalInt(res) } // nolint: vetshadow -func (ec *executionContext) _Droid_name(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { +func (ec *executionContext) _Review_commentary(ctx context.Context, field graphql.CollectedField, obj *Review) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Droid", + Object: "Review", Field: field, Args: nil, } @@ -923,26 +1271,27 @@ func (ec *executionContext) _Droid_name(ctx context.Context, field graphql.Colle ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Commentary, nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) _Droid_friends(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { +func (ec *executionContext) _Review_time(ctx context.Context, field graphql.CollectedField, obj *Review) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Droid", + Object: "Review", Field: field, Args: nil, } @@ -950,62 +1299,83 @@ func (ec *executionContext) _Droid_friends(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Droid().Friends(rctx, obj) + return obj.Time, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.([]Character) + res := resTmp.(time.Time) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalTime(res) +} - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) +// nolint: vetshadow +func (ec *executionContext) _Starship_id(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Starship", + Field: field, + Args: nil, } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalID(res) +} - return ec._Character(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) +// nolint: vetshadow +func (ec *executionContext) _Starship_name(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Starship", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } - + return graphql.Null } - wg.Wait() - return arr1 + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { +func (ec *executionContext) _Starship_length(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Droid", + Object: "Starship", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Droid_friendsConnection_args(ctx, rawArgs) + args, err := ec.field_Starship_length_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -1014,7 +1384,7 @@ func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Droid().FriendsConnection(rctx, obj, args["first"].(*int), args["after"].(*string)) + return ec.resolvers.Starship().Length(rctx, obj, args["unit"].(*LengthUnit)) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1022,19 +1392,18 @@ func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field } return graphql.Null } - res := resTmp.(FriendsConnection) + res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._FriendsConnection(ctx, field.Selections, &res) + return graphql.MarshalFloat(res) } // nolint: vetshadow -func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { +func (ec *executionContext) _Starship_history(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Droid", + Object: "Starship", Field: field, Args: nil, } @@ -1042,7 +1411,7 @@ func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql. ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.AppearsIn, nil + return obj.History, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1050,7 +1419,7 @@ func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql. } return graphql.Null } - res := resTmp.([]Episode) + res := resTmp.([][]int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1058,7 +1427,16 @@ func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql. for idx1 := range res { arr1[idx1] = func() graphql.Marshaler { - return res[idx1] + + arr2 := make(graphql.Array, len(res[idx1])) + + for idx2 := range res[idx1] { + arr2[idx2] = func() graphql.Marshaler { + return graphql.MarshalInt(res[idx1][idx2]) + }() + } + + return arr2 }() } @@ -1066,11 +1444,11 @@ func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql. } // nolint: vetshadow -func (ec *executionContext) _Droid_primaryFunction(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Droid", + Object: "__Directive", Field: field, Args: nil, } @@ -1078,9 +1456,12 @@ func (ec *executionContext) _Droid_primaryFunction(ctx context.Context, field gr ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PrimaryFunction, nil + return obj.Name, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(string) @@ -1089,57 +1470,12 @@ func (ec *executionContext) _Droid_primaryFunction(ctx context.Context, field gr return graphql.MarshalString(res) } -var friendsConnectionImplementors = []string{"FriendsConnection"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _FriendsConnection(ctx context.Context, sel ast.SelectionSet, obj *FriendsConnection) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, friendsConnectionImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("FriendsConnection") - case "totalCount": - out.Values[i] = ec._FriendsConnection_totalCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "edges": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._FriendsConnection_edges(ctx, field, obj) - return res - }) - case "friends": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._FriendsConnection_friends(ctx, field, obj) - return res - }) - case "pageInfo": - out.Values[i] = ec._FriendsConnection_pageInfo(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - // nolint: vetshadow -func (ec *executionContext) _FriendsConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "FriendsConnection", + Object: "__Directive", Field: field, Args: nil, } @@ -1147,26 +1483,23 @@ func (ec *executionContext) _FriendsConnection_totalCount(ctx context.Context, f ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.TotalCount(), nil + return obj.Description, nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(int) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _FriendsConnection_edges(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "FriendsConnection", + Object: "__Directive", Field: field, Args: nil, } @@ -1174,56 +1507,35 @@ func (ec *executionContext) _FriendsConnection_edges(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.FriendsConnection().Edges(rctx, obj) + return obj.Locations, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]FriendsEdge) + res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._FriendsEdge(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - + arr1[idx1] = func() graphql.Marshaler { + return graphql.MarshalString(res[idx1]) + }() } - wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) _FriendsConnection_friends(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "FriendsConnection", + Object: "__Directive", Field: field, Args: nil, } @@ -1231,12 +1543,15 @@ func (ec *executionContext) _FriendsConnection_friends(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.FriendsConnection().Friends(rctx, obj) + return obj.Args, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]Character) + res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1261,7 +1576,7 @@ func (ec *executionContext) _FriendsConnection_friends(ctx context.Context, fiel } arr1[idx1] = func() graphql.Marshaler { - return ec._Character(ctx, field.Selections, &res[idx1]) + return ec.___InputValue(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1276,11 +1591,11 @@ func (ec *executionContext) _FriendsConnection_friends(ctx context.Context, fiel } // nolint: vetshadow -func (ec *executionContext) _FriendsConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "FriendsConnection", + Object: "__EnumValue", Field: field, Args: nil, } @@ -1288,7 +1603,7 @@ func (ec *executionContext) _FriendsConnection_pageInfo(ctx context.Context, fie ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PageInfo(), nil + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1296,49 +1611,18 @@ func (ec *executionContext) _FriendsConnection_pageInfo(ctx context.Context, fie } return graphql.Null } - res := resTmp.(PageInfo) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._PageInfo(ctx, field.Selections, &res) -} - -var friendsEdgeImplementors = []string{"FriendsEdge"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _FriendsEdge(ctx context.Context, sel ast.SelectionSet, obj *FriendsEdge) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, friendsEdgeImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("FriendsEdge") - case "cursor": - out.Values[i] = ec._FriendsEdge_cursor(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "node": - out.Values[i] = ec._FriendsEdge_node(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _FriendsEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *FriendsEdge) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "FriendsEdge", + Object: "__EnumValue", Field: field, Args: nil, } @@ -1346,117 +1630,23 @@ func (ec *executionContext) _FriendsEdge_cursor(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Cursor, nil + return obj.Description, nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) -} - -// nolint: vetshadow -func (ec *executionContext) _FriendsEdge_node(ctx context.Context, field graphql.CollectedField, obj *FriendsEdge) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "FriendsEdge", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Node, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(Character) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._Character(ctx, field.Selections, &res) -} - -var humanImplementors = []string{"Human", "Character"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Human(ctx context.Context, sel ast.SelectionSet, obj *Human) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, humanImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Human") - case "id": - out.Values[i] = ec._Human_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "name": - out.Values[i] = ec._Human_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "height": - out.Values[i] = ec._Human_height(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "mass": - out.Values[i] = ec._Human_mass(ctx, field, obj) - case "friends": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Human_friends(ctx, field, obj) - return res - }) - case "friendsConnection": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Human_friendsConnection(ctx, field, obj) - if res == graphql.Null { - invalid = true - } - return res - }) - case "appearsIn": - out.Values[i] = ec._Human_appearsIn(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "starships": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Human_starships(ctx, field, obj) - return res - }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _Human_id(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Human", + Object: "__EnumValue", Field: field, Args: nil, } @@ -1464,7 +1654,7 @@ func (ec *executionContext) _Human_id(ctx context.Context, field graphql.Collect ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.IsDeprecated(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1472,18 +1662,18 @@ func (ec *executionContext) _Human_id(ctx context.Context, field graphql.Collect } return graphql.Null } - res := resTmp.(string) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) _Human_name(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Human", + Object: "__EnumValue", Field: field, Args: nil, } @@ -1491,41 +1681,35 @@ func (ec *executionContext) _Human_name(ctx context.Context, field graphql.Colle ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.DeprecationReason(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) _Human_height(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Human", + Object: "__Field", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Human_height_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Height(args["unit"].(LengthUnit)), nil + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1533,18 +1717,18 @@ func (ec *executionContext) _Human_height(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(float64) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _Human_mass(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Human", + Object: "__Field", Field: field, Args: nil, } @@ -1552,23 +1736,23 @@ func (ec *executionContext) _Human_mass(ctx context.Context, field graphql.Colle ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Mass, nil + return obj.Description, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(float64) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Human", + Object: "__Field", Field: field, Args: nil, } @@ -1576,12 +1760,15 @@ func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Human().Friends(rctx, obj) + return obj.Args, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]Character) + res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1606,7 +1793,7 @@ func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.Co } arr1[idx1] = func() graphql.Marshaler { - return ec._Character(ctx, field.Selections, &res[idx1]) + return ec.___InputValue(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1621,26 +1808,19 @@ func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.Co } // nolint: vetshadow -func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Human", + Object: "__Field", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Human_friendsConnection_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Human().FriendsConnection(rctx, obj, args["first"].(*int), args["after"].(*string)) + return obj.Type, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1648,19 +1828,26 @@ func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field } return graphql.Null } - res := resTmp.(FriendsConnection) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec._FriendsConnection(ctx, field.Selections, &res) + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) _Human_appearsIn(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Human", + Object: "__Field", Field: field, Args: nil, } @@ -1668,7 +1855,7 @@ func (ec *executionContext) _Human_appearsIn(ctx context.Context, field graphql. ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.AppearsIn, nil + return obj.IsDeprecated(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1676,27 +1863,18 @@ func (ec *executionContext) _Human_appearsIn(ctx context.Context, field graphql. } return graphql.Null } - res := resTmp.([]Episode) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return res[idx1] - }() - } - - return arr1 + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) _Human_starships(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Human", + Object: "__Field", Field: field, Args: nil, } @@ -1704,159 +1882,141 @@ func (ec *executionContext) _Human_starships(ctx context.Context, field graphql. ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Human().Starships(rctx, obj) + return obj.DeprecationReason(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.([]Starship) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) + if res == nil { + return graphql.Null } + return graphql.MarshalString(*res) +} - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._Starship(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - +// nolint: vetshadow +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Field: field, + Args: nil, } - wg.Wait() - return arr1 -} - -var mutationImplementors = []string{"Mutation"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, mutationImplementors) - - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: "Mutation", + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil }) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Mutation") - case "createReview": - out.Values[i] = ec._Mutation_createReview(ctx, field) - default: - panic("unknown field " + strconv.Quote(field.Name)) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } - } - out.Dispatch() - if invalid { return graphql.Null } - return out + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _Mutation_createReview(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Mutation", + Object: "__InputValue", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_createReview_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if resTmp == nil { return graphql.Null } - rctx.Args = args + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} + +// nolint: vetshadow +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateReview(rctx, args["episode"].(Episode), args["review"].(Review)) + return obj.Type, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*Review) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - return ec._Review(ctx, field.Selections, res) + return ec.___Type(ctx, field.Selections, res) } -var pageInfoImplementors = []string{"PageInfo"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *PageInfo) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, pageInfoImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("PageInfo") - case "startCursor": - out.Values[i] = ec._PageInfo_startCursor(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "endCursor": - out.Values[i] = ec._PageInfo_endCursor(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "hasNextPage": - out.Values[i] = ec._PageInfo_hasNextPage(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } +// nolint: vetshadow +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Field: field, + Args: nil, } - out.Dispatch() - if invalid { + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if resTmp == nil { return graphql.Null } - return out + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *PageInfo) graphql.Marshaler { +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "PageInfo", + Object: "__Schema", Field: field, Args: nil, } @@ -1864,7 +2024,7 @@ func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field gra ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.StartCursor, nil + return obj.Types(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1872,18 +2032,51 @@ func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *PageInfo) graphql.Marshaler { +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "PageInfo", + Object: "__Schema", Field: field, Args: nil, } @@ -1891,7 +2084,7 @@ func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.EndCursor, nil + return obj.QueryType(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1899,18 +2092,26 @@ func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graph } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *PageInfo) graphql.Marshaler { +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "PageInfo", + Object: "__Schema", Field: field, Args: nil, } @@ -1918,160 +2119,216 @@ func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field gra ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.HasNextPage, nil + return obj.MutationType(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) -} -var queryImplementors = []string{"Query"} + if res == nil { + return graphql.Null + } -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, queryImplementors) + return ec.___Type(ctx, field.Selections, res) +} - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: "Query", +// nolint: vetshadow +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Query") - case "hero": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_hero(ctx, field) - return res - }) - case "reviews": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_reviews(ctx, field) - if res == graphql.Null { - invalid = true - } - return res - }) - case "search": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_search(ctx, field) - if res == graphql.Null { - invalid = true - } - return res - }) - case "character": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_character(ctx, field) - return res - }) - case "droid": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_droid(ctx, field) - return res - }) - case "human": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_human(ctx, field) - return res - }) - case "starship": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_starship(ctx, field) - return res - }) - case "__type": - out.Values[i] = ec._Query___type(ctx, field) - case "__schema": - out.Values[i] = ec._Query___schema(ctx, field) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } + if res == nil { + return graphql.Null } - out.Dispatch() - if invalid { + + return ec.___Type(ctx, field.Selections, res) +} + +// nolint: vetshadow +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - return out + res := resTmp.([]introspection.Directive) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___Directive(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) _Query_hero(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "__Type", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_hero_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - rctx.Args = args + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} + +// nolint: vetshadow +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Hero(rctx, args["episode"].(*Episode)) + return obj.Name(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(Character) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec._Character(ctx, field.Selections, &res) + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} + +// nolint: vetshadow +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_reviews_args(ctx, rawArgs) + args, err := ec.field___Type_fields_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Reviews(rctx, args["episode"].(Episode), args["since"].(*time.Time)) + return obj.Fields(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]Review) + res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -2096,7 +2353,7 @@ func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.Co } arr1[idx1] = func() graphql.Marshaler { - return ec._Review(ctx, field.Selections, &res[idx1]) + return ec.___Field(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -2111,34 +2368,24 @@ func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.Co } // nolint: vetshadow -func (ec *executionContext) _Query_search(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "__Type", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_search_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Search(rctx, args["text"].(string)) + return obj.Interfaces(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]SearchResult) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -2163,7 +2410,7 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col } arr1[idx1] = func() graphql.Marshaler { - return ec._SearchResult(ctx, field.Selections, &res[idx1]) + return ec.___Type(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -2178,166 +2425,197 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) _Query_character(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "__Type", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_character_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Character(rctx, args["id"].(string)) + return obj.PossibleTypes(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(Character) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec._Character(ctx, field.Selections, &res) -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -// nolint: vetshadow -func (ec *executionContext) _Query_droid(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_droid_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Droid(rctx, args["id"].(string)) - }) - if resTmp == nil { - return graphql.Null + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - res := resTmp.(*Droid) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null - } + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return ec._Droid(ctx, field.Selections, res) + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) _Query_human(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "__Type", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_human_args(ctx, rawArgs) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Human(rctx, args["id"].(string)) + return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*Human) + res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - return ec._Human(ctx, field.Selections, res) + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___EnumValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) _Query_starship(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "__Type", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_starship_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Starship(rctx, args["id"].(string)) + return obj.InputFields(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*Starship) + res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - return ec._Starship(ctx, field.Selections, res) + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "__Type", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query___type_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectType(args["name"].(string)) + return obj.OfType(), nil }) if resTmp == nil { return graphql.Null @@ -2353,1852 +2631,834 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col return ec.___Type(ctx, field.Selections, res) } -// nolint: vetshadow -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Schema) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +// endregion **************************** field.gotpl ***************************** - if res == nil { - return graphql.Null - } +// region ************************** generated.gotpl *************************** - return ec.___Schema(ctx, field.Selections, res) +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } } -var reviewImplementors = []string{"Review"} +type Config struct { + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Review(ctx context.Context, sel ast.SelectionSet, obj *Review) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, reviewImplementors) +type ResolverRoot interface { + Droid() DroidResolver + FriendsConnection() FriendsConnectionResolver + Human() HumanResolver + Mutation() MutationResolver + Query() QueryResolver + Starship() StarshipResolver +} - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Review") - case "stars": - out.Values[i] = ec._Review_stars(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "commentary": - out.Values[i] = ec._Review_commentary(ctx, field, obj) - case "time": - out.Values[i] = ec._Review_time(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out +type DirectiveRoot struct { } -// nolint: vetshadow -func (ec *executionContext) _Review_stars(ctx context.Context, field graphql.CollectedField, obj *Review) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Review", - Field: field, - Args: nil, +type ComplexityRoot struct { + Droid struct { + Id func(childComplexity int) int + Name func(childComplexity int) int + Friends func(childComplexity int) int + FriendsConnection func(childComplexity int, first *int, after *string) int + AppearsIn func(childComplexity int) int + PrimaryFunction func(childComplexity int) int } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Stars, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null + + FriendsConnection struct { + TotalCount func(childComplexity int) int + Edges func(childComplexity int) int + Friends func(childComplexity int) int + PageInfo func(childComplexity int) int } - res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) -} -// nolint: vetshadow -func (ec *executionContext) _Review_commentary(ctx context.Context, field graphql.CollectedField, obj *Review) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Review", - Field: field, - Args: nil, + FriendsEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Commentary, nil - }) - if resTmp == nil { - return graphql.Null + + Human struct { + Id func(childComplexity int) int + Name func(childComplexity int) int + Height func(childComplexity int, unit LengthUnit) int + Mass func(childComplexity int) int + Friends func(childComplexity int) int + FriendsConnection func(childComplexity int, first *int, after *string) int + AppearsIn func(childComplexity int) int + Starships func(childComplexity int) int } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null + Mutation struct { + CreateReview func(childComplexity int, episode Episode, review Review) int } - return graphql.MarshalString(*res) -} -// nolint: vetshadow -func (ec *executionContext) _Review_time(ctx context.Context, field graphql.CollectedField, obj *Review) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Review", - Field: field, - Args: nil, + PageInfo struct { + StartCursor func(childComplexity int) int + EndCursor func(childComplexity int) int + HasNextPage func(childComplexity int) int } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Time, nil - }) - if resTmp == nil { - return graphql.Null + + Query struct { + Hero func(childComplexity int, episode *Episode) int + Reviews func(childComplexity int, episode Episode, since *time.Time) int + Search func(childComplexity int, text string) int + Character func(childComplexity int, id string) int + Droid func(childComplexity int, id string) int + Human func(childComplexity int, id string) int + Starship func(childComplexity int, id string) int + } + + Review struct { + Stars func(childComplexity int) int + Commentary func(childComplexity int) int + Time func(childComplexity int) int + } + + Starship struct { + Id func(childComplexity int) int + Name func(childComplexity int) int + Length func(childComplexity int, unit *LengthUnit) int + History func(childComplexity int) int } - res := resTmp.(time.Time) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalTime(res) } -var starshipImplementors = []string{"Starship"} +type DroidResolver interface { + Friends(ctx context.Context, obj *Droid) ([]Character, error) + FriendsConnection(ctx context.Context, obj *Droid, first *int, after *string) (FriendsConnection, error) +} +type FriendsConnectionResolver interface { + Edges(ctx context.Context, obj *FriendsConnection) ([]FriendsEdge, error) + Friends(ctx context.Context, obj *FriendsConnection) ([]Character, error) +} +type HumanResolver interface { + Friends(ctx context.Context, obj *Human) ([]Character, error) + FriendsConnection(ctx context.Context, obj *Human, first *int, after *string) (FriendsConnection, error) -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Starship(ctx context.Context, sel ast.SelectionSet, obj *Starship) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, starshipImplementors) + Starships(ctx context.Context, obj *Human) ([]Starship, error) +} +type MutationResolver interface { + CreateReview(ctx context.Context, episode Episode, review Review) (*Review, error) +} +type QueryResolver interface { + Hero(ctx context.Context, episode *Episode) (Character, error) + Reviews(ctx context.Context, episode Episode, since *time.Time) ([]Review, error) + Search(ctx context.Context, text string) ([]SearchResult, error) + Character(ctx context.Context, id string) (Character, error) + Droid(ctx context.Context, id string) (*Droid, error) + Human(ctx context.Context, id string) (*Human, error) + Starship(ctx context.Context, id string) (*Starship, error) +} +type StarshipResolver interface { + Length(ctx context.Context, obj *Starship, unit *LengthUnit) (float64, error) +} - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Starship") - case "id": - out.Values[i] = ec._Starship_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "name": - out.Values[i] = ec._Starship_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "length": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Starship_length(ctx, field, obj) - if res == graphql.Null { - invalid = true - } - return res - }) - case "history": - out.Values[i] = ec._Starship_history(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) +func (e *executableSchema) field_Droid_friendsConnection_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *int + if tmp, ok := rawArgs["first"]; ok { + var err error + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + arg0 = &ptr1 + } + + if err != nil { + return nil, err } } - out.Dispatch() - if invalid { - return graphql.Null + args["first"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + var err error + var ptr1 string + if tmp != nil { + ptr1, err = graphql.UnmarshalID(tmp) + arg1 = &ptr1 + } + + if err != nil { + return nil, err + } } - return out + args["after"] = arg1 + return args, nil + } -// nolint: vetshadow -func (ec *executionContext) _Starship_id(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Starship", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +func (e *executableSchema) field_Human_height_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 LengthUnit + if tmp, ok := rawArgs["unit"]; ok { + var err error + err = (&arg0).UnmarshalGQL(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + args["unit"] = arg0 + return args, nil + } -// nolint: vetshadow -func (ec *executionContext) _Starship_name(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Starship", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +func (e *executableSchema) field_Human_friendsConnection_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *int + if tmp, ok := rawArgs["first"]; ok { + var err error + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + arg0 = &ptr1 } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} -// nolint: vetshadow -func (ec *executionContext) _Starship_length(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Starship", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Starship_length_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null + if err != nil { + return nil, err + } } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Starship().Length(rctx, obj, args["unit"].(*LengthUnit)) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + args["first"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + var err error + var ptr1 string + if tmp != nil { + ptr1, err = graphql.UnmarshalID(tmp) + arg1 = &ptr1 + } + + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(float64) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) + args["after"] = arg1 + return args, nil + } -// nolint: vetshadow -func (ec *executionContext) _Starship_history(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Starship", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.History, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +func (e *executableSchema) field_Mutation_createReview_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 Episode + if tmp, ok := rawArgs["episode"]; ok { + var err error + err = (&arg0).UnmarshalGQL(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.([][]int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) + args["episode"] = arg0 + var arg1 Review + if tmp, ok := rawArgs["review"]; ok { + var err error + arg1, err = UnmarshalReviewInput(tmp) + if err != nil { + return nil, err + } - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { + mReviewInput1, err := e.ReviewInputMiddleware(ctx, &arg1) + if err != nil { + return nil, err + } + arg1 = *mReviewInput1 + } + args["review"] = arg1 + return args, nil - arr2 := make(graphql.Array, len(res[idx1])) +} - for idx2 := range res[idx1] { - arr2[idx2] = func() graphql.Marshaler { - return graphql.MarshalInt(res[idx1][idx2]) - }() - } +func (e *executableSchema) field_Query_hero_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *Episode + if tmp, ok := rawArgs["episode"]; ok { + var err error + var ptr1 Episode + if tmp != nil { + err = (&ptr1).UnmarshalGQL(tmp) + arg0 = &ptr1 + } - return arr2 - }() + if err != nil { + return nil, err + } } + args["episode"] = arg0 + return args, nil - return arr1 } -var __DirectiveImplementors = []string{"__Directive"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Directive") - case "name": - out.Values[i] = ec.___Directive_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___Directive_description(ctx, field, obj) - case "locations": - out.Values[i] = ec.___Directive_locations(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "args": - out.Values[i] = ec.___Directive_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) +func (e *executableSchema) field_Query_reviews_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 Episode + if tmp, ok := rawArgs["episode"]; ok { + var err error + err = (&arg0).UnmarshalGQL(tmp) + if err != nil { + return nil, err } } - out.Dispatch() - if invalid { - return graphql.Null + args["episode"] = arg0 + var arg1 *time.Time + if tmp, ok := rawArgs["since"]; ok { + var err error + var ptr1 time.Time + if tmp != nil { + ptr1, err = graphql.UnmarshalTime(tmp) + arg1 = &ptr1 + } + + if err != nil { + return nil, err + } } - return out + args["since"] = arg1 + return args, nil + } -// nolint: vetshadow -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +func (e *executableSchema) field_Query_search_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["text"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + args["text"] = arg0 + return args, nil + } -// nolint: vetshadow -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, +func (e *executableSchema) field_Query_character_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = graphql.UnmarshalID(tmp) + if err != nil { + return nil, err + } } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + args["id"] = arg0 + return args, nil + } -// nolint: vetshadow -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Locations, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +func (e *executableSchema) field_Query_droid_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = graphql.UnmarshalID(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + args["id"] = arg0 + return args, nil - arr1 := make(graphql.Array, len(res)) +} - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() +func (e *executableSchema) field_Query_human_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = graphql.UnmarshalID(tmp) + if err != nil { + return nil, err + } } + args["id"] = arg0 + return args, nil - return arr1 } -// nolint: vetshadow -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Args, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +func (e *executableSchema) field_Query_starship_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = graphql.UnmarshalID(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + args["id"] = arg0 + return args, nil - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup +} - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) +func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } + args["name"] = arg0 + return args, nil - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { +} - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) +func (e *executableSchema) field_Starship_length_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *LengthUnit + if tmp, ok := rawArgs["unit"]; ok { + var err error + var ptr1 LengthUnit + if tmp != nil { + err = (&ptr1).UnmarshalGQL(tmp) + arg0 = &ptr1 } + if err != nil { + return nil, err + } } - wg.Wait() - return arr1 -} - -var __EnumValueImplementors = []string{"__EnumValue"} + args["unit"] = arg0 + return args, nil -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) +} - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__EnumValue") - case "name": - out.Values[i] = ec.___EnumValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___EnumValue_description(ctx, field, obj) - case "isDeprecated": - out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "deprecationReason": - out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err } } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + args["includeDeprecated"] = arg0 + return args, nil + } -// nolint: vetshadow -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + args["includeDeprecated"] = arg0 + return args, nil + } -// nolint: vetshadow -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) +type executableSchema struct { + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot } -// nolint: vetshadow -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) +func (e *executableSchema) Schema() *ast.Schema { + return parsedSchema } -// nolint: vetshadow -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) -} +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + switch typeName + "." + field { -var __FieldImplementors = []string{"__Field"} + case "Droid.id": + if e.complexity.Droid.Id == nil { + break + } -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __FieldImplementors) + return e.complexity.Droid.Id(childComplexity), true - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Field") - case "name": - out.Values[i] = ec.___Field_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___Field_description(ctx, field, obj) - case "args": - out.Values[i] = ec.___Field_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "type": - out.Values[i] = ec.___Field_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "isDeprecated": - out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "deprecationReason": - out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) + case "Droid.name": + if e.complexity.Droid.Name == nil { + break } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} -// nolint: vetshadow -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + return e.complexity.Droid.Name(childComplexity), true + + case "Droid.friends": + if e.complexity.Droid.Friends == nil { + break } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} -// nolint: vetshadow -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} + return e.complexity.Droid.Friends(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Args, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + case "Droid.friendsConnection": + if e.complexity.Droid.FriendsConnection == nil { + break } - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + args, err := e.field_Droid_friendsConnection_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } + return e.complexity.Droid.FriendsConnection(childComplexity, args["first"].(*int), args["after"].(*string)), true - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + case "Droid.appearsIn": + if e.complexity.Droid.AppearsIn == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) + return e.complexity.Droid.AppearsIn(childComplexity), true + + case "Droid.primaryFunction": + if e.complexity.Droid.PrimaryFunction == nil { + break } - } - wg.Wait() - return arr1 -} + return e.complexity.Droid.PrimaryFunction(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Type, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + case "FriendsConnection.totalCount": + if e.complexity.FriendsConnection.TotalCount == nil { + break } - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + return e.complexity.FriendsConnection.TotalCount(childComplexity), true + + case "FriendsConnection.edges": + if e.complexity.FriendsConnection.Edges == nil { + break } - return graphql.Null - } - return ec.___Type(ctx, field.Selections, res) -} + return e.complexity.FriendsConnection.Edges(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + case "FriendsConnection.friends": + if e.complexity.FriendsConnection.Friends == nil { + break } - return graphql.Null - } - res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) -} -// nolint: vetshadow -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return e.complexity.FriendsConnection.Friends(childComplexity), true - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) -} + case "FriendsConnection.pageInfo": + if e.complexity.FriendsConnection.PageInfo == nil { + break + } -var __InputValueImplementors = []string{"__InputValue"} + return e.complexity.FriendsConnection.PageInfo(childComplexity), true -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) + case "FriendsEdge.cursor": + if e.complexity.FriendsEdge.Cursor == nil { + break + } - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__InputValue") - case "name": - out.Values[i] = ec.___InputValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___InputValue_description(ctx, field, obj) - case "type": - out.Values[i] = ec.___InputValue_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "defaultValue": - out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) + return e.complexity.FriendsEdge.Cursor(childComplexity), true + + case "FriendsEdge.node": + if e.complexity.FriendsEdge.Node == nil { + break } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} -// nolint: vetshadow -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + return e.complexity.FriendsEdge.Node(childComplexity), true + + case "Human.id": + if e.complexity.Human.Id == nil { + break } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} -// nolint: vetshadow -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} + return e.complexity.Human.Id(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Type, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + case "Human.name": + if e.complexity.Human.Name == nil { + break } - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + return e.complexity.Human.Name(childComplexity), true + + case "Human.height": + if e.complexity.Human.Height == nil { + break } - return graphql.Null - } - return ec.___Type(ctx, field.Selections, res) -} + args, err := e.field_Human_height_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } -// nolint: vetshadow -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return e.complexity.Human.Height(childComplexity, args["unit"].(LengthUnit)), true - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) -} + case "Human.mass": + if e.complexity.Human.Mass == nil { + break + } -var __SchemaImplementors = []string{"__Schema"} + return e.complexity.Human.Mass(childComplexity), true -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) + case "Human.friends": + if e.complexity.Human.Friends == nil { + break + } - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Schema") - case "types": - out.Values[i] = ec.___Schema_types(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "queryType": - out.Values[i] = ec.___Schema_queryType(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "mutationType": - out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) - case "subscriptionType": - out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) - case "directives": - out.Values[i] = ec.___Schema_directives(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} + return e.complexity.Human.Friends(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Types(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + case "Human.friendsConnection": + if e.complexity.Human.FriendsConnection == nil { + break } - return graphql.Null - } - res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + args, err := e.field_Human_friendsConnection_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } + return e.complexity.Human.FriendsConnection(childComplexity, args["first"].(*int), args["after"].(*string)), true - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + case "Human.appearsIn": + if e.complexity.Human.AppearsIn == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) + return e.complexity.Human.AppearsIn(childComplexity), true + + case "Human.starships": + if e.complexity.Human.Starships == nil { + break } - } - wg.Wait() - return arr1 -} + return e.complexity.Human.Starships(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + case "Mutation.createReview": + if e.complexity.Mutation.CreateReview == nil { + break } - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + args, err := e.field_Mutation_createReview_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - return graphql.Null - } - return ec.___Type(ctx, field.Selections, res) -} + return e.complexity.Mutation.CreateReview(childComplexity, args["episode"].(Episode), args["review"].(Review)), true -// nolint: vetshadow -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + case "PageInfo.startCursor": + if e.complexity.PageInfo.StartCursor == nil { + break + } - if res == nil { - return graphql.Null - } + return e.complexity.PageInfo.StartCursor(childComplexity), true - return ec.___Type(ctx, field.Selections, res) -} + case "PageInfo.endCursor": + if e.complexity.PageInfo.EndCursor == nil { + break + } -// nolint: vetshadow -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return e.complexity.PageInfo.EndCursor(childComplexity), true - if res == nil { - return graphql.Null - } + case "PageInfo.hasNextPage": + if e.complexity.PageInfo.HasNextPage == nil { + break + } - return ec.___Type(ctx, field.Selections, res) -} + return e.complexity.PageInfo.HasNextPage(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + case "Query.hero": + if e.complexity.Query.Hero == nil { + break } - return graphql.Null - } - res := resTmp.([]introspection.Directive) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + args, err := e.field_Query_hero_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } + return e.complexity.Query.Hero(childComplexity, args["episode"].(*Episode)), true - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + case "Query.reviews": + if e.complexity.Query.Reviews == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec.___Directive(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) + args, err := e.field_Query_reviews_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - } - wg.Wait() - return arr1 -} - -var __TypeImplementors = []string{"__Type"} + return e.complexity.Query.Reviews(childComplexity, args["episode"].(Episode), args["since"].(*time.Time)), true -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __TypeImplementors) + case "Query.search": + if e.complexity.Query.Search == nil { + break + } - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Type") - case "kind": - out.Values[i] = ec.___Type_kind(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "name": - out.Values[i] = ec.___Type_name(ctx, field, obj) - case "description": - out.Values[i] = ec.___Type_description(ctx, field, obj) - case "fields": - out.Values[i] = ec.___Type_fields(ctx, field, obj) - case "interfaces": - out.Values[i] = ec.___Type_interfaces(ctx, field, obj) - case "possibleTypes": - out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) - case "enumValues": - out.Values[i] = ec.___Type_enumValues(ctx, field, obj) - case "inputFields": - out.Values[i] = ec.___Type_inputFields(ctx, field, obj) - case "ofType": - out.Values[i] = ec.___Type_ofType(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) + args, err := e.field_Query_search_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} -// nolint: vetshadow -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + return e.complexity.Query.Search(childComplexity, args["text"].(string)), true + + case "Query.character": + if e.complexity.Query.Character == nil { + break } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} -// nolint: vetshadow -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + args, err := e.field_Query_character_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) -} + return e.complexity.Query.Character(childComplexity, args["id"].(string)), true -// nolint: vetshadow -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} + case "Query.droid": + if e.complexity.Query.Droid == nil { + break + } -// nolint: vetshadow -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_fields_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Fields(args["includeDeprecated"].(bool)), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Field) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + args, err := e.field_Query_droid_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + return e.complexity.Query.Droid(childComplexity, args["id"].(string)), true - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } + case "Query.human": + if e.complexity.Query.Human == nil { + break + } - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + args, err := e.field_Query_human_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec.___Field(ctx, field.Selections, &res[idx1]) - }() + return e.complexity.Query.Human(childComplexity, args["id"].(string)), true + + case "Query.starship": + if e.complexity.Query.Starship == nil { + break } - if isLen1 { - f(idx1) - } else { - go f(idx1) + + args, err := e.field_Query_starship_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - } - wg.Wait() - return arr1 -} + return e.complexity.Query.Starship(childComplexity, args["id"].(string)), true -// nolint: vetshadow -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + case "Review.stars": + if e.complexity.Review.Stars == nil { + break + } - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + return e.complexity.Review.Stars(childComplexity), true - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + case "Review.commentary": + if e.complexity.Review.Commentary == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } + return e.complexity.Review.Commentary(childComplexity), true - } - wg.Wait() - return arr1 -} + case "Review.time": + if e.complexity.Review.Time == nil { + break + } -// nolint: vetshadow -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return e.complexity.Review.Time(childComplexity), true - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + case "Starship.id": + if e.complexity.Starship.Id == nil { + break + } - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } + return e.complexity.Starship.Id(childComplexity), true - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + case "Starship.name": + if e.complexity.Starship.Name == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() + return e.complexity.Starship.Name(childComplexity), true + + case "Starship.length": + if e.complexity.Starship.Length == nil { + break } - if isLen1 { - f(idx1) - } else { - go f(idx1) + + args, err := e.field_Starship_length_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - } - wg.Wait() - return arr1 -} + return e.complexity.Starship.Length(childComplexity, args["unit"].(*LengthUnit)), true -// nolint: vetshadow -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_enumValues_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.EnumValues(args["includeDeprecated"].(bool)), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.EnumValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + case "Starship.history": + if e.complexity.Starship.History == nil { + break + } - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + return e.complexity.Starship.History(childComplexity), true - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) } + return 0, false +} - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { +func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._Query(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() + }) - } - wg.Wait() - return arr1 + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions} } -// nolint: vetshadow -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._Mutation(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() + }) - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions, } +} - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { +func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { + return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) +} - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } +type executionContext struct { + *graphql.RequestContext + *executableSchema +} +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + res, err := ec.ResolverMiddleware(ctx, next) + if err != nil { + ec.Error(ctx, err) + return nil } - wg.Wait() - return arr1 -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -func (ec *executionContext) _Character(ctx context.Context, sel ast.SelectionSet, obj *Character) graphql.Marshaler { - switch obj := (*obj).(type) { - case nil: - return graphql.Null - case Human: - return ec._Human(ctx, sel, &obj) - case *Human: - return ec._Human(ctx, sel, obj) - case Droid: - return ec._Droid(ctx, sel, &obj) - case *Droid: - return ec._Droid(ctx, sel, obj) - default: - panic(fmt.Errorf("unexpected type %T", obj)) - } -} - -func (ec *executionContext) _SearchResult(ctx context.Context, sel ast.SelectionSet, obj *SearchResult) graphql.Marshaler { - switch obj := (*obj).(type) { - case nil: - return graphql.Null - case Human: - return ec._Human(ctx, sel, &obj) - case *Human: - return ec._Human(ctx, sel, obj) - case Droid: - return ec._Droid(ctx, sel, &obj) - case *Droid: - return ec._Droid(ctx, sel, obj) - case Starship: - return ec._Starship(ctx, sel, &obj) - case *Starship: - return ec._Starship(ctx, sel, obj) - default: - panic(fmt.Errorf("unexpected type %T", obj)) - } -} - -func UnmarshalReviewInput(v interface{}) (Review, error) { - var it Review - var asMap = v.(map[string]interface{}) - - for k, v := range asMap { - switch k { - case "stars": - var err error - it.Stars, err = graphql.UnmarshalInt(v) - if err != nil { - return it, err - } - case "commentary": - var err error - var ptr1 string - if v != nil { - ptr1, err = graphql.UnmarshalString(v) - it.Commentary = &ptr1 - } - - if err != nil { - return it, err - } - case "time": - var err error - it.Time, err = graphql.UnmarshalTime(v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -func (e *executableSchema) ReviewInputMiddleware(ctx context.Context, obj *Review) (*Review, error) { - - return obj, nil -} - -func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - res, err := ec.ResolverMiddleware(ctx, next) - if err != nil { - ec.Error(ctx, err) - return nil - } - return res + return res } func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { @@ -4384,3 +3644,763 @@ func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMi return next(ctx) } } + +// endregion ************************** generated.gotpl *************************** + +// region **************************** input.gotpl ***************************** + +func UnmarshalReviewInput(v interface{}) (Review, error) { + var it Review + var asMap = v.(map[string]interface{}) + + for k, v := range asMap { + switch k { + case "stars": + var err error + it.Stars, err = graphql.UnmarshalInt(v) + if err != nil { + return it, err + } + case "commentary": + var err error + var ptr1 string + if v != nil { + ptr1, err = graphql.UnmarshalString(v) + it.Commentary = &ptr1 + } + + if err != nil { + return it, err + } + case "time": + var err error + it.Time, err = graphql.UnmarshalTime(v) + if err != nil { + return it, err + } + } + } + + return it, nil +} + +func (e *executableSchema) ReviewInputMiddleware(ctx context.Context, obj *Review) (*Review, error) { + + return obj, nil +} + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +func (ec *executionContext) _Character(ctx context.Context, sel ast.SelectionSet, obj *Character) graphql.Marshaler { + switch obj := (*obj).(type) { + case nil: + return graphql.Null + case Human: + return ec._Human(ctx, sel, &obj) + case *Human: + return ec._Human(ctx, sel, obj) + case Droid: + return ec._Droid(ctx, sel, &obj) + case *Droid: + return ec._Droid(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +func (ec *executionContext) _SearchResult(ctx context.Context, sel ast.SelectionSet, obj *SearchResult) graphql.Marshaler { + switch obj := (*obj).(type) { + case nil: + return graphql.Null + case Human: + return ec._Human(ctx, sel, &obj) + case *Human: + return ec._Human(ctx, sel, obj) + case Droid: + return ec._Droid(ctx, sel, &obj) + case *Droid: + return ec._Droid(ctx, sel, obj) + case Starship: + return ec._Starship(ctx, sel, &obj) + case *Starship: + return ec._Starship(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +var droidImplementors = []string{"Droid", "Character"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Droid(ctx context.Context, sel ast.SelectionSet, obj *Droid) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, droidImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Droid") + case "id": + out.Values[i] = ec._Droid_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "name": + out.Values[i] = ec._Droid_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "friends": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Droid_friends(ctx, field, obj) + return res + }) + case "friendsConnection": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Droid_friendsConnection(ctx, field, obj) + if res == graphql.Null { + invalid = true + } + return res + }) + case "appearsIn": + out.Values[i] = ec._Droid_appearsIn(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "primaryFunction": + out.Values[i] = ec._Droid_primaryFunction(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var friendsConnectionImplementors = []string{"FriendsConnection"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _FriendsConnection(ctx context.Context, sel ast.SelectionSet, obj *FriendsConnection) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, friendsConnectionImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("FriendsConnection") + case "totalCount": + out.Values[i] = ec._FriendsConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "edges": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._FriendsConnection_edges(ctx, field, obj) + return res + }) + case "friends": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._FriendsConnection_friends(ctx, field, obj) + return res + }) + case "pageInfo": + out.Values[i] = ec._FriendsConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var friendsEdgeImplementors = []string{"FriendsEdge"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _FriendsEdge(ctx context.Context, sel ast.SelectionSet, obj *FriendsEdge) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, friendsEdgeImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("FriendsEdge") + case "cursor": + out.Values[i] = ec._FriendsEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "node": + out.Values[i] = ec._FriendsEdge_node(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var humanImplementors = []string{"Human", "Character"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Human(ctx context.Context, sel ast.SelectionSet, obj *Human) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, humanImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Human") + case "id": + out.Values[i] = ec._Human_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "name": + out.Values[i] = ec._Human_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "height": + out.Values[i] = ec._Human_height(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "mass": + out.Values[i] = ec._Human_mass(ctx, field, obj) + case "friends": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Human_friends(ctx, field, obj) + return res + }) + case "friendsConnection": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Human_friendsConnection(ctx, field, obj) + if res == graphql.Null { + invalid = true + } + return res + }) + case "appearsIn": + out.Values[i] = ec._Human_appearsIn(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "starships": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Human_starships(ctx, field, obj) + return res + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var mutationImplementors = []string{"Mutation"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, mutationImplementors) + + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "Mutation", + }) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Mutation") + case "createReview": + out.Values[i] = ec._Mutation_createReview(ctx, field) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var pageInfoImplementors = []string{"PageInfo"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *PageInfo) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, pageInfoImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("PageInfo") + case "startCursor": + out.Values[i] = ec._PageInfo_startCursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "endCursor": + out.Values[i] = ec._PageInfo_endCursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "hasNextPage": + out.Values[i] = ec._PageInfo_hasNextPage(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var queryImplementors = []string{"Query"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, queryImplementors) + + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "Query", + }) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Query") + case "hero": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_hero(ctx, field) + return res + }) + case "reviews": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_reviews(ctx, field) + if res == graphql.Null { + invalid = true + } + return res + }) + case "search": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_search(ctx, field) + if res == graphql.Null { + invalid = true + } + return res + }) + case "character": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_character(ctx, field) + return res + }) + case "droid": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_droid(ctx, field) + return res + }) + case "human": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_human(ctx, field) + return res + }) + case "starship": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_starship(ctx, field) + return res + }) + case "__type": + out.Values[i] = ec._Query___type(ctx, field) + case "__schema": + out.Values[i] = ec._Query___schema(ctx, field) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var reviewImplementors = []string{"Review"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Review(ctx context.Context, sel ast.SelectionSet, obj *Review) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, reviewImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Review") + case "stars": + out.Values[i] = ec._Review_stars(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "commentary": + out.Values[i] = ec._Review_commentary(ctx, field, obj) + case "time": + out.Values[i] = ec._Review_time(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var starshipImplementors = []string{"Starship"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Starship(ctx context.Context, sel ast.SelectionSet, obj *Starship) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, starshipImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Starship") + case "id": + out.Values[i] = ec._Starship_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "name": + out.Values[i] = ec._Starship_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "length": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Starship_length(ctx, field, obj) + if res == graphql.Null { + invalid = true + } + return res + }) + case "history": + out.Values[i] = ec._Starship_history(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __DirectiveImplementors = []string{"__Directive"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __EnumValueImplementors = []string{"__EnumValue"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __FieldImplementors = []string{"__Field"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __FieldImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __InputValueImplementors = []string{"__InputValue"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __SchemaImplementors = []string{"__Schema"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __TypeImplementors = []string{"__Type"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __TypeImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +// endregion **************************** object.gotpl **************************** diff --git a/example/starwars/models_gen.go b/example/starwars/models_gen.go index e418cd89e42..865948479c2 100644 --- a/example/starwars/models_gen.go +++ b/example/starwars/models_gen.go @@ -1,5 +1,3 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - package starwars import ( diff --git a/example/todo/generated.go b/example/todo/generated.go index e27a9494c54..e298e5f4c02 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -15,355 +15,216 @@ import ( "github.com/vektah/gqlparser/ast" ) -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } -} +// region **************************** field.gotpl ***************************** -type Config struct { - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot -} - -type ResolverRoot interface { - MyMutation() MyMutationResolver - MyQuery() MyQueryResolver -} +// nolint: vetshadow +func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "MyMutation", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_MyMutation_createTodo_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.MyMutation().CreateTodo(rctx, args["todo"].(TodoInput)) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(Todo) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -type DirectiveRoot struct { - HasRole func(ctx context.Context, obj interface{}, next graphql.Resolver, role Role) (res interface{}, err error) + return ec._Todo(ctx, field.Selections, &res) } -type ComplexityRoot struct { - MyMutation struct { - CreateTodo func(childComplexity int, todo TodoInput) int - UpdateTodo func(childComplexity int, id int, changes map[string]interface{}) int +// nolint: vetshadow +func (ec *executionContext) _MyMutation_updateTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "MyMutation", + Field: field, + Args: nil, } - - MyQuery struct { - Todo func(childComplexity int, id int) int - LastTodo func(childComplexity int) int - Todos func(childComplexity int) int + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_MyMutation_updateTodo_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.MyMutation().UpdateTodo(rctx, args["id"].(int), args["changes"].(map[string]interface{})) + }) + if resTmp == nil { + return graphql.Null } + res := resTmp.(*Todo) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - Todo struct { - Id func(childComplexity int) int - Text func(childComplexity int) int - Done func(childComplexity int) int + if res == nil { + return graphql.Null } -} -type MyMutationResolver interface { - CreateTodo(ctx context.Context, todo TodoInput) (Todo, error) - UpdateTodo(ctx context.Context, id int, changes map[string]interface{}) (*Todo, error) -} -type MyQueryResolver interface { - Todo(ctx context.Context, id int) (*Todo, error) - LastTodo(ctx context.Context) (*Todo, error) - Todos(ctx context.Context) ([]Todo, error) + return ec._Todo(ctx, field.Selections, res) } -func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 TodoInput - if tmp, ok := rawArgs["todo"]; ok { - var err error - arg0, err = UnmarshalTodoInput(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "MyQuery", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_MyQuery_todo_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.MyQuery().Todo(rctx, args["id"].(int)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Todo) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - mTodoInput1, err := e.TodoInputMiddleware(ctx, &arg0) - if err != nil { - return nil, err - } - arg0 = *mTodoInput1 + if res == nil { + return graphql.Null } - args["todo"] = arg0 - return args, nil + return ec._Todo(ctx, field.Selections, res) } -func (e *executableSchema) field_MyMutation_updateTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 int - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalInt(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _MyQuery_lastTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "MyQuery", + Field: field, + Args: nil, } - args["id"] = arg0 - var arg1 map[string]interface{} - if tmp, ok := rawArgs["changes"]; ok { - var err error - arg1 = tmp.(map[string]interface{}) - if err != nil { - return nil, err - } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.MyQuery().LastTodo(rctx) + }) + if resTmp == nil { + return graphql.Null } - args["changes"] = arg1 - return args, nil - -} + res := resTmp.(*Todo) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -func (e *executableSchema) field_MyQuery_todo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 int - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalInt(tmp) - if err != nil { - return nil, err - } + if res == nil { + return graphql.Null } - args["id"] = arg0 - return args, nil + return ec._Todo(ctx, field.Selections, res) } -func (e *executableSchema) field_MyQuery___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err +// nolint: vetshadow +func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "MyQuery", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.MyQuery().Todos(rctx) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["name"] = arg0 - return args, nil + res := resTmp.([]Todo) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - args["includeDeprecated"] = arg0 - return args, nil - -} -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil - -} - -func (e *executableSchema) dir_hasRole_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 Role - if tmp, ok := rawArgs["role"]; ok { - var err error - err = (&arg0).UnmarshalGQL(tmp) - if err != nil { - return nil, err - } - } - args["role"] = arg0 - return args, nil - -} - -type executableSchema struct { - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot -} - -func (e *executableSchema) Schema() *ast.Schema { - return parsedSchema -} - -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - switch typeName + "." + field { - - case "MyMutation.createTodo": - if e.complexity.MyMutation.CreateTodo == nil { - break - } - - args, err := e.field_MyMutation_createTodo_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.MyMutation.CreateTodo(childComplexity, args["todo"].(TodoInput)), true - - case "MyMutation.updateTodo": - if e.complexity.MyMutation.UpdateTodo == nil { - break - } - - args, err := e.field_MyMutation_updateTodo_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.MyMutation.UpdateTodo(childComplexity, args["id"].(int), args["changes"].(map[string]interface{})), true - - case "MyQuery.todo": - if e.complexity.MyQuery.Todo == nil { - break - } - - args, err := e.field_MyQuery_todo_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.MyQuery.Todo(childComplexity, args["id"].(int)), true - - case "MyQuery.lastTodo": - if e.complexity.MyQuery.LastTodo == nil { - break - } - - return e.complexity.MyQuery.LastTodo(childComplexity), true - - case "MyQuery.todos": - if e.complexity.MyQuery.Todos == nil { - break - } - - return e.complexity.MyQuery.Todos(childComplexity), true - - case "Todo.id": - if e.complexity.Todo.Id == nil { - break + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.Todo.Id(childComplexity), true - - case "Todo.text": - if e.complexity.Todo.Text == nil { - break + return ec._Todo(ctx, field.Selections, &res[idx1]) + }() } - - return e.complexity.Todo.Text(childComplexity), true - - case "Todo.done": - if e.complexity.Todo.Done == nil { - break + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.Todo.Done(childComplexity), true - - } - return 0, false -} - -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._MyQuery(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions} -} - -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._MyMutation(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, - } -} - -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) -} - -type executionContext struct { - *graphql.RequestContext - *executableSchema -} - -var myMutationImplementors = []string{"MyMutation"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, myMutationImplementors) - - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: "MyMutation", - }) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("MyMutation") - case "createTodo": - out.Values[i] = ec._MyMutation_createTodo(ctx, field) - if out.Values[i] == graphql.Null { - invalid = true - } - case "updateTodo": - out.Values[i] = ec._MyMutation_updateTodo(ctx, field) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null } - return out + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MyMutation", + Object: "MyQuery", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_MyMutation_createTodo_args(ctx, rawArgs) + args, err := ec.field_MyQuery___type_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -372,47 +233,41 @@ func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field gr ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.MyMutation().CreateTodo(rctx, args["todo"].(TodoInput)) + return ec.introspectType(args["name"].(string)) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(Todo) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec._Todo(ctx, field.Selections, &res) + if res == nil { + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) _MyMutation_updateTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MyMutation", + Object: "MyQuery", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_MyMutation_updateTodo_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.MyMutation().UpdateTodo(rctx, args["id"].(int), args["changes"].(map[string]interface{})) + return ec.introspectSchema() }) if resTmp == nil { return graphql.Null } - res := resTmp.(*Todo) + res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -420,140 +275,191 @@ func (ec *executionContext) _MyMutation_updateTodo(ctx context.Context, field gr return graphql.Null } - return ec._Todo(ctx, field.Selections, res) + return ec.___Schema(ctx, field.Selections, res) } -var myQueryImplementors = []string{"MyQuery"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, myQueryImplementors) - - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: "MyQuery", - }) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("MyQuery") - case "todo": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._MyQuery_todo(ctx, field) - return res - }) - case "lastTodo": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._MyQuery_lastTodo(ctx, field) - return res - }) - case "todos": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._MyQuery_todos(ctx, field) - if res == graphql.Null { - invalid = true - } - return res - }) - case "__type": - out.Values[i] = ec._MyQuery___type(ctx, field) - case "__schema": - out.Values[i] = ec._MyQuery___schema(ctx, field) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } +// nolint: vetshadow +func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Todo", + Field: field, + Args: nil, } - out.Dispatch() - if invalid { + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - return out + res := resTmp.(int) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalInt(res) } // nolint: vetshadow -func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MyQuery", + Object: "Todo", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_MyQuery_todo_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Text, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - rctx.Args = args + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} + +// nolint: vetshadow +func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Todo", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.MyQuery().Todo(rctx, args["id"].(int)) + return obj.Done, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*Todo) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) +} - if res == nil { +// nolint: vetshadow +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - - return ec._Todo(ctx, field.Selections, res) + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _MyQuery_lastTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MyQuery", + Object: "__Directive", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.MyQuery().LastTodo(rctx) + return obj.Description, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*Todo) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - if res == nil { +// nolint: vetshadow +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } + res := resTmp.([]string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec._Todo(ctx, field.Selections, res) + arr1 := make(graphql.Array, len(res)) + + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { + return graphql.MarshalString(res[idx1]) + }() + } + + return arr1 } // nolint: vetshadow -func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MyQuery", + Object: "__Directive", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.MyQuery().Todos(rctx) + return obj.Args, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -561,7 +467,7 @@ func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.([]Todo) + res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -586,7 +492,7 @@ func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.Co } arr1[idx1] = func() graphql.Marshaler { - return ec._Todo(ctx, field.Selections, &res[idx1]) + return ec.___InputValue(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -601,168 +507,89 @@ func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.Co } // nolint: vetshadow -func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MyQuery", + Object: "__EnumValue", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_MyQuery___type_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectType(args["name"].(string)) + return obj.Name, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MyQuery", + Object: "__EnumValue", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() + return obj.Description, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Schema) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - if res == nil { +// nolint: vetshadow +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - - return ec.___Schema(ctx, field.Selections, res) -} - -var todoImplementors = []string{"Todo"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, todoImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Todo") - case "id": - out.Values[i] = ec._Todo_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "text": - out.Values[i] = ec._Todo_text(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "done": - out.Values[i] = ec._Todo_done(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - -// nolint: vetshadow -func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Todo", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) -} - -// nolint: vetshadow -func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Todo", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Text, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Todo", + Object: "__EnumValue", Field: field, Args: nil, } @@ -770,66 +597,27 @@ func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.Collec ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Done, nil + return obj.DeprecationReason(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) -} - -var __DirectiveImplementors = []string{"__Directive"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Directive") - case "name": - out.Values[i] = ec.___Directive_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___Directive_description(ctx, field, obj) - case "locations": - out.Values[i] = ec.___Directive_locations(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "args": - out.Values[i] = ec.___Directive_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { + if res == nil { return graphql.Null } - return out + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "__Field", Field: field, Args: nil, } @@ -852,11 +640,11 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql } // nolint: vetshadow -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "__Field", Field: field, Args: nil, } @@ -876,47 +664,11 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field } // nolint: vetshadow -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Locations, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 -} - -// nolint: vetshadow -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "__Field", Field: field, Args: nil, } @@ -971,49 +723,12 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql return arr1 } -var __EnumValueImplementors = []string{"__EnumValue"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__EnumValue") - case "name": - out.Values[i] = ec.___EnumValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___EnumValue_description(ctx, field, obj) - case "isDeprecated": - out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "deprecationReason": - out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - // nolint: vetshadow -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "__Field", Field: field, Args: nil, } @@ -1021,7 +736,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Type, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1029,18 +744,26 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "__Field", Field: field, Args: nil, } @@ -1048,23 +771,26 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.IsDeprecated(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(string) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "__Field", Field: field, Args: nil, } @@ -1072,26 +798,27 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.DeprecationReason(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "__InputValue", Field: field, Args: nil, } @@ -1099,74 +826,50 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.Name, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return graphql.MarshalString(res) } -var __FieldImplementors = []string{"__Field"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __FieldImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Field") - case "name": - out.Values[i] = ec.___Field_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___Field_description(ctx, field, obj) - case "args": - out.Values[i] = ec.___Field_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "type": - out.Values[i] = ec.___Field_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "isDeprecated": - out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "deprecationReason": - out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } +// nolint: vetshadow +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Field: field, + Args: nil, } - out.Dispatch() - if invalid { + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if resTmp == nil { return graphql.Null } - return out + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__InputValue", Field: field, Args: nil, } @@ -1174,7 +877,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Type, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1182,18 +885,26 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__InputValue", Field: field, Args: nil, } @@ -1201,23 +912,27 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.DefaultValue, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Schema", Field: field, Args: nil, } @@ -1225,7 +940,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Args, nil + return obj.Types(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1233,7 +948,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1258,7 +973,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } arr1[idx1] = func() graphql.Marshaler { - return ec.___InputValue(ctx, field.Selections, &res[idx1]) + return ec.___Type(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1273,11 +988,11 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Schema", Field: field, Args: nil, } @@ -1285,7 +1000,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.QueryType(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1308,11 +1023,11 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Schema", Field: field, Args: nil, } @@ -1320,26 +1035,28 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.MutationType(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + + if res == nil { + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Schema", Field: field, Args: nil, } @@ -1347,64 +1064,28 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.SubscriptionType(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { return graphql.Null } - return graphql.MarshalString(*res) -} - -var __InputValueImplementors = []string{"__InputValue"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__InputValue") - case "name": - out.Values[i] = ec.___InputValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___InputValue_description(ctx, field, obj) - case "type": - out.Values[i] = ec.___InputValue_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "defaultValue": - out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Schema", Field: field, Args: nil, } @@ -1412,7 +1093,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Directives(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1420,18 +1101,51 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___Directive(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Type", Field: field, Args: nil, } @@ -1439,9 +1153,12 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.Kind(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(string) @@ -1451,11 +1168,11 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field } // nolint: vetshadow -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Type", Field: field, Args: nil, } @@ -1463,34 +1180,27 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.Name(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Type", Field: field, Args: nil, } @@ -1498,85 +1208,43 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil + return obj.Description(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) -} - -var __SchemaImplementors = []string{"__Schema"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Schema") - case "types": - out.Values[i] = ec.___Schema_types(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "queryType": - out.Values[i] = ec.___Schema_queryType(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "mutationType": - out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) - case "subscriptionType": - out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) - case "directives": - out.Values[i] = ec.___Schema_directives(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Type", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_fields_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Types(), nil + return obj.Fields(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1601,7 +1269,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } arr1[idx1] = func() graphql.Marshaler { - return ec.___Type(ctx, field.Selections, &res[idx1]) + return ec.___Field(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1616,11 +1284,11 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } // nolint: vetshadow -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Type", Field: field, Args: nil, } @@ -1628,34 +1296,56 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil + return obj.Interfaces(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - return ec.___Type(ctx, field.Selections, res) + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Type", Field: field, Args: nil, } @@ -1663,57 +1353,120 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil + return obj.PossibleTypes(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - return ec.___Type(ctx, field.Selections, res) + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Type", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil + return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - return ec.___Type(ctx, field.Selections, res) + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___EnumValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Type", Field: field, Args: nil, } @@ -1721,15 +1474,12 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil + return obj.InputFields(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]introspection.Directive) + res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1754,7 +1504,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap } arr1[idx1] = func() graphql.Marshaler { - return ec.___Directive(ctx, field.Selections, &res[idx1]) + return ec.___InputValue(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1768,79 +1518,8 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap return arr1 } -var __TypeImplementors = []string{"__Type"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __TypeImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Type") - case "kind": - out.Values[i] = ec.___Type_kind(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "name": - out.Values[i] = ec.___Type_name(ctx, field, obj) - case "description": - out.Values[i] = ec.___Type_description(ctx, field, obj) - case "fields": - out.Values[i] = ec.___Type_fields(ctx, field, obj) - case "interfaces": - out.Values[i] = ec.___Type_interfaces(ctx, field, obj) - case "possibleTypes": - out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) - case "enumValues": - out.Values[i] = ec.___Type_enumValues(ctx, field, obj) - case "inputFields": - out.Values[i] = ec.___Type_inputFields(ctx, field, obj) - case "ofType": - out.Values[i] = ec.___Type_ofType(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - // nolint: vetshadow -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1852,405 +1531,327 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name(), nil + return obj.OfType(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { return graphql.Null } - return graphql.MarshalString(*res) -} -// nolint: vetshadow -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.___Type(ctx, field.Selections, res) } -// nolint: vetshadow -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_fields_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Fields(args["includeDeprecated"].(bool)), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Field) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +// endregion **************************** field.gotpl ***************************** - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup +// region ************************** generated.gotpl *************************** - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, } +} - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { +type Config struct { + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} - return ec.___Field(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } +type ResolverRoot interface { + MyMutation() MyMutationResolver + MyQuery() MyQueryResolver +} - } - wg.Wait() - return arr1 +type DirectiveRoot struct { + HasRole func(ctx context.Context, obj interface{}, next graphql.Resolver, role Role) (res interface{}, err error) } -// nolint: vetshadow -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil - }) - if resTmp == nil { - return graphql.Null +type ComplexityRoot struct { + MyMutation struct { + CreateTodo func(childComplexity int, todo TodoInput) int + UpdateTodo func(childComplexity int, id int, changes map[string]interface{}) int } - res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + MyQuery struct { + Todo func(childComplexity int, id int) int + LastTodo func(childComplexity int) int + Todos func(childComplexity int) int + } - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) + Todo struct { + Id func(childComplexity int) int + Text func(childComplexity int) int + Done func(childComplexity int) int } +} - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { +type MyMutationResolver interface { + CreateTodo(ctx context.Context, todo TodoInput) (Todo, error) + UpdateTodo(ctx context.Context, id int, changes map[string]interface{}) (*Todo, error) +} +type MyQueryResolver interface { + Todo(ctx context.Context, id int) (*Todo, error) + LastTodo(ctx context.Context) (*Todo, error) + Todos(ctx context.Context) ([]Todo, error) +} - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) +func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 TodoInput + if tmp, ok := rawArgs["todo"]; ok { + var err error + arg0, err = UnmarshalTodoInput(tmp) + if err != nil { + return nil, err } + mTodoInput1, err := e.TodoInputMiddleware(ctx, &arg0) + if err != nil { + return nil, err + } + arg0 = *mTodoInput1 } - wg.Wait() - return arr1 + args["todo"] = arg0 + return args, nil + } -// nolint: vetshadow -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil - }) - if resTmp == nil { - return graphql.Null +func (e *executableSchema) field_MyMutation_updateTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 int + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = graphql.UnmarshalInt(tmp) + if err != nil { + return nil, err + } } - res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + args["id"] = arg0 + var arg1 map[string]interface{} + if tmp, ok := rawArgs["changes"]; ok { + var err error + arg1 = tmp.(map[string]interface{}) + if err != nil { + return nil, err + } + } + args["changes"] = arg1 + return args, nil - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup +} - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) +func (e *executableSchema) field_MyQuery_todo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 int + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = graphql.UnmarshalInt(tmp) + if err != nil { + return nil, err + } } + args["id"] = arg0 + return args, nil - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { +} - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) +func (e *executableSchema) field_MyQuery___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } - } - wg.Wait() - return arr1 + args["name"] = arg0 + return args, nil + } -// nolint: vetshadow -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_enumValues_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.EnumValues(args["includeDeprecated"].(bool)), nil - }) - if resTmp == nil { - return graphql.Null +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } } - res := resTmp.([]introspection.EnumValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + args["includeDeprecated"] = arg0 + return args, nil - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup +} - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } } + args["includeDeprecated"] = arg0 + return args, nil - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { +} - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) +func (e *executableSchema) dir_hasRole_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 Role + if tmp, ok := rawArgs["role"]; ok { + var err error + err = (&arg0).UnmarshalGQL(tmp) + if err != nil { + return nil, err } - } - wg.Wait() - return arr1 + args["role"] = arg0 + return args, nil + } -// nolint: vetshadow -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +type executableSchema struct { + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup +func (e *executableSchema) Schema() *ast.Schema { + return parsedSchema +} - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + switch typeName + "." + field { - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + case "MyMutation.createTodo": + if e.complexity.MyMutation.CreateTodo == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() + args, err := e.field_MyMutation_createTodo_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - if isLen1 { - f(idx1) - } else { - go f(idx1) + + return e.complexity.MyMutation.CreateTodo(childComplexity, args["todo"].(TodoInput)), true + + case "MyMutation.updateTodo": + if e.complexity.MyMutation.UpdateTodo == nil { + break } - } - wg.Wait() - return arr1 -} + args, err := e.field_MyMutation_updateTodo_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } -// nolint: vetshadow -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return e.complexity.MyMutation.UpdateTodo(childComplexity, args["id"].(int), args["changes"].(map[string]interface{})), true - if res == nil { - return graphql.Null - } + case "MyQuery.todo": + if e.complexity.MyQuery.Todo == nil { + break + } - return ec.___Type(ctx, field.Selections, res) -} + args, err := e.field_MyQuery_todo_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } -func UnmarshalTodoInput(v interface{}) (TodoInput, error) { - var it TodoInput - var asMap = v.(map[string]interface{}) + return e.complexity.MyQuery.Todo(childComplexity, args["id"].(int)), true - for k, v := range asMap { - switch k { - case "text": - var err error - it.Text, err = graphql.UnmarshalString(v) - if err != nil { - return it, err - } - case "done": - var err error - var ptr1 bool - if v != nil { - ptr1, err = graphql.UnmarshalBoolean(v) - it.Done = &ptr1 - } + case "MyQuery.lastTodo": + if e.complexity.MyQuery.LastTodo == nil { + break + } - if err != nil { - return it, err - } + return e.complexity.MyQuery.LastTodo(childComplexity), true + + case "MyQuery.todos": + if e.complexity.MyQuery.Todos == nil { + break + } + + return e.complexity.MyQuery.Todos(childComplexity), true + + case "Todo.id": + if e.complexity.Todo.Id == nil { + break + } + + return e.complexity.Todo.Id(childComplexity), true + + case "Todo.text": + if e.complexity.Todo.Text == nil { + break + } + + return e.complexity.Todo.Text(childComplexity), true + + case "Todo.done": + if e.complexity.Todo.Done == nil { + break } + + return e.complexity.Todo.Done(childComplexity), true + } + return 0, false +} - return it, nil +func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._MyQuery(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() + }) + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions} } -func (e *executableSchema) TodoInputMiddleware(ctx context.Context, obj *TodoInput) (*TodoInput, error) { +func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} - return obj, nil + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._MyMutation(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() + }) + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions, + } +} + +func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { + return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) +} + +type executionContext struct { + *graphql.RequestContext + *executableSchema } func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { @@ -2377,3 +1978,422 @@ func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMi return next(ctx) } } + +// endregion ************************** generated.gotpl *************************** + +// region **************************** input.gotpl ***************************** + +func UnmarshalTodoInput(v interface{}) (TodoInput, error) { + var it TodoInput + var asMap = v.(map[string]interface{}) + + for k, v := range asMap { + switch k { + case "text": + var err error + it.Text, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "done": + var err error + var ptr1 bool + if v != nil { + ptr1, err = graphql.UnmarshalBoolean(v) + it.Done = &ptr1 + } + + if err != nil { + return it, err + } + } + } + + return it, nil +} + +func (e *executableSchema) TodoInputMiddleware(ctx context.Context, obj *TodoInput) (*TodoInput, error) { + + return obj, nil +} + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +var myMutationImplementors = []string{"MyMutation"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, myMutationImplementors) + + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "MyMutation", + }) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("MyMutation") + case "createTodo": + out.Values[i] = ec._MyMutation_createTodo(ctx, field) + if out.Values[i] == graphql.Null { + invalid = true + } + case "updateTodo": + out.Values[i] = ec._MyMutation_updateTodo(ctx, field) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var myQueryImplementors = []string{"MyQuery"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, myQueryImplementors) + + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "MyQuery", + }) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("MyQuery") + case "todo": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._MyQuery_todo(ctx, field) + return res + }) + case "lastTodo": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._MyQuery_lastTodo(ctx, field) + return res + }) + case "todos": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._MyQuery_todos(ctx, field) + if res == graphql.Null { + invalid = true + } + return res + }) + case "__type": + out.Values[i] = ec._MyQuery___type(ctx, field) + case "__schema": + out.Values[i] = ec._MyQuery___schema(ctx, field) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var todoImplementors = []string{"Todo"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, todoImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Todo") + case "id": + out.Values[i] = ec._Todo_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "text": + out.Values[i] = ec._Todo_text(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "done": + out.Values[i] = ec._Todo_done(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __DirectiveImplementors = []string{"__Directive"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __EnumValueImplementors = []string{"__EnumValue"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __FieldImplementors = []string{"__Field"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __FieldImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __InputValueImplementors = []string{"__InputValue"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __SchemaImplementors = []string{"__Schema"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __TypeImplementors = []string{"__Type"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __TypeImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +// endregion **************************** object.gotpl **************************** diff --git a/example/todo/models_gen.go b/example/todo/models_gen.go index 74a1c0da57b..28063627c56 100644 --- a/example/todo/models_gen.go +++ b/example/todo/models_gen.go @@ -1,5 +1,3 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - package todo import ( diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index 92b40875151..2a4cab7703b 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -16,320 +16,218 @@ import ( "github.com/vektah/gqlparser/ast" ) -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } -} +// region **************************** field.gotpl ***************************** -type Config struct { - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot -} +// nolint: vetshadow +func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "MyMutation", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_MyMutation_createTodo_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.MyMutation().CreateTodo(rctx, args["todo"].(TodoInput)) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(Todo) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -type ResolverRoot interface { - MyMutation() MyMutationResolver - MyQuery() MyQueryResolver + return ec._Todo(ctx, field.Selections, &res) } -type DirectiveRoot struct { - EnumLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) - - FieldLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) +// nolint: vetshadow +func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "MyQuery", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.MyQuery().Todos(rctx) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]Todo) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - InputLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - InterfaceLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - ObjectLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - ScalarLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) + return ec._Todo(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } - UnionLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) + } + wg.Wait() + return arr1 } -type ComplexityRoot struct { - MyMutation struct { - CreateTodo func(childComplexity int, todo TodoInput) int +// nolint: vetshadow +func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "MyQuery", + Field: field, + Args: nil, } - - MyQuery struct { - Todos func(childComplexity int) int - Todo func(childComplexity int, id string) int + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_MyQuery_todo_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.MyQuery().Todo(rctx, args["id"].(string)) + }) + if resTmp == nil { + return graphql.Null } + res := resTmp.(*Todo) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - Todo struct { - Id func(childComplexity int) int - Text func(childComplexity int) int - State func(childComplexity int) int - Verified func(childComplexity int) int + if res == nil { + return graphql.Null } -} -type MyMutationResolver interface { - CreateTodo(ctx context.Context, todo TodoInput) (Todo, error) -} -type MyQueryResolver interface { - Todos(ctx context.Context) ([]Todo, error) - Todo(ctx context.Context, id string) (*Todo, error) + return ec._Todo(ctx, field.Selections, res) } -func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 TodoInput - if tmp, ok := rawArgs["todo"]; ok { - var err error - arg0, err = UnmarshalTodoInput(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "MyQuery", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_MyQuery___type_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(args["name"].(string)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - mTodoInput1, err := e.TodoInputMiddleware(ctx, &arg0) - if err != nil { - return nil, err - } - arg0 = *mTodoInput1 + if res == nil { + return graphql.Null } - args["todo"] = arg0 - return args, nil + return ec.___Type(ctx, field.Selections, res) } -func (e *executableSchema) field_MyQuery_todo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalID(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "MyQuery", + Field: field, + Args: nil, } - args["id"] = arg0 - return args, nil - -} + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -func (e *executableSchema) field_MyQuery___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + if res == nil { + return graphql.Null } - args["name"] = arg0 - return args, nil -} - -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil - -} - -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil - -} - -type executableSchema struct { - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot -} - -func (e *executableSchema) Schema() *ast.Schema { - return parsedSchema -} - -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - switch typeName + "." + field { - - case "MyMutation.createTodo": - if e.complexity.MyMutation.CreateTodo == nil { - break - } - - args, err := e.field_MyMutation_createTodo_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.MyMutation.CreateTodo(childComplexity, args["todo"].(TodoInput)), true - - case "MyQuery.todos": - if e.complexity.MyQuery.Todos == nil { - break - } - - return e.complexity.MyQuery.Todos(childComplexity), true - - case "MyQuery.todo": - if e.complexity.MyQuery.Todo == nil { - break - } - - args, err := e.field_MyQuery_todo_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.MyQuery.Todo(childComplexity, args["id"].(string)), true - - case "Todo.id": - if e.complexity.Todo.Id == nil { - break - } - - return e.complexity.Todo.Id(childComplexity), true - - case "Todo.text": - if e.complexity.Todo.Text == nil { - break - } - - return e.complexity.Todo.Text(childComplexity), true - - case "Todo.state": - if e.complexity.Todo.State == nil { - break - } - - return e.complexity.Todo.State(childComplexity), true - - case "Todo.verified": - if e.complexity.Todo.Verified == nil { - break - } - - return e.complexity.Todo.Verified(childComplexity), true - - } - return 0, false -} - -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._MyQuery(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions} -} - -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._MyMutation(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, - } -} - -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) -} - -type executionContext struct { - *graphql.RequestContext - *executableSchema -} - -var myMutationImplementors = []string{"MyMutation"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, myMutationImplementors) - - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: "MyMutation", - }) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("MyMutation") - case "createTodo": - out.Values[i] = ec._MyMutation_createTodo(ctx, field) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + return ec.___Schema(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MyMutation", + Object: "Todo", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_MyMutation_createTodo_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.MyMutation().CreateTodo(rctx, args["todo"].(TodoInput)) + return obj.ID, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -337,73 +235,26 @@ func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field gr } return graphql.Null } - res := resTmp.(Todo) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._Todo(ctx, field.Selections, &res) -} - -var myQueryImplementors = []string{"MyQuery"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, myQueryImplementors) - - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: "MyQuery", - }) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("MyQuery") - case "todos": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._MyQuery_todos(ctx, field) - if res == graphql.Null { - invalid = true - } - return res - }) - case "todo": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._MyQuery_todo(ctx, field) - return res - }) - case "__type": - out.Values[i] = ec._MyQuery___type(ctx, field) - case "__schema": - out.Values[i] = ec._MyQuery___schema(ctx, field) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + return graphql.MarshalID(res) } // nolint: vetshadow -func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MyQuery", + Object: "Todo", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.MyQuery().Todos(rctx) + return obj.Text, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -411,195 +262,159 @@ func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.([]Todo) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) +// nolint: vetshadow +func (ec *executionContext) _Todo_state(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Todo", + Field: field, + Args: nil, } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._Todo(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.State, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } - + return graphql.Null } - wg.Wait() - return arr1 + res := resTmp.(State) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return res } // nolint: vetshadow -func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) _Todo_verified(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MyQuery", + Object: "Todo", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_MyQuery_todo_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.MyQuery().Todo(rctx, args["id"].(string)) + return obj.Verified, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*Todo) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec._Todo(ctx, field.Selections, res) + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MyQuery", + Object: "__Directive", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_MyQuery___type_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectType(args["name"].(string)) + return obj.Name, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MyQuery", + Object: "__Directive", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() + return obj.Description, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Schema) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - if res == nil { +// nolint: vetshadow +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } + res := resTmp.([]string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.___Schema(ctx, field.Selections, res) -} - -var todoImplementors = []string{"Todo", "Node"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, todoImplementors) + arr1 := make(graphql.Array, len(res)) - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Todo") - case "id": - out.Values[i] = ec._Todo_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "text": - out.Values[i] = ec._Todo_text(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "state": - out.Values[i] = ec._Todo_state(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "verified": - out.Values[i] = ec._Todo_verified(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { + return graphql.MarshalString(res[idx1]) + }() } - return out + + return arr1 } // nolint: vetshadow -func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Todo", + Object: "__Directive", Field: field, Args: nil, } @@ -607,7 +422,7 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.Args, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -615,18 +430,51 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Todo", + Object: "__EnumValue", Field: field, Args: nil, } @@ -634,7 +482,7 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Text, nil + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -649,11 +497,11 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec } // nolint: vetshadow -func (ec *executionContext) _Todo_state(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Todo", + Object: "__EnumValue", Field: field, Args: nil, } @@ -661,26 +509,23 @@ func (ec *executionContext) _Todo_state(ctx context.Context, field graphql.Colle ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.State, nil + return obj.Description, nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(State) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return res + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _Todo_verified(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Todo", + Object: "__EnumValue", Field: field, Args: nil, } @@ -688,7 +533,7 @@ func (ec *executionContext) _Todo_verified(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Verified, nil + return obj.IsDeprecated(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -702,52 +547,12 @@ func (ec *executionContext) _Todo_verified(ctx context.Context, field graphql.Co return graphql.MarshalBoolean(res) } -var __DirectiveImplementors = []string{"__Directive"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Directive") - case "name": - out.Values[i] = ec.___Directive_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___Directive_description(ctx, field, obj) - case "locations": - out.Values[i] = ec.___Directive_locations(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "args": - out.Values[i] = ec.___Directive_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - // nolint: vetshadow -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "__EnumValue", Field: field, Args: nil, } @@ -755,26 +560,27 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.DeprecationReason(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "__Field", Field: field, Args: nil, } @@ -782,9 +588,12 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.Name, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(string) @@ -794,11 +603,11 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field } // nolint: vetshadow -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "__Field", Field: field, Args: nil, } @@ -806,35 +615,23 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Locations, nil + return obj.Description, nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "__Field", Field: field, Args: nil, } @@ -889,49 +686,12 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql return arr1 } -var __EnumValueImplementors = []string{"__EnumValue"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__EnumValue") - case "name": - out.Values[i] = ec.___EnumValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___EnumValue_description(ctx, field, obj) - case "isDeprecated": - out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "deprecationReason": - out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - // nolint: vetshadow -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "__Field", Field: field, Args: nil, } @@ -939,7 +699,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Type, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -947,42 +707,26 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} -// nolint: vetshadow -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "__Field", Field: field, Args: nil, } @@ -1005,11 +749,11 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "__Field", Field: field, Args: nil, } @@ -1032,59 +776,12 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, return graphql.MarshalString(*res) } -var __FieldImplementors = []string{"__Field"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __FieldImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Field") - case "name": - out.Values[i] = ec.___Field_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___Field_description(ctx, field, obj) - case "args": - out.Values[i] = ec.___Field_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "type": - out.Values[i] = ec.___Field_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "isDeprecated": - out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "deprecationReason": - out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - // nolint: vetshadow -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__InputValue", Field: field, Args: nil, } @@ -1107,11 +804,11 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__InputValue", Field: field, Args: nil, } @@ -1131,11 +828,11 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap } // nolint: vetshadow -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__InputValue", Field: field, Args: nil, } @@ -1143,7 +840,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Args, nil + return obj.Type, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1151,51 +848,26 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null } - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__InputValue", Field: field, Args: nil, } @@ -1203,34 +875,27 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.DefaultValue, nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Schema", Field: field, Args: nil, } @@ -1238,7 +903,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.Types(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1246,83 +911,51 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(bool) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) -} -// nolint: vetshadow -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - if res == nil { - return graphql.Null + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - return graphql.MarshalString(*res) -} - -var __InputValueImplementors = []string{"__InputValue"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__InputValue") - case "name": - out.Values[i] = ec.___InputValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___InputValue_description(ctx, field, obj) - case "type": - out.Values[i] = ec.___InputValue_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() } - case "defaultValue": - out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) + arr1[idx1] = func() graphql.Marshaler { + + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Schema", Field: field, Args: nil, } @@ -1330,7 +963,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.QueryType(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1338,42 +971,26 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} -// nolint: vetshadow -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Schema", Field: field, Args: nil, } @@ -1381,12 +998,9 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.MutationType(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } res := resTmp.(*introspection.Type) @@ -1394,9 +1008,6 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } @@ -1404,11 +1015,11 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq } // nolint: vetshadow -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Schema", Field: field, Args: nil, } @@ -1416,65 +1027,24 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil + return obj.SubscriptionType(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { return graphql.Null } - return graphql.MarshalString(*res) -} - -var __SchemaImplementors = []string{"__Schema"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Schema") - case "types": - out.Values[i] = ec.___Schema_types(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "queryType": - out.Values[i] = ec.___Schema_queryType(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "mutationType": - out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) - case "subscriptionType": - out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) - case "directives": - out.Values[i] = ec.___Schema_directives(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1486,7 +1056,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Types(), nil + return obj.Directives(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1494,7 +1064,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1519,7 +1089,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } arr1[idx1] = func() graphql.Marshaler { - return ec.___Type(ctx, field.Selections, &res[idx1]) + return ec.___Directive(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1534,11 +1104,11 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } // nolint: vetshadow -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Type", Field: field, Args: nil, } @@ -1546,7 +1116,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil + return obj.Kind(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1554,211 +1124,14 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.Directive) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Directive(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 -} - -var __TypeImplementors = []string{"__Type"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __TypeImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Type") - case "kind": - out.Values[i] = ec.___Type_kind(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "name": - out.Values[i] = ec.___Type_name(ctx, field, obj) - case "description": - out.Values[i] = ec.___Type_description(ctx, field, obj) - case "fields": - out.Values[i] = ec.___Type_fields(ctx, field, obj) - case "interfaces": - out.Values[i] = ec.___Type_interfaces(ctx, field, obj) - case "possibleTypes": - out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) - case "enumValues": - out.Values[i] = ec.___Type_enumValues(ctx, field, obj) - case "inputFields": - out.Values[i] = ec.___Type_inputFields(ctx, field, obj) - case "ofType": - out.Values[i] = ec.___Type_ofType(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -2137,70 +1510,269 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co return ec.___Type(ctx, field.Selections, res) } -func (ec *executionContext) _Data(ctx context.Context, sel ast.SelectionSet, obj *Data) graphql.Marshaler { - switch obj := (*obj).(type) { - case nil: - return graphql.Null - case Todo: - return ec._Todo(ctx, sel, &obj) - case *Todo: - return ec._Todo(ctx, sel, obj) - default: - panic(fmt.Errorf("unexpected type %T", obj)) +// endregion **************************** field.gotpl ***************************** + +// region ************************** generated.gotpl *************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, } } -func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj *Node) graphql.Marshaler { - switch obj := (*obj).(type) { - case nil: - return graphql.Null - case Todo: - return ec._Todo(ctx, sel, &obj) - case *Todo: - return ec._Todo(ctx, sel, obj) - default: - panic(fmt.Errorf("unexpected type %T", obj)) - } +type Config struct { + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot } -func UnmarshalTodoInput(v interface{}) (TodoInput, error) { - var it TodoInput - var asMap = v.(map[string]interface{}) +type ResolverRoot interface { + MyMutation() MyMutationResolver + MyQuery() MyQueryResolver +} - for k, v := range asMap { - switch k { - case "text": - var err error - it.Text, err = graphql.UnmarshalString(v) - if err != nil { - return it, err - } - } - } +type DirectiveRoot struct { + EnumLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) - return it, nil -} + FieldLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) -func (e *executableSchema) TodoInputMiddleware(ctx context.Context, obj *TodoInput) (*TodoInput, error) { + InputLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) - cObj, err := chainFieldMiddleware( - []graphql.FieldMiddleware{ - func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { - return e.directives.InputLogging(ctx, obj, n) - }, - }..., - )(ctx, func(ctx context.Context) (interface{}, error) { - return obj, nil - }) - if err != nil || cObj == nil { - return nil, err + InterfaceLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) + + ObjectLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) + + ScalarLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) + + UnionLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) +} + +type ComplexityRoot struct { + MyMutation struct { + CreateTodo func(childComplexity int, todo TodoInput) int } - obj, ok := cObj.(*TodoInput) - if !ok { - return nil, errors.New("expect TodoInput") + + MyQuery struct { + Todos func(childComplexity int) int + Todo func(childComplexity int, id string) int } - return obj, nil + Todo struct { + Id func(childComplexity int) int + Text func(childComplexity int) int + State func(childComplexity int) int + Verified func(childComplexity int) int + } +} + +type MyMutationResolver interface { + CreateTodo(ctx context.Context, todo TodoInput) (Todo, error) +} +type MyQueryResolver interface { + Todos(ctx context.Context) ([]Todo, error) + Todo(ctx context.Context, id string) (*Todo, error) +} + +func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 TodoInput + if tmp, ok := rawArgs["todo"]; ok { + var err error + arg0, err = UnmarshalTodoInput(tmp) + if err != nil { + return nil, err + } + + mTodoInput1, err := e.TodoInputMiddleware(ctx, &arg0) + if err != nil { + return nil, err + } + arg0 = *mTodoInput1 + } + args["todo"] = arg0 + return args, nil + +} + +func (e *executableSchema) field_MyQuery_todo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = graphql.UnmarshalID(tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + return args, nil + +} + +func (e *executableSchema) field_MyQuery___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg0 + return args, nil + +} + +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil + +} + +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil + +} + +type executableSchema struct { + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + switch typeName + "." + field { + + case "MyMutation.createTodo": + if e.complexity.MyMutation.CreateTodo == nil { + break + } + + args, err := e.field_MyMutation_createTodo_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.MyMutation.CreateTodo(childComplexity, args["todo"].(TodoInput)), true + + case "MyQuery.todos": + if e.complexity.MyQuery.Todos == nil { + break + } + + return e.complexity.MyQuery.Todos(childComplexity), true + + case "MyQuery.todo": + if e.complexity.MyQuery.Todo == nil { + break + } + + args, err := e.field_MyQuery_todo_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.MyQuery.Todo(childComplexity, args["id"].(string)), true + + case "Todo.id": + if e.complexity.Todo.Id == nil { + break + } + + return e.complexity.Todo.Id(childComplexity), true + + case "Todo.text": + if e.complexity.Todo.Text == nil { + break + } + + return e.complexity.Todo.Text(childComplexity), true + + case "Todo.state": + if e.complexity.Todo.State == nil { + break + } + + return e.complexity.Todo.State(childComplexity), true + + case "Todo.verified": + if e.complexity.Todo.Verified == nil { + break + } + + return e.complexity.Todo.Verified(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._MyQuery(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() + }) + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions} +} + +func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._MyMutation(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() + }) + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions, + } +} + +func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { + return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) +} + +type executionContext struct { + *graphql.RequestContext + *executableSchema } func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { @@ -2398,3 +1970,451 @@ func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMi return next(ctx) } } + +// endregion ************************** generated.gotpl *************************** + +// region **************************** input.gotpl ***************************** + +func UnmarshalTodoInput(v interface{}) (TodoInput, error) { + var it TodoInput + var asMap = v.(map[string]interface{}) + + for k, v := range asMap { + switch k { + case "text": + var err error + it.Text, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + } + } + + return it, nil +} + +func (e *executableSchema) TodoInputMiddleware(ctx context.Context, obj *TodoInput) (*TodoInput, error) { + + cObj, err := chainFieldMiddleware( + []graphql.FieldMiddleware{ + func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { + return e.directives.InputLogging(ctx, obj, n) + }, + }..., + )(ctx, func(ctx context.Context) (interface{}, error) { + return obj, nil + }) + if err != nil || cObj == nil { + return nil, err + } + obj, ok := cObj.(*TodoInput) + if !ok { + return nil, errors.New("expect TodoInput") + } + + return obj, nil +} + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +func (ec *executionContext) _Data(ctx context.Context, sel ast.SelectionSet, obj *Data) graphql.Marshaler { + switch obj := (*obj).(type) { + case nil: + return graphql.Null + case Todo: + return ec._Todo(ctx, sel, &obj) + case *Todo: + return ec._Todo(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj *Node) graphql.Marshaler { + switch obj := (*obj).(type) { + case nil: + return graphql.Null + case Todo: + return ec._Todo(ctx, sel, &obj) + case *Todo: + return ec._Todo(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +var myMutationImplementors = []string{"MyMutation"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, myMutationImplementors) + + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "MyMutation", + }) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("MyMutation") + case "createTodo": + out.Values[i] = ec._MyMutation_createTodo(ctx, field) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var myQueryImplementors = []string{"MyQuery"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, myQueryImplementors) + + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "MyQuery", + }) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("MyQuery") + case "todos": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._MyQuery_todos(ctx, field) + if res == graphql.Null { + invalid = true + } + return res + }) + case "todo": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._MyQuery_todo(ctx, field) + return res + }) + case "__type": + out.Values[i] = ec._MyQuery___type(ctx, field) + case "__schema": + out.Values[i] = ec._MyQuery___schema(ctx, field) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var todoImplementors = []string{"Todo", "Node"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, todoImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Todo") + case "id": + out.Values[i] = ec._Todo_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "text": + out.Values[i] = ec._Todo_text(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "state": + out.Values[i] = ec._Todo_state(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "verified": + out.Values[i] = ec._Todo_verified(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __DirectiveImplementors = []string{"__Directive"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __EnumValueImplementors = []string{"__EnumValue"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __FieldImplementors = []string{"__Field"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __FieldImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __InputValueImplementors = []string{"__InputValue"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __SchemaImplementors = []string{"__Schema"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __TypeImplementors = []string{"__Type"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __TypeImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +// endregion **************************** object.gotpl **************************** diff --git a/example/type-system-extension/models_gen.go b/example/type-system-extension/models_gen.go index ece1b800b2e..63b1695609e 100644 --- a/example/type-system-extension/models_gen.go +++ b/example/type-system-extension/models_gen.go @@ -1,5 +1,3 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - package type_system_extension import ( diff --git a/exec.go b/exec.go deleted file mode 100644 index 4ec4f7c6669..00000000000 --- a/exec.go +++ /dev/null @@ -1,42 +0,0 @@ -package gqlgen - -import ( - "fmt" - - "github.com/99designs/gqlgen/codegen" - "github.com/99designs/gqlgen/codegen/templates" -) - -type ExecBuild struct { - *codegen.Schema - - PackageName string - QueryRoot *codegen.Object - MutationRoot *codegen.Object - SubscriptionRoot *codegen.Object -} - -// bind a schema together with some code to generate a Build -func buildExec(s *codegen.Schema) error { - b := &ExecBuild{ - Schema: s, - PackageName: s.Config.Exec.Package, - } - - if s.Schema.Query != nil { - b.QueryRoot = b.Objects.ByName(s.Schema.Query.Name) - } else { - return fmt.Errorf("query entry point missing") - } - - if s.Schema.Mutation != nil { - b.MutationRoot = b.Objects.ByName(s.Schema.Mutation.Name) - } - - if s.Schema.Subscription != nil { - b.SubscriptionRoot = b.Objects.ByName(s.Schema.Subscription.Name) - } - - return templates.RenderToFile("generated.gotpl", s.Config.Exec.Filename, b) - -} diff --git a/generate.go b/generate.go index 8576aba0d36..b9e83d400c8 100644 --- a/generate.go +++ b/generate.go @@ -4,13 +4,13 @@ import ( "path/filepath" "syscall" - "golang.org/x/tools/go/packages" - "github.com/99designs/gqlgen/codegen" "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/plugin" "github.com/99designs/gqlgen/plugin/modelgen" + "github.com/99designs/gqlgen/plugin/resolvergen" "github.com/pkg/errors" + "golang.org/x/tools/go/packages" ) func Generate(cfg *config.Config, option ...Option) error { @@ -19,6 +19,7 @@ func Generate(cfg *config.Config, option ...Option) error { plugins := []plugin.Plugin{ modelgen.New(), + resolvergen.New(), } for _, o := range option { @@ -34,18 +35,21 @@ func Generate(cfg *config.Config, option ...Option) error { } } // Merge again now that the generated models have been injected into the typemap - schema, err := codegen.NewSchema(cfg) + data, err := codegen.BuildData(cfg) if err != nil { return errors.Wrap(err, "merging failed") } - if err := buildExec(schema); err != nil { - return errors.Wrap(err, "generating exec failed") + if err = codegen.GenerateCode(data); err != nil { + return errors.Wrap(err, "generating core failed") } - if cfg.Resolver.IsDefined() { - if err := GenerateResolver(schema); err != nil { - return errors.Wrap(err, "generating resolver failed") + for _, p := range plugins { + if mut, ok := p.(plugin.CodeGenerator); ok { + err := mut.GenerateCode(data) + if err != nil { + return errors.Wrap(err, p.Name()) + } } } diff --git a/integration/generated.go b/integration/generated.go index 8336654b9d7..689db4a3630 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -17,400 +17,234 @@ import ( "github.com/vektah/gqlparser/ast" ) -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } -} +// region **************************** field.gotpl ***************************** -type Config struct { - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot -} - -type ResolverRoot interface { - Element() ElementResolver - Query() QueryResolver - User() UserResolver -} +// nolint: vetshadow +func (ec *executionContext) _Element_child(ctx context.Context, field graphql.CollectedField, obj *models.Element) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Element", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Element().Child(rctx, obj) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(models.Element) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -type DirectiveRoot struct { - Magic func(ctx context.Context, obj interface{}, next graphql.Resolver, kind *int) (res interface{}, err error) + return ec._Element(ctx, field.Selections, &res) } -type ComplexityRoot struct { - Element struct { - Child func(childComplexity int) int - Error func(childComplexity int) int - Mismatched func(childComplexity int) int +// nolint: vetshadow +func (ec *executionContext) _Element_error(ctx context.Context, field graphql.CollectedField, obj *models.Element) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Element", + Field: field, + Args: nil, } - - Query struct { - Path func(childComplexity int) int - Date func(childComplexity int, filter models.DateFilter) int - Viewer func(childComplexity int) int - JsonEncoding func(childComplexity int) int - Error func(childComplexity int, typeArg *models.ErrorType) int + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Element().Error(rctx, obj) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null } + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) +} - User struct { - Name func(childComplexity int) int - Likes func(childComplexity int) int +// nolint: vetshadow +func (ec *executionContext) _Element_mismatched(ctx context.Context, field graphql.CollectedField, obj *models.Element) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Element", + Field: field, + Args: nil, } - - Viewer struct { - User func(childComplexity int) int + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Element().Mismatched(rctx, obj) + }) + if resTmp == nil { + return graphql.Null } -} - -type ElementResolver interface { - Child(ctx context.Context, obj *models.Element) (models.Element, error) - Error(ctx context.Context, obj *models.Element) (bool, error) - Mismatched(ctx context.Context, obj *models.Element) ([]bool, error) -} -type QueryResolver interface { - Path(ctx context.Context) ([]*models.Element, error) - Date(ctx context.Context, filter models.DateFilter) (bool, error) - Viewer(ctx context.Context) (*models.Viewer, error) - JSONEncoding(ctx context.Context) (string, error) - Error(ctx context.Context, typeArg *models.ErrorType) (bool, error) -} -type UserResolver interface { - Likes(ctx context.Context, obj *remote_api.User) ([]string, error) -} + res := resTmp.([]bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -func (e *executableSchema) field_Query_date_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 models.DateFilter - if tmp, ok := rawArgs["filter"]; ok { - var err error - arg0, err = UnmarshalDateFilter(tmp) - if err != nil { - return nil, err - } + arr1 := make(graphql.Array, len(res)) - mDateFilter1, err := e.DateFilterMiddleware(ctx, &arg0) - if err != nil { - return nil, err - } - arg0 = *mDateFilter1 + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { + return graphql.MarshalBoolean(res[idx1]) + }() } - args["filter"] = arg0 - return args, nil + return arr1 } -func (e *executableSchema) field_Query_error_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *models.ErrorType - if tmp, ok := rawArgs["type"]; ok { - var err error - var ptr1 models.ErrorType - if tmp != nil { - err = (&ptr1).UnmarshalGQL(tmp) - arg0 = &ptr1 - } - - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Query_path(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["type"] = arg0 - return args, nil + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Path(rctx) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*models.Element) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - args["name"] = arg0 - return args, nil - -} -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: res[idx1], } - } - args["includeDeprecated"] = arg0 - return args, nil + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { -} + if res[idx1] == nil { + return graphql.Null + } -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err + return ec._Element(ctx, field.Selections, res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) } - } - args["includeDeprecated"] = arg0 - return args, nil + } + wg.Wait() + return arr1 } -func (e *executableSchema) dir_magic_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *int - if tmp, ok := rawArgs["kind"]; ok { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg0 = &ptr1 - } - - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Query_date(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["kind"] = arg0 - return args, nil - -} - -type executableSchema struct { - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot -} - -func (e *executableSchema) Schema() *ast.Schema { - return parsedSchema -} - -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - switch typeName + "." + field { - - case "Element.child": - if e.complexity.Element.Child == nil { - break - } - - return e.complexity.Element.Child(childComplexity), true - - case "Element.error": - if e.complexity.Element.Error == nil { - break - } - - return e.complexity.Element.Error(childComplexity), true - - case "Element.mismatched": - if e.complexity.Element.Mismatched == nil { - break - } - - return e.complexity.Element.Mismatched(childComplexity), true - - case "Query.path": - if e.complexity.Query.Path == nil { - break - } - - return e.complexity.Query.Path(childComplexity), true - - case "Query.date": - if e.complexity.Query.Date == nil { - break - } - - args, err := e.field_Query_date_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.Date(childComplexity, args["filter"].(models.DateFilter)), true - - case "Query.viewer": - if e.complexity.Query.Viewer == nil { - break - } - - return e.complexity.Query.Viewer(childComplexity), true - - case "Query.jsonEncoding": - if e.complexity.Query.JsonEncoding == nil { - break - } - - return e.complexity.Query.JsonEncoding(childComplexity), true - - case "Query.error": - if e.complexity.Query.Error == nil { - break - } - - args, err := e.field_Query_error_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.Error(childComplexity, args["type"].(*models.ErrorType)), true - - case "User.name": - if e.complexity.User.Name == nil { - break - } - - return e.complexity.User.Name(childComplexity), true - - case "User.likes": - if e.complexity.User.Likes == nil { - break - } - - return e.complexity.User.Likes(childComplexity), true - - case "Viewer.user": - if e.complexity.Viewer.User == nil { - break - } - - return e.complexity.Viewer.User(childComplexity), true - + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_date_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - return 0, false -} - -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Date(rctx, args["filter"].(models.DateFilter)) }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions} -} - -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - return graphql.ErrorResponse(ctx, "mutations are not supported") -} - -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) -} - -type executionContext struct { - *graphql.RequestContext - *executableSchema -} - -var elementImplementors = []string{"Element"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Element(ctx context.Context, sel ast.SelectionSet, obj *models.Element) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, elementImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Element") - case "child": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Element_child(ctx, field, obj) - if res == graphql.Null { - invalid = true - } - return res - }) - case "error": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Element_error(ctx, field, obj) - if res == graphql.Null { - invalid = true - } - return res - }) - case "mismatched": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Element_mismatched(ctx, field, obj) - return res - }) - default: - panic("unknown field " + strconv.Quote(field.Name)) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } - } - out.Dispatch() - if invalid { return graphql.Null } - return out + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) _Element_child(ctx context.Context, field graphql.CollectedField, obj *models.Element) graphql.Marshaler { +func (ec *executionContext) _Query_viewer(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Element", + Object: "Query", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Element().Child(rctx, obj) + return ec.resolvers.Query().Viewer(rctx) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(models.Element) + res := resTmp.(*models.Viewer) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec._Element(ctx, field.Selections, &res) + if res == nil { + return graphql.Null + } + + return ec._Viewer(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) _Element_error(ctx context.Context, field graphql.CollectedField, obj *models.Element) graphql.Marshaler { +func (ec *executionContext) _Query_jsonEncoding(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Element", + Object: "Query", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Element().Error(rctx, obj) + return ec.resolvers.Query().JSONEncoding(rctx) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -418,178 +252,48 @@ func (ec *executionContext) _Element_error(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _Element_mismatched(ctx context.Context, field graphql.CollectedField, obj *models.Element) graphql.Marshaler { +func (ec *executionContext) _Query_error(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Element", + Object: "Query", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_error_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Element().Mismatched(rctx, obj) + return ec.resolvers.Query().Error(rctx, args["type"].(*models.ErrorType)) }) if resTmp == nil { - return graphql.Null - } - res := resTmp.([]bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalBoolean(res[idx1]) - }() - } - - return arr1 -} - -var queryImplementors = []string{"Query"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, queryImplementors) - - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: "Query", - }) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Query") - case "path": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_path(ctx, field) - return res - }) - case "date": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_date(ctx, field) - if res == graphql.Null { - invalid = true - } - return res - }) - case "viewer": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_viewer(ctx, field) - return res - }) - case "jsonEncoding": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_jsonEncoding(ctx, field) - if res == graphql.Null { - invalid = true - } - return res - }) - case "error": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_error(ctx, field) - if res == graphql.Null { - invalid = true - } - return res - }) - case "__type": - out.Values[i] = ec._Query___type(ctx, field) - case "__schema": - out.Values[i] = ec._Query___schema(ctx, field) - default: - panic("unknown field " + strconv.Quote(field.Name)) + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - -// nolint: vetshadow -func (ec *executionContext) _Query_path(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Path(rctx) - }) - if resTmp == nil { return graphql.Null } - res := resTmp.([]*models.Element) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - if res[idx1] == nil { - return graphql.Null - } - - return ec._Element(ctx, field.Selections, res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) _Query_date(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -599,7 +303,7 @@ func (ec *executionContext) _Query_date(ctx context.Context, field graphql.Colle } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_date_args(ctx, rawArgs) + args, err := ec.field_Query___type_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -608,22 +312,24 @@ func (ec *executionContext) _Query_date(ctx context.Context, field graphql.Colle ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Date(rctx, args["filter"].(models.DateFilter)) + return ec.introspectType(args["name"].(string)) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + + if res == nil { + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) _Query_viewer(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -635,12 +341,12 @@ func (ec *executionContext) _Query_viewer(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Viewer(rctx) + return ec.introspectSchema() }) if resTmp == nil { return graphql.Null } - res := resTmp.(*models.Viewer) + res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -648,23 +354,23 @@ func (ec *executionContext) _Query_viewer(ctx context.Context, field graphql.Col return graphql.Null } - return ec._Viewer(ctx, field.Selections, res) + return ec.___Schema(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) _Query_jsonEncoding(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *remote_api.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "User", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().JSONEncoding(rctx) + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -679,26 +385,19 @@ func (ec *executionContext) _Query_jsonEncoding(ctx context.Context, field graph } // nolint: vetshadow -func (ec *executionContext) _Query_error(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) _User_likes(ctx context.Context, field graphql.CollectedField, obj *remote_api.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "User", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_error_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Error(rctx, args["type"].(*models.ErrorType)) + return ec.resolvers.User().Likes(rctx, obj) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -706,38 +405,40 @@ func (ec *executionContext) _Query_error(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.(bool) + res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + + arr1 := make(graphql.Array, len(res)) + + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { + return graphql.MarshalString(res[idx1]) + }() + } + + return arr1 } // nolint: vetshadow -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) _Viewer_user(ctx context.Context, field graphql.CollectedField, obj *models.Viewer) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "Viewer", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query___type_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectType(args["name"].(string)) + return obj.User, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(*remote_api.User) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -745,257 +446,34 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col return graphql.Null } - return ec.___Type(ctx, field.Selections, res) + return ec._User(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "__Directive", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() + return obj.Name, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Schema) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Schema(ctx, field.Selections, res) -} - -var userImplementors = []string{"User"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *remote_api.User) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, userImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("User") - case "name": - out.Values[i] = ec._User_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "likes": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._User_likes(ctx, field, obj) - if res == graphql.Null { - invalid = true - } - return res - }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - -// nolint: vetshadow -func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *remote_api.User) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) _User_likes(ctx context.Context, field graphql.CollectedField, obj *remote_api.User) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.User().Likes(rctx, obj) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 -} - -var viewerImplementors = []string{"Viewer"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _Viewer(ctx context.Context, sel ast.SelectionSet, obj *models.Viewer) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, viewerImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Viewer") - case "user": - out.Values[i] = ec._Viewer_user(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - -// nolint: vetshadow -func (ec *executionContext) _Viewer_user(ctx context.Context, field graphql.CollectedField, obj *models.Viewer) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Viewer", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.User, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*remote_api.User) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec._User(ctx, field.Selections, res) -} - -var __DirectiveImplementors = []string{"__Directive"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Directive") - case "name": - out.Values[i] = ec.___Directive_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___Directive_description(ctx, field, obj) - case "locations": - out.Values[i] = ec.___Directive_locations(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "args": - out.Values[i] = ec.___Directive_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - -// nolint: vetshadow -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return graphql.MarshalString(res) } // nolint: vetshadow @@ -1118,43 +596,6 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql return arr1 } -var __EnumValueImplementors = []string{"__EnumValue"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__EnumValue") - case "name": - out.Values[i] = ec.___EnumValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___EnumValue_description(ctx, field, obj) - case "isDeprecated": - out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "deprecationReason": - out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - // nolint: vetshadow func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) @@ -1261,53 +702,6 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, return graphql.MarshalString(*res) } -var __FieldImplementors = []string{"__Field"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __FieldImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Field") - case "name": - out.Values[i] = ec.___Field_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___Field_description(ctx, field, obj) - case "args": - out.Values[i] = ec.___Field_args(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "type": - out.Values[i] = ec.___Field_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "isDeprecated": - out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "deprecationReason": - out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - // nolint: vetshadow func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) @@ -1509,43 +903,6 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel return graphql.MarshalString(*res) } -var __InputValueImplementors = []string{"__InputValue"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__InputValue") - case "name": - out.Values[i] = ec.___InputValue_name(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "description": - out.Values[i] = ec.___InputValue_description(ctx, field, obj) - case "type": - out.Values[i] = ec.___InputValue_type(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "defaultValue": - out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - // nolint: vetshadow func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) @@ -1660,48 +1017,6 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel return graphql.MarshalString(*res) } -var __SchemaImplementors = []string{"__Schema"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Schema") - case "types": - out.Values[i] = ec.___Schema_types(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "queryType": - out.Values[i] = ec.___Schema_queryType(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "mutationType": - out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) - case "subscriptionType": - out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) - case "directives": - out.Values[i] = ec.___Schema_directives(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - // nolint: vetshadow func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) @@ -1915,50 +1230,6 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap return arr1 } -var __TypeImplementors = []string{"__Type"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, __TypeImplementors) - - out := graphql.NewFieldSet(fields) - invalid := false - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("__Type") - case "kind": - out.Values[i] = ec.___Type_kind(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - case "name": - out.Values[i] = ec.___Type_name(ctx, field, obj) - case "description": - out.Values[i] = ec.___Type_description(ctx, field, obj) - case "fields": - out.Values[i] = ec.___Type_fields(ctx, field, obj) - case "interfaces": - out.Values[i] = ec.___Type_interfaces(ctx, field, obj) - case "possibleTypes": - out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) - case "enumValues": - out.Values[i] = ec.___Type_enumValues(ctx, field, obj) - case "inputFields": - out.Values[i] = ec.___Type_inputFields(ctx, field, obj) - case "ofType": - out.Values[i] = ec.___Type_ofType(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalid { - return graphql.Null - } - return out -} - // nolint: vetshadow func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) @@ -2366,190 +1637,939 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co return ec.___Type(ctx, field.Selections, res) } -func UnmarshalDateFilter(v interface{}) (models.DateFilter, error) { - var it models.DateFilter - var asMap = v.(map[string]interface{}) +// endregion **************************** field.gotpl ***************************** - if _, present := asMap["timezone"]; !present { - asMap["timezone"] = "UTC" - } - if _, present := asMap["op"]; !present { - asMap["op"] = "EQ" +// region ************************** generated.gotpl *************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, } +} - for k, v := range asMap { - switch k { - case "value": - var err error - it.Value, err = graphql.UnmarshalString(v) - if err != nil { - return it, err - } - case "timezone": - var err error - var ptr1 string - if v != nil { - ptr1, err = graphql.UnmarshalString(v) - it.Timezone = &ptr1 - } +type Config struct { + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} - if err != nil { - return it, err - } - case "op": - var err error - var ptr1 models.DateFilterOp - if v != nil { - err = (&ptr1).UnmarshalGQL(v) - it.Op = &ptr1 - } +type ResolverRoot interface { + Element() ElementResolver + Query() QueryResolver + User() UserResolver +} - if err != nil { - return it, err - } - } +type DirectiveRoot struct { + Magic func(ctx context.Context, obj interface{}, next graphql.Resolver, kind *int) (res interface{}, err error) +} + +type ComplexityRoot struct { + Element struct { + Child func(childComplexity int) int + Error func(childComplexity int) int + Mismatched func(childComplexity int) int } - return it, nil -} + Query struct { + Path func(childComplexity int) int + Date func(childComplexity int, filter models.DateFilter) int + Viewer func(childComplexity int) int + JsonEncoding func(childComplexity int) int + Error func(childComplexity int, typeArg *models.ErrorType) int + } -func (e *executableSchema) DateFilterMiddleware(ctx context.Context, obj *models.DateFilter) (*models.DateFilter, error) { + User struct { + Name func(childComplexity int) int + Likes func(childComplexity int) int + } - return obj, nil + Viewer struct { + User func(childComplexity int) int + } } -func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - rctx := graphql.GetResolverContext(ctx) - for _, d := range rctx.Field.Definition.Directives { - switch d.Name { - case "magic": - if ec.directives.Magic != nil { - rawArgs := d.ArgumentMap(ec.Variables) - args, err := ec.dir_magic_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return nil - } - n := next - next = func(ctx context.Context) (interface{}, error) { - return ec.directives.Magic(ctx, obj, n, args["kind"].(*int)) - } - } +type ElementResolver interface { + Child(ctx context.Context, obj *models.Element) (models.Element, error) + Error(ctx context.Context, obj *models.Element) (bool, error) + Mismatched(ctx context.Context, obj *models.Element) ([]bool, error) +} +type QueryResolver interface { + Path(ctx context.Context) ([]*models.Element, error) + Date(ctx context.Context, filter models.DateFilter) (bool, error) + Viewer(ctx context.Context) (*models.Viewer, error) + JSONEncoding(ctx context.Context) (string, error) + Error(ctx context.Context, typeArg *models.ErrorType) (bool, error) +} +type UserResolver interface { + Likes(ctx context.Context, obj *remote_api.User) ([]string, error) +} + +func (e *executableSchema) field_Query_date_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 models.DateFilter + if tmp, ok := rawArgs["filter"]; ok { + var err error + arg0, err = UnmarshalDateFilter(tmp) + if err != nil { + return nil, err } + + mDateFilter1, err := e.DateFilterMiddleware(ctx, &arg0) + if err != nil { + return nil, err + } + arg0 = *mDateFilter1 } - res, err := ec.ResolverMiddleware(ctx, next) - if err != nil { - ec.Error(ctx, err) - return nil - } - return res + args["filter"] = arg0 + return args, nil + } -func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") +func (e *executableSchema) field_Query_error_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *models.ErrorType + if tmp, ok := rawArgs["type"]; ok { + var err error + var ptr1 models.ErrorType + if tmp != nil { + err = (&ptr1).UnmarshalGQL(tmp) + arg0 = &ptr1 + } + + if err != nil { + return nil, err + } } - return introspection.WrapSchema(parsedSchema), nil + args["type"] = arg0 + return args, nil + } -func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") +func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil + args["name"] = arg0 + return args, nil + } -var parsedSchema = gqlparser.MustLoadSchema( - &ast.Source{Name: "schema.graphql", Input: `"This directive does magical things" -directive @magic(kind: Int) on FIELD_DEFINITION +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil -type Element { - child: Element! - error: Boolean! - mismatched: [Boolean!] } -enum DATE_FILTER_OP { - # multi - # line - # comment - EQ - NEQ - GT - GTE - LT - LTE -} +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil -input DateFilter { - value: String! - timezone: String = "UTC" - op: DATE_FILTER_OP = EQ } -type Viewer { - user: User -} +func (e *executableSchema) dir_magic_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *int + if tmp, ok := rawArgs["kind"]; ok { + var err error + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + arg0 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["kind"] = arg0 + return args, nil -type Query { - path: [Element] - date(filter: DateFilter!): Boolean! - viewer: Viewer - jsonEncoding: String! - error(type: ErrorType = NORMAL): Boolean! } -enum ErrorType { - CUSTOM - NORMAL +type executableSchema struct { + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot } -# this is a comment with a ` + "`" + `backtick` + "`" + ` -`}, - &ast.Source{Name: "user.graphql", Input: `type User { - name: String! - likes: [String!]! +func (e *executableSchema) Schema() *ast.Schema { + return parsedSchema } -`}, -) -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + switch typeName + "." + field { - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err + case "Element.child": + if e.complexity.Element.Child == nil { + break + } - } - return handleFunc[0](ctx, chainHandler) + return e.complexity.Element.Child(childComplexity), true + + case "Element.error": + if e.complexity.Element.Error == nil { + break } - } - if n == 1 { - return handleFunc[0] - } + return e.complexity.Element.Error(childComplexity), true - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) - } -} + case "Element.mismatched": + if e.complexity.Element.Mismatched == nil { + break + } + + return e.complexity.Element.Mismatched(childComplexity), true + + case "Query.path": + if e.complexity.Query.Path == nil { + break + } + + return e.complexity.Query.Path(childComplexity), true + + case "Query.date": + if e.complexity.Query.Date == nil { + break + } + + args, err := e.field_Query_date_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Date(childComplexity, args["filter"].(models.DateFilter)), true + + case "Query.viewer": + if e.complexity.Query.Viewer == nil { + break + } + + return e.complexity.Query.Viewer(childComplexity), true + + case "Query.jsonEncoding": + if e.complexity.Query.JsonEncoding == nil { + break + } + + return e.complexity.Query.JsonEncoding(childComplexity), true + + case "Query.error": + if e.complexity.Query.Error == nil { + break + } + + args, err := e.field_Query_error_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Error(childComplexity, args["type"].(*models.ErrorType)), true + + case "User.name": + if e.complexity.User.Name == nil { + break + } + + return e.complexity.User.Name(childComplexity), true + + case "User.likes": + if e.complexity.User.Likes == nil { + break + } + + return e.complexity.User.Likes(childComplexity), true + + case "Viewer.user": + if e.complexity.Viewer.User == nil { + break + } + + return e.complexity.Viewer.User(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._Query(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() + }) + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions} +} + +func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + return graphql.ErrorResponse(ctx, "mutations are not supported") +} + +func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { + return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) +} + +type executionContext struct { + *graphql.RequestContext + *executableSchema +} + +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + rctx := graphql.GetResolverContext(ctx) + for _, d := range rctx.Field.Definition.Directives { + switch d.Name { + case "magic": + if ec.directives.Magic != nil { + rawArgs := d.ArgumentMap(ec.Variables) + args, err := ec.dir_magic_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return nil + } + n := next + next = func(ctx context.Context) (interface{}, error) { + return ec.directives.Magic(ctx, obj, n, args["kind"].(*int)) + } + } + } + } + res, err := ec.ResolverMiddleware(ctx, next) + if err != nil { + ec.Error(ctx, err) + return nil + } + return res +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(parsedSchema), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil +} + +var parsedSchema = gqlparser.MustLoadSchema( + &ast.Source{Name: "schema.graphql", Input: `"This directive does magical things" +directive @magic(kind: Int) on FIELD_DEFINITION + +type Element { + child: Element! + error: Boolean! + mismatched: [Boolean!] +} + +enum DATE_FILTER_OP { + # multi + # line + # comment + EQ + NEQ + GT + GTE + LT + LTE +} + +input DateFilter { + value: String! + timezone: String = "UTC" + op: DATE_FILTER_OP = EQ +} + +type Viewer { + user: User +} + +type Query { + path: [Element] + date(filter: DateFilter!): Boolean! + viewer: Viewer + jsonEncoding: String! + error(type: ErrorType = NORMAL): Boolean! +} + +enum ErrorType { + CUSTOM + NORMAL +} + +# this is a comment with a ` + "`" + `backtick` + "`" + ` +`}, + &ast.Source{Name: "user.graphql", Input: `type User { + name: String! + likes: [String!]! +} +`}, +) + +// ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + + } + return handleFunc[0](ctx, chainHandler) + } + } + + if n == 1 { + return handleFunc[0] + } + + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) + } +} + +// endregion ************************** generated.gotpl *************************** + +// region **************************** input.gotpl ***************************** + +func UnmarshalDateFilter(v interface{}) (models.DateFilter, error) { + var it models.DateFilter + var asMap = v.(map[string]interface{}) + + if _, present := asMap["timezone"]; !present { + asMap["timezone"] = "UTC" + } + if _, present := asMap["op"]; !present { + asMap["op"] = "EQ" + } + + for k, v := range asMap { + switch k { + case "value": + var err error + it.Value, err = graphql.UnmarshalString(v) + if err != nil { + return it, err + } + case "timezone": + var err error + var ptr1 string + if v != nil { + ptr1, err = graphql.UnmarshalString(v) + it.Timezone = &ptr1 + } + + if err != nil { + return it, err + } + case "op": + var err error + var ptr1 models.DateFilterOp + if v != nil { + err = (&ptr1).UnmarshalGQL(v) + it.Op = &ptr1 + } + + if err != nil { + return it, err + } + } + } + + return it, nil +} + +func (e *executableSchema) DateFilterMiddleware(ctx context.Context, obj *models.DateFilter) (*models.DateFilter, error) { + + return obj, nil +} + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +var elementImplementors = []string{"Element"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Element(ctx context.Context, sel ast.SelectionSet, obj *models.Element) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, elementImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Element") + case "child": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Element_child(ctx, field, obj) + if res == graphql.Null { + invalid = true + } + return res + }) + case "error": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Element_error(ctx, field, obj) + if res == graphql.Null { + invalid = true + } + return res + }) + case "mismatched": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Element_mismatched(ctx, field, obj) + return res + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var queryImplementors = []string{"Query"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, queryImplementors) + + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "Query", + }) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Query") + case "path": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_path(ctx, field) + return res + }) + case "date": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_date(ctx, field) + if res == graphql.Null { + invalid = true + } + return res + }) + case "viewer": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_viewer(ctx, field) + return res + }) + case "jsonEncoding": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_jsonEncoding(ctx, field) + if res == graphql.Null { + invalid = true + } + return res + }) + case "error": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_error(ctx, field) + if res == graphql.Null { + invalid = true + } + return res + }) + case "__type": + out.Values[i] = ec._Query___type(ctx, field) + case "__schema": + out.Values[i] = ec._Query___schema(ctx, field) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var userImplementors = []string{"User"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *remote_api.User) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, userImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("User") + case "name": + out.Values[i] = ec._User_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "likes": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._User_likes(ctx, field, obj) + if res == graphql.Null { + invalid = true + } + return res + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var viewerImplementors = []string{"Viewer"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _Viewer(ctx context.Context, sel ast.SelectionSet, obj *models.Viewer) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, viewerImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Viewer") + case "user": + out.Values[i] = ec._Viewer_user(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __DirectiveImplementors = []string{"__Directive"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + out.Values[i] = ec.___Directive_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___Directive_description(ctx, field, obj) + case "locations": + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "args": + out.Values[i] = ec.___Directive_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __EnumValueImplementors = []string{"__EnumValue"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + case "isDeprecated": + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "deprecationReason": + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __FieldImplementors = []string{"__Field"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __FieldImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + out.Values[i] = ec.___Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___Field_description(ctx, field, obj) + case "args": + out.Values[i] = ec.___Field_args(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "type": + out.Values[i] = ec.___Field_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "isDeprecated": + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "deprecationReason": + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __InputValueImplementors = []string{"__InputValue"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "description": + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + case "type": + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "defaultValue": + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __SchemaImplementors = []string{"__Schema"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "types": + out.Values[i] = ec.___Schema_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "queryType": + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "mutationType": + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + case "subscriptionType": + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + case "directives": + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var __TypeImplementors = []string{"__Type"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, __TypeImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + out.Values[i] = ec.___Type_kind(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "name": + out.Values[i] = ec.___Type_name(ctx, field, obj) + case "description": + out.Values[i] = ec.___Type_description(ctx, field, obj) + case "fields": + out.Values[i] = ec.___Type_fields(ctx, field, obj) + case "interfaces": + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + case "possibleTypes": + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + case "enumValues": + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + case "inputFields": + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + case "ofType": + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +// endregion **************************** object.gotpl **************************** diff --git a/integration/models-go/generated.go b/integration/models-go/generated.go index 7d4b611e83e..62e460cb2ff 100644 --- a/integration/models-go/generated.go +++ b/integration/models-go/generated.go @@ -1,5 +1,3 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - package models import ( diff --git a/plugin/modelgen/models.go b/plugin/modelgen/models.go index c6bfa329fd0..7df76ac853e 100644 --- a/plugin/modelgen/models.go +++ b/plugin/modelgen/models.go @@ -133,7 +133,7 @@ func (m *Plugin) MutateConfig(cfg *config.Config) error { fd := schema.Types[field.Type.Name()] it.Fields = append(it.Fields, &Field{ Name: templates.ToGo(name), - Type: copyModifiersFromAst(field.Type, fd.Kind != ast.Interface, typ), + Type: binder.CopyModifiersFromAst(field.Type, fd.Kind != ast.Interface, typ), Description: field.Description, Tag: `json:"` + field.Name + `"`, }) @@ -177,17 +177,9 @@ func (m *Plugin) MutateConfig(cfg *config.Config) error { return nil } - return templates.RenderToFile("./models.gotpl", cfg.Model.Filename, b) -} - -func copyModifiersFromAst(t *ast.Type, usePtr bool, base types.Type) types.Type { - if t.Elem != nil { - return types.NewSlice(copyModifiersFromAst(t.Elem, usePtr, base)) - } - - if !t.NonNull && usePtr { - return types.NewPointer(base) - } - - return base + return templates.Render(templates.Options{ + PackageName: cfg.Model.Package, + Filename: cfg.Model.Filename, + Data: b, + }) } diff --git a/plugin/modelgen/models.gotpl b/plugin/modelgen/models.gotpl index a587b281f72..8c406194bdc 100644 --- a/plugin/modelgen/models.gotpl +++ b/plugin/modelgen/models.gotpl @@ -1,24 +1,16 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. +{{ reserveImport "context" }} +{{ reserveImport "fmt" }} +{{ reserveImport "io" }} +{{ reserveImport "strconv" }} +{{ reserveImport "time" }} +{{ reserveImport "sync" }} +{{ reserveImport "errors" }} +{{ reserveImport "bytes" }} -package {{ .PackageName }} - -import ( - %%%IMPORTS%%% - - {{ reserveImport "context" }} - {{ reserveImport "fmt" }} - {{ reserveImport "io" }} - {{ reserveImport "strconv" }} - {{ reserveImport "time" }} - {{ reserveImport "sync" }} - {{ reserveImport "errors" }} - {{ reserveImport "bytes" }} - - {{ reserveImport "github.com/vektah/gqlparser" }} - {{ reserveImport "github.com/vektah/gqlparser/ast" }} - {{ reserveImport "github.com/99designs/gqlgen/graphql" }} - {{ reserveImport "github.com/99designs/gqlgen/graphql/introspection" }} -) +{{ reserveImport "github.com/vektah/gqlparser" }} +{{ reserveImport "github.com/vektah/gqlparser/ast" }} +{{ reserveImport "github.com/99designs/gqlgen/graphql" }} +{{ reserveImport "github.com/99designs/gqlgen/graphql/introspection" }} {{- range $model := .Interfaces }} {{ with .Description }} {{.|prefixLines "// "}} {{ end }} diff --git a/plugin/plugin.go b/plugin/plugin.go index 55492b1799f..a84bfd3273d 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -2,7 +2,10 @@ package plugin -import "github.com/99designs/gqlgen/codegen/config" +import ( + "github.com/99designs/gqlgen/codegen" + "github.com/99designs/gqlgen/codegen/config" +) type Plugin interface { Name() string @@ -11,3 +14,7 @@ type Plugin interface { type ConfigMutator interface { MutateConfig(cfg *config.Config) error } + +type CodeGenerator interface { + GenerateCode(cfg *codegen.Data) error +} diff --git a/plugin/resolvergen/resolver.go b/plugin/resolvergen/resolver.go new file mode 100644 index 00000000000..00a6d5c9d42 --- /dev/null +++ b/plugin/resolvergen/resolver.go @@ -0,0 +1,53 @@ +package resolvergen + +import ( + "log" + "os" + + "github.com/99designs/gqlgen/codegen" + "github.com/99designs/gqlgen/codegen/templates" + "github.com/99designs/gqlgen/plugin" + "github.com/pkg/errors" +) + +func New() plugin.Plugin { + return &Plugin{} +} + +type Plugin struct{} + +var _ plugin.CodeGenerator = &Plugin{} + +func (m *Plugin) Name() string { + return "resovlergen" +} +func (m *Plugin) GenerateCode(data *codegen.Data) error { + if !data.Config.Resolver.IsDefined() { + return nil + } + + resolverBuild := &ResolverBuild{ + Data: data, + PackageName: data.Config.Resolver.Package, + ResolverType: data.Config.Resolver.Type, + } + filename := data.Config.Resolver.Filename + + if _, err := os.Stat(filename); os.IsNotExist(errors.Cause(err)) { + return templates.Render(templates.Options{ + PackageName: data.Config.Resolver.Package, + Filename: data.Config.Resolver.Filename, + Data: resolverBuild, + }) + } + + log.Printf("Skipped resolver: %s already exists\n", filename) + return nil +} + +type ResolverBuild struct { + *codegen.Data + + PackageName string + ResolverType string +} diff --git a/codegen/templates/resolver.gotpl b/plugin/resolvergen/resolver.gotpl similarity index 54% rename from codegen/templates/resolver.gotpl rename to plugin/resolvergen/resolver.gotpl index fb3c9125597..c61bb5f36e2 100644 --- a/codegen/templates/resolver.gotpl +++ b/plugin/resolvergen/resolver.gotpl @@ -1,23 +1,19 @@ -package {{ .PackageName }} +// THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES. -import ( - %%%IMPORTS%%% +{{ reserveImport "context" }} +{{ reserveImport "fmt" }} +{{ reserveImport "io" }} +{{ reserveImport "strconv" }} +{{ reserveImport "time" }} +{{ reserveImport "sync" }} +{{ reserveImport "errors" }} +{{ reserveImport "bytes" }} - {{ reserveImport "context" }} - {{ reserveImport "fmt" }} - {{ reserveImport "io" }} - {{ reserveImport "strconv" }} - {{ reserveImport "time" }} - {{ reserveImport "sync" }} - {{ reserveImport "errors" }} - {{ reserveImport "bytes" }} - - {{ reserveImport "github.com/99designs/gqlgen/handler" }} - {{ reserveImport "github.com/vektah/gqlparser" }} - {{ reserveImport "github.com/vektah/gqlparser/ast" }} - {{ reserveImport "github.com/99designs/gqlgen/graphql" }} - {{ reserveImport "github.com/99designs/gqlgen/graphql/introspection" }} -) +{{ reserveImport "github.com/99designs/gqlgen/handler" }} +{{ reserveImport "github.com/vektah/gqlparser" }} +{{ reserveImport "github.com/vektah/gqlparser/ast" }} +{{ reserveImport "github.com/99designs/gqlgen/graphql" }} +{{ reserveImport "github.com/99designs/gqlgen/graphql/introspection" }} type {{.ResolverType}} struct {} diff --git a/plugin/servergen/server.go b/plugin/servergen/server.go new file mode 100644 index 00000000000..22289c0254d --- /dev/null +++ b/plugin/servergen/server.go @@ -0,0 +1,49 @@ +package servergen + +import ( + "log" + "os" + + "github.com/99designs/gqlgen/codegen" + "github.com/99designs/gqlgen/codegen/templates" + "github.com/99designs/gqlgen/plugin" + "github.com/pkg/errors" +) + +func New(filename string) plugin.Plugin { + return &Plugin{filename} +} + +type Plugin struct { + filename string +} + +var _ plugin.CodeGenerator = &Plugin{} + +func (m *Plugin) Name() string { + return "servergen" +} +func (m *Plugin) GenerateCode(data *codegen.Data) error { + serverBuild := &ServerBuild{ + ExecPackageName: data.Config.Exec.ImportPath(), + ResolverPackageName: data.Config.Resolver.ImportPath(), + } + + if _, err := os.Stat(m.filename); os.IsNotExist(errors.Cause(err)) { + return templates.Render(templates.Options{ + PackageName: "main", + Filename: m.filename, + Data: serverBuild, + }) + } + + log.Printf("Skipped server: %s already exists\n", m.filename) + return nil +} + +type ServerBuild struct { + codegen.Data + + ExecPackageName string + ResolverPackageName string +} diff --git a/codegen/templates/server.gotpl b/plugin/servergen/server.gotpl similarity index 70% rename from codegen/templates/server.gotpl rename to plugin/servergen/server.gotpl index 38dc0d18225..fca71c53cda 100644 --- a/codegen/templates/server.gotpl +++ b/plugin/servergen/server.gotpl @@ -1,14 +1,8 @@ -package main - -import ( - %%%IMPORTS%%% - - {{ reserveImport "context" }} - {{ reserveImport "log" }} - {{ reserveImport "net/http" }} - {{ reserveImport "os" }} - {{ reserveImport "github.com/99designs/gqlgen/handler" }} -) +{{ reserveImport "context" }} +{{ reserveImport "log" }} +{{ reserveImport "net/http" }} +{{ reserveImport "os" }} +{{ reserveImport "github.com/99designs/gqlgen/handler" }} const defaultPort = "8080" diff --git a/resolver.go b/resolver.go deleted file mode 100644 index 8146856481b..00000000000 --- a/resolver.go +++ /dev/null @@ -1,43 +0,0 @@ -package gqlgen - -import ( - "log" - "os" - - "github.com/99designs/gqlgen/codegen" - "github.com/99designs/gqlgen/codegen/templates" - "github.com/pkg/errors" -) - -type ResolverBuild struct { - *codegen.Schema - - PackageName string - ResolverType string -} - -func GenerateResolver(schema *codegen.Schema) error { - resolverBuild, err := buildResolver(schema) - if err != nil { - return errors.Wrap(err, "resolver build failed") - } - filename := schema.Config.Resolver.Filename - - if _, err := os.Stat(filename); os.IsNotExist(errors.Cause(err)) { - if err := templates.RenderToFile("resolver.gotpl", filename, resolverBuild); err != nil { - return err - } - } else { - log.Printf("Skipped resolver: %s already exists\n", filename) - } - - return nil -} - -func buildResolver(s *codegen.Schema) (*ResolverBuild, error) { - return &ResolverBuild{ - Schema: s, - PackageName: s.Config.Resolver.Package, - ResolverType: s.Config.Resolver.Type, - }, nil -} diff --git a/server.go b/server.go deleted file mode 100644 index 39b19262e5b..00000000000 --- a/server.go +++ /dev/null @@ -1,42 +0,0 @@ -package gqlgen - -import ( - "log" - "os" - - "github.com/99designs/gqlgen/codegen" - "github.com/99designs/gqlgen/codegen/config" - "github.com/99designs/gqlgen/codegen/templates" - "github.com/pkg/errors" -) - -type ServerBuild struct { - codegen.Schema - - PackageName string - ExecPackageName string - ResolverPackageName string -} - -func GenerateServer(filename string, cfg *config.Config) error { - serverBuild := buildServer(cfg) - - serverFilename := abs(filename) - if _, err := os.Stat(serverFilename); os.IsNotExist(errors.Cause(err)) { - err = templates.RenderToFile("server.gotpl", serverFilename, serverBuild) - if err != nil { - return errors.Wrap(err, "generate server failed") - } - } else { - log.Printf("Skipped server: %s already exists\n", serverFilename) - } - return nil -} - -func buildServer(config *config.Config) *ServerBuild { - return &ServerBuild{ - PackageName: config.Resolver.Package, - ExecPackageName: config.Exec.ImportPath(), - ResolverPackageName: config.Resolver.ImportPath(), - } -} From d380eccfd6721769835f1c3ed486ec5a1e5f9b2e Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Mon, 4 Feb 2019 11:52:55 +1100 Subject: [PATCH 051/147] promote args partial to full template --- codegen/args.go | 24 +++ codegen/{_args.gotpl => args.gotpl} | 4 + codegen/build_directive.go | 8 +- codegen/directive.go | 2 +- codegen/generated.gotpl | 18 --- example/todo/generated.go | 237 ++++++++++++++-------------- 6 files changed, 150 insertions(+), 143 deletions(-) create mode 100644 codegen/args.go rename codegen/{_args.gotpl => args.gotpl} (89%) diff --git a/codegen/args.go b/codegen/args.go new file mode 100644 index 00000000000..6f5fc61e9a8 --- /dev/null +++ b/codegen/args.go @@ -0,0 +1,24 @@ +package codegen + +type ArgSet struct { + Args []*FieldArgument + FuncDecl string +} + +func (a *Data) Args() map[string][]*FieldArgument { + ret := map[string][]*FieldArgument{} + for _, o := range a.Objects { + for _, f := range o.Fields { + if len(f.Args) > 0 { + ret[f.ArgsFunc()] = f.Args + } + } + } + + for _, d := range a.Directives { + if len(d.Args) > 0 { + ret[d.ArgsFunc()] = d.Args + } + } + return ret +} diff --git a/codegen/_args.gotpl b/codegen/args.gotpl similarity index 89% rename from codegen/_args.gotpl rename to codegen/args.gotpl index 7b1c934d67a..254ee6fcf43 100644 --- a/codegen/_args.gotpl +++ b/codegen/args.gotpl @@ -1,3 +1,5 @@ +{{ range $name, $args := .Args }} +func (e *executableSchema){{ $name }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} {{- range $i, $arg := . }} var arg{{$i}} {{$arg.GoType | ref }} @@ -44,3 +46,5 @@ args[{{$arg.GQLName|quote}}] = arg{{$i}} {{- end }} return args, nil +} +{{ end }} diff --git a/codegen/build_directive.go b/codegen/build_directive.go index 9790bddfa38..e1e82a4abd9 100644 --- a/codegen/build_directive.go +++ b/codegen/build_directive.go @@ -20,10 +20,10 @@ func (b *builder) buildDirectives() (map[string]*Directive, error) { continue } - var args []FieldArgument + var args []*FieldArgument for _, arg := range dir.Arguments { - newArg := FieldArgument{ + newArg := &FieldArgument{ GQLName: arg.Name, TypeReference: b.NamedTypes.getType(arg.Type), GoVarName: templates.ToGoPrivate(arg.Name), @@ -68,13 +68,13 @@ func (b *builder) getDirectives(list ast.DirectiveList) ([]*Directive, error) { return nil, fmt.Errorf("directive %s not found", d.Name) } - var args []FieldArgument + var args []*FieldArgument for _, a := range def.Args { value := a.Default if argValue, ok := argValues[a.GQLName]; ok { value = argValue } - args = append(args, FieldArgument{ + args = append(args, &FieldArgument{ GQLName: a.GQLName, Value: value, GoVarName: a.GoVarName, diff --git a/codegen/directive.go b/codegen/directive.go index f9f000bafba..6744daf3dcd 100644 --- a/codegen/directive.go +++ b/codegen/directive.go @@ -10,7 +10,7 @@ import ( type Directive struct { Name string - Args []FieldArgument + Args []*FieldArgument } func (d *Directive) ArgsFunc() string { diff --git a/codegen/generated.gotpl b/codegen/generated.gotpl index cbc6f307060..1dbc82b54c5 100644 --- a/codegen/generated.gotpl +++ b/codegen/generated.gotpl @@ -65,24 +65,6 @@ type ComplexityRoot struct { {{- end }} {{- end }} -{{ range $object := .Objects -}} - {{ range $field := $object.Fields -}} - {{ if $field.Args }} - func (e *executableSchema){{ $field.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - {{ template "_args.gotpl" $field.Args }} - } - {{ end }} - {{ end }} -{{- end }} - -{{ range $directive := .Directives }} - {{ if $directive.Args }} - func (e *executableSchema){{ $directive.ArgsFunc }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - {{ template "_args.gotpl" $directive.Args }} - } - {{ end }} -{{ end }} - type executableSchema struct { resolvers ResolverRoot directives DirectiveRoot diff --git a/example/todo/generated.go b/example/todo/generated.go index e298e5f4c02..aecaf0be2af 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -15,6 +15,123 @@ import ( "github.com/vektah/gqlparser/ast" ) +// region ***************************** args.gotpl ***************************** + +func (e *executableSchema) dir_hasRole_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 Role + if tmp, ok := rawArgs["role"]; ok { + var err error + err = (&arg0).UnmarshalGQL(tmp) + if err != nil { + return nil, err + } + } + args["role"] = arg0 + return args, nil +} + +func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 TodoInput + if tmp, ok := rawArgs["todo"]; ok { + var err error + arg0, err = UnmarshalTodoInput(tmp) + if err != nil { + return nil, err + } + + mTodoInput1, err := e.TodoInputMiddleware(ctx, &arg0) + if err != nil { + return nil, err + } + arg0 = *mTodoInput1 + } + args["todo"] = arg0 + return args, nil +} + +func (e *executableSchema) field_MyMutation_updateTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 int + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = graphql.UnmarshalInt(tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + var arg1 map[string]interface{} + if tmp, ok := rawArgs["changes"]; ok { + var err error + arg1 = tmp.(map[string]interface{}) + if err != nil { + return nil, err + } + } + args["changes"] = arg1 + return args, nil +} + +func (e *executableSchema) field_MyQuery___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg0 + return args, nil +} + +func (e *executableSchema) field_MyQuery_todo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 int + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = graphql.UnmarshalInt(tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + return args, nil +} + +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil +} + +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil +} + +// endregion ***************************** args.gotpl ***************************** + // region **************************** field.gotpl ***************************** // nolint: vetshadow @@ -1604,126 +1721,6 @@ type MyQueryResolver interface { Todos(ctx context.Context) ([]Todo, error) } -func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 TodoInput - if tmp, ok := rawArgs["todo"]; ok { - var err error - arg0, err = UnmarshalTodoInput(tmp) - if err != nil { - return nil, err - } - - mTodoInput1, err := e.TodoInputMiddleware(ctx, &arg0) - if err != nil { - return nil, err - } - arg0 = *mTodoInput1 - } - args["todo"] = arg0 - return args, nil - -} - -func (e *executableSchema) field_MyMutation_updateTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 int - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalInt(tmp) - if err != nil { - return nil, err - } - } - args["id"] = arg0 - var arg1 map[string]interface{} - if tmp, ok := rawArgs["changes"]; ok { - var err error - arg1 = tmp.(map[string]interface{}) - if err != nil { - return nil, err - } - } - args["changes"] = arg1 - return args, nil - -} - -func (e *executableSchema) field_MyQuery_todo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 int - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalInt(tmp) - if err != nil { - return nil, err - } - } - args["id"] = arg0 - return args, nil - -} - -func (e *executableSchema) field_MyQuery___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - } - args["name"] = arg0 - return args, nil - -} - -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil - -} - -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil - -} - -func (e *executableSchema) dir_hasRole_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 Role - if tmp, ok := rawArgs["role"]; ok { - var err error - err = (&arg0).UnmarshalGQL(tmp) - if err != nil { - return nil, err - } - } - args["role"] = arg0 - return args, nil - -} - type executableSchema struct { resolvers ResolverRoot directives DirectiveRoot From 97764aec135905c4be05ad769b4f680a982b70ba Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Mon, 4 Feb 2019 12:05:26 +1100 Subject: [PATCH 052/147] move generated gotpl to top --- codegen/{generated.gotpl => generated!.gotpl} | 0 codegen/templates/templates.go | 16 +- codegen/testserver/generated.go | 6750 ++++++++--------- codegen/testserver/models-gen.go | 2 + example/chat/generated.go | 2094 +++-- example/chat/models_gen.go | 2 + example/config/generated.go | 2008 ++--- example/config/models_gen.go | 2 + example/dataloader/addressloader_gen.go | 23 +- example/dataloader/generated.go | 1931 +++-- example/dataloader/itemsliceloader_gen.go | 23 +- example/dataloader/models_gen.go | 2 + example/dataloader/ordersliceloader_gen.go | 23 +- example/scalars/generated.go | 1865 +++-- example/scalars/model/generated.go | 2 + example/selection/generated.go | 961 +-- example/selection/models_gen.go | 2 + example/starwars/generated.go | 4891 ++++++------ example/starwars/models_gen.go | 2 + example/todo/generated.go | 1540 ++-- example/todo/models_gen.go | 2 + example/type-system-extension/generated.go | 2117 +++--- example/type-system-extension/models_gen.go | 2 + integration/generated.go | 1976 +++-- integration/models-go/generated.go | 2 + plugin/modelgen/models.go | 7 +- 26 files changed, 13091 insertions(+), 13154 deletions(-) rename codegen/{generated.gotpl => generated!.gotpl} (100%) diff --git a/codegen/generated.gotpl b/codegen/generated!.gotpl similarity index 100% rename from codegen/generated.gotpl rename to codegen/generated!.gotpl diff --git a/codegen/templates/templates.go b/codegen/templates/templates.go index e6ffdcfda64..50099b60f9e 100644 --- a/codegen/templates/templates.go +++ b/codegen/templates/templates.go @@ -59,9 +59,8 @@ func Render(cfg Options) error { return errors.Wrap(err, cfg.Filename) } - if !strings.HasPrefix(info.Name(), "_") { - roots = append(roots, name) - } + roots = append(roots, name) + return nil }) if err != nil { @@ -69,7 +68,16 @@ func Render(cfg Options) error { } // then execute all the important looking ones in order, adding them to the same file - sort.Slice(roots, func(i, j int) bool { return roots[i] < roots[j] }) + sort.Slice(roots, func(i, j int) bool { + // important files go first + if strings.HasSuffix(roots[i], "!.gotpl") { + return true + } + if strings.HasSuffix(roots[j], "!.gotpl") { + return false + } + return roots[i] < roots[j] + }) var buf bytes.Buffer for _, root := range roots { if cfg.RegionTags { diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 3fed5f6781d..71817f4aec8 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -19,2121 +19,1521 @@ import ( "github.com/vektah/gqlparser/ast" ) -// region **************************** field.gotpl ***************************** +// region ************************** generated!.gotpl ************************** -// nolint: vetshadow -func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.CollectedField, obj *Circle) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Circle", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Radius, nil - }) - if resTmp == nil { - return graphql.Null +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, } - res := resTmp.(float64) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) } -// nolint: vetshadow -func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.CollectedField, obj *Circle) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Circle", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Area(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(float64) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) +type Config struct { + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot } -// nolint: vetshadow -func (ec *executionContext) _EmbeddedPointer_ID(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "EmbeddedPointer", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) +type ResolverRoot interface { + ForcedResolver() ForcedResolverResolver + ModelMethods() ModelMethodsResolver + Query() QueryResolver + Subscription() SubscriptionResolver + User() UserResolver } -// nolint: vetshadow -func (ec *executionContext) _EmbeddedPointer_Title(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "EmbeddedPointer", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Title, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} +type DirectiveRoot struct { + Length func(ctx context.Context, obj interface{}, next graphql.Resolver, min int, max *int, message string) (res interface{}, err error) -// nolint: vetshadow -func (ec *executionContext) _Error_id(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Error", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + Range func(ctx context.Context, obj interface{}, next graphql.Resolver, min *int, max *int, message *string) (res interface{}, err error) } -// nolint: vetshadow -func (ec *executionContext) _Error_errorOnNonRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Error", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ErrorOnNonRequiredField() - }) - if resTmp == nil { - return graphql.Null +type ComplexityRoot struct { + Circle struct { + Radius func(childComplexity int) int + Area func(childComplexity int) int } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} -// nolint: vetshadow -func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Error", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ErrorOnRequiredField() - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null + EmbeddedPointer struct { + Id func(childComplexity int) int + Title func(childComplexity int) int } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} -// nolint: vetshadow -func (ec *executionContext) _Error_nilOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Error", - Field: field, - Args: nil, + Error struct { + Id func(childComplexity int) int + ErrorOnNonRequiredField func(childComplexity int) int + ErrorOnRequiredField func(childComplexity int) int + NilOnRequiredField func(childComplexity int) int } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.NilOnRequiredField(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null + + ForcedResolver struct { + Field func(childComplexity int) int } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null + InnerObject struct { + Id func(childComplexity int) int } - return graphql.MarshalString(*res) -} -// nolint: vetshadow -func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field graphql.CollectedField, obj *ForcedResolver) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "ForcedResolver", - Field: field, - Args: nil, + InvalidIdentifier struct { + Id func(childComplexity int) int } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.ForcedResolver().Field(rctx, obj) - }) - if resTmp == nil { - return graphql.Null + + It struct { + Id func(childComplexity int) int } - res := resTmp.(*Circle) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null + ModelMethods struct { + ResolverField func(childComplexity int) int + NoContext func(childComplexity int) int + WithContext func(childComplexity int) int } - return ec._Circle(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) _InnerObject_id(ctx context.Context, field graphql.CollectedField, obj *InnerObject) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "InnerObject", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null + OuterObject struct { + Inner func(childComplexity int) int } - res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) -} -// nolint: vetshadow -func (ec *executionContext) _InvalidIdentifier_id(ctx context.Context, field graphql.CollectedField, obj *invalid_packagename.InvalidIdentifier) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "InvalidIdentifier", - Field: field, - Args: nil, + Query struct { + InvalidIdentifier func(childComplexity int) int + Collision func(childComplexity int) int + MapInput func(childComplexity int, input *map[string]interface{}) int + Recursive func(childComplexity int, input *RecursiveInputSlice) int + NestedInputs func(childComplexity int, input [][]*OuterInput) int + NestedOutputs func(childComplexity int) int + Keywords func(childComplexity int, input *Keywords) int + Shapes func(childComplexity int) int + ErrorBubble func(childComplexity int) int + ModelMethods func(childComplexity int) int + Valid func(childComplexity int) int + User func(childComplexity int, id int) int + NullableArg func(childComplexity int, arg *int) int + DirectiveArg func(childComplexity int, arg string) int + DirectiveNullableArg func(childComplexity int, arg *int, arg2 *int) int + DirectiveInputNullable func(childComplexity int, arg *InputDirectives) int + DirectiveInput func(childComplexity int, arg InputDirectives) int + KeywordArgs func(childComplexity int, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) int } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null + + Rectangle struct { + Length func(childComplexity int) int + Width func(childComplexity int) int + Area func(childComplexity int) int } - res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) -} -// nolint: vetshadow -func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedField, obj *introspection.It) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "It", - Field: field, - Args: nil, + Subscription struct { + Updated func(childComplexity int) int + InitPayload func(childComplexity int) int } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null + + User struct { + Id func(childComplexity int) int + Friends func(childComplexity int) int } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) } -// nolint: vetshadow -func (ec *executionContext) _ModelMethods_resolverField(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "ModelMethods", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.ModelMethods().ResolverField(rctx, obj) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) +type ForcedResolverResolver interface { + Field(ctx context.Context, obj *ForcedResolver) (*Circle, error) +} +type ModelMethodsResolver interface { + ResolverField(ctx context.Context, obj *ModelMethods) (bool, error) +} +type QueryResolver interface { + InvalidIdentifier(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) + Collision(ctx context.Context) (*introspection.It, error) + MapInput(ctx context.Context, input *map[string]interface{}) (*bool, error) + Recursive(ctx context.Context, input *RecursiveInputSlice) (*bool, error) + NestedInputs(ctx context.Context, input [][]*OuterInput) (*bool, error) + NestedOutputs(ctx context.Context) ([][]*OuterObject, error) + Keywords(ctx context.Context, input *Keywords) (bool, error) + Shapes(ctx context.Context) ([]Shape, error) + ErrorBubble(ctx context.Context) (*Error, error) + ModelMethods(ctx context.Context) (*ModelMethods, error) + Valid(ctx context.Context) (string, error) + User(ctx context.Context, id int) (User, error) + NullableArg(ctx context.Context, arg *int) (*string, error) + DirectiveArg(ctx context.Context, arg string) (*string, error) + DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int) (*string, error) + DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) + DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) + KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) +} +type SubscriptionResolver interface { + Updated(ctx context.Context) (<-chan string, error) + InitPayload(ctx context.Context) (<-chan string, error) +} +type UserResolver interface { + Friends(ctx context.Context, obj *User) ([]User, error) } -// nolint: vetshadow -func (ec *executionContext) _ModelMethods_noContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "ModelMethods", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.NoContext(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) +type executableSchema struct { + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot } -// nolint: vetshadow -func (ec *executionContext) _ModelMethods_withContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "ModelMethods", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.WithContext(ctx), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) +func (e *executableSchema) Schema() *ast.Schema { + return parsedSchema } -// nolint: vetshadow -func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphql.CollectedField, obj *OuterObject) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "OuterObject", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Inner, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + switch typeName + "." + field { + + case "Circle.radius": + if e.complexity.Circle.Radius == nil { + break } - return graphql.Null - } - res := resTmp.(InnerObject) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec._InnerObject(ctx, field.Selections, &res) -} + return e.complexity.Circle.Radius(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().InvalidIdentifier(rctx) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*invalid_packagename.InvalidIdentifier) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } + case "Circle.area": + if e.complexity.Circle.Area == nil { + break + } - return ec._InvalidIdentifier(ctx, field.Selections, res) -} + return e.complexity.Circle.Area(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) _Query_collision(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Collision(rctx) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.It) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + case "EmbeddedPointer.ID": + if e.complexity.EmbeddedPointer.Id == nil { + break + } - if res == nil { - return graphql.Null - } + return e.complexity.EmbeddedPointer.Id(childComplexity), true - return ec._It(ctx, field.Selections, res) -} + case "EmbeddedPointer.Title": + if e.complexity.EmbeddedPointer.Title == nil { + break + } -// nolint: vetshadow -func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_mapInput_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().MapInput(rctx, args["input"].(*map[string]interface{})) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return e.complexity.EmbeddedPointer.Title(childComplexity), true - if res == nil { - return graphql.Null - } - return graphql.MarshalBoolean(*res) -} + case "Error.id": + if e.complexity.Error.Id == nil { + break + } -// nolint: vetshadow -func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_recursive_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Recursive(rctx, args["input"].(*RecursiveInputSlice)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return e.complexity.Error.Id(childComplexity), true - if res == nil { - return graphql.Null - } - return graphql.MarshalBoolean(*res) -} + case "Error.errorOnNonRequiredField": + if e.complexity.Error.ErrorOnNonRequiredField == nil { + break + } -// nolint: vetshadow -func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_nestedInputs_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().NestedInputs(rctx, args["input"].([][]*OuterInput)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return e.complexity.Error.ErrorOnNonRequiredField(childComplexity), true - if res == nil { - return graphql.Null - } - return graphql.MarshalBoolean(*res) -} + case "Error.errorOnRequiredField": + if e.complexity.Error.ErrorOnRequiredField == nil { + break + } -// nolint: vetshadow -func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().NestedOutputs(rctx) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([][]*OuterObject) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return e.complexity.Error.ErrorOnRequiredField(childComplexity), true - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + case "Error.nilOnRequiredField": + if e.complexity.Error.NilOnRequiredField == nil { + break + } - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } + return e.complexity.Error.NilOnRequiredField(childComplexity), true - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + case "ForcedResolver.field": + if e.complexity.ForcedResolver.Field == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - arr2 := make(graphql.Array, len(res[idx1])) + return e.complexity.ForcedResolver.Field(childComplexity), true - isLen1 := len(res[idx1]) == 1 - if !isLen1 { - wg.Add(len(res[idx1])) - } + case "InnerObject.id": + if e.complexity.InnerObject.Id == nil { + break + } - for idx2 := range res[idx1] { - idx2 := idx2 - rctx := &graphql.ResolverContext{ - Index: &idx2, - Result: res[idx1][idx2], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx2 int) { - if !isLen1 { - defer wg.Done() - } - arr2[idx2] = func() graphql.Marshaler { + return e.complexity.InnerObject.Id(childComplexity), true - if res[idx1][idx2] == nil { - return graphql.Null - } + case "InvalidIdentifier.id": + if e.complexity.InvalidIdentifier.Id == nil { + break + } - return ec._OuterObject(ctx, field.Selections, res[idx1][idx2]) - }() - } - if isLen1 { - f(idx2) - } else { - go f(idx2) - } + return e.complexity.InvalidIdentifier.Id(childComplexity), true - } + case "It.id": + if e.complexity.It.Id == nil { + break + } - return arr2 - }() + return e.complexity.It.Id(childComplexity), true + + case "ModelMethods.resolverField": + if e.complexity.ModelMethods.ResolverField == nil { + break } - if isLen1 { - f(idx1) - } else { - go f(idx1) + + return e.complexity.ModelMethods.ResolverField(childComplexity), true + + case "ModelMethods.noContext": + if e.complexity.ModelMethods.NoContext == nil { + break } - } - wg.Wait() - return arr1 -} + return e.complexity.ModelMethods.NoContext(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) _Query_keywords(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_keywords_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Keywords(rctx, args["input"].(*Keywords)) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + case "ModelMethods.withContext": + if e.complexity.ModelMethods.WithContext == nil { + break } - return graphql.Null - } - res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) -} -// nolint: vetshadow -func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Shapes(rctx) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]Shape) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return e.complexity.ModelMethods.WithContext(childComplexity), true - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + case "OuterObject.inner": + if e.complexity.OuterObject.Inner == nil { + break + } - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } + return e.complexity.OuterObject.Inner(childComplexity), true - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + case "Query.invalidIdentifier": + if e.complexity.Query.InvalidIdentifier == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec._Shape(ctx, field.Selections, &res[idx1]) - }() + return e.complexity.Query.InvalidIdentifier(childComplexity), true + + case "Query.collision": + if e.complexity.Query.Collision == nil { + break } - if isLen1 { - f(idx1) - } else { - go f(idx1) + + return e.complexity.Query.Collision(childComplexity), true + + case "Query.mapInput": + if e.complexity.Query.MapInput == nil { + break } - } - wg.Wait() - return arr1 -} + args, err := e.field_Query_mapInput_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } -// nolint: vetshadow -func (ec *executionContext) _Query_errorBubble(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().ErrorBubble(rctx) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*Error) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return e.complexity.Query.MapInput(childComplexity, args["input"].(*map[string]interface{})), true - if res == nil { - return graphql.Null - } + case "Query.recursive": + if e.complexity.Query.Recursive == nil { + break + } - return ec._Error(ctx, field.Selections, res) -} + args, err := e.field_Query_recursive_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } -// nolint: vetshadow -func (ec *executionContext) _Query_modelMethods(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().ModelMethods(rctx) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*ModelMethods) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return e.complexity.Query.Recursive(childComplexity, args["input"].(*RecursiveInputSlice)), true - if res == nil { - return graphql.Null - } + case "Query.nestedInputs": + if e.complexity.Query.NestedInputs == nil { + break + } - return ec._ModelMethods(ctx, field.Selections, res) -} + args, err := e.field_Query_nestedInputs_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } -// nolint: vetshadow -func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Valid(rctx) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + return e.complexity.Query.NestedInputs(childComplexity, args["input"].([][]*OuterInput)), true + + case "Query.nestedOutputs": + if e.complexity.Query.NestedOutputs == nil { + break } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} -// nolint: vetshadow -func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_user_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().User(rctx, args["id"].(int)) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + return e.complexity.Query.NestedOutputs(childComplexity), true + + case "Query.keywords": + if e.complexity.Query.Keywords == nil { + break } - return graphql.Null - } - res := resTmp.(User) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec._User(ctx, field.Selections, &res) -} + args, err := e.field_Query_keywords_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } -// nolint: vetshadow -func (ec *executionContext) _Query_nullableArg(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_nullableArg_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().NullableArg(rctx, args["arg"].(*int)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return e.complexity.Query.Keywords(childComplexity, args["input"].(*Keywords)), true + + case "Query.shapes": + if e.complexity.Query.Shapes == nil { + break + } + + return e.complexity.Query.Shapes(childComplexity), true + + case "Query.errorBubble": + if e.complexity.Query.ErrorBubble == nil { + break + } + + return e.complexity.Query.ErrorBubble(childComplexity), true + + case "Query.modelMethods": + if e.complexity.Query.ModelMethods == nil { + break + } + + return e.complexity.Query.ModelMethods(childComplexity), true + + case "Query.valid": + if e.complexity.Query.Valid == nil { + break + } + + return e.complexity.Query.Valid(childComplexity), true + + case "Query.user": + if e.complexity.Query.User == nil { + break + } + + args, err := e.field_Query_user_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.User(childComplexity, args["id"].(int)), true + + case "Query.nullableArg": + if e.complexity.Query.NullableArg == nil { + break + } + + args, err := e.field_Query_nullableArg_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.NullableArg(childComplexity, args["arg"].(*int)), true + + case "Query.directiveArg": + if e.complexity.Query.DirectiveArg == nil { + break + } + + args, err := e.field_Query_directiveArg_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.DirectiveArg(childComplexity, args["arg"].(string)), true + + case "Query.directiveNullableArg": + if e.complexity.Query.DirectiveNullableArg == nil { + break + } + + args, err := e.field_Query_directiveNullableArg_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.DirectiveNullableArg(childComplexity, args["arg"].(*int), args["arg2"].(*int)), true + + case "Query.directiveInputNullable": + if e.complexity.Query.DirectiveInputNullable == nil { + break + } + + args, err := e.field_Query_directiveInputNullable_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.DirectiveInputNullable(childComplexity, args["arg"].(*InputDirectives)), true + + case "Query.directiveInput": + if e.complexity.Query.DirectiveInput == nil { + break + } + + args, err := e.field_Query_directiveInput_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.DirectiveInput(childComplexity, args["arg"].(InputDirectives)), true + + case "Query.keywordArgs": + if e.complexity.Query.KeywordArgs == nil { + break + } + + args, err := e.field_Query_keywordArgs_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.KeywordArgs(childComplexity, 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)), true + + case "Rectangle.length": + if e.complexity.Rectangle.Length == nil { + break + } + + return e.complexity.Rectangle.Length(childComplexity), true + + case "Rectangle.width": + if e.complexity.Rectangle.Width == nil { + break + } + + return e.complexity.Rectangle.Width(childComplexity), true + + case "Rectangle.area": + if e.complexity.Rectangle.Area == nil { + break + } + + return e.complexity.Rectangle.Area(childComplexity), true + + case "Subscription.updated": + if e.complexity.Subscription.Updated == nil { + break + } + + return e.complexity.Subscription.Updated(childComplexity), true + + case "Subscription.initPayload": + if e.complexity.Subscription.InitPayload == nil { + break + } + + return e.complexity.Subscription.InitPayload(childComplexity), true + + case "User.id": + if e.complexity.User.Id == nil { + break + } + + return e.complexity.User.Id(childComplexity), true + + case "User.friends": + if e.complexity.User.Friends == nil { + break + } + + return e.complexity.User.Friends(childComplexity), true - if res == nil { - return graphql.Null } - return graphql.MarshalString(*res) + return 0, false } -// nolint: vetshadow -func (ec *executionContext) _Query_directiveArg(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_directiveArg_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().DirectiveArg(rctx, args["arg"].(string)) +func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._Query(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() }) - if resTmp == nil { - return graphql.Null + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions} +} + +func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + return graphql.ErrorResponse(ctx, "mutations are not supported") +} + +func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + next := ec._Subscription(ctx, op.SelectionSet) + if ec.Errors != nil { + return graphql.OneShot(&graphql.Response{Data: []byte("null"), Errors: ec.Errors}) } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null + var buf bytes.Buffer + return func() *graphql.Response { + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + buf.Reset() + data := next() + + if data == nil { + return nil + } + data.MarshalGQL(&buf) + return buf.Bytes() + }) + + if buf == nil { + return nil + } + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions, + } } - return graphql.MarshalString(*res) } -// nolint: vetshadow -func (ec *executionContext) _Query_directiveNullableArg(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, +type executionContext struct { + *graphql.RequestContext + *executableSchema +} + +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + rctx := graphql.GetResolverContext(ctx) + for _, d := range rctx.Field.Definition.Directives { + switch d.Name { + case "length": + if ec.directives.Length != nil { + rawArgs := d.ArgumentMap(ec.Variables) + args, err := ec.dir_length_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return nil + } + n := next + next = func(ctx context.Context) (interface{}, error) { + return ec.directives.Length(ctx, obj, n, args["min"].(int), args["max"].(*int), args["message"].(string)) + } + } + case "range": + if ec.directives.Range != nil { + rawArgs := d.ArgumentMap(ec.Variables) + args, err := ec.dir_range_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return nil + } + n := next + next = func(ctx context.Context) (interface{}, error) { + return ec.directives.Range(ctx, obj, n, args["min"].(*int), args["max"].(*int), args["message"].(*string)) + } + } + } } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_directiveNullableArg_args(ctx, rawArgs) + res, err := ec.ResolverMiddleware(ctx, next) if err != nil { ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().DirectiveNullableArg(rctx, args["arg"].(*int), args["arg2"].(*int)) - }) - if resTmp == nil { - return graphql.Null + return nil } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return res +} - if res == nil { - return graphql.Null +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") } - return graphql.MarshalString(*res) + return introspection.WrapSchema(parsedSchema), nil } -// nolint: vetshadow -func (ec *executionContext) _Query_directiveInputNullable(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_directiveInputNullable_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().DirectiveInputNullable(rctx, args["arg"].(*InputDirectives)) - }) - if resTmp == nil { - return graphql.Null +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil +} - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) +var parsedSchema = gqlparser.MustLoadSchema( + &ast.Source{Name: "schema.graphql", Input: `type Query { + invalidIdentifier: InvalidIdentifier + collision: It + mapInput(input: Changes): Boolean + recursive(input: RecursiveInputSlice): Boolean + nestedInputs(input: [[OuterInput]] = [[{inner: {id: 1}}]]): Boolean + nestedOutputs: [[OuterObject]] + keywords(input: Keywords): Boolean! + shapes: [Shape] + errorBubble: Error + modelMethods: ModelMethods + valid: String! + user(id: Int!): User! + nullableArg(arg: Int = 123): String + directiveArg(arg: String! @length(min:1, max: 255, message: "invalid length")): String + directiveNullableArg(arg: Int @range(min:0), arg2: Int @range): String + directiveInputNullable(arg: InputDirectives): String + directiveInput(arg: InputDirectives!): String } -// nolint: vetshadow -func (ec *executionContext) _Query_directiveInput(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_directiveInput_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().DirectiveInput(rctx, args["arg"].(InputDirectives)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +type Subscription { + updated: String! + initPayload: String! +} - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) +type User { + id: Int! + friends: [User!]! } -// nolint: vetshadow -func (ec *executionContext) _Query_keywordArgs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_keywordArgs_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().KeywordArgs(rctx, args["break"].(string), args["default"].(string), args["func"].(string), args["interface"].(string), args["select"].(string), args["case"].(string), args["defer"].(string), args["go"].(string), args["map"].(string), args["struct"].(string), args["chan"].(string), args["else"].(string), args["goto"].(string), args["package"].(string), args["switch"].(string), args["const"].(string), args["fallthrough"].(string), args["if"].(string), args["range"].(string), args["type"].(string), args["continue"].(string), args["for"].(string), args["import"].(string), args["return"].(string), args["var"].(string)) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) +type Error { + id: ID! + errorOnNonRequiredField: String + errorOnRequiredField: String! + nilOnRequiredField: String! } -// nolint: vetshadow -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query___type_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectType(args["name"].(string)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection1.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +type ModelMethods { + resolverField: Boolean! + noContext: Boolean! + withContext: Boolean! +} - if res == nil { - return graphql.Null - } +type InvalidIdentifier { + id: Int! +} - return ec.___Type(ctx, field.Selections, res) +type It { + id: ID! } -// nolint: vetshadow -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection1.Schema) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +input Changes { + a: Int + b: Int +} - if res == nil { - return graphql.Null - } +input RecursiveInputSlice { + self: [RecursiveInputSlice!] +} + +input InnerInput { + id:Int! +} + +input OuterInput { + inner: InnerInput! +} + +input InputDirectives { + text: String! @length(min: 0, max: 7, message: "not valid") + inner: InnerDirectives! + innerNullable: InnerDirectives +} + +input InnerDirectives { + message: String! @length(min: 1, message: "not valid") +} + +type OuterObject { + inner: InnerObject! +} - return ec.___Schema(ctx, field.Selections, res) +type InnerObject { + id: Int! } -// nolint: vetshadow -func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Rectangle", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Length, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(float64) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) +input Keywords { + break: String! + default: String! + func: String! + interface: String! + select: String! + case: String! + defer: String! + go: String! + map: String! + struct: String! + chan: String! + else: String! + goto: String! + package: String! + switch: String! + const: String! + fallthrough: String! + if: String! + range: String! + type: String! + continue: String! + for: String! + import: String! + return: String! + var: String! } -// nolint: vetshadow -func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Rectangle", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Width, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(float64) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) +extend type Query { + keywordArgs( + break: String!, + default: String!, + func: String!, + interface: String!, + select: String!, + case: String!, + defer: String!, + go: String!, + map: String!, + struct: String!, + chan: String!, + else: String!, + goto: String!, + package: String!, + switch: String!, + const: String!, + fallthrough: String!, + if: String!, + range: String!, + type: String!, + continue: String!, + for: String!, + import: String!, + return: String!, + var: String!, + ): Boolean! } -// nolint: vetshadow -func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Rectangle", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Area(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(float64) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) +interface Shape { + area: Float +} +type Circle implements Shape { + radius: Float + area: Float +} +type Rectangle implements Shape { + length: Float + width: Float + area: Float } +union ShapeUnion = Circle | Rectangle -func (ec *executionContext) _Subscription_updated(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Field: field, - Args: nil, - }) - // FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259 - // and Tracer stack - rctx := ctx - results, err := ec.resolvers.Subscription().Updated(rctx) - if err != nil { - ec.Error(ctx, err) - return nil - } - return func() graphql.Marshaler { - res, ok := <-results - if !ok { - return nil - } - return graphql.WriterFunc(func(w io.Writer) { - w.Write([]byte{'{'}) - graphql.MarshalString(field.Alias).MarshalGQL(w) - w.Write([]byte{':'}) - func() graphql.Marshaler { - return graphql.MarshalString(res) - }().MarshalGQL(w) - w.Write([]byte{'}'}) - }) - } +type ForcedResolver { + field: Circle } -func (ec *executionContext) _Subscription_initPayload(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Field: field, - Args: nil, - }) - // FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259 - // and Tracer stack - rctx := ctx - results, err := ec.resolvers.Subscription().InitPayload(rctx) - if err != nil { - ec.Error(ctx, err) - return nil - } - return func() graphql.Marshaler { - res, ok := <-results - if !ok { - return nil - } - return graphql.WriterFunc(func(w io.Writer) { - w.Write([]byte{'{'}) - graphql.MarshalString(field.Alias).MarshalGQL(w) - w.Write([]byte{':'}) - func() graphql.Marshaler { - return graphql.MarshalString(res) - }().MarshalGQL(w) - w.Write([]byte{'}'}) - }) - } +type EmbeddedPointer { + ID: String + Title: String } -// nolint: vetshadow -func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) +directive @length(min: Int!, max: Int, message: String!) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION +directive @range(min: Int = 0, max: Int, message: String) on ARGUMENT_DEFINITION + +enum Status { + OK + ERROR } +`}, +) -// nolint: vetshadow -func (ec *executionContext) _User_friends(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.User().Friends(rctx, obj) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +// ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + + } + return handleFunc[0](ctx, chainHandler) } - return graphql.Null } - res := resTmp.([]User) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + if n == 1 { + return handleFunc[0] + } - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) } +} - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { +// endregion ************************** generated!.gotpl ************************** - return ec._User(ctx, field.Selections, &res[idx1]) - }() +// region ***************************** args.gotpl ***************************** + +func (e *executableSchema) dir_length_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 int + if tmp, ok := rawArgs["min"]; ok { + var err error + arg0, err = graphql.UnmarshalInt(tmp) + if err != nil { + return nil, err } - if isLen1 { - f(idx1) - } else { - go f(idx1) + } + args["min"] = arg0 + var arg1 *int + if tmp, ok := rawArgs["max"]; ok { + var err error + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + arg1 = &ptr1 } + if err != nil { + return nil, err + } } - wg.Wait() - return arr1 + args["max"] = arg1 + var arg2 string + if tmp, ok := rawArgs["message"]; ok { + var err error + arg2, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["message"] = arg2 + return args, nil } -// nolint: vetshadow -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection1.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +func (e *executableSchema) dir_range_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *int + if tmp, ok := rawArgs["min"]; ok { + var err error + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + arg0 = &ptr1 + } + + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} + args["min"] = arg0 + var arg1 *int + if tmp, ok := rawArgs["max"]; ok { + var err error + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + arg1 = &ptr1 + } -// nolint: vetshadow -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection1.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + if err != nil { + return nil, err + } } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { - return graphql.Null + args["max"] = arg1 + var arg2 *string + if tmp, ok := rawArgs["message"]; ok { + var err error + var ptr1 string + if tmp != nil { + ptr1, err = graphql.UnmarshalString(tmp) + arg2 = &ptr1 + } + + if err != nil { + return nil, err + } } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + args["message"] = arg2 + return args, nil } -// nolint: vetshadow -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection1.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Locations, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) + args["name"] = arg0 + return args, nil +} - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() +func (e *executableSchema) field_Query_directiveArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["arg"]; ok { + argm0, err := chainFieldMiddleware([]graphql.FieldMiddleware{ + func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { + max := 255 + return e.directives.Length(ctx, tmp, n, 1, &max, "invalid length") + }, + }...)(ctx, func(ctx2 context.Context) (interface{}, error) { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + return arg0, nil + }) + if err != nil { + return nil, err + } + if data, ok := argm0.(string); ok { + arg0 = data + } else { + return nil, errors.New("expect string") + } } - - return arr1 + args["arg"] = arg0 + return args, nil } -// nolint: vetshadow -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection1.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Args, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +func (e *executableSchema) field_Query_directiveInputNullable_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *InputDirectives + if tmp, ok := rawArgs["arg"]; ok { + var err error + var ptr1 InputDirectives + if tmp != nil { + ptr1, err = UnmarshalInputDirectives(tmp) + arg0 = &ptr1 } - return graphql.Null - } - res := resTmp.([]introspection1.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + if err != nil { + return nil, err + } - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) + if arg0 != nil { + var err error + arg0, err = e.InputDirectivesMiddleware(ctx, arg0) + if err != nil { + return nil, err + } + } } + args["arg"] = arg0 + return args, nil +} - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], +func (e *executableSchema) field_Query_directiveInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 InputDirectives + if tmp, ok := rawArgs["arg"]; ok { + var err error + arg0, err = UnmarshalInputDirectives(tmp) + if err != nil { + return nil, err } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() + + mInputDirectives1, err := e.InputDirectivesMiddleware(ctx, &arg0) + if err != nil { + return nil, err + } + arg0 = *mInputDirectives1 + } + args["arg"] = arg0 + return args, nil +} + +func (e *executableSchema) field_Query_directiveNullableArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *int + if tmp, ok := rawArgs["arg"]; ok { + argm0, err := chainFieldMiddleware([]graphql.FieldMiddleware{ + func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { + min := 0 + return e.directives.Range(ctx, tmp, n, &min, nil, nil) + }, + }...)(ctx, func(ctx2 context.Context) (interface{}, error) { + var err error + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + arg0 = &ptr1 } - arr1[idx1] = func() graphql.Marshaler { - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() + if err != nil { + return nil, err + } + return arg0, nil + }) + if err != nil { + return nil, err } - if isLen1 { - f(idx1) + if data, ok := argm0.(*int); ok { + arg0 = data } else { - go f(idx1) + return nil, errors.New("expect *int") } + } + args["arg"] = arg0 + var arg1 *int + if tmp, ok := rawArgs["arg2"]; ok { + argm1, err := chainFieldMiddleware([]graphql.FieldMiddleware{ + func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { + min := 0 + return e.directives.Range(ctx, tmp, n, &min, nil, nil) + }, + }...)(ctx, func(ctx2 context.Context) (interface{}, error) { + var err error + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + arg1 = &ptr1 + } + if err != nil { + return nil, err + } + return arg1, nil + }) + if err != nil { + return nil, err + } + if data, ok := argm1.(*int); ok { + arg1 = data + } else { + return nil, errors.New("expect *int") + } } - wg.Wait() - return arr1 + args["arg2"] = arg1 + return args, nil } -// nolint: vetshadow -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection1.EnumValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, +func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["break"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + args["break"] = arg0 + var arg1 string + if tmp, ok := rawArgs["default"]; ok { + var err error + arg1, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection1.EnumValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + args["default"] = arg1 + var arg2 string + if tmp, ok := rawArgs["func"]; ok { + var err error + arg2, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { - return graphql.Null + args["func"] = arg2 + var arg3 string + if tmp, ok := rawArgs["interface"]; ok { + var err error + arg3, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection1.EnumValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + args["interface"] = arg3 + var arg4 string + if tmp, ok := rawArgs["select"]; ok { + var err error + arg4, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + args["select"] = arg4 + var arg5 string + if tmp, ok := rawArgs["case"]; ok { + var err error + arg5, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["case"] = arg5 + var arg6 string + if tmp, ok := rawArgs["defer"]; ok { + var err error + arg6, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["defer"] = arg6 + var arg7 string + if tmp, ok := rawArgs["go"]; ok { + var err error + arg7, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["go"] = arg7 + var arg8 string + if tmp, ok := rawArgs["map"]; ok { + var err error + arg8, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } - return graphql.Null - } - res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection1.EnumValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil - }) - if resTmp == nil { - return graphql.Null + args["map"] = arg8 + var arg9 string + if tmp, ok := rawArgs["struct"]; ok { + var err error + arg9, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null + args["struct"] = arg9 + var arg10 string + if tmp, ok := rawArgs["chan"]; ok { + var err error + arg10, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - return graphql.MarshalString(*res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection1.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + args["chan"] = arg10 + var arg11 string + if tmp, ok := rawArgs["else"]; ok { + var err error + arg11, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + args["else"] = arg11 + var arg12 string + if tmp, ok := rawArgs["goto"]; ok { + var err error + arg12, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection1.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + args["goto"] = arg12 + var arg13 string + if tmp, ok := rawArgs["package"]; ok { + var err error + arg13, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { - return graphql.Null + args["package"] = arg13 + var arg14 string + if tmp, ok := rawArgs["switch"]; ok { + var err error + arg14, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection1.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + args["switch"] = arg14 + var arg15 string + if tmp, ok := rawArgs["const"]; ok { + var err error + arg15, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Args, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + args["const"] = arg15 + var arg16 string + if tmp, ok := rawArgs["fallthrough"]; ok { + var err error + arg16, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.([]introspection1.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) + args["fallthrough"] = arg16 + var arg17 string + if tmp, ok := rawArgs["if"]; ok { + var err error + arg17, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + args["if"] = arg17 + var arg18 string + if tmp, ok := rawArgs["range"]; ok { + var err error + arg18, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() + } + args["range"] = arg18 + var arg19 string + if tmp, ok := rawArgs["type"]; ok { + var err error + arg19, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } - if isLen1 { - f(idx1) - } else { - go f(idx1) + } + args["type"] = arg19 + var arg20 string + if tmp, ok := rawArgs["continue"]; ok { + var err error + arg20, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } - } - wg.Wait() - return arr1 -} - -// nolint: vetshadow -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection1.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + args["continue"] = arg20 + var arg21 string + if tmp, ok := rawArgs["for"]; ok { + var err error + arg21, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Type, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + args["for"] = arg21 + var arg22 string + if tmp, ok := rawArgs["import"]; ok { + var err error + arg22, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(*introspection1.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + args["import"] = arg22 + var arg23 string + if tmp, ok := rawArgs["return"]; ok { + var err error + arg23, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } - return graphql.Null } - - return ec.___Type(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection1.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + args["return"] = arg23 + var arg24 string + if tmp, ok := rawArgs["var"]; ok { + var err error + arg24, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + args["var"] = arg24 + return args, nil } -// nolint: vetshadow -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection1.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +func (e *executableSchema) field_Query_keywords_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *Keywords + if tmp, ok := rawArgs["input"]; ok { + var err error + var ptr1 Keywords + if tmp != nil { + ptr1, err = UnmarshalKeywords(tmp) + arg0 = &ptr1 + } - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) -} + if err != nil { + return nil, err + } -// nolint: vetshadow -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection1.InputValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + if arg0 != nil { + var err error + arg0, err = e.KeywordsMiddleware(ctx, arg0) + if err != nil { + return nil, err + } } - return graphql.Null } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + args["input"] = arg0 + return args, nil } -// nolint: vetshadow -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection1.InputValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} +func (e *executableSchema) field_Query_mapInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *map[string]interface{} + if tmp, ok := rawArgs["input"]; ok { + var err error + var ptr1 map[string]interface{} + if tmp != nil { + ptr1 = tmp.(map[string]interface{}) + arg0 = &ptr1 + } -// nolint: vetshadow -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection1.InputValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Type, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + if err != nil { + return nil, err } - return graphql.Null - } - res := resTmp.(*introspection1.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + if arg0 != nil { + var err error + arg0, err = e.ChangesMiddleware(ctx, arg0) + if err != nil { + return nil, err + } } - return graphql.Null } - - return ec.___Type(ctx, field.Selections, res) + args["input"] = arg0 + return args, nil } -// nolint: vetshadow -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection1.InputValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) -} +func (e *executableSchema) field_Query_nestedInputs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 [][]*OuterInput + if tmp, ok := rawArgs["input"]; ok { + var err error + var rawIf1 []interface{} + if tmp != nil { + if tmp1, ok := tmp.([]interface{}); ok { + rawIf1 = tmp1 + } else { + rawIf1 = []interface{}{tmp} + } + } + arg0 = make([][]*OuterInput, len(rawIf1)) + for idx1 := range rawIf1 { + var rawIf2 []interface{} + if rawIf1[idx1] != nil { + if tmp1, ok := rawIf1[idx1].([]interface{}); ok { + rawIf2 = tmp1 + } else { + rawIf2 = []interface{}{rawIf1[idx1]} + } + } + arg0[idx1] = make([]*OuterInput, len(rawIf2)) + for idx2 := range rawIf2 { + var ptr3 OuterInput + if rawIf2[idx2] != nil { + ptr3, err = UnmarshalOuterInput(rawIf2[idx2]) + arg0[idx1][idx2] = &ptr3 + } + } + } + if err != nil { + return nil, err + } + for idx1 := range arg0 { + for idx2 := range arg0[idx1] { -// nolint: vetshadow -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection1.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Types(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + if arg0[idx1][idx2] != nil { + var err error + arg0[idx1][idx2], err = e.OuterInputMiddleware(ctx, arg0[idx1][idx2]) + if err != nil { + return nil, err + } + } + } } - return graphql.Null } - res := resTmp.([]introspection1.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + args["input"] = arg0 + return args, nil +} - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup +func (e *executableSchema) field_Query_nullableArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *int + if tmp, ok := rawArgs["arg"]; ok { + var err error + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + arg0 = &ptr1 + } - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) + if err != nil { + return nil, err + } } + args["arg"] = arg0 + return args, nil +} - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], +func (e *executableSchema) field_Query_recursive_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *RecursiveInputSlice + if tmp, ok := rawArgs["input"]; ok { + var err error + var ptr1 RecursiveInputSlice + if tmp != nil { + ptr1, err = UnmarshalRecursiveInputSlice(tmp) + arg0 = &ptr1 } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) + if err != nil { + return nil, err } + if arg0 != nil { + var err error + arg0, err = e.RecursiveInputSliceMiddleware(ctx, arg0) + if err != nil { + return nil, err + } + } } - wg.Wait() - return arr1 + args["input"] = arg0 + return args, nil } -// nolint: vetshadow -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection1.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +func (e *executableSchema) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 int + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = graphql.UnmarshalInt(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(*introspection1.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + args["id"] = arg0 + return args, nil +} - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err } - return graphql.Null } - - return ec.___Type(ctx, field.Selections, res) + args["includeDeprecated"] = arg0 + return args, nil } -// nolint: vetshadow -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection1.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection1.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } } - - return ec.___Type(ctx, field.Selections, res) + args["includeDeprecated"] = arg0 + return args, nil } -// nolint: vetshadow -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection1.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection1.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } +// endregion ***************************** args.gotpl ***************************** - return ec.___Type(ctx, field.Selections, res) -} +// region **************************** field.gotpl ***************************** // nolint: vetshadow -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection1.Schema) graphql.Marshaler { +func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.CollectedField, obj *Circle) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "Circle", Field: field, Args: nil, } @@ -2141,59 +1541,23 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil + return obj.Radius, nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]introspection1.Directive) + res := resTmp.(float64) rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Directive(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalFloat(res) } // nolint: vetshadow -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { +func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.CollectedField, obj *Circle) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "Circle", Field: field, Args: nil, } @@ -2201,26 +1565,23 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil + return obj.Area(), nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return graphql.MarshalFloat(res) } // nolint: vetshadow -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { +func (ec *executionContext) _EmbeddedPointer_ID(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "EmbeddedPointer", Field: field, Args: nil, } @@ -2228,27 +1589,23 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name(), nil + return obj.ID, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { +func (ec *executionContext) _EmbeddedPointer_Title(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "EmbeddedPointer", Field: field, Args: nil, } @@ -2256,7 +1613,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.Title, nil }) if resTmp == nil { return graphql.Null @@ -2268,75 +1625,38 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph } // nolint: vetshadow -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { +func (ec *executionContext) _Error_id(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "Error", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_fields_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Fields(args["includeDeprecated"].(bool)), nil + return obj.ID, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection1.Field) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Field(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return graphql.MarshalID(res) } // nolint: vetshadow -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { +func (ec *executionContext) _Error_errorOnNonRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "Error", Field: field, Args: nil, } @@ -2344,56 +1664,50 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil + return obj.ErrorOnNonRequiredField() }) if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection1.Type) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) +// nolint: vetshadow +func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Error", + Field: field, + Args: nil, } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ErrorOnRequiredField() + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } - + return graphql.Null } - wg.Wait() - return arr1 + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { +func (ec *executionContext) _Error_nilOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "Error", Field: field, Args: nil, } @@ -2401,120 +1715,89 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil + return obj.NilOnRequiredField(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection1.Type) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } - + return graphql.Null } - wg.Wait() - return arr1 + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { +func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field graphql.CollectedField, obj *ForcedResolver) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "ForcedResolver", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_enumValues_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.EnumValues(args["includeDeprecated"].(bool)), nil + return ec.resolvers.ForcedResolver().Field(rctx, obj) }) if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection1.EnumValue) + res := resTmp.(*Circle) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) + if res == nil { + return graphql.Null } - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { + return ec._Circle(ctx, field.Selections, res) +} - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) +// nolint: vetshadow +func (ec *executionContext) _InnerObject_id(ctx context.Context, field graphql.CollectedField, obj *InnerObject) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "InnerObject", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } - + return graphql.Null } - wg.Wait() - return arr1 + res := resTmp.(int) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalInt(res) } // nolint: vetshadow -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { +func (ec *executionContext) _InvalidIdentifier_id(ctx context.Context, field graphql.CollectedField, obj *invalid_packagename.InvalidIdentifier) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "InvalidIdentifier", Field: field, Args: nil, } @@ -2522,56 +1805,26 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil + return obj.ID, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection1.InputValue) + res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return graphql.MarshalInt(res) } // nolint: vetshadow -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { +func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedField, obj *introspection.It) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "It", Field: field, Args: nil, } @@ -2579,1542 +1832,2277 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil + return obj.ID, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection1.Type) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// endregion **************************** field.gotpl ***************************** - -// region ************************** generated.gotpl *************************** - -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } -} - -type Config struct { - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot -} - -type ResolverRoot interface { - ForcedResolver() ForcedResolverResolver - ModelMethods() ModelMethodsResolver - Query() QueryResolver - Subscription() SubscriptionResolver - User() UserResolver -} - -type DirectiveRoot struct { - Length func(ctx context.Context, obj interface{}, next graphql.Resolver, min int, max *int, message string) (res interface{}, err error) - - Range func(ctx context.Context, obj interface{}, next graphql.Resolver, min *int, max *int, message *string) (res interface{}, err error) + return graphql.MarshalID(res) } -type ComplexityRoot struct { - Circle struct { - Radius func(childComplexity int) int - Area func(childComplexity int) int - } - - EmbeddedPointer struct { - Id func(childComplexity int) int - Title func(childComplexity int) int - } - - Error struct { - Id func(childComplexity int) int - ErrorOnNonRequiredField func(childComplexity int) int - ErrorOnRequiredField func(childComplexity int) int - NilOnRequiredField func(childComplexity int) int - } - - ForcedResolver struct { - Field func(childComplexity int) int - } - - InnerObject struct { - Id func(childComplexity int) int - } - - InvalidIdentifier struct { - Id func(childComplexity int) int - } - - It struct { - Id func(childComplexity int) int - } - - ModelMethods struct { - ResolverField func(childComplexity int) int - NoContext func(childComplexity int) int - WithContext func(childComplexity int) int - } - - OuterObject struct { - Inner func(childComplexity int) int - } - - Query struct { - InvalidIdentifier func(childComplexity int) int - Collision func(childComplexity int) int - MapInput func(childComplexity int, input *map[string]interface{}) int - Recursive func(childComplexity int, input *RecursiveInputSlice) int - NestedInputs func(childComplexity int, input [][]*OuterInput) int - NestedOutputs func(childComplexity int) int - Keywords func(childComplexity int, input *Keywords) int - Shapes func(childComplexity int) int - ErrorBubble func(childComplexity int) int - ModelMethods func(childComplexity int) int - Valid func(childComplexity int) int - User func(childComplexity int, id int) int - NullableArg func(childComplexity int, arg *int) int - DirectiveArg func(childComplexity int, arg string) int - DirectiveNullableArg func(childComplexity int, arg *int, arg2 *int) int - DirectiveInputNullable func(childComplexity int, arg *InputDirectives) int - DirectiveInput func(childComplexity int, arg InputDirectives) int - KeywordArgs func(childComplexity int, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) int - } - - Rectangle struct { - Length func(childComplexity int) int - Width func(childComplexity int) int - Area func(childComplexity int) int - } - - Subscription struct { - Updated func(childComplexity int) int - InitPayload func(childComplexity int) int +// nolint: vetshadow +func (ec *executionContext) _ModelMethods_resolverField(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "ModelMethods", + Field: field, + Args: nil, } - - User struct { - Id func(childComplexity int) int - Friends func(childComplexity int) int + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.ModelMethods().ResolverField(rctx, obj) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null } + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) } -type ForcedResolverResolver interface { - Field(ctx context.Context, obj *ForcedResolver) (*Circle, error) -} -type ModelMethodsResolver interface { - ResolverField(ctx context.Context, obj *ModelMethods) (bool, error) -} -type QueryResolver interface { - InvalidIdentifier(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) - Collision(ctx context.Context) (*introspection.It, error) - MapInput(ctx context.Context, input *map[string]interface{}) (*bool, error) - Recursive(ctx context.Context, input *RecursiveInputSlice) (*bool, error) - NestedInputs(ctx context.Context, input [][]*OuterInput) (*bool, error) - NestedOutputs(ctx context.Context) ([][]*OuterObject, error) - Keywords(ctx context.Context, input *Keywords) (bool, error) - Shapes(ctx context.Context) ([]Shape, error) - ErrorBubble(ctx context.Context) (*Error, error) - ModelMethods(ctx context.Context) (*ModelMethods, error) - Valid(ctx context.Context) (string, error) - User(ctx context.Context, id int) (User, error) - NullableArg(ctx context.Context, arg *int) (*string, error) - DirectiveArg(ctx context.Context, arg string) (*string, error) - DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int) (*string, error) - DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) - DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) - KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) -} -type SubscriptionResolver interface { - Updated(ctx context.Context) (<-chan string, error) - InitPayload(ctx context.Context) (<-chan string, error) -} -type UserResolver interface { - Friends(ctx context.Context, obj *User) ([]User, error) -} - -func (e *executableSchema) field_Query_mapInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *map[string]interface{} - if tmp, ok := rawArgs["input"]; ok { - var err error - var ptr1 map[string]interface{} - if tmp != nil { - ptr1 = tmp.(map[string]interface{}) - arg0 = &ptr1 +// nolint: vetshadow +func (ec *executionContext) _ModelMethods_noContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "ModelMethods", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.NoContext(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) +} - if err != nil { - return nil, err +// nolint: vetshadow +func (ec *executionContext) _ModelMethods_withContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "ModelMethods", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.WithContext(ctx), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) +} - if arg0 != nil { - var err error - arg0, err = e.ChangesMiddleware(ctx, arg0) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphql.CollectedField, obj *OuterObject) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "OuterObject", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Inner, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["input"] = arg0 - return args, nil + res := resTmp.(InnerObject) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec._InnerObject(ctx, field.Selections, &res) } -func (e *executableSchema) field_Query_recursive_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *RecursiveInputSlice - if tmp, ok := rawArgs["input"]; ok { - var err error - var ptr1 RecursiveInputSlice - if tmp != nil { - ptr1, err = UnmarshalRecursiveInputSlice(tmp) - arg0 = &ptr1 - } - - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().InvalidIdentifier(rctx) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*invalid_packagename.InvalidIdentifier) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - if arg0 != nil { - var err error - arg0, err = e.RecursiveInputSliceMiddleware(ctx, arg0) - if err != nil { - return nil, err - } - } + if res == nil { + return graphql.Null } - args["input"] = arg0 - return args, nil + return ec._InvalidIdentifier(ctx, field.Selections, res) } -func (e *executableSchema) field_Query_nestedInputs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 [][]*OuterInput - if tmp, ok := rawArgs["input"]; ok { - var err error - var rawIf1 []interface{} - if tmp != nil { - if tmp1, ok := tmp.([]interface{}); ok { - rawIf1 = tmp1 - } else { - rawIf1 = []interface{}{tmp} - } - } - arg0 = make([][]*OuterInput, len(rawIf1)) - for idx1 := range rawIf1 { - var rawIf2 []interface{} - if rawIf1[idx1] != nil { - if tmp1, ok := rawIf1[idx1].([]interface{}); ok { - rawIf2 = tmp1 - } else { - rawIf2 = []interface{}{rawIf1[idx1]} - } - } - arg0[idx1] = make([]*OuterInput, len(rawIf2)) - for idx2 := range rawIf2 { - var ptr3 OuterInput - if rawIf2[idx2] != nil { - ptr3, err = UnmarshalOuterInput(rawIf2[idx2]) - arg0[idx1][idx2] = &ptr3 - } - } - } - if err != nil { - return nil, err - } - for idx1 := range arg0 { - for idx2 := range arg0[idx1] { +// nolint: vetshadow +func (ec *executionContext) _Query_collision(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Collision(rctx) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.It) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - if arg0[idx1][idx2] != nil { - var err error - arg0[idx1][idx2], err = e.OuterInputMiddleware(ctx, arg0[idx1][idx2]) - if err != nil { - return nil, err - } - } - } - } + if res == nil { + return graphql.Null } - args["input"] = arg0 - return args, nil + return ec._It(ctx, field.Selections, res) } -func (e *executableSchema) field_Query_keywords_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *Keywords - if tmp, ok := rawArgs["input"]; ok { - var err error - var ptr1 Keywords - if tmp != nil { - ptr1, err = UnmarshalKeywords(tmp) - arg0 = &ptr1 - } +// nolint: vetshadow +func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_mapInput_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().MapInput(rctx, args["input"].(*map[string]interface{})) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - if err != nil { - return nil, err - } + if res == nil { + return graphql.Null + } + return graphql.MarshalBoolean(*res) +} - if arg0 != nil { - var err error - arg0, err = e.KeywordsMiddleware(ctx, arg0) - if err != nil { - return nil, err - } - } +// nolint: vetshadow +func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["input"] = arg0 - return args, nil - -} - -func (e *executableSchema) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 int - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalInt(tmp) - if err != nil { - return nil, err - } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_recursive_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["id"] = arg0 - return args, nil + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Recursive(rctx, args["input"].(*RecursiveInputSlice)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + if res == nil { + return graphql.Null + } + return graphql.MarshalBoolean(*res) } -func (e *executableSchema) field_Query_nullableArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *int - if tmp, ok := rawArgs["arg"]; ok { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg0 = &ptr1 - } - - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["arg"] = arg0 - return args, nil + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_nestedInputs_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().NestedInputs(rctx, args["input"].([][]*OuterInput)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + if res == nil { + return graphql.Null + } + return graphql.MarshalBoolean(*res) } -func (e *executableSchema) field_Query_directiveArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["arg"]; ok { - argm0, err := chainFieldMiddleware([]graphql.FieldMiddleware{ - func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { - max := 255 - return e.directives.Length(ctx, tmp, n, 1, &max, "invalid length") - }, - }...)(ctx, func(ctx2 context.Context) (interface{}, error) { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - return arg0, nil - }) - if err != nil { - return nil, err - } - if data, ok := argm0.(string); ok { - arg0 = data - } else { - return nil, errors.New("expect string") - } +// nolint: vetshadow +func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["arg"] = arg0 - return args, nil + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().NestedOutputs(rctx) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([][]*OuterObject) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -func (e *executableSchema) field_Query_directiveNullableArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *int - if tmp, ok := rawArgs["arg"]; ok { - argm0, err := chainFieldMiddleware([]graphql.FieldMiddleware{ - func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { - min := 0 - return e.directives.Range(ctx, tmp, n, &min, nil, nil) - }, - }...)(ctx, func(ctx2 context.Context) (interface{}, error) { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg0 = &ptr1 - } + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - if err != nil { - return nil, err - } - return arg0, nil - }) - if err != nil { - return nil, err - } - if data, ok := argm0.(*int); ok { - arg0 = data - } else { - return nil, errors.New("expect *int") + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } - } - args["arg"] = arg0 - var arg1 *int - if tmp, ok := rawArgs["arg2"]; ok { - argm1, err := chainFieldMiddleware([]graphql.FieldMiddleware{ - func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { - min := 0 - return e.directives.Range(ctx, tmp, n, &min, nil, nil) - }, - }...)(ctx, func(ctx2 context.Context) (interface{}, error) { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg1 = &ptr1 + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() } + arr1[idx1] = func() graphql.Marshaler { - if err != nil { - return nil, err - } - return arg1, nil - }) - if err != nil { - return nil, err - } - if data, ok := argm1.(*int); ok { - arg1 = data - } else { - return nil, errors.New("expect *int") - } - } - args["arg2"] = arg1 - return args, nil + arr2 := make(graphql.Array, len(res[idx1])) -} + isLen1 := len(res[idx1]) == 1 + if !isLen1 { + wg.Add(len(res[idx1])) + } -func (e *executableSchema) field_Query_directiveInputNullable_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *InputDirectives - if tmp, ok := rawArgs["arg"]; ok { - var err error - var ptr1 InputDirectives - if tmp != nil { - ptr1, err = UnmarshalInputDirectives(tmp) - arg0 = &ptr1 - } + for idx2 := range res[idx1] { + idx2 := idx2 + rctx := &graphql.ResolverContext{ + Index: &idx2, + Result: res[idx1][idx2], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx2 int) { + if !isLen1 { + defer wg.Done() + } + arr2[idx2] = func() graphql.Marshaler { - if err != nil { - return nil, err - } + if res[idx1][idx2] == nil { + return graphql.Null + } - if arg0 != nil { - var err error - arg0, err = e.InputDirectivesMiddleware(ctx, arg0) - if err != nil { - return nil, err - } - } - } - args["arg"] = arg0 - return args, nil + return ec._OuterObject(ctx, field.Selections, res[idx1][idx2]) + }() + } + if isLen1 { + f(idx2) + } else { + go f(idx2) + } -} + } -func (e *executableSchema) field_Query_directiveInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 InputDirectives - if tmp, ok := rawArgs["arg"]; ok { - var err error - arg0, err = UnmarshalInputDirectives(tmp) - if err != nil { - return nil, err + return arr2 + }() } - - mInputDirectives1, err := e.InputDirectivesMiddleware(ctx, &arg0) - if err != nil { - return nil, err + if isLen1 { + f(idx1) + } else { + go f(idx1) } - arg0 = *mInputDirectives1 - } - args["arg"] = arg0 - return args, nil + } + wg.Wait() + return arr1 } -func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["break"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - } - args["break"] = arg0 - var arg1 string - if tmp, ok := rawArgs["default"]; ok { - var err error - arg1, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - } - args["default"] = arg1 - var arg2 string - if tmp, ok := rawArgs["func"]; ok { - var err error - arg2, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - } - args["func"] = arg2 - var arg3 string - if tmp, ok := rawArgs["interface"]; ok { - var err error - arg3, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - } - args["interface"] = arg3 - var arg4 string - if tmp, ok := rawArgs["select"]; ok { - var err error - arg4, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - } - args["select"] = arg4 - var arg5 string - if tmp, ok := rawArgs["case"]; ok { - var err error - arg5, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - } - args["case"] = arg5 - var arg6 string - if tmp, ok := rawArgs["defer"]; ok { - var err error - arg6, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - } - args["defer"] = arg6 - var arg7 string - if tmp, ok := rawArgs["go"]; ok { - var err error - arg7, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - } - args["go"] = arg7 - var arg8 string - if tmp, ok := rawArgs["map"]; ok { - var err error - arg8, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - } - args["map"] = arg8 - var arg9 string - if tmp, ok := rawArgs["struct"]; ok { - var err error - arg9, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Query_keywords(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["struct"] = arg9 - var arg10 string - if tmp, ok := rawArgs["chan"]; ok { - var err error - arg10, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_keywords_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["chan"] = arg10 - var arg11 string - if tmp, ok := rawArgs["else"]; ok { - var err error - arg11, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Keywords(rctx, args["input"].(*Keywords)) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["else"] = arg11 - var arg12 string - if tmp, ok := rawArgs["goto"]; ok { - var err error - arg12, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) +} + +// nolint: vetshadow +func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["goto"] = arg12 - var arg13 string - if tmp, ok := rawArgs["package"]; ok { - var err error - arg13, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Shapes(rctx) + }) + if resTmp == nil { + return graphql.Null } - args["package"] = arg13 - var arg14 string - if tmp, ok := rawArgs["switch"]; ok { - var err error - arg14, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + res := resTmp.([]Shape) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - args["switch"] = arg14 - var arg15 string - if tmp, ok := rawArgs["const"]; ok { - var err error - arg15, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err + + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } - } - args["const"] = arg15 - var arg16 string - if tmp, ok := rawArgs["fallthrough"]; ok { - var err error - arg16, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec._Shape(ctx, field.Selections, &res[idx1]) + }() } - } - args["fallthrough"] = arg16 - var arg17 string - if tmp, ok := rawArgs["if"]; ok { - var err error - arg17, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err + if isLen1 { + f(idx1) + } else { + go f(idx1) } + } - args["if"] = arg17 - var arg18 string - if tmp, ok := rawArgs["range"]; ok { - var err error - arg18, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + wg.Wait() + return arr1 +} + +// nolint: vetshadow +func (ec *executionContext) _Query_errorBubble(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["range"] = arg18 - var arg19 string - if tmp, ok := rawArgs["type"]; ok { - var err error - arg19, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().ErrorBubble(rctx) + }) + if resTmp == nil { + return graphql.Null } - args["type"] = arg19 - var arg20 string - if tmp, ok := rawArgs["continue"]; ok { - var err error - arg20, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + res := resTmp.(*Error) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { + return graphql.Null } - args["continue"] = arg20 - var arg21 string - if tmp, ok := rawArgs["for"]; ok { - var err error - arg21, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + + return ec._Error(ctx, field.Selections, res) +} + +// nolint: vetshadow +func (ec *executionContext) _Query_modelMethods(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["for"] = arg21 - var arg22 string - if tmp, ok := rawArgs["import"]; ok { - var err error - arg22, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().ModelMethods(rctx) + }) + if resTmp == nil { + return graphql.Null } - args["import"] = arg22 - var arg23 string - if tmp, ok := rawArgs["return"]; ok { - var err error - arg23, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + res := resTmp.(*ModelMethods) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { + return graphql.Null } - args["return"] = arg23 - var arg24 string - if tmp, ok := rawArgs["var"]; ok { - var err error - arg24, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err + + return ec._ModelMethods(ctx, field.Selections, res) +} + +// nolint: vetshadow +func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Valid(rctx) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["var"] = arg24 - return args, nil - + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } -func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err +// nolint: vetshadow +func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_user_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().User(rctx, args["id"].(int)) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["name"] = arg0 - return args, nil + res := resTmp.(User) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec._User(ctx, field.Selections, &res) } -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Query_nullableArg(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["includeDeprecated"] = arg0 - return args, nil + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_nullableArg_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().NullableArg(rctx, args["arg"].(*int)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Query_directiveArg(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_directiveArg_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().DirectiveArg(rctx, args["arg"].(string)) + }) + if resTmp == nil { + return graphql.Null } - args["includeDeprecated"] = arg0 - return args, nil + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } -func (e *executableSchema) dir_length_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 int - if tmp, ok := rawArgs["min"]; ok { - var err error - arg0, err = graphql.UnmarshalInt(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Query_directiveNullableArg(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["min"] = arg0 - var arg1 *int - if tmp, ok := rawArgs["max"]; ok { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg1 = &ptr1 - } - - if err != nil { - return nil, err - } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_directiveNullableArg_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["max"] = arg1 - var arg2 string - if tmp, ok := rawArgs["message"]; ok { - var err error - arg2, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().DirectiveNullableArg(rctx, args["arg"].(*int), args["arg2"].(*int)) + }) + if resTmp == nil { + return graphql.Null } - args["message"] = arg2 - return args, nil + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } -func (e *executableSchema) dir_range_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *int - if tmp, ok := rawArgs["min"]; ok { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg0 = &ptr1 - } - - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Query_directiveInputNullable(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - args["min"] = arg0 - var arg1 *int - if tmp, ok := rawArgs["max"]; ok { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg1 = &ptr1 - } - - if err != nil { - return nil, err - } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_directiveInputNullable_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null } - args["max"] = arg1 - var arg2 *string - if tmp, ok := rawArgs["message"]; ok { - var err error - var ptr1 string - if tmp != nil { - ptr1, err = graphql.UnmarshalString(tmp) - arg2 = &ptr1 - } - - if err != nil { - return nil, err - } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().DirectiveInputNullable(rctx, args["arg"].(*InputDirectives)) + }) + if resTmp == nil { + return graphql.Null } - args["message"] = arg2 - return args, nil + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } -type executableSchema struct { - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot -} +// nolint: vetshadow +func (ec *executionContext) _Query_directiveInput(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_directiveInput_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().DirectiveInput(rctx, args["arg"].(InputDirectives)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -func (e *executableSchema) Schema() *ast.Schema { - return parsedSchema + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - switch typeName + "." + field { - - case "Circle.radius": - if e.complexity.Circle.Radius == nil { - break - } - - return e.complexity.Circle.Radius(childComplexity), true - - case "Circle.area": - if e.complexity.Circle.Area == nil { - break - } - - return e.complexity.Circle.Area(childComplexity), true - - case "EmbeddedPointer.ID": - if e.complexity.EmbeddedPointer.Id == nil { - break - } - - return e.complexity.EmbeddedPointer.Id(childComplexity), true - - case "EmbeddedPointer.Title": - if e.complexity.EmbeddedPointer.Title == nil { - break - } - - return e.complexity.EmbeddedPointer.Title(childComplexity), true - - case "Error.id": - if e.complexity.Error.Id == nil { - break - } - - return e.complexity.Error.Id(childComplexity), true - - case "Error.errorOnNonRequiredField": - if e.complexity.Error.ErrorOnNonRequiredField == nil { - break - } - - return e.complexity.Error.ErrorOnNonRequiredField(childComplexity), true - - case "Error.errorOnRequiredField": - if e.complexity.Error.ErrorOnRequiredField == nil { - break - } - - return e.complexity.Error.ErrorOnRequiredField(childComplexity), true - - case "Error.nilOnRequiredField": - if e.complexity.Error.NilOnRequiredField == nil { - break - } - - return e.complexity.Error.NilOnRequiredField(childComplexity), true - - case "ForcedResolver.field": - if e.complexity.ForcedResolver.Field == nil { - break - } - - return e.complexity.ForcedResolver.Field(childComplexity), true - - case "InnerObject.id": - if e.complexity.InnerObject.Id == nil { - break +// nolint: vetshadow +func (ec *executionContext) _Query_keywordArgs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_keywordArgs_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().KeywordArgs(rctx, args["break"].(string), args["default"].(string), args["func"].(string), args["interface"].(string), args["select"].(string), args["case"].(string), args["defer"].(string), args["go"].(string), args["map"].(string), args["struct"].(string), args["chan"].(string), args["else"].(string), args["goto"].(string), args["package"].(string), args["switch"].(string), args["const"].(string), args["fallthrough"].(string), args["if"].(string), args["range"].(string), args["type"].(string), args["continue"].(string), args["for"].(string), args["import"].(string), args["return"].(string), args["var"].(string)) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) +} - return e.complexity.InnerObject.Id(childComplexity), true +// nolint: vetshadow +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query___type_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(args["name"].(string)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection1.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - case "InvalidIdentifier.id": - if e.complexity.InvalidIdentifier.Id == nil { - break - } + if res == nil { + return graphql.Null + } - return e.complexity.InvalidIdentifier.Id(childComplexity), true + return ec.___Type(ctx, field.Selections, res) +} - case "It.id": - if e.complexity.It.Id == nil { - break - } +// nolint: vetshadow +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection1.Schema) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.It.Id(childComplexity), true + if res == nil { + return graphql.Null + } - case "ModelMethods.resolverField": - if e.complexity.ModelMethods.ResolverField == nil { - break - } + return ec.___Schema(ctx, field.Selections, res) +} - return e.complexity.ModelMethods.ResolverField(childComplexity), true +// nolint: vetshadow +func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Rectangle", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Length, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(float64) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalFloat(res) +} - case "ModelMethods.noContext": - if e.complexity.ModelMethods.NoContext == nil { - break - } +// nolint: vetshadow +func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Rectangle", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Width, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(float64) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalFloat(res) +} - return e.complexity.ModelMethods.NoContext(childComplexity), true +// nolint: vetshadow +func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Rectangle", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Area(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(float64) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalFloat(res) +} - case "ModelMethods.withContext": - if e.complexity.ModelMethods.WithContext == nil { - break +func (ec *executionContext) _Subscription_updated(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Field: field, + Args: nil, + }) + // FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259 + // and Tracer stack + rctx := ctx + results, err := ec.resolvers.Subscription().Updated(rctx) + if err != nil { + ec.Error(ctx, err) + return nil + } + return func() graphql.Marshaler { + res, ok := <-results + if !ok { + return nil } + return graphql.WriterFunc(func(w io.Writer) { + w.Write([]byte{'{'}) + graphql.MarshalString(field.Alias).MarshalGQL(w) + w.Write([]byte{':'}) + func() graphql.Marshaler { + return graphql.MarshalString(res) + }().MarshalGQL(w) + w.Write([]byte{'}'}) + }) + } +} - return e.complexity.ModelMethods.WithContext(childComplexity), true - - case "OuterObject.inner": - if e.complexity.OuterObject.Inner == nil { - break +func (ec *executionContext) _Subscription_initPayload(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Field: field, + Args: nil, + }) + // FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259 + // and Tracer stack + rctx := ctx + results, err := ec.resolvers.Subscription().InitPayload(rctx) + if err != nil { + ec.Error(ctx, err) + return nil + } + return func() graphql.Marshaler { + res, ok := <-results + if !ok { + return nil } + return graphql.WriterFunc(func(w io.Writer) { + w.Write([]byte{'{'}) + graphql.MarshalString(field.Alias).MarshalGQL(w) + w.Write([]byte{':'}) + func() graphql.Marshaler { + return graphql.MarshalString(res) + }().MarshalGQL(w) + w.Write([]byte{'}'}) + }) + } +} - return e.complexity.OuterObject.Inner(childComplexity), true - - case "Query.invalidIdentifier": - if e.complexity.Query.InvalidIdentifier == nil { - break +// nolint: vetshadow +func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "User", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(int) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalInt(res) +} - return e.complexity.Query.InvalidIdentifier(childComplexity), true - - case "Query.collision": - if e.complexity.Query.Collision == nil { - break +// nolint: vetshadow +func (ec *executionContext) _User_friends(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "User", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.User().Friends(rctx, obj) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.([]User) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.Query.Collision(childComplexity), true + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - case "Query.mapInput": - if e.complexity.Query.MapInput == nil { - break - } + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - args, err := e.field_Query_mapInput_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.Query.MapInput(childComplexity, args["input"].(*map[string]interface{})), true - - case "Query.recursive": - if e.complexity.Query.Recursive == nil { - break + return ec._User(ctx, field.Selections, &res[idx1]) + }() } - - args, err := e.field_Query_recursive_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.Query.Recursive(childComplexity, args["input"].(*RecursiveInputSlice)), true + } + wg.Wait() + return arr1 +} - case "Query.nestedInputs": - if e.complexity.Query.NestedInputs == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection1.Directive) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - args, err := e.field_Query_nestedInputs_args(context.TODO(), rawArgs) - if err != nil { - return 0, false +// nolint: vetshadow +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection1.Directive) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} + +// nolint: vetshadow +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection1.Directive) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.([]string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.Query.NestedInputs(childComplexity, args["input"].([][]*OuterInput)), true + arr1 := make(graphql.Array, len(res)) - case "Query.nestedOutputs": - if e.complexity.Query.NestedOutputs == nil { - break - } + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { + return graphql.MarshalString(res[idx1]) + }() + } - return e.complexity.Query.NestedOutputs(childComplexity), true + return arr1 +} - case "Query.keywords": - if e.complexity.Query.Keywords == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection1.Directive) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.([]introspection1.InputValue) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - args, err := e.field_Query_keywords_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - return e.complexity.Query.Keywords(childComplexity, args["input"].(*Keywords)), true + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - case "Query.shapes": - if e.complexity.Query.Shapes == nil { - break + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.Query.Shapes(childComplexity), true - - case "Query.errorBubble": - if e.complexity.Query.ErrorBubble == nil { - break + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.Query.ErrorBubble(childComplexity), true + } + wg.Wait() + return arr1 +} - case "Query.modelMethods": - if e.complexity.Query.ModelMethods == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection1.EnumValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - return e.complexity.Query.ModelMethods(childComplexity), true +// nolint: vetshadow +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection1.EnumValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - case "Query.valid": - if e.complexity.Query.Valid == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection1.EnumValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) +} - return e.complexity.Query.Valid(childComplexity), true +// nolint: vetshadow +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection1.EnumValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - case "Query.user": - if e.complexity.Query.User == nil { - break - } + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) +} - args, err := e.field_Query_user_args(context.TODO(), rawArgs) - if err != nil { - return 0, false +// nolint: vetshadow +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection1.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - return e.complexity.Query.User(childComplexity, args["id"].(int)), true +// nolint: vetshadow +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection1.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - case "Query.nullableArg": - if e.complexity.Query.NullableArg == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection1.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.([]introspection1.InputValue) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - args, err := e.field_Query_nullableArg_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - return e.complexity.Query.NullableArg(childComplexity, args["arg"].(*int)), true + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - case "Query.directiveArg": - if e.complexity.Query.DirectiveArg == nil { - break + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - args, err := e.field_Query_directiveArg_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }() } - - return e.complexity.Query.DirectiveArg(childComplexity, args["arg"].(string)), true - - case "Query.directiveNullableArg": - if e.complexity.Query.DirectiveNullableArg == nil { - break + if isLen1 { + f(idx1) + } else { + go f(idx1) } - args, err := e.field_Query_directiveNullableArg_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } + } + wg.Wait() + return arr1 +} - return e.complexity.Query.DirectiveNullableArg(childComplexity, args["arg"].(*int), args["arg2"].(*int)), true +// nolint: vetshadow +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection1.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*introspection1.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - case "Query.directiveInputNullable": - if e.complexity.Query.DirectiveInputNullable == nil { - break + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } - args, err := e.field_Query_directiveInputNullable_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + return ec.___Type(ctx, field.Selections, res) +} + +// nolint: vetshadow +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection1.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) +} - return e.complexity.Query.DirectiveInputNullable(childComplexity, args["arg"].(*InputDirectives)), true +// nolint: vetshadow +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection1.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - case "Query.directiveInput": - if e.complexity.Query.DirectiveInput == nil { - break - } + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) +} - args, err := e.field_Query_directiveInput_args(context.TODO(), rawArgs) - if err != nil { - return 0, false +// nolint: vetshadow +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection1.InputValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - return e.complexity.Query.DirectiveInput(childComplexity, args["arg"].(InputDirectives)), true +// nolint: vetshadow +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection1.InputValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - case "Query.keywordArgs": - if e.complexity.Query.KeywordArgs == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection1.InputValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(*introspection1.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - args, err := e.field_Query_keywordArgs_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } - return e.complexity.Query.KeywordArgs(childComplexity, 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)), true + return ec.___Type(ctx, field.Selections, res) +} - case "Rectangle.length": - if e.complexity.Rectangle.Length == nil { - break - } +// nolint: vetshadow +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection1.InputValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.Rectangle.Length(childComplexity), true + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) +} - case "Rectangle.width": - if e.complexity.Rectangle.Width == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection1.Schema) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.([]introspection1.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.Rectangle.Width(childComplexity), true - - case "Rectangle.area": - if e.complexity.Rectangle.Area == nil { - break - } + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - return e.complexity.Rectangle.Area(childComplexity), true + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - case "Subscription.updated": - if e.complexity.Subscription.Updated == nil { - break + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.Subscription.Updated(childComplexity), true - - case "Subscription.initPayload": - if e.complexity.Subscription.InitPayload == nil { - break + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.Subscription.InitPayload(childComplexity), true + } + wg.Wait() + return arr1 +} - case "User.id": - if e.complexity.User.Id == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection1.Schema) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(*introspection1.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.User.Id(childComplexity), true - - case "User.friends": - if e.complexity.User.Friends == nil { - break + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } - return e.complexity.User.Friends(childComplexity), true + return ec.___Type(ctx, field.Selections, res) +} +// nolint: vetshadow +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection1.Schema) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Field: field, + Args: nil, } - return 0, false -} + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection1.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} + if res == nil { + return graphql.Null + } - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() + return ec.___Type(ctx, field.Selections, res) +} + +// nolint: vetshadow +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection1.Schema) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection1.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions} -} + if res == nil { + return graphql.Null + } -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - return graphql.ErrorResponse(ctx, "mutations are not supported") + return ec.___Type(ctx, field.Selections, res) } -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - next := ec._Subscription(ctx, op.SelectionSet) - if ec.Errors != nil { - return graphql.OneShot(&graphql.Response{Data: []byte("null"), Errors: ec.Errors}) +// nolint: vetshadow +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection1.Schema) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null } + res := resTmp.([]introspection1.Directive) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - var buf bytes.Buffer - return func() *graphql.Response { - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - buf.Reset() - data := next() + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - if data == nil { - return nil - } - data.MarshalGQL(&buf) - return buf.Bytes() - }) + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - if buf == nil { - return nil + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, + return ec.___Directive(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) } + } + wg.Wait() + return arr1 } -type executionContext struct { - *graphql.RequestContext - *executableSchema +// nolint: vetshadow +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } -func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - rctx := graphql.GetResolverContext(ctx) - for _, d := range rctx.Field.Definition.Directives { - switch d.Name { - case "length": - if ec.directives.Length != nil { - rawArgs := d.ArgumentMap(ec.Variables) - args, err := ec.dir_length_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return nil - } - n := next - next = func(ctx context.Context) (interface{}, error) { - return ec.directives.Length(ctx, obj, n, args["min"].(int), args["max"].(*int), args["message"].(string)) - } - } - case "range": - if ec.directives.Range != nil { - rawArgs := d.ArgumentMap(ec.Variables) - args, err := ec.dir_range_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return nil - } - n := next - next = func(ctx context.Context) (interface{}, error) { - return ec.directives.Range(ctx, obj, n, args["min"].(*int), args["max"].(*int), args["message"].(*string)) - } - } - } +// nolint: vetshadow +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name(), nil + }) + if resTmp == nil { + return graphql.Null } - res, err := ec.ResolverMiddleware(ctx, next) - if err != nil { - ec.Error(ctx, err) - return nil + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { + return graphql.Null } - return res + return graphql.MarshalString(*res) } -func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") +// nolint: vetshadow +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, } - return introspection.WrapSchema(parsedSchema), nil + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } -func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") +// nolint: vetshadow +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil -} + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_fields_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(args["includeDeprecated"].(bool)), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection1.Field) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -var parsedSchema = gqlparser.MustLoadSchema( - &ast.Source{Name: "schema.graphql", Input: `type Query { - invalidIdentifier: InvalidIdentifier - collision: It - mapInput(input: Changes): Boolean - recursive(input: RecursiveInputSlice): Boolean - nestedInputs(input: [[OuterInput]] = [[{inner: {id: 1}}]]): Boolean - nestedOutputs: [[OuterObject]] - keywords(input: Keywords): Boolean! - shapes: [Shape] - errorBubble: Error - modelMethods: ModelMethods - valid: String! - user(id: Int!): User! - nullableArg(arg: Int = 123): String - directiveArg(arg: String! @length(min:1, max: 255, message: "invalid length")): String - directiveNullableArg(arg: Int @range(min:0), arg2: Int @range): String - directiveInputNullable(arg: InputDirectives): String - directiveInput(arg: InputDirectives!): String -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -type Subscription { - updated: String! - initPayload: String! -} + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } -type User { - id: Int! - friends: [User!]! -} + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { -type Error { - id: ID! - errorOnNonRequiredField: String - errorOnRequiredField: String! - nilOnRequiredField: String! -} + return ec.___Field(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } -type ModelMethods { - resolverField: Boolean! - noContext: Boolean! - withContext: Boolean! + } + wg.Wait() + return arr1 } -type InvalidIdentifier { - id: Int! -} +// nolint: vetshadow +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection1.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -type It { - id: ID! -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -input Changes { - a: Int - b: Int -} + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } -input RecursiveInputSlice { - self: [RecursiveInputSlice!] -} + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { -input InnerInput { - id:Int! -} + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } -input OuterInput { - inner: InnerInput! + } + wg.Wait() + return arr1 } -input InputDirectives { - text: String! @length(min: 0, max: 7, message: "not valid") - inner: InnerDirectives! - innerNullable: InnerDirectives -} +// nolint: vetshadow +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection1.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -input InnerDirectives { - message: String! @length(min: 1, message: "not valid") -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -type OuterObject { - inner: InnerObject! -} + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { -type InnerObject { - id: Int! -} + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } -input Keywords { - break: String! - default: String! - func: String! - interface: String! - select: String! - case: String! - defer: String! - go: String! - map: String! - struct: String! - chan: String! - else: String! - goto: String! - package: String! - switch: String! - const: String! - fallthrough: String! - if: String! - range: String! - type: String! - continue: String! - for: String! - import: String! - return: String! - var: String! + } + wg.Wait() + return arr1 } -extend type Query { - keywordArgs( - break: String!, - default: String!, - func: String!, - interface: String!, - select: String!, - case: String!, - defer: String!, - go: String!, - map: String!, - struct: String!, - chan: String!, - else: String!, - goto: String!, - package: String!, - switch: String!, - const: String!, - fallthrough: String!, - if: String!, - range: String!, - type: String!, - continue: String!, - for: String!, - import: String!, - return: String!, - var: String!, - ): Boolean! -} +// nolint: vetshadow +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(args["includeDeprecated"].(bool)), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection1.EnumValue) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -interface Shape { - area: Float -} -type Circle implements Shape { - radius: Float - area: Float -} -type Rectangle implements Shape { - length: Float - width: Float - area: Float -} -union ShapeUnion = Circle | Rectangle + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -type ForcedResolver { - field: Circle -} + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } -type EmbeddedPointer { - ID: String - Title: String -} + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { -directive @length(min: Int!, max: Int, message: String!) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION -directive @range(min: Int = 0, max: Int, message: String) on ARGUMENT_DEFINITION + return ec.___EnumValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } -enum Status { - OK - ERROR + } + wg.Wait() + return arr1 } -`}, -) -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) +// nolint: vetshadow +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection1.InputValue) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() } - return handleFunc[0](ctx, chainHandler) + arr1[idx1] = func() graphql.Marshaler { + + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) } + } + wg.Wait() + return arr1 +} - if n == 1 { - return handleFunc[0] +// nolint: vetshadow +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if resTmp == nil { + return graphql.Null } + res := resTmp.(*introspection1.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) + if res == nil { + return graphql.Null } + + return ec.___Type(ctx, field.Selections, res) } -// endregion ************************** generated.gotpl *************************** +// endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** diff --git a/codegen/testserver/models-gen.go b/codegen/testserver/models-gen.go index c82c28a435d..b358d12a397 100644 --- a/codegen/testserver/models-gen.go +++ b/codegen/testserver/models-gen.go @@ -1,3 +1,5 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + package testserver import ( diff --git a/example/chat/generated.go b/example/chat/generated.go index bbd5ab5cf5e..324f2079748 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -17,382 +17,530 @@ import ( "github.com/vektah/gqlparser/ast" ) -// region **************************** field.gotpl ***************************** +// region ************************** generated!.gotpl ************************** -// nolint: vetshadow -func (ec *executionContext) _Chatroom_name(ctx context.Context, field graphql.CollectedField, obj *Chatroom) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Chatroom", - Field: field, - Args: nil, +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil +} + +type Config struct { + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Mutation() MutationResolver + Query() QueryResolver + Subscription() SubscriptionResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + Chatroom struct { + Name func(childComplexity int) int + Messages func(childComplexity int) int + } + + Message struct { + Id func(childComplexity int) int + Text func(childComplexity int) int + CreatedBy func(childComplexity int) int + CreatedAt func(childComplexity int) int + } + + Mutation struct { + Post func(childComplexity int, text string, username string, roomName string) int + } + + Query struct { + Room func(childComplexity int, name string) int + } + + Subscription struct { + MessageAdded func(childComplexity int, roomName string) int + } +} + +type MutationResolver interface { + Post(ctx context.Context, text string, username string, roomName string) (Message, error) +} +type QueryResolver interface { + Room(ctx context.Context, name string) (*Chatroom, error) +} +type SubscriptionResolver interface { + MessageAdded(ctx context.Context, roomName string) (<-chan Message, error) +} + +type executableSchema struct { + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + switch typeName + "." + field { + + case "Chatroom.name": + if e.complexity.Chatroom.Name == nil { + break + } + + return e.complexity.Chatroom.Name(childComplexity), true + + case "Chatroom.messages": + if e.complexity.Chatroom.Messages == nil { + break + } + + return e.complexity.Chatroom.Messages(childComplexity), true + + case "Message.id": + if e.complexity.Message.Id == nil { + break + } + + return e.complexity.Message.Id(childComplexity), true + + case "Message.text": + if e.complexity.Message.Text == nil { + break + } + + return e.complexity.Message.Text(childComplexity), true + + case "Message.createdBy": + if e.complexity.Message.CreatedBy == nil { + break + } + + return e.complexity.Message.CreatedBy(childComplexity), true + + case "Message.createdAt": + if e.complexity.Message.CreatedAt == nil { + break + } + + return e.complexity.Message.CreatedAt(childComplexity), true + + case "Mutation.post": + if e.complexity.Mutation.Post == nil { + break + } + + args, err := e.field_Mutation_post_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.Post(childComplexity, args["text"].(string), args["username"].(string), args["roomName"].(string)), true + + case "Query.room": + if e.complexity.Query.Room == nil { + break + } + + args, err := e.field_Query_room_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Room(childComplexity, args["name"].(string)), true + + case "Subscription.messageAdded": + if e.complexity.Subscription.MessageAdded == nil { + break + } + + args, err := e.field_Subscription_messageAdded_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Subscription.MessageAdded(childComplexity, args["roomName"].(string)), true + + } + return 0, false +} + +func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._Query(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions} +} + +func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._Mutation(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() + }) + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions, + } +} + +func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + next := ec._Subscription(ctx, op.SelectionSet) + if ec.Errors != nil { + return graphql.OneShot(&graphql.Response{Data: []byte("null"), Errors: ec.Errors}) + } + + var buf bytes.Buffer + return func() *graphql.Response { + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + buf.Reset() + data := next() + + if data == nil { + return nil + } + data.MarshalGQL(&buf) + return buf.Bytes() + }) + + if buf == nil { + return nil + } + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions, } - return graphql.Null } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) } -// nolint: vetshadow -func (ec *executionContext) _Chatroom_messages(ctx context.Context, field graphql.CollectedField, obj *Chatroom) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Chatroom", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Messages, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]Message) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +type executionContext struct { + *graphql.RequestContext + *executableSchema +} + +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + res, err := ec.ResolverMiddleware(ctx, next) + if err != nil { + ec.Error(ctx, err) + return nil + } + return res +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(parsedSchema), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil +} + +var parsedSchema = gqlparser.MustLoadSchema( + &ast.Source{Name: "schema.graphql", Input: `type Chatroom { + name: String! + messages: [Message!]! +} + +type Message { + id: ID! + text: String! + createdBy: String! + createdAt: Time! +} + +type Query { + room(name:String!): Chatroom +} + +type Mutation { + post(text: String!, username: String!, roomName: String!): Message! +} + +type Subscription { + messageAdded(roomName: String!): Message! +} + +scalar Time +`}, +) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup +// ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() } - arr1[idx1] = func() graphql.Marshaler { - - return ec._Message(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) + return handleFunc[0](ctx, chainHandler) } + } + if n == 1 { + return handleFunc[0] + } + + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) } - wg.Wait() - return arr1 } -// nolint: vetshadow -func (ec *executionContext) _Message_id(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Message", - Field: field, - Args: nil, +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (e *executableSchema) field_Mutation_post_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["text"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + args["text"] = arg0 + var arg1 string + if tmp, ok := rawArgs["username"]; ok { + var err error + arg1, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + args["username"] = arg1 + var arg2 string + if tmp, ok := rawArgs["roomName"]; ok { + var err error + arg2, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["roomName"] = arg2 + return args, nil } -// nolint: vetshadow -func (ec *executionContext) _Message_text(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Message", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Text, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + args["name"] = arg0 + return args, nil } -// nolint: vetshadow -func (ec *executionContext) _Message_createdBy(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Message", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.CreatedBy, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +func (e *executableSchema) field_Query_room_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + args["name"] = arg0 + return args, nil } -// nolint: vetshadow -func (ec *executionContext) _Message_createdAt(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Message", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.CreatedAt, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +func (e *executableSchema) field_Subscription_messageAdded_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["roomName"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(time.Time) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalTime(res) + args["roomName"] = arg0 + return args, nil } -// nolint: vetshadow -func (ec *executionContext) _Mutation_post(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Mutation", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_post_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().Post(rctx, args["text"].(string), args["username"].(string), args["roomName"].(string)) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(Message) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._Message(ctx, field.Selections, &res) + args["includeDeprecated"] = arg0 + return args, nil } -// nolint: vetshadow -func (ec *executionContext) _Query_room(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_room_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Room(rctx, args["name"].(string)) - }) - if resTmp == nil { - return graphql.Null +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } } - res := resTmp.(*Chatroom) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + args["includeDeprecated"] = arg0 + return args, nil +} - if res == nil { - return graphql.Null - } +// endregion ***************************** args.gotpl ***************************** - return ec._Chatroom(ctx, field.Selections, res) -} +// region **************************** field.gotpl ***************************** // nolint: vetshadow -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) _Chatroom_name(ctx context.Context, field graphql.CollectedField, obj *Chatroom) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "Chatroom", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query___type_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectType(args["name"].(string)) + return obj.Name, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) _Chatroom_messages(ctx context.Context, field graphql.CollectedField, obj *Chatroom) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", + Object: "Chatroom", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() + return obj.Messages, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Schema) + res := resTmp.([]Message) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - return ec.___Schema(ctx, field.Selections, res) -} + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { -func (ec *executionContext) _Subscription_messageAdded(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { - ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Field: field, - Args: nil, - }) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Subscription_messageAdded_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return nil - } - // FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259 - // and Tracer stack - rctx := ctx - results, err := ec.resolvers.Subscription().MessageAdded(rctx, args["roomName"].(string)) - if err != nil { - ec.Error(ctx, err) - return nil - } - return func() graphql.Marshaler { - res, ok := <-results - if !ok { - return nil + return ec._Message(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return graphql.WriterFunc(func(w io.Writer) { - w.Write([]byte{'{'}) - graphql.MarshalString(field.Alias).MarshalGQL(w) - w.Write([]byte{':'}) - func() graphql.Marshaler { - return ec._Message(ctx, field.Selections, &res) - }().MarshalGQL(w) - w.Write([]byte{'}'}) - }) } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) _Message_id(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "Message", Field: field, Args: nil, } @@ -400,7 +548,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.ID, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -411,15 +559,15 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return graphql.MarshalID(res) } // nolint: vetshadow -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) _Message_text(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "Message", Field: field, Args: nil, } @@ -427,9 +575,12 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.Text, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(string) @@ -439,11 +590,11 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field } // nolint: vetshadow -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) _Message_createdBy(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "Message", Field: field, Args: nil, } @@ -451,7 +602,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Locations, nil + return obj.CreatedBy, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -459,27 +610,18 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr } return graphql.Null } - res := resTmp.([]string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) _Message_createdAt(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "Message", Field: field, Args: nil, } @@ -487,7 +629,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Args, nil + return obj.CreatedAt, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -495,59 +637,33 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.(time.Time) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return graphql.MarshalTime(res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _Mutation_post(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "Mutation", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_post_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return ec.resolvers.Mutation().Post(rctx, args["text"].(string), args["username"].(string), args["roomName"].(string)) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -555,97 +671,157 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(string) + res := resTmp.(Message) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + return ec._Message(ctx, field.Selections, &res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _Query_room(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "Query", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_room_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return ec.resolvers.Query().Room(rctx, args["name"].(string)) }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*Chatroom) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + + return ec._Chatroom(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "Query", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query___type_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return ec.introspectType(args["name"].(string)) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + + if res == nil { + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "Query", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return ec.introspectSchema() }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { return graphql.Null } - return graphql.MarshalString(*res) + + return ec.___Schema(ctx, field.Selections, res) +} + +func (ec *executionContext) _Subscription_messageAdded(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Field: field, + Args: nil, + }) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Subscription_messageAdded_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return nil + } + // FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259 + // and Tracer stack + rctx := ctx + results, err := ec.resolvers.Subscription().MessageAdded(rctx, args["roomName"].(string)) + if err != nil { + ec.Error(ctx, err) + return nil + } + return func() graphql.Marshaler { + res, ok := <-results + if !ok { + return nil + } + return graphql.WriterFunc(func(w io.Writer) { + w.Write([]byte{'{'}) + graphql.MarshalString(field.Alias).MarshalGQL(w) + w.Write([]byte{':'}) + func() graphql.Marshaler { + + return ec._Message(ctx, field.Selections, &res) + }().MarshalGQL(w) + w.Write([]byte{'}'}) + }) + } } // nolint: vetshadow -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Directive", Field: field, Args: nil, } @@ -668,11 +844,11 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Directive", Field: field, Args: nil, } @@ -692,11 +868,47 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap } // nolint: vetshadow -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Directive", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + arr1 := make(graphql.Array, len(res)) + + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { + return graphql.MarshalString(res[idx1]) + }() + } + + return arr1 +} + +// nolint: vetshadow +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Directive", Field: field, Args: nil, } @@ -752,46 +964,11 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Type, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__EnumValue", Field: field, Args: nil, } @@ -799,7 +976,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -807,18 +984,18 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__EnumValue", Field: field, Args: nil, } @@ -826,27 +1003,23 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.Description, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__EnumValue", Field: field, Args: nil, } @@ -854,7 +1027,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.IsDeprecated(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -862,18 +1035,18 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(string) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__EnumValue", Field: field, Args: nil, } @@ -881,23 +1054,27 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.DeprecationReason(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Field", Field: field, Args: nil, } @@ -905,34 +1082,26 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.Name, nil }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } - - return ec.___Type(ctx, field.Selections, res) + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Field", Field: field, Args: nil, } @@ -940,27 +1109,23 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil + return obj.Description, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Field", Field: field, Args: nil, } @@ -968,7 +1133,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Types(), nil + return obj.Args, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -976,7 +1141,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1001,7 +1166,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } arr1[idx1] = func() graphql.Marshaler { - return ec.___Type(ctx, field.Selections, &res[idx1]) + return ec.___InputValue(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1016,11 +1181,11 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } // nolint: vetshadow -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Field", Field: field, Args: nil, } @@ -1028,7 +1193,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil + return obj.Type, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1051,11 +1216,11 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } // nolint: vetshadow -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Field", Field: field, Args: nil, } @@ -1063,28 +1228,26 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil + return obj.IsDeprecated(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Field", Field: field, Args: nil, } @@ -1092,28 +1255,27 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil + return obj.DeprecationReason(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { return graphql.Null } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__InputValue", Field: field, Args: nil, } @@ -1121,7 +1283,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1129,51 +1291,18 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap } return graphql.Null } - res := resTmp.([]introspection.Directive) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Directive(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__InputValue", Field: field, Args: nil, } @@ -1181,12 +1310,9 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil + return obj.Description, nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } res := resTmp.(string) @@ -1196,11 +1322,11 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll } // nolint: vetshadow -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__InputValue", Field: field, Args: nil, } @@ -1208,27 +1334,34 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name(), nil + return obj.Type, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - return graphql.MarshalString(*res) + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__InputValue", Field: field, Args: nil, } @@ -1236,43 +1369,43 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.DefaultValue, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_fields_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Fields(args["includeDeprecated"].(bool)), nil + return obj.Types(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.Field) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1297,7 +1430,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } arr1[idx1] = func() graphql.Marshaler { - return ec.___Field(ctx, field.Selections, &res[idx1]) + return ec.___Type(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1312,11 +1445,11 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } // nolint: vetshadow -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } @@ -1324,56 +1457,34 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil + return obj.QueryType(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } - + return graphql.Null } - wg.Wait() - return arr1 + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } @@ -1381,120 +1492,57 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil + return obj.MutationType(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - + if res == nil { + return graphql.Null } - wg.Wait() - return arr1 + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_enumValues_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.EnumValues(args["includeDeprecated"].(bool)), nil + return obj.SubscriptionType(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.EnumValue) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) + if res == nil { + return graphql.Null } - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } @@ -1502,12 +1550,15 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil + return obj.Directives(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1532,7 +1583,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph } arr1[idx1] = func() graphql.Marshaler { - return ec.___InputValue(ctx, field.Selections, &res[idx1]) + return ec.___Directive(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1547,7 +1598,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph } // nolint: vetshadow -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1559,454 +1610,401 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil + return obj.Kind(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// endregion **************************** field.gotpl ***************************** - -// region ************************** generated.gotpl *************************** - -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } -} - -type Config struct { - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot -} - -type ResolverRoot interface { - Mutation() MutationResolver - Query() QueryResolver - Subscription() SubscriptionResolver -} - -type DirectiveRoot struct { -} - -type ComplexityRoot struct { - Chatroom struct { - Name func(childComplexity int) int - Messages func(childComplexity int) int - } - - Message struct { - Id func(childComplexity int) int - Text func(childComplexity int) int - CreatedBy func(childComplexity int) int - CreatedAt func(childComplexity int) int - } - - Mutation struct { - Post func(childComplexity int, text string, username string, roomName string) int - } - - Query struct { - Room func(childComplexity int, name string) int - } - - Subscription struct { - MessageAdded func(childComplexity int, roomName string) int - } -} - -type MutationResolver interface { - Post(ctx context.Context, text string, username string, roomName string) (Message, error) -} -type QueryResolver interface { - Room(ctx context.Context, name string) (*Chatroom, error) -} -type SubscriptionResolver interface { - MessageAdded(ctx context.Context, roomName string) (<-chan Message, error) -} - -func (e *executableSchema) field_Mutation_post_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["text"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - } - args["text"] = arg0 - var arg1 string - if tmp, ok := rawArgs["username"]; ok { - var err error - arg1, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - } - args["username"] = arg1 - var arg2 string - if tmp, ok := rawArgs["roomName"]; ok { - var err error - arg2, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - } - args["roomName"] = arg2 - return args, nil - -} - -func (e *executableSchema) field_Query_room_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - } - args["name"] = arg0 - return args, nil - -} - -func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - } - args["name"] = arg0 - return args, nil - -} - -func (e *executableSchema) field_Subscription_messageAdded_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["roomName"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - } - args["roomName"] = arg0 - return args, nil - + return graphql.MarshalString(res) } -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, } - args["includeDeprecated"] = arg0 - return args, nil - -} - -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name(), nil + }) + if resTmp == nil { + return graphql.Null } - args["includeDeprecated"] = arg0 - return args, nil - -} + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -type executableSchema struct { - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } -func (e *executableSchema) Schema() *ast.Schema { - return parsedSchema +// nolint: vetshadow +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - switch typeName + "." + field { - - case "Chatroom.name": - if e.complexity.Chatroom.Name == nil { - break - } - - return e.complexity.Chatroom.Name(childComplexity), true - - case "Chatroom.messages": - if e.complexity.Chatroom.Messages == nil { - break - } - - return e.complexity.Chatroom.Messages(childComplexity), true +// nolint: vetshadow +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_fields_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(args["includeDeprecated"].(bool)), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - case "Message.id": - if e.complexity.Message.Id == nil { - break - } + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - return e.complexity.Message.Id(childComplexity), true + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - case "Message.text": - if e.complexity.Message.Text == nil { - break + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.Message.Text(childComplexity), true - - case "Message.createdBy": - if e.complexity.Message.CreatedBy == nil { - break + return ec.___Field(ctx, field.Selections, &res[idx1]) + }() } - - return e.complexity.Message.CreatedBy(childComplexity), true - - case "Message.createdAt": - if e.complexity.Message.CreatedAt == nil { - break + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.Message.CreatedAt(childComplexity), true - - case "Mutation.post": - if e.complexity.Mutation.Post == nil { - break - } + } + wg.Wait() + return arr1 +} - args, err := e.field_Mutation_post_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } +// nolint: vetshadow +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.Mutation.Post(childComplexity, args["text"].(string), args["username"].(string), args["roomName"].(string)), true + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - case "Query.room": - if e.complexity.Query.Room == nil { - break - } + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - args, err := e.field_Query_room_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.Query.Room(childComplexity, args["name"].(string)), true - - case "Subscription.messageAdded": - if e.complexity.Subscription.MessageAdded == nil { - break + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() } - - args, err := e.field_Subscription_messageAdded_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.Subscription.MessageAdded(childComplexity, args["roomName"].(string)), true - } - return 0, false -} - -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions} + wg.Wait() + return arr1 } -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Mutation(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() +// nolint: vetshadow +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, + if resTmp == nil { + return graphql.Null } -} + res := resTmp.([]introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - next := ec._Subscription(ctx, op.SelectionSet) - if ec.Errors != nil { - return graphql.OneShot(&graphql.Response{Data: []byte("null"), Errors: ec.Errors}) + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - var buf bytes.Buffer - return func() *graphql.Response { - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - buf.Reset() - data := next() - - if data == nil { - return nil + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() } - data.MarshalGQL(&buf) - return buf.Bytes() - }) + arr1[idx1] = func() graphql.Marshaler { - if buf == nil { - return nil + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() } - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, + if isLen1 { + f(idx1) + } else { + go f(idx1) } - } -} -type executionContext struct { - *graphql.RequestContext - *executableSchema + } + wg.Wait() + return arr1 } -func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - res, err := ec.ResolverMiddleware(ctx, next) +// nolint: vetshadow +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) - return nil - } - return res -} - -func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") + return graphql.Null } - return introspection.WrapSchema(parsedSchema), nil -} - -func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(args["includeDeprecated"].(bool)), nil + }) + if resTmp == nil { + return graphql.Null } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil -} + res := resTmp.([]introspection.EnumValue) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -var parsedSchema = gqlparser.MustLoadSchema( - &ast.Source{Name: "schema.graphql", Input: `type Chatroom { - name: String! - messages: [Message!]! -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -type Message { - id: ID! - text: String! - createdBy: String! - createdAt: Time! -} + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } -type Query { - room(name:String!): Chatroom -} + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { -type Mutation { - post(text: String!, username: String!, roomName: String!): Message! -} + return ec.___EnumValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } -type Subscription { - messageAdded(roomName: String!): Message! + } + wg.Wait() + return arr1 } -scalar Time -`}, -) +// nolint: vetshadow +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() } - return handleFunc[0](ctx, chainHandler) + arr1[idx1] = func() graphql.Marshaler { + + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) } + } + wg.Wait() + return arr1 +} - if n == 1 { - return handleFunc[0] +// nolint: vetshadow +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if resTmp == nil { + return graphql.Null } + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) + if res == nil { + return graphql.Null } + + return ec.___Type(ctx, field.Selections, res) } -// endregion ************************** generated.gotpl *************************** +// endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** diff --git a/example/chat/models_gen.go b/example/chat/models_gen.go index b35be48c938..27fbb4a9223 100644 --- a/example/chat/models_gen.go +++ b/example/chat/models_gen.go @@ -1,3 +1,5 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + package chat import ( diff --git a/example/config/generated.go b/example/config/generated.go index 994710ed14c..89f256aea33 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -15,423 +15,377 @@ import ( "github.com/vektah/gqlparser/ast" ) -// region **************************** field.gotpl ***************************** +// region ************************** generated!.gotpl ************************** -// nolint: vetshadow -func (ec *executionContext) _Mutation_createTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Mutation", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_createTodo_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateTodo(rctx, args["input"].(NewTodo)) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, } - res := resTmp.(Todo) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +} - return ec._Todo(ctx, field.Selections, &res) +type Config struct { + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot } -// nolint: vetshadow -func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, +type ResolverRoot interface { + Mutation() MutationResolver + Query() QueryResolver + Todo() TodoResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + Mutation struct { + CreateTodo func(childComplexity int, input NewTodo) int } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Todos(rctx) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null + + Query struct { + Todos func(childComplexity int) int } - res := resTmp.([]Todo) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + Todo struct { + Id func(childComplexity int) int + DatabaseId func(childComplexity int) int + Text func(childComplexity int) int + Done func(childComplexity int) int + User func(childComplexity int) int + } - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) + User struct { + Id func(childComplexity int) int + Name func(childComplexity int) int } +} - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], +type MutationResolver interface { + CreateTodo(ctx context.Context, input NewTodo) (Todo, error) +} +type QueryResolver interface { + Todos(ctx context.Context) ([]Todo, error) +} +type TodoResolver interface { + ID(ctx context.Context, obj *Todo) (string, error) +} + +type executableSchema struct { + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + switch typeName + "." + field { + + case "Mutation.createTodo": + if e.complexity.Mutation.CreateTodo == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec._Todo(ctx, field.Selections, &res[idx1]) - }() + args, err := e.field_Mutation_createTodo_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - if isLen1 { - f(idx1) - } else { - go f(idx1) + + return e.complexity.Mutation.CreateTodo(childComplexity, args["input"].(NewTodo)), true + + case "Query.todos": + if e.complexity.Query.Todos == nil { + break + } + + return e.complexity.Query.Todos(childComplexity), true + + case "Todo.id": + if e.complexity.Todo.Id == nil { + break + } + + return e.complexity.Todo.Id(childComplexity), true + + case "Todo.databaseId": + if e.complexity.Todo.DatabaseId == nil { + break + } + + return e.complexity.Todo.DatabaseId(childComplexity), true + + case "Todo.text": + if e.complexity.Todo.Text == nil { + break + } + + return e.complexity.Todo.Text(childComplexity), true + + case "Todo.done": + if e.complexity.Todo.Done == nil { + break + } + + return e.complexity.Todo.Done(childComplexity), true + + case "Todo.user": + if e.complexity.Todo.User == nil { + break + } + + return e.complexity.Todo.User(childComplexity), true + + case "User.id": + if e.complexity.User.Id == nil { + break } + return e.complexity.User.Id(childComplexity), true + + case "User.name": + if e.complexity.User.Name == nil { + break + } + + return e.complexity.User.Name(childComplexity), true + } - wg.Wait() - return arr1 + return 0, false } -// nolint: vetshadow -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query___type_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectType(args["name"].(string)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} - if res == nil { - return graphql.Null - } + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._Query(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() + }) - return ec.___Type(ctx, field.Selections, res) + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions} } -// nolint: vetshadow -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() +func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._Mutation(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Schema) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions, } +} - return ec.___Schema(ctx, field.Selections, res) +func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { + return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) } -// nolint: vetshadow -func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Todo", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Todo().ID(rctx, obj) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) +type executionContext struct { + *graphql.RequestContext + *executableSchema } -// nolint: vetshadow -func (ec *executionContext) _Todo_databaseId(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Todo", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DatabaseID, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil } - return graphql.Null + }() + res, err := ec.ResolverMiddleware(ctx, next) + if err != nil { + ec.Error(ctx, err) + return nil } - res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) + return res } -// nolint: vetshadow -func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Todo", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return introspection.WrapSchema(parsedSchema), nil } -// nolint: vetshadow -func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Todo", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Done, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") } - res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil } -// nolint: vetshadow -func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Todo", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.User, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +var parsedSchema = gqlparser.MustLoadSchema( + &ast.Source{Name: "schema.graphql", Input: `type Query { + todos: [Todo!]! +} + +type Mutation { + createTodo(input: NewTodo!): Todo! +} +`}, + &ast.Source{Name: "todo.graphql", Input: `type Todo { + id: ID! + databaseId: Int! + text: String! + done: Boolean! + user: User! +} + +input NewTodo { + text: String! + userId: String! +} + +`}, + &ast.Source{Name: "user.graphql", Input: `type User { + id: ID! + name: String! +} +`}, +) + +// ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + + } + return handleFunc[0](ctx, chainHandler) } - return graphql.Null } - res := resTmp.(User) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec._User(ctx, field.Selections, &res) -} + if n == 1 { + return handleFunc[0] + } -// nolint: vetshadow -func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +} + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (e *executableSchema) field_Mutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 NewTodo + if tmp, ok := rawArgs["input"]; ok { + var err error + arg0, err = UnmarshalNewTodo(tmp) + if err != nil { + return nil, err } - return graphql.Null + + mNewTodo1, err := e.NewTodoMiddleware(ctx, &arg0) + if err != nil { + return nil, err + } + arg0 = *mNewTodo1 } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + args["input"] = arg0 + return args, nil } -// nolint: vetshadow -func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.FullName(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + args["name"] = arg0 + return args, nil } -// nolint: vetshadow -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + args["includeDeprecated"] = arg0 + return args, nil } -// nolint: vetshadow -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { - return graphql.Null +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + args["includeDeprecated"] = arg0 + return args, nil } +// endregion ***************************** args.gotpl ***************************** + +// region **************************** field.gotpl ***************************** + // nolint: vetshadow -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) _Mutation_createTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "Mutation", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_createTodo_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Locations, nil + return ec.resolvers.Mutation().CreateTodo(rctx, args["input"].(NewTodo)) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -439,35 +393,27 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr } return graphql.Null } - res := resTmp.([]string) + res := resTmp.(Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 + return ec._Todo(ctx, field.Selections, &res) } // nolint: vetshadow -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "Query", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Args, nil + return ec.resolvers.Query().Todos(rctx) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -475,7 +421,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.([]Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -500,7 +446,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql } arr1[idx1] = func() graphql.Marshaler { - return ec.___InputValue(ctx, field.Selections, &res[idx1]) + return ec._Todo(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -515,117 +461,76 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "Query", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query___type_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) return graphql.Null } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return ec.introspectType(args["name"].(string)) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + + if res == nil { + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "Query", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return ec.introspectSchema() }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { return graphql.Null } - return graphql.MarshalString(*res) + + return ec.___Schema(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "Todo", Field: field, Args: nil, } @@ -633,7 +538,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return ec.resolvers.Todo().ID(rctx, obj) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -644,15 +549,15 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return graphql.MarshalID(res) } // nolint: vetshadow -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) _Todo_databaseId(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "Todo", Field: field, Args: nil, } @@ -660,23 +565,26 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.DatabaseID, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(string) + res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return graphql.MarshalInt(res) } // nolint: vetshadow -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "Todo", Field: field, Args: nil, } @@ -684,7 +592,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Args, nil + return obj.Description, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -692,51 +600,18 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "Todo", Field: field, Args: nil, } @@ -744,7 +619,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.Done, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -752,26 +627,18 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "Todo", Field: field, Args: nil, } @@ -779,7 +646,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.User, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -787,18 +654,19 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(User) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + + return ec._User(ctx, field.Selections, &res) } // nolint: vetshadow -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "User", Field: field, Args: nil, } @@ -806,27 +674,26 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.ID, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return graphql.MarshalID(res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "User", Field: field, Args: nil, } @@ -834,7 +701,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.FullName(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -849,11 +716,11 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } // nolint: vetshadow -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Directive", Field: field, Args: nil, } @@ -861,9 +728,12 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.Name, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(string) @@ -873,11 +743,11 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field } // nolint: vetshadow -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Directive", Field: field, Args: nil, } @@ -885,34 +755,23 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.Description, nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Directive", Field: field, Args: nil, } @@ -920,27 +779,35 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil + return obj.Locations, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null + arr1 := make(graphql.Array, len(res)) + + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { + return graphql.MarshalString(res[idx1]) + }() } - return graphql.MarshalString(*res) + + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Directive", Field: field, Args: nil, } @@ -948,7 +815,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Types(), nil + return obj.Args, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -956,7 +823,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -981,7 +848,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } arr1[idx1] = func() graphql.Marshaler { - return ec.___Type(ctx, field.Selections, &res[idx1]) + return ec.___InputValue(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -991,16 +858,67 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } } - wg.Wait() - return arr1 + wg.Wait() + return arr1 +} + +// nolint: vetshadow +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} + +// nolint: vetshadow +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__EnumValue", Field: field, Args: nil, } @@ -1008,7 +926,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil + return obj.IsDeprecated(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1016,26 +934,18 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__EnumValue", Field: field, Args: nil, } @@ -1043,28 +953,27 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil + return obj.DeprecationReason(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { return graphql.Null } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Field", Field: field, Args: nil, } @@ -1072,28 +981,50 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil + return obj.Name, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - if res == nil { +// nolint: vetshadow +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if resTmp == nil { return graphql.Null } - - return ec.___Type(ctx, field.Selections, res) + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Field", Field: field, Args: nil, } @@ -1101,7 +1032,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil + return obj.Args, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1109,7 +1040,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap } return graphql.Null } - res := resTmp.([]introspection.Directive) + res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1134,7 +1065,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap } arr1[idx1] = func() graphql.Marshaler { - return ec.___Directive(ctx, field.Selections, &res[idx1]) + return ec.___InputValue(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1149,11 +1080,11 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap } // nolint: vetshadow -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Field", Field: field, Args: nil, } @@ -1161,7 +1092,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil + return obj.Type, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1169,18 +1100,26 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Field", Field: field, Args: nil, } @@ -1188,7 +1127,34 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name(), nil + return obj.IsDeprecated(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) +} + +// nolint: vetshadow +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil }) if resTmp == nil { return graphql.Null @@ -1204,11 +1170,11 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll } // nolint: vetshadow -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__InputValue", Field: field, Args: nil, } @@ -1216,9 +1182,12 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.Name, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(string) @@ -1228,75 +1197,35 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph } // nolint: vetshadow -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__InputValue", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_fields_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Fields(args["includeDeprecated"].(bool)), nil + return obj.Description, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.Field) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Field(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__InputValue", Field: field, Args: nil, } @@ -1304,56 +1233,62 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil + return obj.Type, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null } - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { + return ec.___Type(ctx, field.Selections, res) +} - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } +// nolint: vetshadow +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + if res == nil { + return graphql.Null } - wg.Wait() - return arr1 + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } @@ -1361,9 +1296,12 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil + return obj.Types(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.([]introspection.Type) @@ -1406,75 +1344,104 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra } // nolint: vetshadow -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_enumValues_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - rctx.Args = args + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) +} + +// nolint: vetshadow +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.EnumValues(args["includeDeprecated"].(bool)), nil + return obj.MutationType(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.EnumValue) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) + if res == nil { + return graphql.Null } - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { + return ec.___Type(ctx, field.Selections, res) +} - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } +// nolint: vetshadow +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + if res == nil { + return graphql.Null } - wg.Wait() - return arr1 + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } @@ -1482,12 +1449,15 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil + return obj.Directives(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1512,7 +1482,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph } arr1[idx1] = func() graphql.Marshaler { - return ec.___InputValue(ctx, field.Selections, &res[idx1]) + return ec.___Directive(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1527,7 +1497,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph } // nolint: vetshadow -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1539,371 +1509,401 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil + return obj.Kind(), nil }) if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// endregion **************************** field.gotpl ***************************** - -// region ************************** generated.gotpl *************************** - -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } -} - -type Config struct { - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot -} - -type ResolverRoot interface { - Mutation() MutationResolver - Query() QueryResolver - Todo() TodoResolver -} - -type DirectiveRoot struct { -} - -type ComplexityRoot struct { - Mutation struct { - CreateTodo func(childComplexity int, input NewTodo) int - } - - Query struct { - Todos func(childComplexity int) int - } - - Todo struct { - Id func(childComplexity int) int - DatabaseId func(childComplexity int) int - Text func(childComplexity int) int - Done func(childComplexity int) int - User func(childComplexity int) int - } - - User struct { - Id func(childComplexity int) int - Name func(childComplexity int) int - } -} - -type MutationResolver interface { - CreateTodo(ctx context.Context, input NewTodo) (Todo, error) -} -type QueryResolver interface { - Todos(ctx context.Context) ([]Todo, error) -} -type TodoResolver interface { - ID(ctx context.Context, obj *Todo) (string, error) -} - -func (e *executableSchema) field_Mutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 NewTodo - if tmp, ok := rawArgs["input"]; ok { - var err error - arg0, err = UnmarshalNewTodo(tmp) - if err != nil { - return nil, err - } - - mNewTodo1, err := e.NewTodoMiddleware(ctx, &arg0) - if err != nil { - return nil, err - } - arg0 = *mNewTodo1 - } - args["input"] = arg0 - return args, nil - -} - -func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - } - args["name"] = arg0 - return args, nil - -} - -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["includeDeprecated"] = arg0 - return args, nil - + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, } - args["includeDeprecated"] = arg0 - return args, nil - -} + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -type executableSchema struct { - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } -func (e *executableSchema) Schema() *ast.Schema { - return parsedSchema +// nolint: vetshadow +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - switch typeName + "." + field { - - case "Mutation.createTodo": - if e.complexity.Mutation.CreateTodo == nil { - break - } +// nolint: vetshadow +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_fields_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(args["includeDeprecated"].(bool)), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - args, err := e.field_Mutation_createTodo_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - return e.complexity.Mutation.CreateTodo(childComplexity, args["input"].(NewTodo)), true + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - case "Query.todos": - if e.complexity.Query.Todos == nil { - break + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.Query.Todos(childComplexity), true - - case "Todo.id": - if e.complexity.Todo.Id == nil { - break + return ec.___Field(ctx, field.Selections, &res[idx1]) + }() } - - return e.complexity.Todo.Id(childComplexity), true - - case "Todo.databaseId": - if e.complexity.Todo.DatabaseId == nil { - break + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.Todo.DatabaseId(childComplexity), true - - case "Todo.text": - if e.complexity.Todo.Text == nil { - break - } + } + wg.Wait() + return arr1 +} - return e.complexity.Todo.Text(childComplexity), true +// nolint: vetshadow +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - case "Todo.done": - if e.complexity.Todo.Done == nil { - break - } + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - return e.complexity.Todo.Done(childComplexity), true + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - case "Todo.user": - if e.complexity.Todo.User == nil { - break + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.Todo.User(childComplexity), true - - case "User.id": - if e.complexity.User.Id == nil { - break + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() } - - return e.complexity.User.Id(childComplexity), true - - case "User.name": - if e.complexity.User.Name == nil { - break + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.User.Name(childComplexity), true - } - return 0, false -} - -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions} + wg.Wait() + return arr1 } -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Mutation(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() +// nolint: vetshadow +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } -} -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) -} + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { -type executionContext struct { - *graphql.RequestContext - *executableSchema + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } -func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - res, err := ec.ResolverMiddleware(ctx, next) +// nolint: vetshadow +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) - return nil + return graphql.Null } - return res -} - -func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(args["includeDeprecated"].(bool)), nil + }) + if resTmp == nil { + return graphql.Null } - return introspection.WrapSchema(parsedSchema), nil -} + res := resTmp.([]introspection.EnumValue) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil -} -var parsedSchema = gqlparser.MustLoadSchema( - &ast.Source{Name: "schema.graphql", Input: `type Query { - todos: [Todo!]! -} + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { -type Mutation { - createTodo(input: NewTodo!): Todo! -} -`}, - &ast.Source{Name: "todo.graphql", Input: `type Todo { - id: ID! - databaseId: Int! - text: String! - done: Boolean! - user: User! -} + return ec.___EnumValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } -input NewTodo { - text: String! - userId: String! + } + wg.Wait() + return arr1 } -`}, - &ast.Source{Name: "user.graphql", Input: `type User { - id: ID! - name: String! -} -`}, -) +// nolint: vetshadow +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() } - return handleFunc[0](ctx, chainHandler) + arr1[idx1] = func() graphql.Marshaler { + + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) } + } + wg.Wait() + return arr1 +} - if n == 1 { - return handleFunc[0] +// nolint: vetshadow +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if resTmp == nil { + return graphql.Null } + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) + if res == nil { + return graphql.Null } + + return ec.___Type(ctx, field.Selections, res) } -// endregion ************************** generated.gotpl *************************** +// endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** diff --git a/example/config/models_gen.go b/example/config/models_gen.go index c749821922e..056757da9f4 100644 --- a/example/config/models_gen.go +++ b/example/config/models_gen.go @@ -1,3 +1,5 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + package config type NewTodo struct { diff --git a/example/dataloader/addressloader_gen.go b/example/dataloader/addressloader_gen.go index 90e1d433fc5..0465446faa7 100644 --- a/example/dataloader/addressloader_gen.go +++ b/example/dataloader/addressloader_gen.go @@ -1,4 +1,4 @@ -// Code generated by github.com/vektah/dataloaden, DO NOT EDIT. +// generated by github.com/vektah/dataloaden ; DO NOT EDIT package dataloader @@ -7,27 +7,6 @@ import ( "time" ) -// AddressLoaderConfig captures the config to create a new AddressLoader -type AddressLoaderConfig struct { - // Fetch is a method that provides the data for the loader - Fetch func(keys []int) ([]*Address, []error) - - // Wait is how long wait before sending a batch - Wait time.Duration - - // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit - MaxBatch int -} - -// NewAddressLoader creates a new AddressLoader given a fetch, wait, and maxBatch -func NewAddressLoader(config AddressLoaderConfig) *AddressLoader { - return &AddressLoader{ - fetch: config.Fetch, - wait: config.Wait, - maxBatch: config.MaxBatch, - } -} - // AddressLoader batches and caches requests type AddressLoader struct { // this method provides the data for the loader diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index 0bb2142832f..a5a7072c089 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -16,6 +16,447 @@ import ( "github.com/vektah/gqlparser/ast" ) +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Customer() CustomerResolver + Order() OrderResolver + Query() QueryResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + Address struct { + Id func(childComplexity int) int + Street func(childComplexity int) int + Country func(childComplexity int) int + } + + Customer struct { + Id func(childComplexity int) int + Name func(childComplexity int) int + Address func(childComplexity int) int + Orders func(childComplexity int) int + } + + Item struct { + Name func(childComplexity int) int + } + + Order struct { + Id func(childComplexity int) int + Date func(childComplexity int) int + Amount func(childComplexity int) int + Items func(childComplexity int) int + } + + Query struct { + Customers func(childComplexity int) int + Torture1d func(childComplexity int, customerIds []int) int + Torture2d func(childComplexity int, customerIds [][]int) int + } +} + +type CustomerResolver interface { + Address(ctx context.Context, obj *Customer) (*Address, error) + Orders(ctx context.Context, obj *Customer) ([]Order, error) +} +type OrderResolver interface { + Items(ctx context.Context, obj *Order) ([]Item, error) +} +type QueryResolver interface { + Customers(ctx context.Context) ([]Customer, error) + Torture1d(ctx context.Context, customerIds []int) ([]Customer, error) + Torture2d(ctx context.Context, customerIds [][]int) ([][]Customer, error) +} + +type executableSchema struct { + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + switch typeName + "." + field { + + case "Address.id": + if e.complexity.Address.Id == nil { + break + } + + return e.complexity.Address.Id(childComplexity), true + + case "Address.street": + if e.complexity.Address.Street == nil { + break + } + + return e.complexity.Address.Street(childComplexity), true + + case "Address.country": + if e.complexity.Address.Country == nil { + break + } + + return e.complexity.Address.Country(childComplexity), true + + case "Customer.id": + if e.complexity.Customer.Id == nil { + break + } + + return e.complexity.Customer.Id(childComplexity), true + + case "Customer.name": + if e.complexity.Customer.Name == nil { + break + } + + return e.complexity.Customer.Name(childComplexity), true + + case "Customer.address": + if e.complexity.Customer.Address == nil { + break + } + + return e.complexity.Customer.Address(childComplexity), true + + case "Customer.orders": + if e.complexity.Customer.Orders == nil { + break + } + + return e.complexity.Customer.Orders(childComplexity), true + + case "Item.name": + if e.complexity.Item.Name == nil { + break + } + + return e.complexity.Item.Name(childComplexity), true + + case "Order.id": + if e.complexity.Order.Id == nil { + break + } + + return e.complexity.Order.Id(childComplexity), true + + case "Order.date": + if e.complexity.Order.Date == nil { + break + } + + return e.complexity.Order.Date(childComplexity), true + + case "Order.amount": + if e.complexity.Order.Amount == nil { + break + } + + return e.complexity.Order.Amount(childComplexity), true + + case "Order.items": + if e.complexity.Order.Items == nil { + break + } + + return e.complexity.Order.Items(childComplexity), true + + case "Query.customers": + if e.complexity.Query.Customers == nil { + break + } + + return e.complexity.Query.Customers(childComplexity), true + + case "Query.torture1d": + if e.complexity.Query.Torture1d == nil { + break + } + + args, err := e.field_Query_torture1d_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Torture1d(childComplexity, args["customerIds"].([]int)), true + + case "Query.torture2d": + if e.complexity.Query.Torture2d == nil { + break + } + + args, err := e.field_Query_torture2d_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Torture2d(childComplexity, args["customerIds"].([][]int)), true + + } + return 0, false +} + +func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._Query(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() + }) + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions} +} + +func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + return graphql.ErrorResponse(ctx, "mutations are not supported") +} + +func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { + return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) +} + +type executionContext struct { + *graphql.RequestContext + *executableSchema +} + +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + res, err := ec.ResolverMiddleware(ctx, next) + if err != nil { + ec.Error(ctx, err) + return nil + } + return res +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(parsedSchema), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil +} + +var parsedSchema = gqlparser.MustLoadSchema( + &ast.Source{Name: "schema.graphql", Input: `type Query { + customers: [Customer!] + + # these methods are here to test code generation of nested arrays + torture1d(customerIds: [Int!]): [Customer!] + torture2d(customerIds: [[Int!]]): [[Customer!]] +} + +type Customer { + id: Int! + name: String! + address: Address + orders: [Order!] +} + +type Address { + id: Int! + street: String! + country: String! +} + +type Order { + id: Int! + date: Time! + amount: Float! + items: [Item!] +} + +type Item { + name: String! +} +scalar Time +`}, +) + +// ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + + } + return handleFunc[0](ctx, chainHandler) + } + } + + if n == 1 { + return handleFunc[0] + } + + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) + } +} + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg0 + return args, nil +} + +func (e *executableSchema) field_Query_torture1d_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 []int + if tmp, ok := rawArgs["customerIds"]; ok { + var err error + var rawIf1 []interface{} + if tmp != nil { + if tmp1, ok := tmp.([]interface{}); ok { + rawIf1 = tmp1 + } else { + rawIf1 = []interface{}{tmp} + } + } + arg0 = make([]int, len(rawIf1)) + for idx1 := range rawIf1 { + arg0[idx1], err = graphql.UnmarshalInt(rawIf1[idx1]) + } + if err != nil { + return nil, err + } + } + args["customerIds"] = arg0 + return args, nil +} + +func (e *executableSchema) field_Query_torture2d_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 [][]int + if tmp, ok := rawArgs["customerIds"]; ok { + var err error + var rawIf1 []interface{} + if tmp != nil { + if tmp1, ok := tmp.([]interface{}); ok { + rawIf1 = tmp1 + } else { + rawIf1 = []interface{}{tmp} + } + } + arg0 = make([][]int, len(rawIf1)) + for idx1 := range rawIf1 { + var rawIf2 []interface{} + if rawIf1[idx1] != nil { + if tmp1, ok := rawIf1[idx1].([]interface{}); ok { + rawIf2 = tmp1 + } else { + rawIf2 = []interface{}{rawIf1[idx1]} + } + } + arg0[idx1] = make([]int, len(rawIf2)) + for idx2 := range rawIf2 { + arg0[idx1][idx2], err = graphql.UnmarshalInt(rawIf2[idx2]) + } + } + if err != nil { + return nil, err + } + } + args["customerIds"] = arg0 + return args, nil +} + +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil +} + +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil +} + +// endregion ***************************** args.gotpl ***************************** + // region **************************** field.gotpl ***************************** // nolint: vetshadow @@ -596,229 +1037,17 @@ func (ec *executionContext) _Query_torture2d(ctx context.Context, field graphql. arr2[idx2] = func() graphql.Marshaler { return ec._Customer(ctx, field.Selections, &res[idx1][idx2]) - }() - } - if isLen1 { - f(idx2) - } else { - go f(idx2) - } - - } - - return arr2 - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 -} - -// nolint: vetshadow -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query___type_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectType(args["name"].(string)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Schema) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Schema(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Locations, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 -} - -// nolint: vetshadow -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Args, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } + }() + } + if isLen1 { + f(idx2) + } else { + go f(idx2) + } - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { + } - return ec.___InputValue(ctx, field.Selections, &res[idx1]) + return arr2 }() } if isLen1 { @@ -833,62 +1062,76 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "Query", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query___type_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return ec.introspectType(args["name"].(string)) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "Query", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return ec.introspectSchema() }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + + return ec.___Schema(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "__Directive", Field: field, Args: nil, } @@ -896,7 +1139,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -904,18 +1147,18 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "__Directive", Field: field, Args: nil, } @@ -923,27 +1166,23 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.Description, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Directive", Field: field, Args: nil, } @@ -951,7 +1190,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Locations, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -959,42 +1198,27 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} -// nolint: vetshadow -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { - return graphql.Null + arr1 := make(graphql.Array, len(res)) + + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { + return graphql.MarshalString(res[idx1]) + }() } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Directive", Field: field, Args: nil, } @@ -1050,46 +1274,11 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Type, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__EnumValue", Field: field, Args: nil, } @@ -1097,7 +1286,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1105,18 +1294,18 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__EnumValue", Field: field, Args: nil, } @@ -1124,27 +1313,23 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.Description, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__EnumValue", Field: field, Args: nil, } @@ -1152,7 +1337,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.IsDeprecated(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1160,18 +1345,18 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(string) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__EnumValue", Field: field, Args: nil, } @@ -1179,23 +1364,27 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.DeprecationReason(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Field", Field: field, Args: nil, } @@ -1203,7 +1392,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1211,26 +1400,18 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Field", Field: field, Args: nil, } @@ -1238,27 +1419,23 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil + return obj.Description, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Field", Field: field, Args: nil, } @@ -1266,7 +1443,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Types(), nil + return obj.Args, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1274,7 +1451,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1299,7 +1476,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } arr1[idx1] = func() graphql.Marshaler { - return ec.___Type(ctx, field.Selections, &res[idx1]) + return ec.___InputValue(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1314,11 +1491,11 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } // nolint: vetshadow -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Field", Field: field, Args: nil, } @@ -1326,7 +1503,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil + return obj.Type, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1349,11 +1526,11 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } // nolint: vetshadow -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Field", Field: field, Args: nil, } @@ -1361,28 +1538,26 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil + return obj.IsDeprecated(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Field", Field: field, Args: nil, } @@ -1390,28 +1565,27 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil + return obj.DeprecationReason(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { return graphql.Null } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__InputValue", Field: field, Args: nil, } @@ -1419,7 +1593,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1427,51 +1601,18 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap } return graphql.Null } - res := resTmp.([]introspection.Directive) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Directive(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__InputValue", Field: field, Args: nil, } @@ -1479,12 +1620,9 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil + return obj.Description, nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } res := resTmp.(string) @@ -1494,11 +1632,11 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll } // nolint: vetshadow -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__InputValue", Field: field, Args: nil, } @@ -1506,27 +1644,34 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name(), nil + return obj.Type, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - return graphql.MarshalString(*res) + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__InputValue", Field: field, Args: nil, } @@ -1534,43 +1679,43 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.DefaultValue, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_fields_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Fields(args["includeDeprecated"].(bool)), nil + return obj.Types(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.Field) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1595,7 +1740,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } arr1[idx1] = func() graphql.Marshaler { - return ec.___Field(ctx, field.Selections, &res[idx1]) + return ec.___Type(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1610,11 +1755,11 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } // nolint: vetshadow -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } @@ -1622,56 +1767,34 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil + return obj.QueryType(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } - + return graphql.Null } - wg.Wait() - return arr1 + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } @@ -1679,76 +1802,73 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil + return obj.MutationType(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) + if res == nil { + return graphql.Null } - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { + return ec.___Type(ctx, field.Selections, res) +} - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } +// nolint: vetshadow +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + if res == nil { + return graphql.Null } - wg.Wait() - return arr1 + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_enumValues_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.EnumValues(args["includeDeprecated"].(bool)), nil + return obj.Directives(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.EnumValue) + res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1773,7 +1893,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } arr1[idx1] = func() graphql.Marshaler { - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) + return ec.___Directive(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1788,7 +1908,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } // nolint: vetshadow -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1800,52 +1920,22 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil + return obj.Kind(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1857,465 +1947,374 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil + return obj.Name(), nil }) if resTmp == nil { return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// endregion **************************** field.gotpl ***************************** - -// region ************************** generated.gotpl *************************** - -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } -} - -type Config struct { - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot -} - -type ResolverRoot interface { - Customer() CustomerResolver - Order() OrderResolver - Query() QueryResolver -} - -type DirectiveRoot struct { -} - -type ComplexityRoot struct { - Address struct { - Id func(childComplexity int) int - Street func(childComplexity int) int - Country func(childComplexity int) int - } - - Customer struct { - Id func(childComplexity int) int - Name func(childComplexity int) int - Address func(childComplexity int) int - Orders func(childComplexity int) int - } - - Item struct { - Name func(childComplexity int) int - } - - Order struct { - Id func(childComplexity int) int - Date func(childComplexity int) int - Amount func(childComplexity int) int - Items func(childComplexity int) int - } - - Query struct { - Customers func(childComplexity int) int - Torture1d func(childComplexity int, customerIds []int) int - Torture2d func(childComplexity int, customerIds [][]int) int - } -} - -type CustomerResolver interface { - Address(ctx context.Context, obj *Customer) (*Address, error) - Orders(ctx context.Context, obj *Customer) ([]Order, error) -} -type OrderResolver interface { - Items(ctx context.Context, obj *Order) ([]Item, error) -} -type QueryResolver interface { - Customers(ctx context.Context) ([]Customer, error) - Torture1d(ctx context.Context, customerIds []int) ([]Customer, error) - Torture2d(ctx context.Context, customerIds [][]int) ([][]Customer, error) -} - -func (e *executableSchema) field_Query_torture1d_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 []int - if tmp, ok := rawArgs["customerIds"]; ok { - var err error - var rawIf1 []interface{} - if tmp != nil { - if tmp1, ok := tmp.([]interface{}); ok { - rawIf1 = tmp1 - } else { - rawIf1 = []interface{}{tmp} - } - } - arg0 = make([]int, len(rawIf1)) - for idx1 := range rawIf1 { - arg0[idx1], err = graphql.UnmarshalInt(rawIf1[idx1]) - } - if err != nil { - return nil, err - } - } - args["customerIds"] = arg0 - return args, nil - -} - -func (e *executableSchema) field_Query_torture2d_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 [][]int - if tmp, ok := rawArgs["customerIds"]; ok { - var err error - var rawIf1 []interface{} - if tmp != nil { - if tmp1, ok := tmp.([]interface{}); ok { - rawIf1 = tmp1 - } else { - rawIf1 = []interface{}{tmp} - } - } - arg0 = make([][]int, len(rawIf1)) - for idx1 := range rawIf1 { - var rawIf2 []interface{} - if rawIf1[idx1] != nil { - if tmp1, ok := rawIf1[idx1].([]interface{}); ok { - rawIf2 = tmp1 - } else { - rawIf2 = []interface{}{rawIf1[idx1]} - } - } - arg0[idx1] = make([]int, len(rawIf2)) - for idx2 := range rawIf2 { - arg0[idx1][idx2], err = graphql.UnmarshalInt(rawIf2[idx2]) - } - } - if err != nil { - return nil, err - } - } - args["customerIds"] = arg0 - return args, nil - -} - -func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - } - args["name"] = arg0 - return args, nil - -} - -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil - -} - -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil - -} + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -type executableSchema struct { - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } -func (e *executableSchema) Schema() *ast.Schema { - return parsedSchema +// nolint: vetshadow +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - switch typeName + "." + field { - - case "Address.id": - if e.complexity.Address.Id == nil { - break - } - - return e.complexity.Address.Id(childComplexity), true - - case "Address.street": - if e.complexity.Address.Street == nil { - break - } - - return e.complexity.Address.Street(childComplexity), true - - case "Address.country": - if e.complexity.Address.Country == nil { - break - } - - return e.complexity.Address.Country(childComplexity), true - - case "Customer.id": - if e.complexity.Customer.Id == nil { - break - } - - return e.complexity.Customer.Id(childComplexity), true +// nolint: vetshadow +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_fields_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(args["includeDeprecated"].(bool)), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - case "Customer.name": - if e.complexity.Customer.Name == nil { - break - } + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - return e.complexity.Customer.Name(childComplexity), true + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - case "Customer.address": - if e.complexity.Customer.Address == nil { - break + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.Customer.Address(childComplexity), true - - case "Customer.orders": - if e.complexity.Customer.Orders == nil { - break + return ec.___Field(ctx, field.Selections, &res[idx1]) + }() } - - return e.complexity.Customer.Orders(childComplexity), true - - case "Item.name": - if e.complexity.Item.Name == nil { - break + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.Item.Name(childComplexity), true - - case "Order.id": - if e.complexity.Order.Id == nil { - break - } + } + wg.Wait() + return arr1 +} - return e.complexity.Order.Id(childComplexity), true +// nolint: vetshadow +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - case "Order.date": - if e.complexity.Order.Date == nil { - break - } + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - return e.complexity.Order.Date(childComplexity), true + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - case "Order.amount": - if e.complexity.Order.Amount == nil { - break + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.Order.Amount(childComplexity), true - - case "Order.items": - if e.complexity.Order.Items == nil { - break + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() } - - return e.complexity.Order.Items(childComplexity), true - - case "Query.customers": - if e.complexity.Query.Customers == nil { - break + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.Query.Customers(childComplexity), true + } + wg.Wait() + return arr1 +} - case "Query.torture1d": - if e.complexity.Query.Torture1d == nil { - break - } +// nolint: vetshadow +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - args, err := e.field_Query_torture1d_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - return e.complexity.Query.Torture1d(childComplexity, args["customerIds"].([]int)), true + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - case "Query.torture2d": - if e.complexity.Query.Torture2d == nil { - break + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - args, err := e.field_Query_torture2d_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) } - - return e.complexity.Query.Torture2d(childComplexity, args["customerIds"].([][]int)), true } - return 0, false + wg.Wait() + return arr1 } -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() +// nolint: vetshadow +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions} -} - -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - return graphql.ErrorResponse(ctx, "mutations are not supported") -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) -} + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } -type executionContext struct { - *graphql.RequestContext - *executableSchema -} + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { -func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil + return ec.___EnumValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) } - }() - res, err := ec.ResolverMiddleware(ctx, next) - if err != nil { - ec.Error(ctx, err) - return nil - } - return res -} -func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") } - return introspection.WrapSchema(parsedSchema), nil + wg.Wait() + return arr1 } -func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") +// nolint: vetshadow +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil -} - -var parsedSchema = gqlparser.MustLoadSchema( - &ast.Source{Name: "schema.graphql", Input: `type Query { - customers: [Customer!] + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - # these methods are here to test code generation of nested arrays - torture1d(customerIds: [Int!]): [Customer!] - torture2d(customerIds: [[Int!]]): [[Customer!]] -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -type Customer { - id: Int! - name: String! - address: Address - orders: [Order!] -} + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } -type Address { - id: Int! - street: String! - country: String! -} + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { -type Order { - id: Int! - date: Time! - amount: Float! - items: [Item!] -} + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } -type Item { - name: String! + } + wg.Wait() + return arr1 } -scalar Time -`}, -) - -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) - - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err - } - return handleFunc[0](ctx, chainHandler) - } +// nolint: vetshadow +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, } - - if n == 1 { - return handleFunc[0] + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if resTmp == nil { + return graphql.Null } + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) + if res == nil { + return graphql.Null } + + return ec.___Type(ctx, field.Selections, res) } -// endregion ************************** generated.gotpl *************************** +// endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** diff --git a/example/dataloader/itemsliceloader_gen.go b/example/dataloader/itemsliceloader_gen.go index 5fa10078401..55f21b4cae5 100644 --- a/example/dataloader/itemsliceloader_gen.go +++ b/example/dataloader/itemsliceloader_gen.go @@ -1,4 +1,4 @@ -// Code generated by github.com/vektah/dataloaden, DO NOT EDIT. +// generated by github.com/vektah/dataloaden ; DO NOT EDIT package dataloader @@ -7,27 +7,6 @@ import ( "time" ) -// ItemSliceLoaderConfig captures the config to create a new ItemSliceLoader -type ItemSliceLoaderConfig struct { - // Fetch is a method that provides the data for the loader - Fetch func(keys []int) ([][]Item, []error) - - // Wait is how long wait before sending a batch - Wait time.Duration - - // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit - MaxBatch int -} - -// NewItemSliceLoader creates a new ItemSliceLoader given a fetch, wait, and maxBatch -func NewItemSliceLoader(config ItemSliceLoaderConfig) *ItemSliceLoader { - return &ItemSliceLoader{ - fetch: config.Fetch, - wait: config.Wait, - maxBatch: config.MaxBatch, - } -} - // ItemSliceLoader batches and caches requests type ItemSliceLoader struct { // this method provides the data for the loader diff --git a/example/dataloader/models_gen.go b/example/dataloader/models_gen.go index c0ff90ce82b..fb141c173fb 100644 --- a/example/dataloader/models_gen.go +++ b/example/dataloader/models_gen.go @@ -1,3 +1,5 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + package dataloader type Address struct { diff --git a/example/dataloader/ordersliceloader_gen.go b/example/dataloader/ordersliceloader_gen.go index e76e24d31f0..6b168ec1fb4 100644 --- a/example/dataloader/ordersliceloader_gen.go +++ b/example/dataloader/ordersliceloader_gen.go @@ -1,4 +1,4 @@ -// Code generated by github.com/vektah/dataloaden, DO NOT EDIT. +// generated by github.com/vektah/dataloaden ; DO NOT EDIT package dataloader @@ -7,27 +7,6 @@ import ( "time" ) -// OrderSliceLoaderConfig captures the config to create a new OrderSliceLoader -type OrderSliceLoaderConfig struct { - // Fetch is a method that provides the data for the loader - Fetch func(keys []int) ([][]Order, []error) - - // Wait is how long wait before sending a batch - Wait time.Duration - - // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit - MaxBatch int -} - -// NewOrderSliceLoader creates a new OrderSliceLoader given a fetch, wait, and maxBatch -func NewOrderSliceLoader(config OrderSliceLoaderConfig) *OrderSliceLoader { - return &OrderSliceLoader{ - fetch: config.Fetch, - wait: config.Wait, - maxBatch: config.MaxBatch, - } -} - // OrderSliceLoader batches and caches requests type OrderSliceLoader struct { // this method provides the data for the loader diff --git a/example/scalars/generated.go b/example/scalars/generated.go index 5e422d3e5f8..31002a068fc 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -18,6 +18,396 @@ import ( "github.com/vektah/gqlparser/ast" ) +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Query() QueryResolver + User() UserResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + Address struct { + Id func(childComplexity int) int + Location func(childComplexity int) int + } + + Query struct { + User func(childComplexity int, id external.ObjectID) int + Search func(childComplexity int, input *model.SearchArgs) int + } + + User struct { + Id func(childComplexity int) int + Name func(childComplexity int) int + Created func(childComplexity int) int + IsBanned func(childComplexity int) int + PrimitiveResolver func(childComplexity int) int + CustomResolver func(childComplexity int) int + Address func(childComplexity int) int + Tier func(childComplexity int) int + } +} + +type QueryResolver interface { + User(ctx context.Context, id external.ObjectID) (*model.User, error) + Search(ctx context.Context, input *model.SearchArgs) ([]model.User, error) +} +type UserResolver interface { + PrimitiveResolver(ctx context.Context, obj *model.User) (string, error) + CustomResolver(ctx context.Context, obj *model.User) (model.Point, error) +} + +type executableSchema struct { + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + switch typeName + "." + field { + + case "Address.id": + if e.complexity.Address.Id == nil { + break + } + + return e.complexity.Address.Id(childComplexity), true + + case "Address.location": + if e.complexity.Address.Location == nil { + break + } + + return e.complexity.Address.Location(childComplexity), true + + case "Query.user": + if e.complexity.Query.User == nil { + break + } + + args, err := e.field_Query_user_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.User(childComplexity, args["id"].(external.ObjectID)), true + + case "Query.search": + if e.complexity.Query.Search == nil { + break + } + + args, err := e.field_Query_search_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Search(childComplexity, args["input"].(*model.SearchArgs)), true + + case "User.id": + if e.complexity.User.Id == nil { + break + } + + return e.complexity.User.Id(childComplexity), true + + case "User.name": + if e.complexity.User.Name == nil { + break + } + + return e.complexity.User.Name(childComplexity), true + + case "User.created": + if e.complexity.User.Created == nil { + break + } + + return e.complexity.User.Created(childComplexity), true + + case "User.isBanned": + if e.complexity.User.IsBanned == nil { + break + } + + return e.complexity.User.IsBanned(childComplexity), true + + case "User.primitiveResolver": + if e.complexity.User.PrimitiveResolver == nil { + break + } + + return e.complexity.User.PrimitiveResolver(childComplexity), true + + case "User.customResolver": + if e.complexity.User.CustomResolver == nil { + break + } + + return e.complexity.User.CustomResolver(childComplexity), true + + case "User.address": + if e.complexity.User.Address == nil { + break + } + + return e.complexity.User.Address(childComplexity), true + + case "User.tier": + if e.complexity.User.Tier == nil { + break + } + + return e.complexity.User.Tier(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._Query(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() + }) + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions} +} + +func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + return graphql.ErrorResponse(ctx, "mutations are not supported") +} + +func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { + return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) +} + +type executionContext struct { + *graphql.RequestContext + *executableSchema +} + +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + res, err := ec.ResolverMiddleware(ctx, next) + if err != nil { + ec.Error(ctx, err) + return nil + } + return res +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(parsedSchema), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil +} + +var parsedSchema = gqlparser.MustLoadSchema( + &ast.Source{Name: "schema.graphql", Input: `type Query { + user(id: ID!): User + search(input: SearchArgs = {location: "37,144", isBanned: false}): [User!]! +} + +type User { + id: ID! + name: String! + created: Timestamp + isBanned: Banned! + primitiveResolver: String! + customResolver: Point! + address: Address + tier: Tier +} + +type Address { + id: ID! + location: Point +} + +input SearchArgs { + location: Point + createdAfter: Timestamp + isBanned: Banned # TODO: This can be a Boolean again once multiple backing types are allowed +} + +enum Tier { + A + B + C +} + +scalar Timestamp +scalar Point +scalar Banned +`}, +) + +// ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + + } + return handleFunc[0](ctx, chainHandler) + } + } + + if n == 1 { + return handleFunc[0] + } + + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) + } +} + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg0 + return args, nil +} + +func (e *executableSchema) field_Query_search_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *model.SearchArgs + if tmp, ok := rawArgs["input"]; ok { + var err error + var ptr1 model.SearchArgs + if tmp != nil { + ptr1, err = UnmarshalSearchArgs(tmp) + arg0 = &ptr1 + } + + if err != nil { + return nil, err + } + + if arg0 != nil { + var err error + arg0, err = e.SearchArgsMiddleware(ctx, arg0) + if err != nil { + return nil, err + } + } + } + args["input"] = arg0 + return args, nil +} + +func (e *executableSchema) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 external.ObjectID + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = model.UnmarshalID(tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + return args, nil +} + +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil +} + +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil +} + +// endregion ***************************** args.gotpl ***************************** + // region **************************** field.gotpl ***************************** // nolint: vetshadow @@ -206,229 +596,45 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Schema) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Schema(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(external.ObjectID) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return model.MarshalID(res) -} - -// nolint: vetshadow -func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) _User_created(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Created, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(time.Time) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return model.MarshalTimestamp(res) -} - -// nolint: vetshadow -func (ec *executionContext) _User_isBanned(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsBanned, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(model.Banned) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return res -} - -// nolint: vetshadow -func (ec *executionContext) _User_primitiveResolver(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.User().PrimitiveResolver(rctx, obj) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) _User_customResolver(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.User().CustomResolver(rctx, obj) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(model.Point) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return res + + if res == nil { + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) _User_address(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "User", + Object: "Query", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Address, nil + return ec.introspectSchema() }) if resTmp == nil { return graphql.Null } - res := resTmp.(model.Address) + res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec._Address(ctx, field.Selections, &res) + if res == nil { + return graphql.Null + } + + return ec.___Schema(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) _User_tier(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { +func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -440,23 +646,26 @@ func (ec *executionContext) _User_tier(ctx context.Context, field graphql.Collec ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Tier, nil + return obj.ID, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(model.Tier) + res := resTmp.(external.ObjectID) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return res + return model.MarshalID(res) } // nolint: vetshadow -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "User", Field: field, Args: nil, } @@ -479,11 +688,11 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql } // nolint: vetshadow -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) _User_created(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "User", Field: field, Args: nil, } @@ -491,23 +700,23 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.Created, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(time.Time) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return model.MarshalTimestamp(res) } // nolint: vetshadow -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) _User_isBanned(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "User", Field: field, Args: nil, } @@ -515,7 +724,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Locations, nil + return obj.IsBanned, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -523,27 +732,18 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr } return graphql.Null } - res := resTmp.([]string) + res := resTmp.(model.Banned) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 + return res } // nolint: vetshadow -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) _User_primitiveResolver(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "User", Field: field, Args: nil, } @@ -551,7 +751,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Args, nil + return ec.resolvers.User().PrimitiveResolver(rctx, obj) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -559,51 +759,18 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _User_customResolver(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "User", Field: field, Args: nil, } @@ -611,7 +778,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return ec.resolvers.User().CustomResolver(rctx, obj) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -619,18 +786,18 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(string) + res := resTmp.(model.Point) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return res } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _User_address(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "User", Field: field, Args: nil, } @@ -638,23 +805,24 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.Address, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(model.Address) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + return ec._Address(ctx, field.Selections, &res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _User_tier(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "User", Field: field, Args: nil, } @@ -662,26 +830,23 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.Tier, nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(model.Tier) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return res } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "__Directive", Field: field, Args: nil, } @@ -689,27 +854,26 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.Name, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Directive", Field: field, Args: nil, } @@ -717,12 +881,9 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Description, nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } res := resTmp.(string) @@ -732,11 +893,11 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Directive", Field: field, Args: nil, } @@ -744,23 +905,35 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.Locations, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + arr1 := make(graphql.Array, len(res)) + + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { + return graphql.MarshalString(res[idx1]) + }() + } + + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Directive", Field: field, Args: nil, } @@ -816,46 +989,11 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Type, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__EnumValue", Field: field, Args: nil, } @@ -863,7 +1001,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -871,18 +1009,18 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__EnumValue", Field: field, Args: nil, } @@ -890,27 +1028,23 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.Description, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__EnumValue", Field: field, Args: nil, } @@ -918,7 +1052,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.IsDeprecated(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -926,18 +1060,18 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(string) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__EnumValue", Field: field, Args: nil, } @@ -945,23 +1079,27 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.DeprecationReason(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Field", Field: field, Args: nil, } @@ -969,7 +1107,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -977,26 +1115,18 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Field", Field: field, Args: nil, } @@ -1004,27 +1134,23 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil + return obj.Description, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Field", Field: field, Args: nil, } @@ -1032,7 +1158,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Types(), nil + return obj.Args, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1040,7 +1166,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1065,7 +1191,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } arr1[idx1] = func() graphql.Marshaler { - return ec.___Type(ctx, field.Selections, &res[idx1]) + return ec.___InputValue(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1080,11 +1206,11 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } // nolint: vetshadow -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Field", Field: field, Args: nil, } @@ -1092,7 +1218,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil + return obj.Type, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1115,11 +1241,11 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } // nolint: vetshadow -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Field", Field: field, Args: nil, } @@ -1127,28 +1253,26 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil + return obj.IsDeprecated(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Field", Field: field, Args: nil, } @@ -1156,28 +1280,27 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil + return obj.DeprecationReason(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { return graphql.Null } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__InputValue", Field: field, Args: nil, } @@ -1185,7 +1308,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1193,51 +1316,18 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap } return graphql.Null } - res := resTmp.([]introspection.Directive) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Directive(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__InputValue", Field: field, Args: nil, } @@ -1245,12 +1335,9 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil + return obj.Description, nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } res := resTmp.(string) @@ -1260,11 +1347,11 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll } // nolint: vetshadow -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__InputValue", Field: field, Args: nil, } @@ -1272,27 +1359,34 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name(), nil + return obj.Type, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - return graphql.MarshalString(*res) + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__InputValue", Field: field, Args: nil, } @@ -1300,43 +1394,43 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.DefaultValue, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_fields_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Fields(args["includeDeprecated"].(bool)), nil + return obj.Types(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.Field) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1361,7 +1455,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } arr1[idx1] = func() graphql.Marshaler { - return ec.___Field(ctx, field.Selections, &res[idx1]) + return ec.___Type(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1376,11 +1470,11 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } // nolint: vetshadow -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } @@ -1388,56 +1482,34 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil + return obj.QueryType(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } - + return graphql.Null } - wg.Wait() - return arr1 + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } @@ -1445,120 +1517,57 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil + return obj.MutationType(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) + if res == nil { + return graphql.Null } - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_enumValues_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.EnumValues(args["includeDeprecated"].(bool)), nil + return obj.SubscriptionType(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.EnumValue) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) + if res == nil { + return graphql.Null } - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } @@ -1566,12 +1575,15 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil + return obj.Directives(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1596,7 +1608,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph } arr1[idx1] = func() graphql.Marshaler { - return ec.___InputValue(ctx, field.Selections, &res[idx1]) + return ec.___Directive(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1611,7 +1623,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph } // nolint: vetshadow -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1623,414 +1635,401 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil + return obj.Kind(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// endregion **************************** field.gotpl ***************************** - -// region ************************** generated.gotpl *************************** - -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } -} - -type Config struct { - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot -} - -type ResolverRoot interface { - Query() QueryResolver - User() UserResolver -} - -type DirectiveRoot struct { -} - -type ComplexityRoot struct { - Address struct { - Id func(childComplexity int) int - Location func(childComplexity int) int - } - - Query struct { - User func(childComplexity int, id external.ObjectID) int - Search func(childComplexity int, input *model.SearchArgs) int - } - - User struct { - Id func(childComplexity int) int - Name func(childComplexity int) int - Created func(childComplexity int) int - IsBanned func(childComplexity int) int - PrimitiveResolver func(childComplexity int) int - CustomResolver func(childComplexity int) int - Address func(childComplexity int) int - Tier func(childComplexity int) int - } -} - -type QueryResolver interface { - User(ctx context.Context, id external.ObjectID) (*model.User, error) - Search(ctx context.Context, input *model.SearchArgs) ([]model.User, error) -} -type UserResolver interface { - PrimitiveResolver(ctx context.Context, obj *model.User) (string, error) - CustomResolver(ctx context.Context, obj *model.User) (model.Point, error) -} - -func (e *executableSchema) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 external.ObjectID - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = model.UnmarshalID(tmp) - if err != nil { - return nil, err - } - } - args["id"] = arg0 - return args, nil - -} - -func (e *executableSchema) field_Query_search_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *model.SearchArgs - if tmp, ok := rawArgs["input"]; ok { - var err error - var ptr1 model.SearchArgs - if tmp != nil { - ptr1, err = UnmarshalSearchArgs(tmp) - arg0 = &ptr1 - } - - if err != nil { - return nil, err - } - - if arg0 != nil { - var err error - arg0, err = e.SearchArgsMiddleware(ctx, arg0) - if err != nil { - return nil, err - } - } - } - args["input"] = arg0 - return args, nil - + return graphql.MarshalString(res) } -func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, } - args["name"] = arg0 - return args, nil - -} - -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name(), nil + }) + if resTmp == nil { + return graphql.Null } - args["includeDeprecated"] = arg0 - return args, nil - -} + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } + if res == nil { + return graphql.Null } - args["includeDeprecated"] = arg0 - return args, nil - -} - -type executableSchema struct { - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot + return graphql.MarshalString(*res) } -func (e *executableSchema) Schema() *ast.Schema { - return parsedSchema +// nolint: vetshadow +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - switch typeName + "." + field { +// nolint: vetshadow +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_fields_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(args["includeDeprecated"].(bool)), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - case "Address.id": - if e.complexity.Address.Id == nil { - break - } + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - return e.complexity.Address.Id(childComplexity), true + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - case "Address.location": - if e.complexity.Address.Location == nil { - break + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.Address.Location(childComplexity), true - - case "Query.user": - if e.complexity.Query.User == nil { - break + return ec.___Field(ctx, field.Selections, &res[idx1]) + }() } - - args, err := e.field_Query_user_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.Query.User(childComplexity, args["id"].(external.ObjectID)), true + } + wg.Wait() + return arr1 +} - case "Query.search": - if e.complexity.Query.Search == nil { - break - } +// nolint: vetshadow +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - args, err := e.field_Query_search_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - return e.complexity.Query.Search(childComplexity, args["input"].(*model.SearchArgs)), true + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - case "User.id": - if e.complexity.User.Id == nil { - break + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.User.Id(childComplexity), true - - case "User.name": - if e.complexity.User.Name == nil { - break + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() } - - return e.complexity.User.Name(childComplexity), true - - case "User.created": - if e.complexity.User.Created == nil { - break + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.User.Created(childComplexity), true - - case "User.isBanned": - if e.complexity.User.IsBanned == nil { - break - } + } + wg.Wait() + return arr1 +} - return e.complexity.User.IsBanned(childComplexity), true +// nolint: vetshadow +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - case "User.primitiveResolver": - if e.complexity.User.PrimitiveResolver == nil { - break - } + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - return e.complexity.User.PrimitiveResolver(childComplexity), true + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - case "User.customResolver": - if e.complexity.User.CustomResolver == nil { - break + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.User.CustomResolver(childComplexity), true - - case "User.address": - if e.complexity.User.Address == nil { - break + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() } - - return e.complexity.User.Address(childComplexity), true - - case "User.tier": - if e.complexity.User.Tier == nil { - break + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.User.Tier(childComplexity), true - } - return 0, false + wg.Wait() + return arr1 } -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() +// nolint: vetshadow +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions} -} - -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - return graphql.ErrorResponse(ctx, "mutations are not supported") -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) -} + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } -type executionContext struct { - *graphql.RequestContext - *executableSchema -} + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { -func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil + return ec.___EnumValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) } - }() - res, err := ec.ResolverMiddleware(ctx, next) - if err != nil { - ec.Error(ctx, err) - return nil - } - return res -} -func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") } - return introspection.WrapSchema(parsedSchema), nil + wg.Wait() + return arr1 } -func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") +// nolint: vetshadow +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil -} + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -var parsedSchema = gqlparser.MustLoadSchema( - &ast.Source{Name: "schema.graphql", Input: `type Query { - user(id: ID!): User - search(input: SearchArgs = {location: "37,144", isBanned: false}): [User!]! -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -type User { - id: ID! - name: String! - created: Timestamp - isBanned: Banned! - primitiveResolver: String! - customResolver: Point! - address: Address - tier: Tier -} + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } -type Address { - id: ID! - location: Point -} + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { -input SearchArgs { - location: Point - createdAfter: Timestamp - isBanned: Banned # TODO: This can be a Boolean again once multiple backing types are allowed -} + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } -enum Tier { - A - B - C + } + wg.Wait() + return arr1 } -scalar Timestamp -scalar Point -scalar Banned -`}, -) - -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) - - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err - - } - return handleFunc[0](ctx, chainHandler) - } +// nolint: vetshadow +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, } - - if n == 1 { - return handleFunc[0] + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if resTmp == nil { + return graphql.Null } + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) + if res == nil { + return graphql.Null } + + return ec.___Type(ctx, field.Selections, res) } -// endregion ************************** generated.gotpl *************************** +// endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** diff --git a/example/scalars/model/generated.go b/example/scalars/model/generated.go index 3330e525b55..2ee63fc8aba 100644 --- a/example/scalars/model/generated.go +++ b/example/scalars/model/generated.go @@ -1,3 +1,5 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + package model import ( diff --git a/example/selection/generated.go b/example/selection/generated.go index a8040ac8e1d..6663f40235f 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -17,6 +17,303 @@ import ( "github.com/vektah/gqlparser/ast" ) +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Query() QueryResolver +} + +type DirectiveRoot struct { +} + +type ComplexityRoot struct { + Like struct { + Reaction func(childComplexity int) int + Sent func(childComplexity int) int + Selection func(childComplexity int) int + Collected func(childComplexity int) int + } + + Post struct { + Message func(childComplexity int) int + Sent func(childComplexity int) int + Selection func(childComplexity int) int + Collected func(childComplexity int) int + } + + Query struct { + Events func(childComplexity int) int + } +} + +type QueryResolver interface { + Events(ctx context.Context) ([]Event, error) +} + +type executableSchema struct { + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + switch typeName + "." + field { + + case "Like.reaction": + if e.complexity.Like.Reaction == nil { + break + } + + return e.complexity.Like.Reaction(childComplexity), true + + case "Like.sent": + if e.complexity.Like.Sent == nil { + break + } + + return e.complexity.Like.Sent(childComplexity), true + + case "Like.selection": + if e.complexity.Like.Selection == nil { + break + } + + return e.complexity.Like.Selection(childComplexity), true + + case "Like.collected": + if e.complexity.Like.Collected == nil { + break + } + + return e.complexity.Like.Collected(childComplexity), true + + case "Post.message": + if e.complexity.Post.Message == nil { + break + } + + return e.complexity.Post.Message(childComplexity), true + + case "Post.sent": + if e.complexity.Post.Sent == nil { + break + } + + return e.complexity.Post.Sent(childComplexity), true + + case "Post.selection": + if e.complexity.Post.Selection == nil { + break + } + + return e.complexity.Post.Selection(childComplexity), true + + case "Post.collected": + if e.complexity.Post.Collected == nil { + break + } + + return e.complexity.Post.Collected(childComplexity), true + + case "Query.events": + if e.complexity.Query.Events == nil { + break + } + + return e.complexity.Query.Events(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._Query(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() + }) + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions} +} + +func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + return graphql.ErrorResponse(ctx, "mutations are not supported") +} + +func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { + return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) +} + +type executionContext struct { + *graphql.RequestContext + *executableSchema +} + +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + res, err := ec.ResolverMiddleware(ctx, next) + if err != nil { + ec.Error(ctx, err) + return nil + } + return res +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(parsedSchema), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil +} + +var parsedSchema = gqlparser.MustLoadSchema( + &ast.Source{Name: "schema.graphql", Input: `interface Event { + selection: [String!] + collected: [String!] +} + +type Post implements Event { + message: String! + sent: Time! + selection: [String!] + collected: [String!] +} + +type Like implements Event { + reaction: String! + sent: Time! + selection: [String!] + collected: [String!] +} + +type Query { + events: [Event!] +} + +scalar Time +`}, +) + +// ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + + } + return handleFunc[0](ctx, chainHandler) + } + } + + if n == 1 { + return handleFunc[0] + } + + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) + } +} + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg0 + return args, nil +} + +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil +} + +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil +} + +// endregion ***************************** args.gotpl ***************************** + // region **************************** field.gotpl ***************************** // nolint: vetshadow @@ -1206,164 +1503,19 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll }) if resTmp == nil { return graphql.Null - } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_fields_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Fields(args["includeDeprecated"].(bool)), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Field) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Field(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + if res == nil { + return graphql.Null } - wg.Wait() - return arr1 + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1375,52 +1527,19 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil + return obj.Description(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1430,7 +1549,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_enumValues_args(ctx, rawArgs) + args, err := ec.field___Type_fields_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -1439,12 +1558,12 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.EnumValues(args["includeDeprecated"].(bool)), nil + return obj.Fields(args["includeDeprecated"].(bool)), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.EnumValue) + res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1469,7 +1588,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } arr1[idx1] = func() graphql.Marshaler { - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) + return ec.___Field(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1484,7 +1603,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } // nolint: vetshadow -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1496,12 +1615,12 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil + return obj.Interfaces(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1526,7 +1645,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph } arr1[idx1] = func() graphql.Marshaler { - return ec.___InputValue(ctx, field.Selections, &res[idx1]) + return ec.___Type(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1541,7 +1660,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph } // nolint: vetshadow -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1553,319 +1672,201 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil + return obj.PossibleTypes(), nil }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// endregion **************************** field.gotpl ***************************** - -// region ************************** generated.gotpl *************************** - -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } -} - -type Config struct { - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot -} - -type ResolverRoot interface { - Query() QueryResolver -} - -type DirectiveRoot struct { -} - -type ComplexityRoot struct { - Like struct { - Reaction func(childComplexity int) int - Sent func(childComplexity int) int - Selection func(childComplexity int) int - Collected func(childComplexity int) int - } - - Post struct { - Message func(childComplexity int) int - Sent func(childComplexity int) int - Selection func(childComplexity int) int - Collected func(childComplexity int) int - } - - Query struct { - Events func(childComplexity int) int - } -} - -type QueryResolver interface { - Events(ctx context.Context) ([]Event, error) -} - -func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - } - args["name"] = arg0 - return args, nil - -} - -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil - -} - -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil - -} - -type executableSchema struct { - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot -} - -func (e *executableSchema) Schema() *ast.Schema { - return parsedSchema -} - -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - switch typeName + "." + field { - - case "Like.reaction": - if e.complexity.Like.Reaction == nil { - break - } - - return e.complexity.Like.Reaction(childComplexity), true - - case "Like.sent": - if e.complexity.Like.Sent == nil { - break - } - - return e.complexity.Like.Sent(childComplexity), true - - case "Like.selection": - if e.complexity.Like.Selection == nil { - break - } - - return e.complexity.Like.Selection(childComplexity), true - - case "Like.collected": - if e.complexity.Like.Collected == nil { - break - } - - return e.complexity.Like.Collected(childComplexity), true - - case "Post.message": - if e.complexity.Post.Message == nil { - break - } - - return e.complexity.Post.Message(childComplexity), true - - case "Post.sent": - if e.complexity.Post.Sent == nil { - break - } - - return e.complexity.Post.Sent(childComplexity), true - - case "Post.selection": - if e.complexity.Post.Selection == nil { - break - } - - return e.complexity.Post.Selection(childComplexity), true - - case "Post.collected": - if e.complexity.Post.Collected == nil { - break - } - - return e.complexity.Post.Collected(childComplexity), true - - case "Query.events": - if e.complexity.Query.Events == nil { - break - } - - return e.complexity.Query.Events(childComplexity), true - + if resTmp == nil { + return graphql.Null } - return 0, false -} - -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} + res := resTmp.([]introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions} -} + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - return graphql.ErrorResponse(ctx, "mutations are not supported") -} + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) -} + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } -type executionContext struct { - *graphql.RequestContext - *executableSchema + } + wg.Wait() + return arr1 } -func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - res, err := ec.ResolverMiddleware(ctx, next) +// nolint: vetshadow +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) - return nil + return graphql.Null } - return res -} - -func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(args["includeDeprecated"].(bool)), nil + }) + if resTmp == nil { + return graphql.Null } - return introspection.WrapSchema(parsedSchema), nil -} + res := resTmp.([]introspection.EnumValue) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") - } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -var parsedSchema = gqlparser.MustLoadSchema( - &ast.Source{Name: "schema.graphql", Input: `interface Event { - selection: [String!] - collected: [String!] -} + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } -type Post implements Event { - message: String! - sent: Time! - selection: [String!] - collected: [String!] -} + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { -type Like implements Event { - reaction: String! - sent: Time! - selection: [String!] - collected: [String!] -} + return ec.___EnumValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } -type Query { - events: [Event!] + } + wg.Wait() + return arr1 } -scalar Time -`}, -) +// nolint: vetshadow +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() } - return handleFunc[0](ctx, chainHandler) + arr1[idx1] = func() graphql.Marshaler { + + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) } + } + wg.Wait() + return arr1 +} - if n == 1 { - return handleFunc[0] +// nolint: vetshadow +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if resTmp == nil { + return graphql.Null } + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) + if res == nil { + return graphql.Null } + + return ec.___Type(ctx, field.Selections, res) } -// endregion ************************** generated.gotpl *************************** +// endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** diff --git a/example/selection/models_gen.go b/example/selection/models_gen.go index 4a194b0d638..a8183a3cbe0 100644 --- a/example/selection/models_gen.go +++ b/example/selection/models_gen.go @@ -1,3 +1,5 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + package selection import ( diff --git a/example/starwars/generated.go b/example/starwars/generated.go index 13859be80e8..8fd27e66cf4 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -17,1438 +17,1017 @@ import ( "github.com/vektah/gqlparser/ast" ) -// region **************************** field.gotpl ***************************** +// region ************************** generated!.gotpl ************************** -// nolint: vetshadow -func (ec *executionContext) _Droid_id(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Droid", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) } -// nolint: vetshadow -func (ec *executionContext) _Droid_name(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Droid", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) +type Config struct { + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot } -// nolint: vetshadow -func (ec *executionContext) _Droid_friends(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Droid", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Droid().Friends(rctx, obj) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]Character) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +type ResolverRoot interface { + Droid() DroidResolver + FriendsConnection() FriendsConnectionResolver + Human() HumanResolver + Mutation() MutationResolver + Query() QueryResolver + Starship() StarshipResolver +} - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup +type DirectiveRoot struct { +} - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) +type ComplexityRoot struct { + Droid struct { + Id func(childComplexity int) int + Name func(childComplexity int) int + Friends func(childComplexity int) int + FriendsConnection func(childComplexity int, first *int, after *string) int + AppearsIn func(childComplexity int) int + PrimaryFunction func(childComplexity int) int } - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._Character(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - + FriendsConnection struct { + TotalCount func(childComplexity int) int + Edges func(childComplexity int) int + Friends func(childComplexity int) int + PageInfo func(childComplexity int) int } - wg.Wait() - return arr1 -} -// nolint: vetshadow -func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Droid", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Droid_friendsConnection_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Droid().FriendsConnection(rctx, obj, args["first"].(*int), args["after"].(*string)) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null + FriendsEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int } - res := resTmp.(FriendsConnection) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._FriendsConnection(ctx, field.Selections, &res) -} -// nolint: vetshadow -func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Droid", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.AppearsIn, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null + Human struct { + Id func(childComplexity int) int + Name func(childComplexity int) int + Height func(childComplexity int, unit LengthUnit) int + Mass func(childComplexity int) int + Friends func(childComplexity int) int + FriendsConnection func(childComplexity int, first *int, after *string) int + AppearsIn func(childComplexity int) int + Starships func(childComplexity int) int } - res := resTmp.([]Episode) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) + Mutation struct { + CreateReview func(childComplexity int, episode Episode, review Review) int + } - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return res[idx1] - }() + PageInfo struct { + StartCursor func(childComplexity int) int + EndCursor func(childComplexity int) int + HasNextPage func(childComplexity int) int } - return arr1 -} + Query struct { + Hero func(childComplexity int, episode *Episode) int + Reviews func(childComplexity int, episode Episode, since *time.Time) int + Search func(childComplexity int, text string) int + Character func(childComplexity int, id string) int + Droid func(childComplexity int, id string) int + Human func(childComplexity int, id string) int + Starship func(childComplexity int, id string) int + } -// nolint: vetshadow -func (ec *executionContext) _Droid_primaryFunction(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Droid", - Field: field, - Args: nil, + Review struct { + Stars func(childComplexity int) int + Commentary func(childComplexity int) int + Time func(childComplexity int) int } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PrimaryFunction, nil - }) - if resTmp == nil { - return graphql.Null + + Starship struct { + Id func(childComplexity int) int + Name func(childComplexity int) int + Length func(childComplexity int, unit *LengthUnit) int + History func(childComplexity int) int } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) } -// nolint: vetshadow -func (ec *executionContext) _FriendsConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "FriendsConnection", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.TotalCount(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) +type DroidResolver interface { + Friends(ctx context.Context, obj *Droid) ([]Character, error) + FriendsConnection(ctx context.Context, obj *Droid, first *int, after *string) (FriendsConnection, error) +} +type FriendsConnectionResolver interface { + Edges(ctx context.Context, obj *FriendsConnection) ([]FriendsEdge, error) + Friends(ctx context.Context, obj *FriendsConnection) ([]Character, error) } +type HumanResolver interface { + Friends(ctx context.Context, obj *Human) ([]Character, error) + FriendsConnection(ctx context.Context, obj *Human, first *int, after *string) (FriendsConnection, error) -// nolint: vetshadow -func (ec *executionContext) _FriendsConnection_edges(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "FriendsConnection", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.FriendsConnection().Edges(rctx, obj) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]FriendsEdge) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + Starships(ctx context.Context, obj *Human) ([]Starship, error) +} +type MutationResolver interface { + CreateReview(ctx context.Context, episode Episode, review Review) (*Review, error) +} +type QueryResolver interface { + Hero(ctx context.Context, episode *Episode) (Character, error) + Reviews(ctx context.Context, episode Episode, since *time.Time) ([]Review, error) + Search(ctx context.Context, text string) ([]SearchResult, error) + Character(ctx context.Context, id string) (Character, error) + Droid(ctx context.Context, id string) (*Droid, error) + Human(ctx context.Context, id string) (*Human, error) + Starship(ctx context.Context, id string) (*Starship, error) +} +type StarshipResolver interface { + Length(ctx context.Context, obj *Starship, unit *LengthUnit) (float64, error) +} - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup +type executableSchema struct { + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } +func (e *executableSchema) Schema() *ast.Schema { + return parsedSchema +} - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + switch typeName + "." + field { + + case "Droid.id": + if e.complexity.Droid.Id == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec._FriendsEdge(ctx, field.Selections, &res[idx1]) - }() + return e.complexity.Droid.Id(childComplexity), true + + case "Droid.name": + if e.complexity.Droid.Name == nil { + break } - if isLen1 { - f(idx1) - } else { - go f(idx1) + + return e.complexity.Droid.Name(childComplexity), true + + case "Droid.friends": + if e.complexity.Droid.Friends == nil { + break } - } - wg.Wait() - return arr1 -} + return e.complexity.Droid.Friends(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) _FriendsConnection_friends(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "FriendsConnection", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.FriendsConnection().Friends(rctx, obj) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]Character) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + case "Droid.friendsConnection": + if e.complexity.Droid.FriendsConnection == nil { + break + } - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + args, err := e.field_Droid_friendsConnection_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } + return e.complexity.Droid.FriendsConnection(childComplexity, args["first"].(*int), args["after"].(*string)), true - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + case "Droid.appearsIn": + if e.complexity.Droid.AppearsIn == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec._Character(ctx, field.Selections, &res[idx1]) - }() + return e.complexity.Droid.AppearsIn(childComplexity), true + + case "Droid.primaryFunction": + if e.complexity.Droid.PrimaryFunction == nil { + break } - if isLen1 { - f(idx1) - } else { - go f(idx1) + + return e.complexity.Droid.PrimaryFunction(childComplexity), true + + case "FriendsConnection.totalCount": + if e.complexity.FriendsConnection.TotalCount == nil { + break } - } - wg.Wait() - return arr1 -} + return e.complexity.FriendsConnection.TotalCount(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) _FriendsConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "FriendsConnection", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.PageInfo(), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + case "FriendsConnection.edges": + if e.complexity.FriendsConnection.Edges == nil { + break } - return graphql.Null - } - res := resTmp.(PageInfo) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec._PageInfo(ctx, field.Selections, &res) -} + return e.complexity.FriendsConnection.Edges(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) _FriendsEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *FriendsEdge) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "FriendsEdge", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Cursor, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + case "FriendsConnection.friends": + if e.complexity.FriendsConnection.Friends == nil { + break } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) -} -// nolint: vetshadow -func (ec *executionContext) _FriendsEdge_node(ctx context.Context, field graphql.CollectedField, obj *FriendsEdge) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "FriendsEdge", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Node, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(Character) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._Character(ctx, field.Selections, &res) -} + return e.complexity.FriendsConnection.Friends(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) _Human_id(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Human", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + case "FriendsConnection.pageInfo": + if e.complexity.FriendsConnection.PageInfo == nil { + break } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) -} -// nolint: vetshadow -func (ec *executionContext) _Human_name(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Human", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + return e.complexity.FriendsConnection.PageInfo(childComplexity), true + + case "FriendsEdge.cursor": + if e.complexity.FriendsEdge.Cursor == nil { + break } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} -// nolint: vetshadow -func (ec *executionContext) _Human_height(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Human", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Human_height_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Height(args["unit"].(LengthUnit)), nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + return e.complexity.FriendsEdge.Cursor(childComplexity), true + + case "FriendsEdge.node": + if e.complexity.FriendsEdge.Node == nil { + break } - return graphql.Null - } - res := resTmp.(float64) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) -} -// nolint: vetshadow -func (ec *executionContext) _Human_mass(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Human", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Mass, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(float64) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) -} + return e.complexity.FriendsEdge.Node(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Human", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Human().Friends(rctx, obj) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]Character) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + case "Human.id": + if e.complexity.Human.Id == nil { + break + } - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + return e.complexity.Human.Id(childComplexity), true - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } + case "Human.name": + if e.complexity.Human.Name == nil { + break + } - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + return e.complexity.Human.Name(childComplexity), true + + case "Human.height": + if e.complexity.Human.Height == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec._Character(ctx, field.Selections, &res[idx1]) - }() + args, err := e.field_Human_height_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - if isLen1 { - f(idx1) - } else { - go f(idx1) + + return e.complexity.Human.Height(childComplexity, args["unit"].(LengthUnit)), true + + case "Human.mass": + if e.complexity.Human.Mass == nil { + break } - } - wg.Wait() - return arr1 -} + return e.complexity.Human.Mass(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Human", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Human_friendsConnection_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Human().FriendsConnection(rctx, obj, args["first"].(*int), args["after"].(*string)) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + case "Human.friends": + if e.complexity.Human.Friends == nil { + break } - return graphql.Null - } - res := resTmp.(FriendsConnection) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec._FriendsConnection(ctx, field.Selections, &res) -} + return e.complexity.Human.Friends(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) _Human_appearsIn(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Human", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.AppearsIn, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + case "Human.friendsConnection": + if e.complexity.Human.FriendsConnection == nil { + break } - return graphql.Null - } - res := resTmp.([]Episode) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) + args, err := e.field_Human_friendsConnection_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return res[idx1] - }() - } + return e.complexity.Human.FriendsConnection(childComplexity, args["first"].(*int), args["after"].(*string)), true - return arr1 -} + case "Human.appearsIn": + if e.complexity.Human.AppearsIn == nil { + break + } -// nolint: vetshadow -func (ec *executionContext) _Human_starships(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Human", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Human().Starships(rctx, obj) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]Starship) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return e.complexity.Human.AppearsIn(childComplexity), true - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + case "Human.starships": + if e.complexity.Human.Starships == nil { + break + } - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } + return e.complexity.Human.Starships(childComplexity), true - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + case "Mutation.createReview": + if e.complexity.Mutation.CreateReview == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec._Starship(ctx, field.Selections, &res[idx1]) - }() + args, err := e.field_Mutation_createReview_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - if isLen1 { - f(idx1) - } else { - go f(idx1) + + return e.complexity.Mutation.CreateReview(childComplexity, args["episode"].(Episode), args["review"].(Review)), true + + case "PageInfo.startCursor": + if e.complexity.PageInfo.StartCursor == nil { + break } - } - wg.Wait() - return arr1 -} + return e.complexity.PageInfo.StartCursor(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) _Mutation_createReview(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Mutation", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_createReview_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateReview(rctx, args["episode"].(Episode), args["review"].(Review)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*Review) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + case "PageInfo.endCursor": + if e.complexity.PageInfo.EndCursor == nil { + break + } - if res == nil { - return graphql.Null - } + return e.complexity.PageInfo.EndCursor(childComplexity), true - return ec._Review(ctx, field.Selections, res) -} + case "PageInfo.hasNextPage": + if e.complexity.PageInfo.HasNextPage == nil { + break + } -// nolint: vetshadow -func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *PageInfo) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "PageInfo", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.StartCursor, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + return e.complexity.PageInfo.HasNextPage(childComplexity), true + + case "Query.hero": + if e.complexity.Query.Hero == nil { + break } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) -} -// nolint: vetshadow -func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *PageInfo) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "PageInfo", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.EndCursor, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + args, err := e.field_Query_hero_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) -} -// nolint: vetshadow -func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *PageInfo) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "PageInfo", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.HasNextPage, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + return e.complexity.Query.Hero(childComplexity, args["episode"].(*Episode)), true + + case "Query.reviews": + if e.complexity.Query.Reviews == nil { + break } - return graphql.Null - } - res := resTmp.(bool) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) -} -// nolint: vetshadow -func (ec *executionContext) _Query_hero(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_hero_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Hero(rctx, args["episode"].(*Episode)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(Character) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + args, err := e.field_Query_reviews_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } - return ec._Character(ctx, field.Selections, &res) -} + return e.complexity.Query.Reviews(childComplexity, args["episode"].(Episode), args["since"].(*time.Time)), true -// nolint: vetshadow -func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_reviews_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Reviews(rctx, args["episode"].(Episode), args["since"].(*time.Time)) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + case "Query.search": + if e.complexity.Query.Search == nil { + break } - return graphql.Null - } - res := resTmp.([]Review) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + args, err := e.field_Query_search_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } + return e.complexity.Query.Search(childComplexity, args["text"].(string)), true - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + case "Query.character": + if e.complexity.Query.Character == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec._Review(ctx, field.Selections, &res[idx1]) - }() + args, err := e.field_Query_character_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - if isLen1 { - f(idx1) - } else { - go f(idx1) + + return e.complexity.Query.Character(childComplexity, args["id"].(string)), true + + case "Query.droid": + if e.complexity.Query.Droid == nil { + break } - } - wg.Wait() - return arr1 -} + args, err := e.field_Query_droid_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } -// nolint: vetshadow -func (ec *executionContext) _Query_search(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_search_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Search(rctx, args["text"].(string)) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + return e.complexity.Query.Droid(childComplexity, args["id"].(string)), true + + case "Query.human": + if e.complexity.Query.Human == nil { + break } - return graphql.Null - } - res := resTmp.([]SearchResult) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + args, err := e.field_Query_human_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } + return e.complexity.Query.Human(childComplexity, args["id"].(string)), true - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], + case "Query.starship": + if e.complexity.Query.Starship == nil { + break } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - return ec._SearchResult(ctx, field.Selections, &res[idx1]) - }() + args, err := e.field_Query_starship_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - if isLen1 { - f(idx1) - } else { - go f(idx1) + + return e.complexity.Query.Starship(childComplexity, args["id"].(string)), true + + case "Review.stars": + if e.complexity.Review.Stars == nil { + break } - } - wg.Wait() - return arr1 -} + return e.complexity.Review.Stars(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) _Query_character(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_character_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Character(rctx, args["id"].(string)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(Character) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + case "Review.commentary": + if e.complexity.Review.Commentary == nil { + break + } - return ec._Character(ctx, field.Selections, &res) -} + return e.complexity.Review.Commentary(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) _Query_droid(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_droid_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Droid(rctx, args["id"].(string)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*Droid) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + case "Review.time": + if e.complexity.Review.Time == nil { + break + } - if res == nil { - return graphql.Null - } + return e.complexity.Review.Time(childComplexity), true - return ec._Droid(ctx, field.Selections, res) -} + case "Starship.id": + if e.complexity.Starship.Id == nil { + break + } -// nolint: vetshadow -func (ec *executionContext) _Query_human(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_human_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Human(rctx, args["id"].(string)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*Human) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return e.complexity.Starship.Id(childComplexity), true - if res == nil { - return graphql.Null - } + case "Starship.name": + if e.complexity.Starship.Name == nil { + break + } - return ec._Human(ctx, field.Selections, res) -} + return e.complexity.Starship.Name(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) _Query_starship(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_starship_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Starship(rctx, args["id"].(string)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*Starship) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + case "Starship.length": + if e.complexity.Starship.Length == nil { + break + } - if res == nil { - return graphql.Null - } + args, err := e.field_Starship_length_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } - return ec._Starship(ctx, field.Selections, res) -} + return e.complexity.Starship.Length(childComplexity, args["unit"].(*LengthUnit)), true -// nolint: vetshadow -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query___type_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectType(args["name"].(string)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + case "Starship.history": + if e.complexity.Starship.History == nil { + break + } + + return e.complexity.Starship.History(childComplexity), true - if res == nil { - return graphql.Null } + return 0, false +} - return ec.___Type(ctx, field.Selections, res) +func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._Query(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() + }) + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions} } -// nolint: vetshadow -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() +func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._Mutation(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Schema) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions, } +} - return ec.___Schema(ctx, field.Selections, res) +func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { + return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) } -// nolint: vetshadow -func (ec *executionContext) _Review_stars(ctx context.Context, field graphql.CollectedField, obj *Review) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Review", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Stars, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +type executionContext struct { + *graphql.RequestContext + *executableSchema +} + +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil } - return graphql.Null + }() + res, err := ec.ResolverMiddleware(ctx, next) + if err != nil { + ec.Error(ctx, err) + return nil } - res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) + return res } -// nolint: vetshadow -func (ec *executionContext) _Review_commentary(ctx context.Context, field graphql.CollectedField, obj *Review) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Review", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Commentary, nil - }) - if resTmp == nil { - return graphql.Null +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") } - res := resTmp.(*string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return introspection.WrapSchema(parsedSchema), nil +} - if res == nil { - return graphql.Null +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") } - return graphql.MarshalString(*res) + return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil } -// nolint: vetshadow -func (ec *executionContext) _Review_time(ctx context.Context, field graphql.CollectedField, obj *Review) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Review", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Time, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(time.Time) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalTime(res) +var parsedSchema = gqlparser.MustLoadSchema( + &ast.Source{Name: "schema.graphql", Input: `# The query type, represents all of the entry points into our object graph +type Query { + hero(episode: Episode = NEWHOPE): Character + reviews(episode: Episode!, since: Time): [Review!]! + search(text: String!): [SearchResult!]! + character(id: ID!): Character + droid(id: ID!): Droid + human(id: ID!): Human + starship(id: ID!): Starship +} +# The mutation type, represents all updates we can make to our data +type Mutation { + createReview(episode: Episode!, review: ReviewInput!): Review +} +# The episodes in the Star Wars trilogy +enum Episode { + # Star Wars Episode IV: A New Hope, released in 1977. + NEWHOPE + # Star Wars Episode V: The Empire Strikes Back, released in 1980. + EMPIRE + # Star Wars Episode VI: Return of the Jedi, released in 1983. + JEDI +} +# A character from the Star Wars universe +interface Character { + # The ID of the character + id: ID! + # The name of the character + name: String! + # The friends of the character, or an empty list if they have none + friends: [Character!] + # The friends of the character exposed as a connection with edges + friendsConnection(first: Int, after: ID): FriendsConnection! + # The movies this character appears in + appearsIn: [Episode!]! +} +# Units of height +enum LengthUnit { + # The standard unit around the world + METER + # Primarily used in the United States + FOOT +} +# A humanoid creature from the Star Wars universe +type Human implements Character { + # The ID of the human + id: ID! + # What this human calls themselves + name: String! + # Height in the preferred unit, default is meters + height(unit: LengthUnit = METER): Float! + # Mass in kilograms, or null if unknown + mass: Float + # This human's friends, or an empty list if they have none + friends: [Character!] + # The friends of the human exposed as a connection with edges + friendsConnection(first: Int, after: ID): FriendsConnection! + # The movies this human appears in + appearsIn: [Episode!]! + # A list of starships this person has piloted, or an empty list if none + starships: [Starship!] +} +# An autonomous mechanical character in the Star Wars universe +type Droid implements Character { + # The ID of the droid + id: ID! + # What others call this droid + name: String! + # This droid's friends, or an empty list if they have none + friends: [Character!] + # The friends of the droid exposed as a connection with edges + friendsConnection(first: Int, after: ID): FriendsConnection! + # The movies this droid appears in + appearsIn: [Episode!]! + # This droid's primary function + primaryFunction: String +} +# A connection object for a character's friends +type FriendsConnection { + # The total number of friends + totalCount: Int! + # The edges for each of the character's friends. + edges: [FriendsEdge!] + # A list of the friends, as a convenience when edges are not needed. + friends: [Character!] + # Information for paginating this connection + pageInfo: PageInfo! +} +# An edge object for a character's friends +type FriendsEdge { + # A cursor used for pagination + cursor: ID! + # The character represented by this friendship edge + node: Character +} +# Information for paginating this connection +type PageInfo { + startCursor: ID! + endCursor: ID! + hasNextPage: Boolean! +} +# Represents a review for a movie +type Review { + # The number of stars this review gave, 1-5 + stars: Int! + # Comment about the movie + commentary: String + # when the review was posted + time: Time +} +# The input object sent when someone is creating a new review +input ReviewInput { + # 0-5 stars + stars: Int! + # Comment about the movie, optional + commentary: String + # when the review was posted + time: Time +} +type Starship { + # The ID of the starship + id: ID! + # The name of the starship + name: String! + # Length of the starship, along the longest axis + length(unit: LengthUnit = METER): Float! + # coordinates tracking this ship + history: [[Int!]!]! +} +union SearchResult = Human | Droid | Starship +scalar Time +`}, +) + +// ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + + } + return handleFunc[0](ctx, chainHandler) + } + } + + if n == 1 { + return handleFunc[0] + } + + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) + } +} + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (e *executableSchema) field_Droid_friendsConnection_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *int + if tmp, ok := rawArgs["first"]; ok { + var err error + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + arg0 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["first"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + var err error + var ptr1 string + if tmp != nil { + ptr1, err = graphql.UnmarshalID(tmp) + arg1 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["after"] = arg1 + return args, nil +} + +func (e *executableSchema) field_Human_friendsConnection_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *int + if tmp, ok := rawArgs["first"]; ok { + var err error + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + arg0 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["first"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + var err error + var ptr1 string + if tmp != nil { + ptr1, err = graphql.UnmarshalID(tmp) + arg1 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["after"] = arg1 + return args, nil +} + +func (e *executableSchema) field_Human_height_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 LengthUnit + if tmp, ok := rawArgs["unit"]; ok { + var err error + err = (&arg0).UnmarshalGQL(tmp) + if err != nil { + return nil, err + } + } + args["unit"] = arg0 + return args, nil +} + +func (e *executableSchema) field_Mutation_createReview_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 Episode + if tmp, ok := rawArgs["episode"]; ok { + var err error + err = (&arg0).UnmarshalGQL(tmp) + if err != nil { + return nil, err + } + } + args["episode"] = arg0 + var arg1 Review + if tmp, ok := rawArgs["review"]; ok { + var err error + arg1, err = UnmarshalReviewInput(tmp) + if err != nil { + return nil, err + } + + mReviewInput1, err := e.ReviewInputMiddleware(ctx, &arg1) + if err != nil { + return nil, err + } + arg1 = *mReviewInput1 + } + args["review"] = arg1 + return args, nil } -// nolint: vetshadow -func (ec *executionContext) _Starship_id(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Starship", - Field: field, - Args: nil, +func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + args["name"] = arg0 + return args, nil +} + +func (e *executableSchema) field_Query_character_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = graphql.UnmarshalID(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + args["id"] = arg0 + return args, nil } -// nolint: vetshadow -func (ec *executionContext) _Starship_name(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Starship", - Field: field, - Args: nil, +func (e *executableSchema) field_Query_droid_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = graphql.UnmarshalID(tmp) + if err != nil { + return nil, err + } } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + args["id"] = arg0 + return args, nil +} + +func (e *executableSchema) field_Query_hero_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *Episode + if tmp, ok := rawArgs["episode"]; ok { + var err error + var ptr1 Episode + if tmp != nil { + err = (&ptr1).UnmarshalGQL(tmp) + arg0 = &ptr1 + } + + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + args["episode"] = arg0 + return args, nil } -// nolint: vetshadow -func (ec *executionContext) _Starship_length(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Starship", - Field: field, - Args: nil, +func (e *executableSchema) field_Query_human_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = graphql.UnmarshalID(tmp) + if err != nil { + return nil, err + } } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Starship_length_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null + args["id"] = arg0 + return args, nil +} + +func (e *executableSchema) field_Query_reviews_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 Episode + if tmp, ok := rawArgs["episode"]; ok { + var err error + err = (&arg0).UnmarshalGQL(tmp) + if err != nil { + return nil, err + } } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Starship().Length(rctx, obj, args["unit"].(*LengthUnit)) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + args["episode"] = arg0 + var arg1 *time.Time + if tmp, ok := rawArgs["since"]; ok { + var err error + var ptr1 time.Time + if tmp != nil { + ptr1, err = graphql.UnmarshalTime(tmp) + arg1 = &ptr1 + } + + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(float64) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) + args["since"] = arg1 + return args, nil } -// nolint: vetshadow -func (ec *executionContext) _Starship_history(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Starship", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.History, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +func (e *executableSchema) field_Query_search_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["text"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.([][]int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + args["text"] = arg0 + return args, nil +} - arr1 := make(graphql.Array, len(res)) +func (e *executableSchema) field_Query_starship_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = graphql.UnmarshalID(tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + return args, nil +} - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { +func (e *executableSchema) field_Starship_length_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *LengthUnit + if tmp, ok := rawArgs["unit"]; ok { + var err error + var ptr1 LengthUnit + if tmp != nil { + err = (&ptr1).UnmarshalGQL(tmp) + arg0 = &ptr1 + } - arr2 := make(graphql.Array, len(res[idx1])) + if err != nil { + return nil, err + } + } + args["unit"] = arg0 + return args, nil +} - for idx2 := range res[idx1] { - arr2[idx2] = func() graphql.Marshaler { - return graphql.MarshalInt(res[idx1][idx2]) - }() - } +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil +} - return arr2 - }() +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } } - - return arr1 + args["includeDeprecated"] = arg0 + return args, nil } +// endregion ***************************** args.gotpl ***************************** + +// region **************************** field.gotpl ***************************** + // nolint: vetshadow -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) _Droid_id(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "Droid", Field: field, Args: nil, } @@ -1456,7 +1035,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.ID, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1467,39 +1046,15 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return graphql.MarshalID(res) } // nolint: vetshadow -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) _Droid_name(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "Droid", Field: field, Args: nil, } @@ -1507,7 +1062,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Locations, nil + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1515,27 +1070,18 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr } return graphql.Null } - res := resTmp.([]string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) _Droid_friends(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "Droid", Field: field, Args: nil, } @@ -1543,15 +1089,12 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Args, nil + return ec.resolvers.Droid().Friends(rctx, obj) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.([]Character) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1576,7 +1119,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql } arr1[idx1] = func() graphql.Marshaler { - return ec.___InputValue(ctx, field.Selections, &res[idx1]) + return ec._Character(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1591,19 +1134,26 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "Droid", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Droid_friendsConnection_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return ec.resolvers.Droid().FriendsConnection(rctx, obj, args["first"].(*int), args["after"].(*string)) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1611,42 +1161,19 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(string) + res := resTmp.(FriendsConnection) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} -// nolint: vetshadow -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec._FriendsConnection(ctx, field.Selections, &res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "Droid", Field: field, Args: nil, } @@ -1654,7 +1181,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.AppearsIn, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1662,18 +1189,27 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field } return graphql.Null } - res := resTmp.(bool) + res := resTmp.([]Episode) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + + arr1 := make(graphql.Array, len(res)) + + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { + return res[idx1] + }() + } + + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _Droid_primaryFunction(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "Droid", Field: field, Args: nil, } @@ -1681,27 +1217,23 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.PrimaryFunction, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) _FriendsConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "FriendsConnection", Field: field, Args: nil, } @@ -1709,7 +1241,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.TotalCount(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1717,18 +1249,18 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(string) + res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return graphql.MarshalInt(res) } // nolint: vetshadow -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) _FriendsConnection_edges(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "FriendsConnection", Field: field, Args: nil, } @@ -1736,23 +1268,56 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return ec.resolvers.FriendsConnection().Edges(rctx, obj) }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.([]FriendsEdge) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec._FriendsEdge(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) _FriendsConnection_friends(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "FriendsConnection", Field: field, Args: nil, } @@ -1760,15 +1325,12 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Args, nil + return ec.resolvers.FriendsConnection().Friends(rctx, obj) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.([]Character) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1793,7 +1355,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } arr1[idx1] = func() graphql.Marshaler { - return ec.___InputValue(ctx, field.Selections, &res[idx1]) + return ec._Character(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1808,11 +1370,11 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) _FriendsConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "FriendsConnection", Field: field, Args: nil, } @@ -1820,7 +1382,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.PageInfo(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1828,26 +1390,19 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(PageInfo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec._PageInfo(ctx, field.Selections, &res) } // nolint: vetshadow -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) _FriendsEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *FriendsEdge) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "FriendsEdge", Field: field, Args: nil, } @@ -1855,7 +1410,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.Cursor, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1863,18 +1418,18 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return graphql.MarshalID(res) } // nolint: vetshadow -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) _FriendsEdge_node(ctx context.Context, field graphql.CollectedField, obj *FriendsEdge) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "FriendsEdge", Field: field, Args: nil, } @@ -1882,27 +1437,24 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.Node, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(Character) rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + return ec._Character(ctx, field.Selections, &res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) _Human_id(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "Human", Field: field, Args: nil, } @@ -1910,7 +1462,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.ID, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1921,15 +1473,15 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return graphql.MarshalID(res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) _Human_name(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "Human", Field: field, Args: nil, } @@ -1937,9 +1489,12 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.Name, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(string) @@ -1949,19 +1504,26 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field } // nolint: vetshadow -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) _Human_height(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "Human", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Human_height_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.Height(args["unit"].(LengthUnit)), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1969,26 +1531,18 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalFloat(res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) _Human_mass(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "Human", Field: field, Args: nil, } @@ -1996,27 +1550,23 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil + return obj.Mass, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return graphql.MarshalFloat(res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "Human", Field: field, Args: nil, } @@ -2024,15 +1574,12 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Types(), nil + return ec.resolvers.Human().Friends(rctx, obj) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.([]Character) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -2057,7 +1604,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } arr1[idx1] = func() graphql.Marshaler { - return ec.___Type(ctx, field.Selections, &res[idx1]) + return ec._Character(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -2072,19 +1619,26 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } // nolint: vetshadow -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "Human", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Human_friendsConnection_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil + return ec.resolvers.Human().FriendsConnection(rctx, obj, args["first"].(*int), args["after"].(*string)) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -2092,26 +1646,19 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(FriendsConnection) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec._FriendsConnection(ctx, field.Selections, &res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) _Human_appearsIn(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "Human", Field: field, Args: nil, } @@ -2119,57 +1666,35 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil + return obj.AppearsIn, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.([]Episode) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + arr1 := make(graphql.Array, len(res)) - if res == nil { - return graphql.Null + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { + return res[idx1] + }() } - return ec.___Type(ctx, field.Selections, res) + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) _Human_starships(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "Human", Field: field, Args: nil, } @@ -2177,15 +1702,12 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil + return ec.resolvers.Human().Starships(rctx, obj) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]introspection.Directive) + res := resTmp.([]Starship) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -2210,7 +1732,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap } arr1[idx1] = func() graphql.Marshaler { - return ec.___Directive(ctx, field.Selections, &res[idx1]) + return ec._Starship(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -2225,11 +1747,47 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap } // nolint: vetshadow -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) _Mutation_createReview(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "Mutation", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_createReview_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().CreateReview(rctx, args["episode"].(Episode), args["review"].(Review)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Review) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { + return graphql.Null + } + + return ec._Review(ctx, field.Selections, res) +} + +// nolint: vetshadow +func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *PageInfo) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "PageInfo", Field: field, Args: nil, } @@ -2237,7 +1795,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil + return obj.StartCursor, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -2248,15 +1806,15 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return graphql.MarshalID(res) } // nolint: vetshadow -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *PageInfo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "PageInfo", Field: field, Args: nil, } @@ -2264,71 +1822,108 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name(), nil + return obj.EndCursor, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalID(res) +} - if res == nil { +// nolint: vetshadow +func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *PageInfo) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "PageInfo", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.HasNextPage, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - return graphql.MarshalString(*res) + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) _Query_hero(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "Query", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_hero_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return ec.resolvers.Query().Hero(rctx, args["episode"].(*Episode)) }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(Character) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + return ec._Character(ctx, field.Selections, &res) } // nolint: vetshadow -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "Query", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_fields_args(ctx, rawArgs) + args, err := ec.field_Query_reviews_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Fields(args["includeDeprecated"].(bool)), nil + return ec.resolvers.Query().Reviews(rctx, args["episode"].(Episode), args["since"].(*time.Time)) }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.Field) + res := resTmp.([]Review) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -2353,7 +1948,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } arr1[idx1] = func() graphql.Marshaler { - return ec.___Field(ctx, field.Selections, &res[idx1]) + return ec._Review(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -2368,24 +1963,34 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } // nolint: vetshadow -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) _Query_search(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "Query", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_search_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil + return ec.resolvers.Query().Search(rctx, args["text"].(string)) }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.([]SearchResult) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -2410,7 +2015,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq } arr1[idx1] = func() graphql.Marshaler { - return ec.___Type(ctx, field.Selections, &res[idx1]) + return ec._SearchResult(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -2425,132 +2030,216 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq } // nolint: vetshadow -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) _Query_character(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "Query", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_character_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil + return ec.resolvers.Query().Character(rctx, args["id"].(string)) }) if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(Character) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + return ec._Character(ctx, field.Selections, &res) +} - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) +// nolint: vetshadow +func (ec *executionContext) _Query_droid(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_droid_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Droid(rctx, args["id"].(string)) + }) + if resTmp == nil { + return graphql.Null } + res := resTmp.(*Droid) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { + if res == nil { + return graphql.Null + } - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } + return ec._Droid(ctx, field.Selections, res) +} +// nolint: vetshadow +func (ec *executionContext) _Query_human(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - wg.Wait() - return arr1 + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_human_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Human(rctx, args["id"].(string)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Human) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { + return graphql.Null + } + + return ec._Human(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) _Query_starship(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "Query", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_enumValues_args(ctx, rawArgs) + args, err := ec.field_Query_starship_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.EnumValues(args["includeDeprecated"].(bool)), nil + return ec.resolvers.Query().Starship(rctx, args["id"].(string)) }) if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.EnumValue) + res := resTmp.(*Starship) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup + if res == nil { + return graphql.Null + } - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) + return ec._Starship(ctx, field.Selections, res) +} + +// nolint: vetshadow +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query___type_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(args["name"].(string)) + }) + if resTmp == nil { + return graphql.Null } + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { + if res == nil { + return graphql.Null + } - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } + return ec.___Type(ctx, field.Selections, res) +} +// nolint: vetshadow +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, } - wg.Wait() - return arr1 + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { + return graphql.Null + } + + return ec.___Schema(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) _Review_stars(ctx context.Context, field graphql.CollectedField, obj *Review) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "Review", Field: field, Args: nil, } @@ -2558,56 +2247,26 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil + return obj.Stars, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return graphql.MarshalInt(res) } // nolint: vetshadow -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) _Review_commentary(ctx context.Context, field graphql.CollectedField, obj *Review) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "Review", Field: field, Args: nil, } @@ -2615,1037 +2274,1367 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil + return obj.Commentary, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { return graphql.Null } - - return ec.___Type(ctx, field.Selections, res) -} - -// endregion **************************** field.gotpl ***************************** - -// region ************************** generated.gotpl *************************** - -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } -} - -type Config struct { - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot -} - -type ResolverRoot interface { - Droid() DroidResolver - FriendsConnection() FriendsConnectionResolver - Human() HumanResolver - Mutation() MutationResolver - Query() QueryResolver - Starship() StarshipResolver -} - -type DirectiveRoot struct { + return graphql.MarshalString(*res) } -type ComplexityRoot struct { - Droid struct { - Id func(childComplexity int) int - Name func(childComplexity int) int - Friends func(childComplexity int) int - FriendsConnection func(childComplexity int, first *int, after *string) int - AppearsIn func(childComplexity int) int - PrimaryFunction func(childComplexity int) int - } - - FriendsConnection struct { - TotalCount func(childComplexity int) int - Edges func(childComplexity int) int - Friends func(childComplexity int) int - PageInfo func(childComplexity int) int - } - - FriendsEdge struct { - Cursor func(childComplexity int) int - Node func(childComplexity int) int - } - - Human struct { - Id func(childComplexity int) int - Name func(childComplexity int) int - Height func(childComplexity int, unit LengthUnit) int - Mass func(childComplexity int) int - Friends func(childComplexity int) int - FriendsConnection func(childComplexity int, first *int, after *string) int - AppearsIn func(childComplexity int) int - Starships func(childComplexity int) int - } - - Mutation struct { - CreateReview func(childComplexity int, episode Episode, review Review) int - } - - PageInfo struct { - StartCursor func(childComplexity int) int - EndCursor func(childComplexity int) int - HasNextPage func(childComplexity int) int - } - - Query struct { - Hero func(childComplexity int, episode *Episode) int - Reviews func(childComplexity int, episode Episode, since *time.Time) int - Search func(childComplexity int, text string) int - Character func(childComplexity int, id string) int - Droid func(childComplexity int, id string) int - Human func(childComplexity int, id string) int - Starship func(childComplexity int, id string) int - } - - Review struct { - Stars func(childComplexity int) int - Commentary func(childComplexity int) int - Time func(childComplexity int) int +// nolint: vetshadow +func (ec *executionContext) _Review_time(ctx context.Context, field graphql.CollectedField, obj *Review) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Review", + Field: field, + Args: nil, } - - Starship struct { - Id func(childComplexity int) int - Name func(childComplexity int) int - Length func(childComplexity int, unit *LengthUnit) int - History func(childComplexity int) int + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Time, nil + }) + if resTmp == nil { + return graphql.Null } + res := resTmp.(time.Time) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalTime(res) } -type DroidResolver interface { - Friends(ctx context.Context, obj *Droid) ([]Character, error) - FriendsConnection(ctx context.Context, obj *Droid, first *int, after *string) (FriendsConnection, error) -} -type FriendsConnectionResolver interface { - Edges(ctx context.Context, obj *FriendsConnection) ([]FriendsEdge, error) - Friends(ctx context.Context, obj *FriendsConnection) ([]Character, error) -} -type HumanResolver interface { - Friends(ctx context.Context, obj *Human) ([]Character, error) - FriendsConnection(ctx context.Context, obj *Human, first *int, after *string) (FriendsConnection, error) - - Starships(ctx context.Context, obj *Human) ([]Starship, error) -} -type MutationResolver interface { - CreateReview(ctx context.Context, episode Episode, review Review) (*Review, error) -} -type QueryResolver interface { - Hero(ctx context.Context, episode *Episode) (Character, error) - Reviews(ctx context.Context, episode Episode, since *time.Time) ([]Review, error) - Search(ctx context.Context, text string) ([]SearchResult, error) - Character(ctx context.Context, id string) (Character, error) - Droid(ctx context.Context, id string) (*Droid, error) - Human(ctx context.Context, id string) (*Human, error) - Starship(ctx context.Context, id string) (*Starship, error) -} -type StarshipResolver interface { - Length(ctx context.Context, obj *Starship, unit *LengthUnit) (float64, error) -} - -func (e *executableSchema) field_Droid_friendsConnection_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *int - if tmp, ok := rawArgs["first"]; ok { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg0 = &ptr1 - } - - if err != nil { - return nil, err - } - } - args["first"] = arg0 - var arg1 *string - if tmp, ok := rawArgs["after"]; ok { - var err error - var ptr1 string - if tmp != nil { - ptr1, err = graphql.UnmarshalID(tmp) - arg1 = &ptr1 - } - - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Starship_id(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Starship", + Field: field, + Args: nil, } - args["after"] = arg1 - return args, nil - -} - -func (e *executableSchema) field_Human_height_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 LengthUnit - if tmp, ok := rawArgs["unit"]; ok { - var err error - err = (&arg0).UnmarshalGQL(tmp) - if err != nil { - return nil, err + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["unit"] = arg0 - return args, nil - + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalID(res) } -func (e *executableSchema) field_Human_friendsConnection_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *int - if tmp, ok := rawArgs["first"]; ok { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg0 = &ptr1 - } - - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Starship_name(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Starship", + Field: field, + Args: nil, } - args["first"] = arg0 - var arg1 *string - if tmp, ok := rawArgs["after"]; ok { - var err error - var ptr1 string - if tmp != nil { - ptr1, err = graphql.UnmarshalID(tmp) - arg1 = &ptr1 - } - - if err != nil { - return nil, err + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["after"] = arg1 - return args, nil - + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } -func (e *executableSchema) field_Mutation_createReview_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 Episode - if tmp, ok := rawArgs["episode"]; ok { - var err error - err = (&arg0).UnmarshalGQL(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) _Starship_length(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Starship", + Field: field, + Args: nil, } - args["episode"] = arg0 - var arg1 Review - if tmp, ok := rawArgs["review"]; ok { - var err error - arg1, err = UnmarshalReviewInput(tmp) - if err != nil { - return nil, err + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Starship_length_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Starship().Length(rctx, obj, args["unit"].(*LengthUnit)) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(float64) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalFloat(res) +} - mReviewInput1, err := e.ReviewInputMiddleware(ctx, &arg1) - if err != nil { - return nil, err +// nolint: vetshadow +func (ec *executionContext) _Starship_history(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Starship", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.History, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } - arg1 = *mReviewInput1 + return graphql.Null } - args["review"] = arg1 - return args, nil + res := resTmp.([][]int) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -} + arr1 := make(graphql.Array, len(res)) -func (e *executableSchema) field_Query_hero_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *Episode - if tmp, ok := rawArgs["episode"]; ok { - var err error - var ptr1 Episode - if tmp != nil { - err = (&ptr1).UnmarshalGQL(tmp) - arg0 = &ptr1 - } + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { - if err != nil { - return nil, err - } + arr2 := make(graphql.Array, len(res[idx1])) + + for idx2 := range res[idx1] { + arr2[idx2] = func() graphql.Marshaler { + return graphql.MarshalInt(res[idx1][idx2]) + }() + } + + return arr2 + }() } - args["episode"] = arg0 - return args, nil + return arr1 } -func (e *executableSchema) field_Query_reviews_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 Episode - if tmp, ok := rawArgs["episode"]; ok { - var err error - err = (&arg0).UnmarshalGQL(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Field: field, + Args: nil, } - args["episode"] = arg0 - var arg1 *time.Time - if tmp, ok := rawArgs["since"]; ok { - var err error - var ptr1 time.Time - if tmp != nil { - ptr1, err = graphql.UnmarshalTime(tmp) - arg1 = &ptr1 - } - - if err != nil { - return nil, err + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["since"] = arg1 - return args, nil + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} +// nolint: vetshadow +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } -func (e *executableSchema) field_Query_search_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["text"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err +// nolint: vetshadow +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["text"] = arg0 - return args, nil + res := resTmp.([]string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -} + arr1 := make(graphql.Array, len(res)) -func (e *executableSchema) field_Query_character_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalID(tmp) - if err != nil { - return nil, err - } + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { + return graphql.MarshalString(res[idx1]) + }() } - args["id"] = arg0 - return args, nil + return arr1 } -func (e *executableSchema) field_Query_droid_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalID(tmp) - if err != nil { - return nil, err +// nolint: vetshadow +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Directive", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["id"] = arg0 - return args, nil + res := resTmp.([]introspection.InputValue) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -func (e *executableSchema) field_Query_human_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalID(tmp) - if err != nil { - return nil, err - } + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } - args["id"] = arg0 - return args, nil -} + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { -func (e *executableSchema) field_Query_starship_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalID(tmp) - if err != nil { - return nil, err + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) } - } - args["id"] = arg0 - return args, nil + } + wg.Wait() + return arr1 } -func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err +// nolint: vetshadow +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["name"] = arg0 - return args, nil + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} +// nolint: vetshadow +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } -func (e *executableSchema) field_Starship_length_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *LengthUnit - if tmp, ok := rawArgs["unit"]; ok { - var err error - var ptr1 LengthUnit - if tmp != nil { - err = (&ptr1).UnmarshalGQL(tmp) - arg0 = &ptr1 +// nolint: vetshadow +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) +} - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Field: field, + Args: nil, } - args["unit"] = arg0 - return args, nil + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err +// nolint: vetshadow +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - args["includeDeprecated"] = arg0 - return args, nil - + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, } - args["includeDeprecated"] = arg0 - return args, nil - -} - -type executableSchema struct { - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot -} - -func (e *executableSchema) Schema() *ast.Schema { - return parsedSchema + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - switch typeName + "." + field { - - case "Droid.id": - if e.complexity.Droid.Id == nil { - break - } - - return e.complexity.Droid.Id(childComplexity), true - - case "Droid.name": - if e.complexity.Droid.Name == nil { - break - } - - return e.complexity.Droid.Name(childComplexity), true - - case "Droid.friends": - if e.complexity.Droid.Friends == nil { - break - } - - return e.complexity.Droid.Friends(childComplexity), true - - case "Droid.friendsConnection": - if e.complexity.Droid.FriendsConnection == nil { - break - } - - args, err := e.field_Droid_friendsConnection_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Droid.FriendsConnection(childComplexity, args["first"].(*int), args["after"].(*string)), true - - case "Droid.appearsIn": - if e.complexity.Droid.AppearsIn == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.Droid.AppearsIn(childComplexity), true - - case "Droid.primaryFunction": - if e.complexity.Droid.PrimaryFunction == nil { - break - } + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - return e.complexity.Droid.PrimaryFunction(childComplexity), true + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - case "FriendsConnection.totalCount": - if e.complexity.FriendsConnection.TotalCount == nil { - break + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.FriendsConnection.TotalCount(childComplexity), true - - case "FriendsConnection.edges": - if e.complexity.FriendsConnection.Edges == nil { - break + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }() } - - return e.complexity.FriendsConnection.Edges(childComplexity), true - - case "FriendsConnection.friends": - if e.complexity.FriendsConnection.Friends == nil { - break + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.FriendsConnection.Friends(childComplexity), true + } + wg.Wait() + return arr1 +} - case "FriendsConnection.pageInfo": - if e.complexity.FriendsConnection.PageInfo == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.FriendsConnection.PageInfo(childComplexity), true - - case "FriendsEdge.cursor": - if e.complexity.FriendsEdge.Cursor == nil { - break + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } - return e.complexity.FriendsEdge.Cursor(childComplexity), true + return ec.___Type(ctx, field.Selections, res) +} - case "FriendsEdge.node": - if e.complexity.FriendsEdge.Node == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) +} - return e.complexity.FriendsEdge.Node(childComplexity), true - - case "Human.id": - if e.complexity.Human.Id == nil { - break - } +// nolint: vetshadow +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.Human.Id(childComplexity), true + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) +} - case "Human.name": - if e.complexity.Human.Name == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - return e.complexity.Human.Name(childComplexity), true +// nolint: vetshadow +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - case "Human.height": - if e.complexity.Human.Height == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - args, err := e.field_Human_height_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } - return e.complexity.Human.Height(childComplexity, args["unit"].(LengthUnit)), true + return ec.___Type(ctx, field.Selections, res) +} - case "Human.mass": - if e.complexity.Human.Mass == nil { - break - } +// nolint: vetshadow +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.Human.Mass(childComplexity), true + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) +} - case "Human.friends": - if e.complexity.Human.Friends == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.([]introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.Human.Friends(childComplexity), true + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - case "Human.friendsConnection": - if e.complexity.Human.FriendsConnection == nil { - break - } + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - args, err := e.field_Human_friendsConnection_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.Human.FriendsConnection(childComplexity, args["first"].(*int), args["after"].(*string)), true - - case "Human.appearsIn": - if e.complexity.Human.AppearsIn == nil { - break + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() } - - return e.complexity.Human.AppearsIn(childComplexity), true - - case "Human.starships": - if e.complexity.Human.Starships == nil { - break + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.Human.Starships(childComplexity), true + } + wg.Wait() + return arr1 +} - case "Mutation.createReview": - if e.complexity.Mutation.CreateReview == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - args, err := e.field_Mutation_createReview_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) +} + +// nolint: vetshadow +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.Mutation.CreateReview(childComplexity, args["episode"].(Episode), args["review"].(Review)), true + if res == nil { + return graphql.Null + } - case "PageInfo.startCursor": - if e.complexity.PageInfo.StartCursor == nil { - break - } + return ec.___Type(ctx, field.Selections, res) +} - return e.complexity.PageInfo.StartCursor(childComplexity), true +// nolint: vetshadow +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - case "PageInfo.endCursor": - if e.complexity.PageInfo.EndCursor == nil { - break - } + if res == nil { + return graphql.Null + } - return e.complexity.PageInfo.EndCursor(childComplexity), true + return ec.___Type(ctx, field.Selections, res) +} - case "PageInfo.hasNextPage": - if e.complexity.PageInfo.HasNextPage == nil { - break +// nolint: vetshadow +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.([]introspection.Directive) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.PageInfo.HasNextPage(childComplexity), true + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - case "Query.hero": - if e.complexity.Query.Hero == nil { - break - } + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - args, err := e.field_Query_hero_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.Query.Hero(childComplexity, args["episode"].(*Episode)), true - - case "Query.reviews": - if e.complexity.Query.Reviews == nil { - break + return ec.___Directive(ctx, field.Selections, &res[idx1]) + }() } - - args, err := e.field_Query_reviews_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.Query.Reviews(childComplexity, args["episode"].(Episode), args["since"].(*time.Time)), true - - case "Query.search": - if e.complexity.Query.Search == nil { - break - } + } + wg.Wait() + return arr1 +} - args, err := e.field_Query_search_args(context.TODO(), rawArgs) - if err != nil { - return 0, false +// nolint: vetshadow +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - return e.complexity.Query.Search(childComplexity, args["text"].(string)), true - - case "Query.character": - if e.complexity.Query.Character == nil { - break - } +// nolint: vetshadow +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - args, err := e.field_Query_character_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) +} - return e.complexity.Query.Character(childComplexity, args["id"].(string)), true +// nolint: vetshadow +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - case "Query.droid": - if e.complexity.Query.Droid == nil { - break - } +// nolint: vetshadow +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_fields_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(args["includeDeprecated"].(bool)), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - args, err := e.field_Query_droid_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - return e.complexity.Query.Droid(childComplexity, args["id"].(string)), true + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - case "Query.human": - if e.complexity.Query.Human == nil { - break + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - args, err := e.field_Query_human_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + return ec.___Field(ctx, field.Selections, &res[idx1]) + }() } - - return e.complexity.Query.Human(childComplexity, args["id"].(string)), true - - case "Query.starship": - if e.complexity.Query.Starship == nil { - break + if isLen1 { + f(idx1) + } else { + go f(idx1) } - args, err := e.field_Query_starship_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } + } + wg.Wait() + return arr1 +} - return e.complexity.Query.Starship(childComplexity, args["id"].(string)), true +// nolint: vetshadow +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - case "Review.stars": - if e.complexity.Review.Stars == nil { - break - } + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - return e.complexity.Review.Stars(childComplexity), true + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - case "Review.commentary": - if e.complexity.Review.Commentary == nil { - break + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.Review.Commentary(childComplexity), true - - case "Review.time": - if e.complexity.Review.Time == nil { - break + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() } - - return e.complexity.Review.Time(childComplexity), true - - case "Starship.id": - if e.complexity.Starship.Id == nil { - break + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.Starship.Id(childComplexity), true + } + wg.Wait() + return arr1 +} - case "Starship.name": - if e.complexity.Starship.Name == nil { - break - } +// nolint: vetshadow +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.Starship.Name(childComplexity), true + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - case "Starship.length": - if e.complexity.Starship.Length == nil { - break - } + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - args, err := e.field_Starship_length_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.Starship.Length(childComplexity, args["unit"].(*LengthUnit)), true - - case "Starship.history": - if e.complexity.Starship.History == nil { - break + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) } - - return e.complexity.Starship.History(childComplexity), true } - return 0, false + wg.Wait() + return arr1 } -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() +// nolint: vetshadow +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions} -} - -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Mutation(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) } -} - -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) -} -type executionContext struct { - *graphql.RequestContext - *executableSchema -} + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { -func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil + return ec.___EnumValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) } - }() - res, err := ec.ResolverMiddleware(ctx, next) - if err != nil { - ec.Error(ctx, err) - return nil - } - return res -} -func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") } - return introspection.WrapSchema(parsedSchema), nil + wg.Wait() + return arr1 } -func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") +// nolint: vetshadow +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil -} - -var parsedSchema = gqlparser.MustLoadSchema( - &ast.Source{Name: "schema.graphql", Input: `# The query type, represents all of the entry points into our object graph -type Query { - hero(episode: Episode = NEWHOPE): Character - reviews(episode: Episode!, since: Time): [Review!]! - search(text: String!): [SearchResult!]! - character(id: ID!): Character - droid(id: ID!): Droid - human(id: ID!): Human - starship(id: ID!): Starship -} -# The mutation type, represents all updates we can make to our data -type Mutation { - createReview(episode: Episode!, review: ReviewInput!): Review -} -# The episodes in the Star Wars trilogy -enum Episode { - # Star Wars Episode IV: A New Hope, released in 1977. - NEWHOPE - # Star Wars Episode V: The Empire Strikes Back, released in 1980. - EMPIRE - # Star Wars Episode VI: Return of the Jedi, released in 1983. - JEDI -} -# A character from the Star Wars universe -interface Character { - # The ID of the character - id: ID! - # The name of the character - name: String! - # The friends of the character, or an empty list if they have none - friends: [Character!] - # The friends of the character exposed as a connection with edges - friendsConnection(first: Int, after: ID): FriendsConnection! - # The movies this character appears in - appearsIn: [Episode!]! -} -# Units of height -enum LengthUnit { - # The standard unit around the world - METER - # Primarily used in the United States - FOOT -} -# A humanoid creature from the Star Wars universe -type Human implements Character { - # The ID of the human - id: ID! - # What this human calls themselves - name: String! - # Height in the preferred unit, default is meters - height(unit: LengthUnit = METER): Float! - # Mass in kilograms, or null if unknown - mass: Float - # This human's friends, or an empty list if they have none - friends: [Character!] - # The friends of the human exposed as a connection with edges - friendsConnection(first: Int, after: ID): FriendsConnection! - # The movies this human appears in - appearsIn: [Episode!]! - # A list of starships this person has piloted, or an empty list if none - starships: [Starship!] -} -# An autonomous mechanical character in the Star Wars universe -type Droid implements Character { - # The ID of the droid - id: ID! - # What others call this droid - name: String! - # This droid's friends, or an empty list if they have none - friends: [Character!] - # The friends of the droid exposed as a connection with edges - friendsConnection(first: Int, after: ID): FriendsConnection! - # The movies this droid appears in - appearsIn: [Episode!]! - # This droid's primary function - primaryFunction: String -} -# A connection object for a character's friends -type FriendsConnection { - # The total number of friends - totalCount: Int! - # The edges for each of the character's friends. - edges: [FriendsEdge!] - # A list of the friends, as a convenience when edges are not needed. - friends: [Character!] - # Information for paginating this connection - pageInfo: PageInfo! -} -# An edge object for a character's friends -type FriendsEdge { - # A cursor used for pagination - cursor: ID! - # The character represented by this friendship edge - node: Character -} -# Information for paginating this connection -type PageInfo { - startCursor: ID! - endCursor: ID! - hasNextPage: Boolean! -} -# Represents a review for a movie -type Review { - # The number of stars this review gave, 1-5 - stars: Int! - # Comment about the movie - commentary: String - # when the review was posted - time: Time -} -# The input object sent when someone is creating a new review -input ReviewInput { - # 0-5 stars - stars: Int! - # Comment about the movie, optional - commentary: String - # when the review was posted - time: Time -} -type Starship { - # The ID of the starship - id: ID! - # The name of the starship - name: String! - # Length of the starship, along the longest axis - length(unit: LengthUnit = METER): Float! - # coordinates tracking this ship - history: [[Int!]!]! -} -union SearchResult = Human | Droid | Starship -scalar Time -`}, -) + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() } - return handleFunc[0](ctx, chainHandler) + arr1[idx1] = func() graphql.Marshaler { + + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) } + } + wg.Wait() + return arr1 +} - if n == 1 { - return handleFunc[0] +// nolint: vetshadow +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if resTmp == nil { + return graphql.Null } + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) + if res == nil { + return graphql.Null } + + return ec.___Type(ctx, field.Selections, res) } -// endregion ************************** generated.gotpl *************************** +// endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** diff --git a/example/starwars/models_gen.go b/example/starwars/models_gen.go index 865948479c2..e418cd89e42 100644 --- a/example/starwars/models_gen.go +++ b/example/starwars/models_gen.go @@ -1,3 +1,5 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + package starwars import ( diff --git a/example/todo/generated.go b/example/todo/generated.go index aecaf0be2af..078b2e623d9 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -15,427 +15,458 @@ import ( "github.com/vektah/gqlparser/ast" ) -// region ***************************** args.gotpl ***************************** +// region ************************** generated!.gotpl ************************** -func (e *executableSchema) dir_hasRole_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 Role - if tmp, ok := rawArgs["role"]; ok { - var err error - err = (&arg0).UnmarshalGQL(tmp) - if err != nil { - return nil, err - } +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, } - args["role"] = arg0 - return args, nil } -func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 TodoInput - if tmp, ok := rawArgs["todo"]; ok { - var err error - arg0, err = UnmarshalTodoInput(tmp) - if err != nil { - return nil, err - } +type Config struct { + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} - mTodoInput1, err := e.TodoInputMiddleware(ctx, &arg0) - if err != nil { - return nil, err - } - arg0 = *mTodoInput1 - } - args["todo"] = arg0 - return args, nil +type ResolverRoot interface { + MyMutation() MyMutationResolver + MyQuery() MyQueryResolver } -func (e *executableSchema) field_MyMutation_updateTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 int - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalInt(tmp) - if err != nil { - return nil, err - } +type DirectiveRoot struct { + HasRole func(ctx context.Context, obj interface{}, next graphql.Resolver, role Role) (res interface{}, err error) +} + +type ComplexityRoot struct { + MyMutation struct { + CreateTodo func(childComplexity int, todo TodoInput) int + UpdateTodo func(childComplexity int, id int, changes map[string]interface{}) int } - args["id"] = arg0 - var arg1 map[string]interface{} - if tmp, ok := rawArgs["changes"]; ok { - var err error - arg1 = tmp.(map[string]interface{}) - if err != nil { - return nil, err - } + + MyQuery struct { + Todo func(childComplexity int, id int) int + LastTodo func(childComplexity int) int + Todos func(childComplexity int) int } - args["changes"] = arg1 - return args, nil -} -func (e *executableSchema) field_MyQuery___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } + Todo struct { + Id func(childComplexity int) int + Text func(childComplexity int) int + Done func(childComplexity int) int } - args["name"] = arg0 - return args, nil } -func (e *executableSchema) field_MyQuery_todo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 int - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalInt(tmp) - if err != nil { - return nil, err - } - } - args["id"] = arg0 - return args, nil +type MyMutationResolver interface { + CreateTodo(ctx context.Context, todo TodoInput) (Todo, error) + UpdateTodo(ctx context.Context, id int, changes map[string]interface{}) (*Todo, error) +} +type MyQueryResolver interface { + Todo(ctx context.Context, id int) (*Todo, error) + LastTodo(ctx context.Context) (*Todo, error) + Todos(ctx context.Context) ([]Todo, error) } -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) +type executableSchema struct { + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + switch typeName + "." + field { + + case "MyMutation.createTodo": + if e.complexity.MyMutation.CreateTodo == nil { + break + } + + args, err := e.field_MyMutation_createTodo_args(context.TODO(), rawArgs) if err != nil { - return nil, err + return 0, false } - } - args["includeDeprecated"] = arg0 - return args, nil -} -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) + return e.complexity.MyMutation.CreateTodo(childComplexity, args["todo"].(TodoInput)), true + + case "MyMutation.updateTodo": + if e.complexity.MyMutation.UpdateTodo == nil { + break + } + + args, err := e.field_MyMutation_updateTodo_args(context.TODO(), rawArgs) if err != nil { - return nil, err + return 0, false } - } - args["includeDeprecated"] = arg0 - return args, nil -} -// endregion ***************************** args.gotpl ***************************** + return e.complexity.MyMutation.UpdateTodo(childComplexity, args["id"].(int), args["changes"].(map[string]interface{})), true -// region **************************** field.gotpl ***************************** + case "MyQuery.todo": + if e.complexity.MyQuery.Todo == nil { + break + } -// nolint: vetshadow -func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "MyMutation", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_MyMutation_createTodo_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.MyMutation().CreateTodo(rctx, args["todo"].(TodoInput)) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + args, err := e.field_MyQuery_todo_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - return graphql.Null - } - res := resTmp.(Todo) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec._Todo(ctx, field.Selections, &res) -} + return e.complexity.MyQuery.Todo(childComplexity, args["id"].(int)), true -// nolint: vetshadow -func (ec *executionContext) _MyMutation_updateTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "MyMutation", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_MyMutation_updateTodo_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.MyMutation().UpdateTodo(rctx, args["id"].(int), args["changes"].(map[string]interface{})) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*Todo) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + case "MyQuery.lastTodo": + if e.complexity.MyQuery.LastTodo == nil { + break + } - if res == nil { - return graphql.Null - } + return e.complexity.MyQuery.LastTodo(childComplexity), true - return ec._Todo(ctx, field.Selections, res) -} + case "MyQuery.todos": + if e.complexity.MyQuery.Todos == nil { + break + } -// nolint: vetshadow -func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "MyQuery", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_MyQuery_todo_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.MyQuery().Todo(rctx, args["id"].(int)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*Todo) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return e.complexity.MyQuery.Todos(childComplexity), true - if res == nil { - return graphql.Null - } + case "Todo.id": + if e.complexity.Todo.Id == nil { + break + } - return ec._Todo(ctx, field.Selections, res) -} + return e.complexity.Todo.Id(childComplexity), true -// nolint: vetshadow -func (ec *executionContext) _MyQuery_lastTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "MyQuery", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.MyQuery().LastTodo(rctx) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*Todo) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + case "Todo.text": + if e.complexity.Todo.Text == nil { + break + } + + return e.complexity.Todo.Text(childComplexity), true + + case "Todo.done": + if e.complexity.Todo.Done == nil { + break + } + + return e.complexity.Todo.Done(childComplexity), true - if res == nil { - return graphql.Null } + return 0, false +} - return ec._Todo(ctx, field.Selections, res) +func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._MyQuery(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() + }) + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions} } -// nolint: vetshadow -func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "MyQuery", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.MyQuery().Todos(rctx) +func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._MyMutation(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions, } - res := resTmp.([]Todo) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +} - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup +func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { + return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) +} - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } +type executionContext struct { + *graphql.RequestContext + *executableSchema +} - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() + }() + rctx := graphql.GetResolverContext(ctx) + for _, d := range rctx.Field.Definition.Directives { + switch d.Name { + case "hasRole": + if ec.directives.HasRole != nil { + rawArgs := d.ArgumentMap(ec.Variables) + args, err := ec.dir_hasRole_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return nil + } + n := next + next = func(ctx context.Context) (interface{}, error) { + return ec.directives.HasRole(ctx, obj, n, args["role"].(Role)) + } } - arr1[idx1] = func() graphql.Marshaler { - - return ec._Todo(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) } - - } - wg.Wait() - return arr1 -} - -// nolint: vetshadow -func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "MyQuery", - Field: field, - Args: nil, } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_MyQuery___type_args(ctx, rawArgs) + res, err := ec.ResolverMiddleware(ctx, next) if err != nil { ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectType(args["name"].(string)) - }) - if resTmp == nil { - return graphql.Null + return nil } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return res +} - if res == nil { - return graphql.Null +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") } - - return ec.___Type(ctx, field.Selections, res) + return introspection.WrapSchema(parsedSchema), nil } -// nolint: vetshadow -func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "MyQuery", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() - }) - if resTmp == nil { - return graphql.Null +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") } - res := resTmp.(*introspection.Schema) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil +} - if res == nil { - return graphql.Null - } +var parsedSchema = gqlparser.MustLoadSchema( + &ast.Source{Name: "schema.graphql", Input: `schema { + query: MyQuery + mutation: MyMutation +} - return ec.___Schema(ctx, field.Selections, res) +type MyQuery { + todo(id: Int!): Todo + lastTodo: Todo + todos: [Todo!]! } -// nolint: vetshadow -func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Todo", - Field: field, - Args: nil, +type MyMutation { + createTodo(todo: TodoInput!): Todo! + updateTodo(id: Int!, changes: Map!): Todo +} + +type Todo { + id: Int! + text: String! + done: Boolean! @hasRole(role: OWNER) # only the owner can see if a todo is done +} + +"Passed to createTodo to create a new todo" +input TodoInput { + "The body text" + text: String! + "Is it done already?" + done: Boolean +} + +scalar Map + +"Prevents access to a field if the user doesnt have the matching role" +directive @hasRole(role: Role!) on FIELD_DEFINITION + +enum Role { + ADMIN + OWNER +} +`}, +) + +// ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + + } + return handleFunc[0](ctx, chainHandler) + } } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + + if n == 1 { + return handleFunc[0] + } + + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) + } +} + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (e *executableSchema) dir_hasRole_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 Role + if tmp, ok := rawArgs["role"]; ok { + var err error + err = (&arg0).UnmarshalGQL(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(int) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) + args["role"] = arg0 + return args, nil +} + +func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 TodoInput + if tmp, ok := rawArgs["todo"]; ok { + var err error + arg0, err = UnmarshalTodoInput(tmp) + if err != nil { + return nil, err + } + + mTodoInput1, err := e.TodoInputMiddleware(ctx, &arg0) + if err != nil { + return nil, err + } + arg0 = *mTodoInput1 + } + args["todo"] = arg0 + return args, nil +} + +func (e *executableSchema) field_MyMutation_updateTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 int + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = graphql.UnmarshalInt(tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + var arg1 map[string]interface{} + if tmp, ok := rawArgs["changes"]; ok { + var err error + arg1 = tmp.(map[string]interface{}) + if err != nil { + return nil, err + } + } + args["changes"] = arg1 + return args, nil +} + +func (e *executableSchema) field_MyQuery___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg0 + return args, nil +} + +func (e *executableSchema) field_MyQuery_todo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 int + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = graphql.UnmarshalInt(tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + return args, nil +} + +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil +} + +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil } +// endregion ***************************** args.gotpl ***************************** + +// region **************************** field.gotpl ***************************** + // nolint: vetshadow -func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { +func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Todo", + Object: "MyMutation", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_MyMutation_createTodo_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Text, nil + return ec.resolvers.MyMutation().CreateTodo(rctx, args["todo"].(TodoInput)) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -443,140 +474,128 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec } return graphql.Null } - res := resTmp.(string) + res := resTmp.(Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + return ec._Todo(ctx, field.Selections, &res) } // nolint: vetshadow -func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { +func (ec *executionContext) _MyMutation_updateTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Todo", + Object: "MyMutation", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_MyMutation_updateTodo_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Done, nil + return ec.resolvers.MyMutation().UpdateTodo(rctx, args["id"].(int), args["changes"].(map[string]interface{})) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + + if res == nil { + return graphql.Null + } + + return ec._Todo(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "MyQuery", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_MyQuery_todo_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return ec.resolvers.MyQuery().Todo(rctx, args["id"].(int)) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} -// nolint: vetshadow -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { + if res == nil { return graphql.Null } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + return ec._Todo(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) _MyQuery_lastTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "MyQuery", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Locations, nil + return ec.resolvers.MyQuery().LastTodo(rctx) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]string) + res := resTmp.(*Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() + if res == nil { + return graphql.Null } - return arr1 + return ec._Todo(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "MyQuery", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Args, nil + return ec.resolvers.MyQuery().Todos(rctx) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -584,7 +603,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.([]Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -609,7 +628,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql } arr1[idx1] = func() graphql.Marshaler { - return ec.___InputValue(ctx, field.Selections, &res[idx1]) + return ec._Todo(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -624,62 +643,76 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "MyQuery", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_MyQuery___type_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return ec.introspectType(args["name"].(string)) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "MyQuery", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return ec.introspectSchema() }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + + return ec.___Schema(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "Todo", Field: field, Args: nil, } @@ -687,7 +720,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.ID, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -695,18 +728,18 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return graphql.MarshalInt(res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "Todo", Field: field, Args: nil, } @@ -714,27 +747,53 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.Text, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - if res == nil { +// nolint: vetshadow +func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Todo", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Done, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - return graphql.MarshalString(*res) + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Directive", Field: field, Args: nil, } @@ -757,11 +816,11 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Directive", Field: field, Args: nil, } @@ -781,11 +840,47 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap } // nolint: vetshadow -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Directive", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + arr1 := make(graphql.Array, len(res)) + + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { + return graphql.MarshalString(res[idx1]) + }() + } + + return arr1 +} + +// nolint: vetshadow +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Directive", Field: field, Args: nil, } @@ -841,11 +936,11 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__EnumValue", Field: field, Args: nil, } @@ -853,7 +948,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -861,26 +956,42 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } +// nolint: vetshadow +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__EnumValue", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if resTmp == nil { return graphql.Null } - - return ec.___Type(ctx, field.Selections, res) + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__EnumValue", Field: field, Args: nil, } @@ -903,11 +1014,11 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra } // nolint: vetshadow -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__EnumValue", Field: field, Args: nil, } @@ -931,11 +1042,212 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel } // nolint: vetshadow -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} + +// nolint: vetshadow +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) +} + +// nolint: vetshadow +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 +} + +// nolint: vetshadow +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + + return ec.___Type(ctx, field.Selections, res) +} + +// nolint: vetshadow +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) +} + +// nolint: vetshadow +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Field", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) +} + +// nolint: vetshadow +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__InputValue", Field: field, Args: nil, } @@ -1666,318 +1978,6 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co // endregion **************************** field.gotpl ***************************** -// region ************************** generated.gotpl *************************** - -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } -} - -type Config struct { - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot -} - -type ResolverRoot interface { - MyMutation() MyMutationResolver - MyQuery() MyQueryResolver -} - -type DirectiveRoot struct { - HasRole func(ctx context.Context, obj interface{}, next graphql.Resolver, role Role) (res interface{}, err error) -} - -type ComplexityRoot struct { - MyMutation struct { - CreateTodo func(childComplexity int, todo TodoInput) int - UpdateTodo func(childComplexity int, id int, changes map[string]interface{}) int - } - - MyQuery struct { - Todo func(childComplexity int, id int) int - LastTodo func(childComplexity int) int - Todos func(childComplexity int) int - } - - Todo struct { - Id func(childComplexity int) int - Text func(childComplexity int) int - Done func(childComplexity int) int - } -} - -type MyMutationResolver interface { - CreateTodo(ctx context.Context, todo TodoInput) (Todo, error) - UpdateTodo(ctx context.Context, id int, changes map[string]interface{}) (*Todo, error) -} -type MyQueryResolver interface { - Todo(ctx context.Context, id int) (*Todo, error) - LastTodo(ctx context.Context) (*Todo, error) - Todos(ctx context.Context) ([]Todo, error) -} - -type executableSchema struct { - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot -} - -func (e *executableSchema) Schema() *ast.Schema { - return parsedSchema -} - -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - switch typeName + "." + field { - - case "MyMutation.createTodo": - if e.complexity.MyMutation.CreateTodo == nil { - break - } - - args, err := e.field_MyMutation_createTodo_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.MyMutation.CreateTodo(childComplexity, args["todo"].(TodoInput)), true - - case "MyMutation.updateTodo": - if e.complexity.MyMutation.UpdateTodo == nil { - break - } - - args, err := e.field_MyMutation_updateTodo_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.MyMutation.UpdateTodo(childComplexity, args["id"].(int), args["changes"].(map[string]interface{})), true - - case "MyQuery.todo": - if e.complexity.MyQuery.Todo == nil { - break - } - - args, err := e.field_MyQuery_todo_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.MyQuery.Todo(childComplexity, args["id"].(int)), true - - case "MyQuery.lastTodo": - if e.complexity.MyQuery.LastTodo == nil { - break - } - - return e.complexity.MyQuery.LastTodo(childComplexity), true - - case "MyQuery.todos": - if e.complexity.MyQuery.Todos == nil { - break - } - - return e.complexity.MyQuery.Todos(childComplexity), true - - case "Todo.id": - if e.complexity.Todo.Id == nil { - break - } - - return e.complexity.Todo.Id(childComplexity), true - - case "Todo.text": - if e.complexity.Todo.Text == nil { - break - } - - return e.complexity.Todo.Text(childComplexity), true - - case "Todo.done": - if e.complexity.Todo.Done == nil { - break - } - - return e.complexity.Todo.Done(childComplexity), true - - } - return 0, false -} - -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._MyQuery(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions} -} - -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._MyMutation(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() - }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, - } -} - -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) -} - -type executionContext struct { - *graphql.RequestContext - *executableSchema -} - -func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - rctx := graphql.GetResolverContext(ctx) - for _, d := range rctx.Field.Definition.Directives { - switch d.Name { - case "hasRole": - if ec.directives.HasRole != nil { - rawArgs := d.ArgumentMap(ec.Variables) - args, err := ec.dir_hasRole_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return nil - } - n := next - next = func(ctx context.Context) (interface{}, error) { - return ec.directives.HasRole(ctx, obj, n, args["role"].(Role)) - } - } - } - } - res, err := ec.ResolverMiddleware(ctx, next) - if err != nil { - ec.Error(ctx, err) - return nil - } - return res -} - -func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") - } - return introspection.WrapSchema(parsedSchema), nil -} - -func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") - } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil -} - -var parsedSchema = gqlparser.MustLoadSchema( - &ast.Source{Name: "schema.graphql", Input: `schema { - query: MyQuery - mutation: MyMutation -} - -type MyQuery { - todo(id: Int!): Todo - lastTodo: Todo - todos: [Todo!]! -} - -type MyMutation { - createTodo(todo: TodoInput!): Todo! - updateTodo(id: Int!, changes: Map!): Todo -} - -type Todo { - id: Int! - text: String! - done: Boolean! @hasRole(role: OWNER) # only the owner can see if a todo is done -} - -"Passed to createTodo to create a new todo" -input TodoInput { - "The body text" - text: String! - "Is it done already?" - done: Boolean -} - -scalar Map - -"Prevents access to a field if the user doesnt have the matching role" -directive @hasRole(role: Role!) on FIELD_DEFINITION - -enum Role { - ADMIN - OWNER -} -`}, -) - -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) - - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err - - } - return handleFunc[0](ctx, chainHandler) - } - } - - if n == 1 { - return handleFunc[0] - } - - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) - } -} - -// endregion ************************** generated.gotpl *************************** - // region **************************** input.gotpl ***************************** func UnmarshalTodoInput(v interface{}) (TodoInput, error) { diff --git a/example/todo/models_gen.go b/example/todo/models_gen.go index 28063627c56..74a1c0da57b 100644 --- a/example/todo/models_gen.go +++ b/example/todo/models_gen.go @@ -1,3 +1,5 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + package todo import ( diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index 2a4cab7703b..9494e01f41e 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -16,299 +16,489 @@ import ( "github.com/vektah/gqlparser/ast" ) -// region **************************** field.gotpl ***************************** +// region ************************** generated!.gotpl ************************** -// nolint: vetshadow -func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "MyMutation", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_MyMutation_createTodo_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.MyMutation().CreateTodo(rctx, args["todo"].(TodoInput)) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, } - res := resTmp.(Todo) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._Todo(ctx, field.Selections, &res) } -// nolint: vetshadow -func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "MyQuery", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.MyQuery().Todos(rctx) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]Todo) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +type Config struct { + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup +type ResolverRoot interface { + MyMutation() MyMutationResolver + MyQuery() MyQueryResolver +} - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } +type DirectiveRoot struct { + EnumLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { + FieldLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) - return ec._Todo(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } + InputLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) - } - wg.Wait() - return arr1 -} + InterfaceLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) -// nolint: vetshadow -func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "MyQuery", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_MyQuery_todo_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.MyQuery().Todo(rctx, args["id"].(string)) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*Todo) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) + ObjectLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) - if res == nil { - return graphql.Null - } + ScalarLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) - return ec._Todo(ctx, field.Selections, res) + UnionLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) } -// nolint: vetshadow -func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "MyQuery", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_MyQuery___type_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectType(args["name"].(string)) - }) - if resTmp == nil { - return graphql.Null +type ComplexityRoot struct { + MyMutation struct { + CreateTodo func(childComplexity int, todo TodoInput) int } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - if res == nil { - return graphql.Null + MyQuery struct { + Todos func(childComplexity int) int + Todo func(childComplexity int, id string) int } - return ec.___Type(ctx, field.Selections, res) + Todo struct { + Id func(childComplexity int) int + Text func(childComplexity int) int + State func(childComplexity int) int + Verified func(childComplexity int) int + } } -// nolint: vetshadow -func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "MyQuery", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Schema) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) +type MyMutationResolver interface { + CreateTodo(ctx context.Context, todo TodoInput) (Todo, error) +} +type MyQueryResolver interface { + Todos(ctx context.Context) ([]Todo, error) + Todo(ctx context.Context, id string) (*Todo, error) +} - if res == nil { - return graphql.Null - } +type executableSchema struct { + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} - return ec.___Schema(ctx, field.Selections, res) +func (e *executableSchema) Schema() *ast.Schema { + return parsedSchema } -// nolint: vetshadow -func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Todo", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + switch typeName + "." + field { + + case "MyMutation.createTodo": + if e.complexity.MyMutation.CreateTodo == nil { + break } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) -} -// nolint: vetshadow -func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Todo", - Field: field, - Args: nil, + args, err := e.field_MyMutation_createTodo_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.MyMutation.CreateTodo(childComplexity, args["todo"].(TodoInput)), true + + case "MyQuery.todos": + if e.complexity.MyQuery.Todos == nil { + break + } + + return e.complexity.MyQuery.Todos(childComplexity), true + + case "MyQuery.todo": + if e.complexity.MyQuery.Todo == nil { + break + } + + args, err := e.field_MyQuery_todo_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.MyQuery.Todo(childComplexity, args["id"].(string)), true + + case "Todo.id": + if e.complexity.Todo.Id == nil { + break + } + + return e.complexity.Todo.Id(childComplexity), true + + case "Todo.text": + if e.complexity.Todo.Text == nil { + break + } + + return e.complexity.Todo.Text(childComplexity), true + + case "Todo.state": + if e.complexity.Todo.State == nil { + break + } + + return e.complexity.Todo.State(childComplexity), true + + case "Todo.verified": + if e.complexity.Todo.Verified == nil { + break + } + + return e.complexity.Todo.Verified(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._MyQuery(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() + }) + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions} +} + +func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._MyMutation(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() + }) + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions, + } +} + +func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { + return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) +} + +type executionContext struct { + *graphql.RequestContext + *executableSchema +} + +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + rctx := graphql.GetResolverContext(ctx) + for _, d := range rctx.Field.Definition.Directives { + switch d.Name { + case "enumLogging": + if ec.directives.EnumLogging != nil { + n := next + next = func(ctx context.Context) (interface{}, error) { + return ec.directives.EnumLogging(ctx, obj, n) + } + } + case "fieldLogging": + if ec.directives.FieldLogging != nil { + n := next + next = func(ctx context.Context) (interface{}, error) { + return ec.directives.FieldLogging(ctx, obj, n) + } + } + case "inputLogging": + if ec.directives.InputLogging != nil { + n := next + next = func(ctx context.Context) (interface{}, error) { + return ec.directives.InputLogging(ctx, obj, n) + } + } + case "interfaceLogging": + if ec.directives.InterfaceLogging != nil { + n := next + next = func(ctx context.Context) (interface{}, error) { + return ec.directives.InterfaceLogging(ctx, obj, n) + } + } + case "objectLogging": + if ec.directives.ObjectLogging != nil { + n := next + next = func(ctx context.Context) (interface{}, error) { + return ec.directives.ObjectLogging(ctx, obj, n) + } + } + case "scalarLogging": + if ec.directives.ScalarLogging != nil { + n := next + next = func(ctx context.Context) (interface{}, error) { + return ec.directives.ScalarLogging(ctx, obj, n) + } + } + case "unionLogging": + if ec.directives.UnionLogging != nil { + n := next + next = func(ctx context.Context) (interface{}, error) { + return ec.directives.UnionLogging(ctx, obj, n) + } + } + } + } + res, err := ec.ResolverMiddleware(ctx, next) + if err != nil { + ec.Error(ctx, err) + return nil + } + return res +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(parsedSchema), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil +} + +var parsedSchema = gqlparser.MustLoadSchema( + &ast.Source{Name: "schemas/enum-extension.graphql", Input: `directive @enumLogging on ENUM + +extend enum State @enumLogging +`}, + &ast.Source{Name: "schemas/input-object-extension.graphql", Input: `directive @inputLogging on INPUT_OBJECT + +extend input TodoInput @inputLogging +`}, + &ast.Source{Name: "schemas/interface-extension.graphql", Input: `directive @interfaceLogging on INTERFACE + +extend interface Node @interfaceLogging +`}, + &ast.Source{Name: "schemas/object-extension.graphql", Input: `directive @objectLogging on OBJECT + +extend type Todo @objectLogging +`}, + &ast.Source{Name: "schemas/scalar-extension.graphql", Input: `directive @scalarLogging on SCALAR + +extend scalar ID @scalarLogging +`}, + &ast.Source{Name: "schemas/schema-extension.graphql", Input: `extend schema { + mutation: MyMutation +} + +extend type MyQuery { + todo(id: ID!): Todo +} + +type MyMutation { + createTodo(todo: TodoInput!): Todo! +} + +input TodoInput { + text: String! +} +`}, + &ast.Source{Name: "schemas/schema.graphql", Input: `# GraphQL schema example +# +# https://gqlgen.com/getting-started/ + +schema { + query: MyQuery +} + +interface Node { + id: ID! +} + +type Todo implements Node { + id: ID! + text: String! + state: State! +} + +type MyQuery { + todos: [Todo!]! +} + +union Data = Todo + +enum State { + NOT_YET + DONE +} +`}, + &ast.Source{Name: "schemas/type-extension.graphql", Input: `directive @fieldLogging on FIELD_DEFINITION + +extend type Todo { + verified: Boolean! @fieldLogging +} +`}, + &ast.Source{Name: "schemas/union-extension.graphql", Input: `directive @unionLogging on UNION + +extend union Data @unionLogging +`}, +) + +// ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + + } + return handleFunc[0](ctx, chainHandler) + } + } + + if n == 1 { + return handleFunc[0] + } + + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) + } +} + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 TodoInput + if tmp, ok := rawArgs["todo"]; ok { + var err error + arg0, err = UnmarshalTodoInput(tmp) + if err != nil { + return nil, err + } + + mTodoInput1, err := e.TodoInputMiddleware(ctx, &arg0) + if err != nil { + return nil, err + } + arg0 = *mTodoInput1 } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Text, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + args["todo"] = arg0 + return args, nil +} + +func (e *executableSchema) field_MyQuery___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + args["name"] = arg0 + return args, nil } -// nolint: vetshadow -func (ec *executionContext) _Todo_state(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Todo", - Field: field, - Args: nil, +func (e *executableSchema) field_MyQuery_todo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = graphql.UnmarshalID(tmp) + if err != nil { + return nil, err + } } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.State, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") + args["id"] = arg0 + return args, nil +} + +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err } - return graphql.Null } - res := resTmp.(State) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return res + args["includeDeprecated"] = arg0 + return args, nil +} + +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil } +// endregion ***************************** args.gotpl ***************************** + +// region **************************** field.gotpl ***************************** + // nolint: vetshadow -func (ec *executionContext) _Todo_verified(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { +func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Todo", + Object: "MyMutation", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_MyMutation_createTodo_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Verified, nil + return ec.resolvers.MyMutation().CreateTodo(rctx, args["todo"].(TodoInput)) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -316,26 +506,27 @@ func (ec *executionContext) _Todo_verified(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + + return ec._Todo(ctx, field.Selections, &res) } // nolint: vetshadow -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "MyQuery", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return ec.resolvers.MyQuery().Todos(rctx) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -343,138 +534,152 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup + + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec._Todo(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "MyQuery", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_MyQuery_todo_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return ec.resolvers.MyQuery().Todo(rctx, args["id"].(string)) }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + + return ec._Todo(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "MyQuery", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_MyQuery___type_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Locations, nil + return ec.introspectType(args["name"].(string)) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() + if res == nil { + return graphql.Null } - return arr1 + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { +func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", + Object: "MyQuery", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Args, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } + return ec.introspectSchema() + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + if res == nil { + return graphql.Null } - wg.Wait() - return arr1 + + return ec.___Schema(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "Todo", Field: field, Args: nil, } @@ -482,7 +687,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.ID, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -493,15 +698,15 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return graphql.MarshalID(res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "Todo", Field: field, Args: nil, } @@ -509,9 +714,12 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.Text, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(string) @@ -521,11 +729,11 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _Todo_state(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "Todo", Field: field, Args: nil, } @@ -533,7 +741,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.State, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -541,18 +749,18 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(State) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return res } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _Todo_verified(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "Todo", Field: field, Args: nil, } @@ -560,27 +768,26 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.Verified, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Directive", Field: field, Args: nil, } @@ -603,11 +810,11 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Directive", Field: field, Args: nil, } @@ -627,11 +834,47 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap } // nolint: vetshadow -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Directive", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + arr1 := make(graphql.Array, len(res)) + + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { + return graphql.MarshalString(res[idx1]) + }() + } + + return arr1 +} + +// nolint: vetshadow +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Directive", Field: field, Args: nil, } @@ -687,46 +930,11 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Type, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__EnumValue", Field: field, Args: nil, } @@ -734,7 +942,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -742,18 +950,18 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__EnumValue", Field: field, Args: nil, } @@ -761,27 +969,23 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.Description, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__EnumValue", Field: field, Args: nil, } @@ -789,7 +993,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.IsDeprecated(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -797,18 +1001,18 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(string) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__EnumValue", Field: field, Args: nil, } @@ -816,23 +1020,27 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.DeprecationReason(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Field", Field: field, Args: nil, } @@ -840,7 +1048,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -848,26 +1056,18 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Field", Field: field, Args: nil, } @@ -875,27 +1075,23 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil + return obj.Description, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Field", Field: field, Args: nil, } @@ -903,7 +1099,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Types(), nil + return obj.Args, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -911,7 +1107,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -936,7 +1132,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } arr1[idx1] = func() graphql.Marshaler { - return ec.___Type(ctx, field.Selections, &res[idx1]) + return ec.___InputValue(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -951,11 +1147,11 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } // nolint: vetshadow -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Field", Field: field, Args: nil, } @@ -963,7 +1159,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil + return obj.Type, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -986,11 +1182,11 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } // nolint: vetshadow -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Field", Field: field, Args: nil, } @@ -998,28 +1194,26 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil + return obj.IsDeprecated(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Field", Field: field, Args: nil, } @@ -1027,28 +1221,27 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil + return obj.DeprecationReason(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { return graphql.Null } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__InputValue", Field: field, Args: nil, } @@ -1056,7 +1249,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1064,51 +1257,18 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap } return graphql.Null } - res := resTmp.([]introspection.Directive) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Directive(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__InputValue", Field: field, Args: nil, } @@ -1116,12 +1276,9 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil + return obj.Description, nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } res := resTmp.(string) @@ -1131,11 +1288,11 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll } // nolint: vetshadow -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__InputValue", Field: field, Args: nil, } @@ -1143,27 +1300,34 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name(), nil + return obj.Type, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - return graphql.MarshalString(*res) + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__InputValue", Field: field, Args: nil, } @@ -1171,43 +1335,43 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.DefaultValue, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_fields_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Fields(args["includeDeprecated"].(bool)), nil + return obj.Types(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.Field) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1232,7 +1396,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } arr1[idx1] = func() graphql.Marshaler { - return ec.___Field(ctx, field.Selections, &res[idx1]) + return ec.___Type(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1247,11 +1411,11 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } // nolint: vetshadow -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } @@ -1259,56 +1423,34 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil + return obj.QueryType(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } - + return graphql.Null } - wg.Wait() - return arr1 + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } @@ -1316,120 +1458,57 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil + return obj.MutationType(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) + if res == nil { + return graphql.Null } - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_enumValues_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.EnumValues(args["includeDeprecated"].(bool)), nil + return obj.SubscriptionType(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.EnumValue) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - + if res == nil { + return graphql.Null } - wg.Wait() - return arr1 + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } @@ -1437,12 +1516,15 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil + return obj.Directives(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1467,7 +1549,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph } arr1[idx1] = func() graphql.Marshaler { - return ec.___InputValue(ctx, field.Selections, &res[idx1]) + return ec.___Directive(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1482,7 +1564,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph } // nolint: vetshadow -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1494,484 +1576,401 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil + return obj.Kind(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// endregion **************************** field.gotpl ***************************** - -// region ************************** generated.gotpl *************************** - -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } -} - -type Config struct { - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot -} - -type ResolverRoot interface { - MyMutation() MyMutationResolver - MyQuery() MyQueryResolver -} - -type DirectiveRoot struct { - EnumLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) - - FieldLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) - - InputLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) - - InterfaceLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) - - ObjectLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) - - ScalarLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) - - UnionLogging func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) -} - -type ComplexityRoot struct { - MyMutation struct { - CreateTodo func(childComplexity int, todo TodoInput) int - } - - MyQuery struct { - Todos func(childComplexity int) int - Todo func(childComplexity int, id string) int - } - - Todo struct { - Id func(childComplexity int) int - Text func(childComplexity int) int - State func(childComplexity int) int - Verified func(childComplexity int) int - } -} - -type MyMutationResolver interface { - CreateTodo(ctx context.Context, todo TodoInput) (Todo, error) -} -type MyQueryResolver interface { - Todos(ctx context.Context) ([]Todo, error) - Todo(ctx context.Context, id string) (*Todo, error) -} - -func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 TodoInput - if tmp, ok := rawArgs["todo"]; ok { - var err error - arg0, err = UnmarshalTodoInput(tmp) - if err != nil { - return nil, err - } - - mTodoInput1, err := e.TodoInputMiddleware(ctx, &arg0) - if err != nil { - return nil, err - } - arg0 = *mTodoInput1 - } - args["todo"] = arg0 - return args, nil - -} - -func (e *executableSchema) field_MyQuery_todo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalID(tmp) - if err != nil { - return nil, err - } - } - args["id"] = arg0 - return args, nil - -} - -func (e *executableSchema) field_MyQuery___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - } - args["name"] = arg0 - return args, nil - -} - -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil - + return graphql.MarshalString(res) } -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } +// nolint: vetshadow +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, } - args["includeDeprecated"] = arg0 - return args, nil - -} - -type executableSchema struct { - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot -} - -func (e *executableSchema) Schema() *ast.Schema { - return parsedSchema -} - -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - switch typeName + "." + field { - - case "MyMutation.createTodo": - if e.complexity.MyMutation.CreateTodo == nil { - break - } - - args, err := e.field_MyMutation_createTodo_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.MyMutation.CreateTodo(childComplexity, args["todo"].(TodoInput)), true - - case "MyQuery.todos": - if e.complexity.MyQuery.Todos == nil { - break - } - - return e.complexity.MyQuery.Todos(childComplexity), true - - case "MyQuery.todo": - if e.complexity.MyQuery.Todo == nil { - break - } - - args, err := e.field_MyQuery_todo_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.MyQuery.Todo(childComplexity, args["id"].(string)), true - - case "Todo.id": - if e.complexity.Todo.Id == nil { - break - } - - return e.complexity.Todo.Id(childComplexity), true - - case "Todo.text": - if e.complexity.Todo.Text == nil { - break - } - - return e.complexity.Todo.Text(childComplexity), true - - case "Todo.state": - if e.complexity.Todo.State == nil { - break - } - - return e.complexity.Todo.State(childComplexity), true - - case "Todo.verified": - if e.complexity.Todo.Verified == nil { - break - } - - return e.complexity.Todo.Verified(childComplexity), true + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + if res == nil { + return graphql.Null } - return 0, false + return graphql.MarshalString(*res) } -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._MyQuery(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() +// nolint: vetshadow +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions} + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._MyMutation(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() +// nolint: vetshadow +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_fields_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(args["includeDeprecated"].(bool)), nil }) - - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions, + if resTmp == nil { + return graphql.Null } -} + res := resTmp.([]introspection.Field) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -type executionContext struct { - *graphql.RequestContext - *executableSchema -} + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } -func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } - }() - rctx := graphql.GetResolverContext(ctx) - for _, d := range rctx.Field.Definition.Directives { - switch d.Name { - case "enumLogging": - if ec.directives.EnumLogging != nil { - n := next - next = func(ctx context.Context) (interface{}, error) { - return ec.directives.EnumLogging(ctx, obj, n) - } - } - case "fieldLogging": - if ec.directives.FieldLogging != nil { - n := next - next = func(ctx context.Context) (interface{}, error) { - return ec.directives.FieldLogging(ctx, obj, n) - } - } - case "inputLogging": - if ec.directives.InputLogging != nil { - n := next - next = func(ctx context.Context) (interface{}, error) { - return ec.directives.InputLogging(ctx, obj, n) - } - } - case "interfaceLogging": - if ec.directives.InterfaceLogging != nil { - n := next - next = func(ctx context.Context) (interface{}, error) { - return ec.directives.InterfaceLogging(ctx, obj, n) - } - } - case "objectLogging": - if ec.directives.ObjectLogging != nil { - n := next - next = func(ctx context.Context) (interface{}, error) { - return ec.directives.ObjectLogging(ctx, obj, n) - } - } - case "scalarLogging": - if ec.directives.ScalarLogging != nil { - n := next - next = func(ctx context.Context) (interface{}, error) { - return ec.directives.ScalarLogging(ctx, obj, n) - } - } - case "unionLogging": - if ec.directives.UnionLogging != nil { - n := next - next = func(ctx context.Context) (interface{}, error) { - return ec.directives.UnionLogging(ctx, obj, n) - } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___Field(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) } - } - res, err := ec.ResolverMiddleware(ctx, next) - if err != nil { - ec.Error(ctx, err) - return nil - } - return res -} -func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") } - return introspection.WrapSchema(parsedSchema), nil + wg.Wait() + return arr1 } -func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") +// nolint: vetshadow +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil -} - -var parsedSchema = gqlparser.MustLoadSchema( - &ast.Source{Name: "schemas/enum-extension.graphql", Input: `directive @enumLogging on ENUM + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -extend enum State @enumLogging -`}, - &ast.Source{Name: "schemas/input-object-extension.graphql", Input: `directive @inputLogging on INPUT_OBJECT + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -extend input TodoInput @inputLogging -`}, - &ast.Source{Name: "schemas/interface-extension.graphql", Input: `directive @interfaceLogging on INTERFACE + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } -extend interface Node @interfaceLogging -`}, - &ast.Source{Name: "schemas/object-extension.graphql", Input: `directive @objectLogging on OBJECT + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { -extend type Todo @objectLogging -`}, - &ast.Source{Name: "schemas/scalar-extension.graphql", Input: `directive @scalarLogging on SCALAR + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } -extend scalar ID @scalarLogging -`}, - &ast.Source{Name: "schemas/schema-extension.graphql", Input: `extend schema { - mutation: MyMutation + } + wg.Wait() + return arr1 } -extend type MyQuery { - todo(id: ID!): Todo -} +// nolint: vetshadow +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -type MyMutation { - createTodo(todo: TodoInput!): Todo! -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -input TodoInput { - text: String! -} -`}, - &ast.Source{Name: "schemas/schema.graphql", Input: `# GraphQL schema example -# -# https://gqlgen.com/getting-started/ + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } -schema { - query: MyQuery -} + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { -interface Node { - id: ID! -} + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } -type Todo implements Node { - id: ID! - text: String! - state: State! + } + wg.Wait() + return arr1 } -type MyQuery { - todos: [Todo!]! -} +// nolint: vetshadow +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(args["includeDeprecated"].(bool)), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -union Data = Todo + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -enum State { - NOT_YET - DONE -} -`}, - &ast.Source{Name: "schemas/type-extension.graphql", Input: `directive @fieldLogging on FIELD_DEFINITION + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } -extend type Todo { - verified: Boolean! @fieldLogging + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { + + return ec.___EnumValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } + + } + wg.Wait() + return arr1 } -`}, - &ast.Source{Name: "schemas/union-extension.graphql", Input: `directive @unionLogging on UNION -extend union Data @unionLogging -`}, -) +// nolint: vetshadow +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() } - return handleFunc[0](ctx, chainHandler) + arr1[idx1] = func() graphql.Marshaler { + + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) } + } + wg.Wait() + return arr1 +} - if n == 1 { - return handleFunc[0] +// nolint: vetshadow +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if resTmp == nil { + return graphql.Null } + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) + if res == nil { + return graphql.Null } + + return ec.___Type(ctx, field.Selections, res) } -// endregion ************************** generated.gotpl *************************** +// endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** diff --git a/example/type-system-extension/models_gen.go b/example/type-system-extension/models_gen.go index 63b1695609e..ece1b800b2e 100644 --- a/example/type-system-extension/models_gen.go +++ b/example/type-system-extension/models_gen.go @@ -1,3 +1,5 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + package type_system_extension import ( diff --git a/integration/generated.go b/integration/generated.go index 689db4a3630..4e3fcf406e5 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -17,6 +17,449 @@ import ( "github.com/vektah/gqlparser/ast" ) +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + Element() ElementResolver + Query() QueryResolver + User() UserResolver +} + +type DirectiveRoot struct { + Magic func(ctx context.Context, obj interface{}, next graphql.Resolver, kind *int) (res interface{}, err error) +} + +type ComplexityRoot struct { + Element struct { + Child func(childComplexity int) int + Error func(childComplexity int) int + Mismatched func(childComplexity int) int + } + + Query struct { + Path func(childComplexity int) int + Date func(childComplexity int, filter models.DateFilter) int + Viewer func(childComplexity int) int + JsonEncoding func(childComplexity int) int + Error func(childComplexity int, typeArg *models.ErrorType) int + } + + User struct { + Name func(childComplexity int) int + Likes func(childComplexity int) int + } + + Viewer struct { + User func(childComplexity int) int + } +} + +type ElementResolver interface { + Child(ctx context.Context, obj *models.Element) (models.Element, error) + Error(ctx context.Context, obj *models.Element) (bool, error) + Mismatched(ctx context.Context, obj *models.Element) ([]bool, error) +} +type QueryResolver interface { + Path(ctx context.Context) ([]*models.Element, error) + Date(ctx context.Context, filter models.DateFilter) (bool, error) + Viewer(ctx context.Context) (*models.Viewer, error) + JSONEncoding(ctx context.Context) (string, error) + Error(ctx context.Context, typeArg *models.ErrorType) (bool, error) +} +type UserResolver interface { + Likes(ctx context.Context, obj *remote_api.User) ([]string, error) +} + +type executableSchema struct { + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + switch typeName + "." + field { + + case "Element.child": + if e.complexity.Element.Child == nil { + break + } + + return e.complexity.Element.Child(childComplexity), true + + case "Element.error": + if e.complexity.Element.Error == nil { + break + } + + return e.complexity.Element.Error(childComplexity), true + + case "Element.mismatched": + if e.complexity.Element.Mismatched == nil { + break + } + + return e.complexity.Element.Mismatched(childComplexity), true + + case "Query.path": + if e.complexity.Query.Path == nil { + break + } + + return e.complexity.Query.Path(childComplexity), true + + case "Query.date": + if e.complexity.Query.Date == nil { + break + } + + args, err := e.field_Query_date_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Date(childComplexity, args["filter"].(models.DateFilter)), true + + case "Query.viewer": + if e.complexity.Query.Viewer == nil { + break + } + + return e.complexity.Query.Viewer(childComplexity), true + + case "Query.jsonEncoding": + if e.complexity.Query.JsonEncoding == nil { + break + } + + return e.complexity.Query.JsonEncoding(childComplexity), true + + case "Query.error": + if e.complexity.Query.Error == nil { + break + } + + args, err := e.field_Query_error_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Error(childComplexity, args["type"].(*models.ErrorType)), true + + case "User.name": + if e.complexity.User.Name == nil { + break + } + + return e.complexity.User.Name(childComplexity), true + + case "User.likes": + if e.complexity.User.Likes == nil { + break + } + + return e.complexity.User.Likes(childComplexity), true + + case "Viewer.user": + if e.complexity.Viewer.User == nil { + break + } + + return e.complexity.Viewer.User(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + ec := executionContext{graphql.GetRequestContext(ctx), e} + + buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { + data := ec._Query(ctx, op.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + return buf.Bytes() + }) + + return &graphql.Response{ + Data: buf, + Errors: ec.Errors, + Extensions: ec.Extensions} +} + +func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { + return graphql.ErrorResponse(ctx, "mutations are not supported") +} + +func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { + return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) +} + +type executionContext struct { + *graphql.RequestContext + *executableSchema +} + +func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + rctx := graphql.GetResolverContext(ctx) + for _, d := range rctx.Field.Definition.Directives { + switch d.Name { + case "magic": + if ec.directives.Magic != nil { + rawArgs := d.ArgumentMap(ec.Variables) + args, err := ec.dir_magic_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return nil + } + n := next + next = func(ctx context.Context) (interface{}, error) { + return ec.directives.Magic(ctx, obj, n, args["kind"].(*int)) + } + } + } + } + res, err := ec.ResolverMiddleware(ctx, next) + if err != nil { + ec.Error(ctx, err) + return nil + } + return res +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(parsedSchema), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil +} + +var parsedSchema = gqlparser.MustLoadSchema( + &ast.Source{Name: "schema.graphql", Input: `"This directive does magical things" +directive @magic(kind: Int) on FIELD_DEFINITION + +type Element { + child: Element! + error: Boolean! + mismatched: [Boolean!] +} + +enum DATE_FILTER_OP { + # multi + # line + # comment + EQ + NEQ + GT + GTE + LT + LTE +} + +input DateFilter { + value: String! + timezone: String = "UTC" + op: DATE_FILTER_OP = EQ +} + +type Viewer { + user: User +} + +type Query { + path: [Element] + date(filter: DateFilter!): Boolean! + viewer: Viewer + jsonEncoding: String! + error(type: ErrorType = NORMAL): Boolean! +} + +enum ErrorType { + CUSTOM + NORMAL +} + +# this is a comment with a ` + "`" + `backtick` + "`" + ` +`}, + &ast.Source{Name: "user.graphql", Input: `type User { + name: String! + likes: [String!]! +} +`}, +) + +// ChainFieldMiddleware add chain by FieldMiddleware +// nolint: deadcode +func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { + n := len(handleFunc) + + if n > 1 { + lastI := n - 1 + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + var ( + chainHandler graphql.Resolver + curI int + ) + chainHandler = func(currentCtx context.Context) (interface{}, error) { + if curI == lastI { + return next(currentCtx) + } + curI++ + res, err := handleFunc[curI](currentCtx, chainHandler) + curI-- + return res, err + + } + return handleFunc[0](ctx, chainHandler) + } + } + + if n == 1 { + return handleFunc[0] + } + + return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { + return next(ctx) + } +} + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (e *executableSchema) dir_magic_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *int + if tmp, ok := rawArgs["kind"]; ok { + var err error + var ptr1 int + if tmp != nil { + ptr1, err = graphql.UnmarshalInt(tmp) + arg0 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["kind"] = arg0 + return args, nil +} + +func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + var err error + arg0, err = graphql.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg0 + return args, nil +} + +func (e *executableSchema) field_Query_date_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 models.DateFilter + if tmp, ok := rawArgs["filter"]; ok { + var err error + arg0, err = UnmarshalDateFilter(tmp) + if err != nil { + return nil, err + } + + mDateFilter1, err := e.DateFilterMiddleware(ctx, &arg0) + if err != nil { + return nil, err + } + arg0 = *mDateFilter1 + } + args["filter"] = arg0 + return args, nil +} + +func (e *executableSchema) field_Query_error_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *models.ErrorType + if tmp, ok := rawArgs["type"]; ok { + var err error + var ptr1 models.ErrorType + if tmp != nil { + err = (&ptr1).UnmarshalGQL(tmp) + arg0 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["type"] = arg0 + return args, nil +} + +func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil +} + +func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + var err error + arg0, err = graphql.UnmarshalBoolean(tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil +} + +// endregion ***************************** args.gotpl ***************************** + // region **************************** field.gotpl ***************************** // nolint: vetshadow @@ -317,318 +760,52 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Schema) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Schema(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *remote_api.User) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) _User_likes(ctx context.Context, field graphql.CollectedField, obj *remote_api.User) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.User().Likes(rctx, obj) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 -} - -// nolint: vetshadow -func (ec *executionContext) _Viewer_user(ctx context.Context, field graphql.CollectedField, obj *models.Viewer) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Viewer", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.User, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*remote_api.User) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec._User(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Description, nil - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Locations, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]string) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 -} - -// nolint: vetshadow -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Args, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]introspection.InputValue) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + if res == nil { + return graphql.Null } - wg.Wait() - return arr1 + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "Query", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return ec.introspectSchema() }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + + return ec.___Schema(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *remote_api.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "User", Field: field, Args: nil, } @@ -636,9 +813,12 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.Name, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(string) @@ -648,11 +828,11 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _User_likes(ctx context.Context, field graphql.CollectedField, obj *remote_api.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "User", Field: field, Args: nil, } @@ -660,7 +840,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return ec.resolvers.User().Likes(rctx, obj) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -668,18 +848,27 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field } return graphql.Null } - res := resTmp.(bool) + res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + + arr1 := make(graphql.Array, len(res)) + + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { + return graphql.MarshalString(res[idx1]) + }() + } + + return arr1 } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) _Viewer_user(ctx context.Context, field graphql.CollectedField, obj *models.Viewer) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", + Object: "Viewer", Field: field, Args: nil, } @@ -687,27 +876,28 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.User, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*remote_api.User) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { return graphql.Null } - return graphql.MarshalString(*res) + + return ec._User(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Directive", Field: field, Args: nil, } @@ -730,11 +920,11 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Directive", Field: field, Args: nil, } @@ -754,11 +944,47 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap } // nolint: vetshadow -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__Directive", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + + arr1 := make(graphql.Array, len(res)) + + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { + return graphql.MarshalString(res[idx1]) + }() + } + + return arr1 +} + +// nolint: vetshadow +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Directive", Field: field, Args: nil, } @@ -814,46 +1040,11 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Type, nil - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*introspection.Type) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// nolint: vetshadow -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__EnumValue", Field: field, Args: nil, } @@ -861,7 +1052,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IsDeprecated(), nil + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -869,18 +1060,18 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", + Object: "__EnumValue", Field: field, Args: nil, } @@ -888,27 +1079,23 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DeprecationReason(), nil + return obj.Description, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__EnumValue", Field: field, Args: nil, } @@ -916,7 +1103,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.IsDeprecated(), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -924,18 +1111,18 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(string) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__EnumValue", Field: field, Args: nil, } @@ -943,23 +1130,27 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.DeprecationReason(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Field", Field: field, Args: nil, } @@ -967,7 +1158,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Type, nil + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -975,26 +1166,18 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", + Object: "__Field", Field: field, Args: nil, } @@ -1002,27 +1185,23 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.DefaultValue, nil + return obj.Description, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Field", Field: field, Args: nil, } @@ -1030,7 +1209,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Types(), nil + return obj.Args, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1038,7 +1217,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1063,7 +1242,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } arr1[idx1] = func() graphql.Marshaler { - return ec.___Type(ctx, field.Selections, &res[idx1]) + return ec.___InputValue(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1078,11 +1257,11 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } // nolint: vetshadow -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Field", Field: field, Args: nil, } @@ -1090,7 +1269,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.QueryType(), nil + return obj.Type, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1113,11 +1292,11 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } // nolint: vetshadow -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Field", Field: field, Args: nil, } @@ -1125,28 +1304,26 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.MutationType(), nil + return obj.IsDeprecated(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalBoolean(res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__Field", Field: field, Args: nil, } @@ -1154,28 +1331,27 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.SubscriptionType(), nil + return obj.DeprecationReason(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { return graphql.Null } - - return ec.___Type(ctx, field.Selections, res) + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", + Object: "__InputValue", Field: field, Args: nil, } @@ -1183,7 +1359,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Directives(), nil + return obj.Name, nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1191,51 +1367,18 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap } return graphql.Null } - res := resTmp.([]introspection.Directive) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Directive(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__InputValue", Field: field, Args: nil, } @@ -1243,12 +1386,9 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Kind(), nil + return obj.Description, nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } res := resTmp.(string) @@ -1258,11 +1398,11 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll } // nolint: vetshadow -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__InputValue", Field: field, Args: nil, } @@ -1270,27 +1410,34 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name(), nil + return obj.Type, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - return graphql.MarshalString(*res) + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__InputValue", Field: field, Args: nil, } @@ -1298,43 +1445,43 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description(), nil + return obj.DefaultValue, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(string) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + + if res == nil { + return graphql.Null + } + return graphql.MarshalString(*res) } // nolint: vetshadow -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_fields_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Fields(args["includeDeprecated"].(bool)), nil + return obj.Types(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.Field) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1359,7 +1506,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } arr1[idx1] = func() graphql.Marshaler { - return ec.___Field(ctx, field.Selections, &res[idx1]) + return ec.___Type(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1374,11 +1521,11 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } // nolint: vetshadow -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } @@ -1386,56 +1533,34 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Interfaces(), nil + return obj.QueryType(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) + if res == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") } - + return graphql.Null } - wg.Wait() - return arr1 + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } @@ -1443,76 +1568,73 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PossibleTypes(), nil + return obj.MutationType(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection.Type) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) + if res == nil { + return graphql.Null } - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { + return ec.___Type(ctx, field.Selections, res) +} - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } +// nolint: vetshadow +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Schema", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + if res == nil { + return graphql.Null } - wg.Wait() - return arr1 + + return ec.___Type(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", + Object: "__Schema", Field: field, Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field___Type_enumValues_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.EnumValues(args["includeDeprecated"].(bool)), nil + return obj.Directives(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.EnumValue) + res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -1537,7 +1659,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } arr1[idx1] = func() graphql.Marshaler { - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) + return ec.___Directive(ctx, field.Selections, &res[idx1]) }() } if isLen1 { @@ -1552,7 +1674,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } // nolint: vetshadow -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1564,52 +1686,22 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.InputFields(), nil + return obj.Kind(), nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]introspection.InputValue) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return graphql.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1621,468 +1713,374 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.OfType(), nil + return obj.Name(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) if res == nil { return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) -} - -// endregion **************************** field.gotpl ***************************** - -// region ************************** generated.gotpl *************************** - -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - resolvers: cfg.Resolvers, - directives: cfg.Directives, - complexity: cfg.Complexity, - } -} - -type Config struct { - Resolvers ResolverRoot - Directives DirectiveRoot - Complexity ComplexityRoot -} - -type ResolverRoot interface { - Element() ElementResolver - Query() QueryResolver - User() UserResolver -} - -type DirectiveRoot struct { - Magic func(ctx context.Context, obj interface{}, next graphql.Resolver, kind *int) (res interface{}, err error) -} - -type ComplexityRoot struct { - Element struct { - Child func(childComplexity int) int - Error func(childComplexity int) int - Mismatched func(childComplexity int) int - } - - Query struct { - Path func(childComplexity int) int - Date func(childComplexity int, filter models.DateFilter) int - Viewer func(childComplexity int) int - JsonEncoding func(childComplexity int) int - Error func(childComplexity int, typeArg *models.ErrorType) int - } - - User struct { - Name func(childComplexity int) int - Likes func(childComplexity int) int - } - - Viewer struct { - User func(childComplexity int) int - } -} - -type ElementResolver interface { - Child(ctx context.Context, obj *models.Element) (models.Element, error) - Error(ctx context.Context, obj *models.Element) (bool, error) - Mismatched(ctx context.Context, obj *models.Element) ([]bool, error) -} -type QueryResolver interface { - Path(ctx context.Context) ([]*models.Element, error) - Date(ctx context.Context, filter models.DateFilter) (bool, error) - Viewer(ctx context.Context) (*models.Viewer, error) - JSONEncoding(ctx context.Context) (string, error) - Error(ctx context.Context, typeArg *models.ErrorType) (bool, error) -} -type UserResolver interface { - Likes(ctx context.Context, obj *remote_api.User) ([]string, error) -} - -func (e *executableSchema) field_Query_date_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 models.DateFilter - if tmp, ok := rawArgs["filter"]; ok { - var err error - arg0, err = UnmarshalDateFilter(tmp) - if err != nil { - return nil, err - } - - mDateFilter1, err := e.DateFilterMiddleware(ctx, &arg0) - if err != nil { - return nil, err - } - arg0 = *mDateFilter1 - } - args["filter"] = arg0 - return args, nil - -} - -func (e *executableSchema) field_Query_error_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *models.ErrorType - if tmp, ok := rawArgs["type"]; ok { - var err error - var ptr1 models.ErrorType - if tmp != nil { - err = (&ptr1).UnmarshalGQL(tmp) - arg0 = &ptr1 - } - - if err != nil { - return nil, err - } - } - args["type"] = arg0 - return args, nil - -} - -func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - } - args["name"] = arg0 - return args, nil - -} - -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil - -} - -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 bool - if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) - if err != nil { - return nil, err - } - } - args["includeDeprecated"] = arg0 - return args, nil - -} - -func (e *executableSchema) dir_magic_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - args := map[string]interface{}{} - var arg0 *int - if tmp, ok := rawArgs["kind"]; ok { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg0 = &ptr1 - } - - if err != nil { - return nil, err - } - } - args["kind"] = arg0 - return args, nil - -} - -type executableSchema struct { - resolvers ResolverRoot - directives DirectiveRoot - complexity ComplexityRoot + } + return graphql.MarshalString(*res) } -func (e *executableSchema) Schema() *ast.Schema { - return parsedSchema +// nolint: vetshadow +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return graphql.MarshalString(res) } -func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { - switch typeName + "." + field { - - case "Element.child": - if e.complexity.Element.Child == nil { - break - } - - return e.complexity.Element.Child(childComplexity), true - - case "Element.error": - if e.complexity.Element.Error == nil { - break - } - - return e.complexity.Element.Error(childComplexity), true - - case "Element.mismatched": - if e.complexity.Element.Mismatched == nil { - break - } - - return e.complexity.Element.Mismatched(childComplexity), true - - case "Query.path": - if e.complexity.Query.Path == nil { - break - } +// nolint: vetshadow +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_fields_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(args["includeDeprecated"].(bool)), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return e.complexity.Query.Path(childComplexity), true + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - case "Query.date": - if e.complexity.Query.Date == nil { - break - } + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - args, err := e.field_Query_date_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.Query.Date(childComplexity, args["filter"].(models.DateFilter)), true - - case "Query.viewer": - if e.complexity.Query.Viewer == nil { - break + return ec.___Field(ctx, field.Selections, &res[idx1]) + }() } - - return e.complexity.Query.Viewer(childComplexity), true - - case "Query.jsonEncoding": - if e.complexity.Query.JsonEncoding == nil { - break + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.Query.JsonEncoding(childComplexity), true + } + wg.Wait() + return arr1 +} - case "Query.error": - if e.complexity.Query.Error == nil { - break - } +// nolint: vetshadow +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - args, err := e.field_Query_error_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - return e.complexity.Query.Error(childComplexity, args["type"].(*models.ErrorType)), true + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } - case "User.name": - if e.complexity.User.Name == nil { - break + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { - return e.complexity.User.Name(childComplexity), true - - case "User.likes": - if e.complexity.User.Likes == nil { - break + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() } - - return e.complexity.User.Likes(childComplexity), true - - case "Viewer.user": - if e.complexity.Viewer.User == nil { - break + if isLen1 { + f(idx1) + } else { + go f(idx1) } - return e.complexity.Viewer.User(childComplexity), true - } - return 0, false + wg.Wait() + return arr1 } -func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - ec := executionContext{graphql.GetRequestContext(ctx), e} - - buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._Query(ctx, op.SelectionSet) - var buf bytes.Buffer - data.MarshalGQL(&buf) - return buf.Bytes() +// nolint: vetshadow +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return &graphql.Response{ - Data: buf, - Errors: ec.Errors, - Extensions: ec.Extensions} -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { - return graphql.ErrorResponse(ctx, "mutations are not supported") -} + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { -func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { - return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) -} + return ec.___Type(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } -type executionContext struct { - *graphql.RequestContext - *executableSchema + } + wg.Wait() + return arr1 } -func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) (ret interface{}) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - rctx := graphql.GetResolverContext(ctx) - for _, d := range rctx.Field.Definition.Directives { - switch d.Name { - case "magic": - if ec.directives.Magic != nil { - rawArgs := d.ArgumentMap(ec.Variables) - args, err := ec.dir_magic_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return nil - } - n := next - next = func(ctx context.Context) (interface{}, error) { - return ec.directives.Magic(ctx, obj, n, args["kind"].(*int)) - } - } - } +// nolint: vetshadow +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, } - res, err := ec.ResolverMiddleware(ctx, next) + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field___Type_enumValues_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) - return nil - } - return res -} - -func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") + return graphql.Null } - return introspection.WrapSchema(parsedSchema), nil -} - -func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { - if ec.DisableIntrospection { - return nil, errors.New("introspection disabled") + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(args["includeDeprecated"].(bool)), nil + }) + if resTmp == nil { + return graphql.Null } - return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil -} - -var parsedSchema = gqlparser.MustLoadSchema( - &ast.Source{Name: "schema.graphql", Input: `"This directive does magical things" -directive @magic(kind: Int) on FIELD_DEFINITION - -type Element { - child: Element! - error: Boolean! - mismatched: [Boolean!] -} + res := resTmp.([]introspection.EnumValue) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -enum DATE_FILTER_OP { - # multi - # line - # comment - EQ - NEQ - GT - GTE - LT - LTE -} + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup -input DateFilter { - value: String! - timezone: String = "UTC" - op: DATE_FILTER_OP = EQ -} + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } -type Viewer { - user: User -} + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() + } + arr1[idx1] = func() graphql.Marshaler { -type Query { - path: [Element] - date(filter: DateFilter!): Boolean! - viewer: Viewer - jsonEncoding: String! - error(type: ErrorType = NORMAL): Boolean! -} + return ec.___EnumValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) + } -enum ErrorType { - CUSTOM - NORMAL + } + wg.Wait() + return arr1 } -# this is a comment with a ` + "`" + `backtick` + "`" + ` -`}, - &ast.Source{Name: "user.graphql", Input: `type User { - name: String! - likes: [String!]! -} -`}, -) +// nolint: vetshadow +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) + arr1 := make(graphql.Array, len(res)) + var wg sync.WaitGroup - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err + isLen1 := len(res) == 1 + if !isLen1 { + wg.Add(len(res)) + } + for idx1 := range res { + idx1 := idx1 + rctx := &graphql.ResolverContext{ + Index: &idx1, + Result: &res[idx1], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(idx1 int) { + if !isLen1 { + defer wg.Done() } - return handleFunc[0](ctx, chainHandler) + arr1[idx1] = func() graphql.Marshaler { + + return ec.___InputValue(ctx, field.Selections, &res[idx1]) + }() + } + if isLen1 { + f(idx1) + } else { + go f(idx1) } + } + wg.Wait() + return arr1 +} - if n == 1 { - return handleFunc[0] +// nolint: vetshadow +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if resTmp == nil { + return graphql.Null } + res := resTmp.(*introspection.Type) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) + if res == nil { + return graphql.Null } + + return ec.___Type(ctx, field.Selections, res) } -// endregion ************************** generated.gotpl *************************** +// endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** diff --git a/integration/models-go/generated.go b/integration/models-go/generated.go index 62e460cb2ff..7d4b611e83e 100644 --- a/integration/models-go/generated.go +++ b/integration/models-go/generated.go @@ -1,3 +1,5 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + package models import ( diff --git a/plugin/modelgen/models.go b/plugin/modelgen/models.go index 7df76ac853e..b2a92bcfa7f 100644 --- a/plugin/modelgen/models.go +++ b/plugin/modelgen/models.go @@ -178,8 +178,9 @@ func (m *Plugin) MutateConfig(cfg *config.Config) error { } return templates.Render(templates.Options{ - PackageName: cfg.Model.Package, - Filename: cfg.Model.Filename, - Data: b, + PackageName: cfg.Model.Package, + Filename: cfg.Model.Filename, + Data: b, + GeneratedHeader: true, }) } From 4e49d489cf589001179b68efe5ee2f5f1f823070 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Mon, 4 Feb 2019 14:50:26 +1100 Subject: [PATCH 053/147] Merge object build and bind --- codegen/build_bind.go | 61 ---------- codegen/build_object.go | 66 +---------- codegen/build_typedef.go | 12 +- codegen/config/binder.go | 41 ++++++- codegen/config/config.go | 13 ++- codegen/data.go | 6 +- codegen/field.go | 8 +- codegen/field.gotpl | 6 +- codegen/generated!.gotpl | 22 ++-- codegen/input.gotpl | 14 +-- codegen/object.go | 122 ++++++++++++++++++-- codegen/object.gotpl | 22 ++-- codegen/schema_test.go | 4 + codegen/testserver/generated.go | 125 +++++++++++---------- codegen/testserver/generated_test.go | 6 +- example/chat/generated.go | 3 +- example/config/generated.go | 3 +- example/dataloader/generated.go | 3 +- example/scalars/generated.go | 3 +- example/selection/generated.go | 3 +- example/starwars/generated.go | 3 +- example/todo/generated.go | 3 +- example/type-system-extension/generated.go | 3 +- graphql/root.go | 7 ++ integration/generated.go | 3 +- plugin/modelgen/models.go | 2 + plugin/resolvergen/resolver.gotpl | 8 +- 27 files changed, 308 insertions(+), 264 deletions(-) create mode 100644 graphql/root.go diff --git a/codegen/build_bind.go b/codegen/build_bind.go index 208785ec6f2..bb6b9e0e28a 100644 --- a/codegen/build_bind.go +++ b/codegen/build_bind.go @@ -10,67 +10,6 @@ import ( "github.com/pkg/errors" ) -type BindError struct { - object *Object - field *Field - typ types.Type - methodErr error - varErr error -} - -func (b BindError) Error() string { - return fmt.Sprintf( - "\nunable to bind %s.%s to %s\n %s\n %s", - b.object.Definition.GQLDefinition.Name, - b.field.GQLName, - b.typ.String(), - b.methodErr.Error(), - b.varErr.Error(), - ) -} - -type BindErrors []BindError - -func (b BindErrors) Error() string { - var errs []string - for _, err := range b { - errs = append(errs, err.Error()) - } - return strings.Join(errs, "\n\n") -} - -func (b *builder) bindObject(object *Object) BindErrors { - var errs BindErrors - for _, field := range object.Fields { - if field.IsResolver { - continue - } - - // first try binding to a method - methodErr := b.bindMethod(object.Definition.GoType, field) - if methodErr == nil { - continue - } - - // otherwise try binding to a var - varErr := b.bindVar(object.Definition.GoType, field) - - // if both failed, add a resolver - if varErr != nil { - field.IsResolver = true - - errs = append(errs, BindError{ - object: object, - typ: object.Definition.GoType, - field: field, - varErr: varErr, - methodErr: methodErr, - }) - } - } - return errs -} - func (b *builder) bindMethod(t types.Type, field *Field) error { namedType, err := findGoNamedType(t) if err != nil { diff --git a/codegen/build_object.go b/codegen/build_object.go index 75a0bf8c567..5154a018041 100644 --- a/codegen/build_object.go +++ b/codegen/build_object.go @@ -1,75 +1,11 @@ package codegen import ( - "go/types" - "log" - "strings" - "github.com/99designs/gqlgen/codegen/templates" - "github.com/pkg/errors" "github.com/vektah/gqlparser/ast" ) -func (b *builder) buildObject(typ *ast.Definition) (*Object, error) { - dirs, err := b.getDirectives(typ.Directives) - if err != nil { - return nil, errors.Wrap(err, typ.Name) - } - - isRoot := typ == b.Schema.Query || typ == b.Schema.Mutation || typ == b.Schema.Subscription - - obj := &Object{ - Definition: b.NamedTypes[typ.Name], - InTypemap: b.Config.Models.UserDefined(typ.Name) || isRoot, - Root: isRoot, - DisableConcurrency: typ == b.Schema.Mutation, - Stream: typ == b.Schema.Subscription, - Directives: dirs, - ResolverInterface: types.NewNamed( - types.NewTypeName(0, b.Config.Exec.Pkg(), typ.Name+"Resolver", nil), - nil, - nil, - ), - } - - for _, intf := range b.Schema.GetImplements(typ) { - obj.Implements = append(obj.Implements, b.NamedTypes[intf.Name]) - } - - for _, field := range typ.Fields { - if strings.HasPrefix(field.Name, "__") { - continue - } - - f, err := b.buildField(obj, field) - if err != nil { - return nil, errors.Wrap(err, typ.Name+"."+field.Name) - } - - if typ.Kind == ast.InputObject && !f.TypeReference.Definition.GQLDefinition.IsInputType() { - return nil, errors.Errorf( - "%s.%s: cannot use %s because %s is not a valid input type", - typ.Name, - field.Name, - f.Definition.GQLDefinition.Name, - f.TypeReference.Definition.GQLDefinition.Kind, - ) - } - - obj.Fields = append(obj.Fields, f) - } - - if obj.InTypemap && !isMap(obj.Definition.GoType) { - for _, bindErr := range b.bindObject(obj) { - log.Println(bindErr.Error()) - log.Println(" Adding resolver method") - } - } - - return obj, nil -} - func (b *builder) buildField(obj *Object, field *ast.FieldDefinition) (*Field, error) { dirs, err := b.getDirectives(field.Directives) if err != nil { @@ -94,7 +30,7 @@ func (b *builder) buildField(obj *Object, field *ast.FieldDefinition) (*Field, e } } - typeEntry, entryExists := b.Config.Models[obj.Definition.GQLDefinition.Name] + typeEntry, entryExists := b.Config.Models[obj.Definition.Name] if entryExists { if typeField, ok := typeEntry.Fields[field.Name]; ok { if typeField.Resolver { diff --git a/codegen/build_typedef.go b/codegen/build_typedef.go index e167ae416d3..989ced94803 100644 --- a/codegen/build_typedef.go +++ b/codegen/build_typedef.go @@ -4,9 +4,9 @@ import ( "fmt" "go/types" - "github.com/99designs/gqlgen/internal/code" - + "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/codegen/templates" + "github.com/99designs/gqlgen/internal/code" "github.com/pkg/errors" "github.com/vektah/gqlparser/ast" ) @@ -20,7 +20,13 @@ func (b *builder) buildTypeDef(schemaType *ast.Definition) (*TypeDefinition, err if userEntry, ok := b.Config.Models[t.GQLDefinition.Name]; ok && userEntry.Model != "" { // special case for maps if userEntry.Model == "map[string]interface{}" { - t.GoType = types.NewMap(types.Typ[types.String], types.NewInterfaceType(nil, nil).Complete()) + t.GoType = config.MapType + + return t, nil + } + + if userEntry.Model == "interface{}" { + t.GoType = config.InterfaceType return t, nil } diff --git a/codegen/config/binder.go b/codegen/config/binder.go index 2b8e6af31f2..3878f4701f7 100644 --- a/codegen/config/binder.go +++ b/codegen/config/binder.go @@ -7,9 +7,8 @@ import ( "strings" "github.com/99designs/gqlgen/internal/code" - "github.com/vektah/gqlparser/ast" - "github.com/pkg/errors" + "github.com/vektah/gqlparser/ast" "golang.org/x/tools/go/packages" ) @@ -52,6 +51,36 @@ func (b *Binder) getPkg(find string) *packages.Package { return nil } +var MapType = types.NewMap(types.Typ[types.String], types.NewInterfaceType(nil, nil).Complete()) +var InterfaceType = types.NewInterfaceType(nil, nil) + +func (b *Binder) FindUserObject(name string) (types.Type, error) { + userEntry, ok := b.types[name] + if !ok { + return nil, fmt.Errorf(name + " not found") + } + + if userEntry.Model == "map[string]interface{}" { + return MapType, nil + } + + if userEntry.Model == "interface{}" { + return InterfaceType, nil + } + + pkgName, typeName := code.PkgAndType(userEntry.Model) + if pkgName == "" { + return nil, fmt.Errorf("missing package name for %s", name) + } + + obj, err := b.FindObject(pkgName, typeName) + if err != nil { + return nil, err + } + + return obj.Type(), nil +} + func (b *Binder) FindObject(pkgName string, typeName string) (types.Object, error) { if pkgName == "" { return nil, fmt.Errorf("package cannot be nil") @@ -95,12 +124,16 @@ func (b *Binder) FindBackingType(schemaType *ast.Type) (types.Type, error) { if userEntry, ok := b.types[schemaType.Name()]; ok && userEntry.Model != "" { // special case for maps if userEntry.Model == "map[string]interface{}" { - return types.NewMap(types.Typ[types.String], types.NewInterfaceType(nil, nil).Complete()), nil + return MapType, nil + } + + if userEntry.Model == "interface{}" { + return InterfaceType, nil } pkgName, typeName = code.PkgAndType(userEntry.Model) if pkgName == "" { - return nil, fmt.Errorf("missing package name for %s", schemaType.Name) + return nil, fmt.Errorf("missing package name for %s", schemaType.Name()) } } else { diff --git a/codegen/config/config.go b/codegen/config/config.go index 688763d5843..5e07ef02ba8 100644 --- a/codegen/config/config.go +++ b/codegen/config/config.go @@ -293,6 +293,14 @@ func (c *Config) normalize() error { } } + if c.Models == nil { + c.Models = TypeMap{} + } + + return nil +} + +func (c *Config) InjectBuiltins(s *ast.Schema) { builtins := TypeMap{ "__Directive": {Model: "github.com/99designs/gqlgen/graphql/introspection.Directive"}, "__DirectiveLocation": {Model: "github.com/99designs/gqlgen/graphql.String"}, @@ -311,16 +319,11 @@ func (c *Config) normalize() error { "Map": {Model: "github.com/99designs/gqlgen/graphql.Map"}, } - if c.Models == nil { - c.Models = TypeMap{} - } for typeName, entry := range builtins { if !c.Models.Exists(typeName) { c.Models[typeName] = entry } } - - return nil } func (c *TypeMapEntry) PkgAndType() (string, string) { diff --git a/codegen/data.go b/codegen/data.go index 43866c7a8d7..d81a92d9aa8 100644 --- a/codegen/data.go +++ b/codegen/data.go @@ -52,6 +52,8 @@ func BuildData(cfg *config.Config) (*Data, error) { return nil, err } + cfg.InjectBuiltins(b.Schema) + b.Binder, err = b.Config.NewBinder() if err != nil { return nil, err @@ -124,11 +126,11 @@ func BuildData(cfg *config.Config) (*Data, error) { } sort.Slice(s.Objects, func(i, j int) bool { - return s.Objects[i].Definition.GQLDefinition.Name < s.Objects[j].Definition.GQLDefinition.Name + return s.Objects[i].Definition.Name < s.Objects[j].Definition.Name }) sort.Slice(s.Inputs, func(i, j int) bool { - return s.Inputs[i].Definition.GQLDefinition.Name < s.Inputs[j].Definition.GQLDefinition.Name + return s.Inputs[i].Definition.Name < s.Inputs[j].Definition.Name }) sort.Slice(s.Interfaces, func(i, j int) bool { diff --git a/codegen/field.go b/codegen/field.go index e2763bf0d3b..7a03df14a24 100644 --- a/codegen/field.go +++ b/codegen/field.go @@ -53,7 +53,7 @@ func (f *Field) GoNameUnexported() string { } func (f *Field) ShortInvocation() string { - return fmt.Sprintf("%s().%s(%s)", f.Object.Definition.GQLDefinition.Name, f.GoFieldName, f.CallArgs()) + return fmt.Sprintf("%s().%s(%s)", f.Object.Definition.Name, f.GoFieldName, f.CallArgs()) } func (f *Field) ArgsFunc() string { @@ -61,7 +61,7 @@ func (f *Field) ArgsFunc() string { return "" } - return "field_" + f.Object.Definition.GQLDefinition.Name + "_" + f.GQLName + "_args" + return "field_" + f.Object.Definition.Name + "_" + f.GQLName + "_args" } func (f *Field) ResolverType() string { @@ -69,7 +69,7 @@ func (f *Field) ResolverType() string { return "" } - return fmt.Sprintf("%s().%s(%s)", f.Object.Definition.GQLDefinition.Name, f.GoFieldName, f.CallArgs()) + return fmt.Sprintf("%s().%s(%s)", f.Object.Definition.Name, f.GoFieldName, f.CallArgs()) } func (f *Field) ShortResolverDeclaration() string { @@ -79,7 +79,7 @@ func (f *Field) ShortResolverDeclaration() string { res := fmt.Sprintf("%s(ctx context.Context", f.GoFieldName) if !f.Object.Root { - res += fmt.Sprintf(", obj *%s", templates.CurrentImports.LookupType(f.Object.Definition.GoType)) + res += fmt.Sprintf(", obj *%s", templates.CurrentImports.LookupType(f.Object.Type)) } for _, arg := range f.Args { res += fmt.Sprintf(", %s %s", arg.GoVarName, templates.CurrentImports.LookupType(arg.GoType)) diff --git a/codegen/field.gotpl b/codegen/field.gotpl index 7b88c4a047e..0a4792d0099 100644 --- a/codegen/field.gotpl +++ b/codegen/field.gotpl @@ -1,7 +1,7 @@ {{- range $object := .Objects }}{{- range $field := $object.Fields }} {{- if $object.Stream }} - func (ec *executionContext) _{{$object.Definition.GQLDefinition.Name}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { + func (ec *executionContext) _{{$object.Name}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Field: field, Args: nil, @@ -40,11 +40,11 @@ } {{ else }} // nolint: vetshadow - func (ec *executionContext) _{{$object.Definition.GQLDefinition.Name}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField, {{if not $object.Root}}obj *{{$object.Definition.GoType | ref}}{{end}}) graphql.Marshaler { + func (ec *executionContext) _{{$object.Name}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField{{ if not $object.Root }}, obj *{{$object.Type | ref}}{{end}}) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func () { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: {{$object.Definition.GQLDefinition.Name|quote}}, + Object: {{$object.Name|quote}}, Field: field, Args: nil, } diff --git a/codegen/generated!.gotpl b/codegen/generated!.gotpl index 1dbc82b54c5..9f9f53be8b1 100644 --- a/codegen/generated!.gotpl +++ b/codegen/generated!.gotpl @@ -10,6 +10,7 @@ {{ reserveImport "github.com/vektah/gqlparser" }} {{ reserveImport "github.com/vektah/gqlparser/ast" }} {{ reserveImport "github.com/99designs/gqlgen/graphql" }} +{{ reserveImport "github.com/99designs/gqlgen/graphql/introspection" }} // NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. @@ -30,7 +31,7 @@ type Config struct { type ResolverRoot interface { {{- range $object := .Objects -}} {{ if $object.HasResolvers -}} - {{$object.Definition.GQLDefinition.Name}}() {{$object.Definition.GQLDefinition.Name}}Resolver + {{$object.Name}}() {{$object.Name}}Resolver {{ end }} {{- end }} } @@ -44,7 +45,7 @@ type DirectiveRoot struct { type ComplexityRoot struct { {{ range $object := .Objects }} {{ if not $object.IsReserved -}} - {{ $object.Definition.GQLDefinition.Name|toCamel }} struct { + {{ $object.Name|toCamel }} struct { {{ range $field := $object.Fields -}} {{ if not $field.IsReserved -}} {{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }} @@ -57,7 +58,7 @@ type ComplexityRoot struct { {{ range $object := .Objects -}} {{ if $object.HasResolvers }} - type {{$object.Definition.GQLDefinition.Name}}Resolver interface { + type {{$object.Name}}Resolver interface { {{ range $field := $object.Fields -}} {{ $field.ShortResolverDeclaration }} {{ end }} @@ -81,8 +82,8 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in {{ if not $object.IsReserved }} {{ range $field := $object.Fields }} {{ if not $field.IsReserved }} - case "{{$object.Definition.GQLDefinition.Name}}.{{$field.GQLName}}": - if e.complexity.{{$object.Definition.GQLDefinition.Name|toCamel}}.{{$field.GQLName|toCamel}} == nil { + case "{{$object.Name}}.{{$field.GQLName}}": + if e.complexity.{{$object.Name|toCamel}}.{{$field.GQLName|toCamel}} == nil { break } {{ if $field.Args }} @@ -91,7 +92,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } {{ end }} - return e.complexity.{{$object.Definition.GQLDefinition.Name|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true + return e.complexity.{{$object.Name|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true {{ end }} {{ end }} {{ end }} @@ -105,7 +106,7 @@ func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinitio ec := executionContext{graphql.GetRequestContext(ctx), e} buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._{{.QueryRoot.Definition.GQLDefinition.Name}}(ctx, op.SelectionSet) + data := ec._{{.QueryRoot.Name}}(ctx, op.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) return buf.Bytes() @@ -114,7 +115,8 @@ func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinitio return &graphql.Response{ Data: buf, Errors: ec.Errors, - Extensions: ec.Extensions, } + Extensions: ec.Extensions, + } {{- else }} return graphql.ErrorResponse(ctx, "queries are not supported") {{- end }} @@ -125,7 +127,7 @@ func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefini ec := executionContext{graphql.GetRequestContext(ctx), e} buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { - data := ec._{{.MutationRoot.Definition.GQLDefinition.Name}}(ctx, op.SelectionSet) + data := ec._{{.MutationRoot.Name}}(ctx, op.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) return buf.Bytes() @@ -145,7 +147,7 @@ func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDe {{- if .SubscriptionRoot }} ec := executionContext{graphql.GetRequestContext(ctx), e} - next := ec._{{.SubscriptionRoot.Definition.GQLDefinition.Name}}(ctx, op.SelectionSet) + next := ec._{{.SubscriptionRoot.Name}}(ctx, op.SelectionSet) if ec.Errors != nil { return graphql.OneShot(&graphql.Response{Data: []byte("null"), Errors: ec.Errors}) } diff --git a/codegen/input.gotpl b/codegen/input.gotpl index f74c199f38e..1e8e01fca64 100644 --- a/codegen/input.gotpl +++ b/codegen/input.gotpl @@ -1,7 +1,7 @@ {{- range $input := .Inputs }} - {{- if .Definition.IsMarshaled }} - func Unmarshal{{ .Definition.GQLDefinition.Name }}(v interface{}) ({{.Definition.GoType | ref}}, error) { - var it {{.Definition.GoType | ref}} + {{- if not .HasUnmarshal }} + func Unmarshal{{ .Name }}(v interface{}) ({{.Type | ref}}, error) { + var it {{.Type | ref}} var asMap = v.(map[string]interface{}) {{ range $field := .Fields}} {{- if $field.Default}} @@ -28,7 +28,7 @@ } {{- end }} - func (e *executableSchema) {{ .Definition.GQLDefinition.Name }}Middleware(ctx context.Context, obj *{{.Definition.GoType | ref}}) (*{{.Definition.GoType | ref}}, error) { + func (e *executableSchema) {{ .Name }}Middleware(ctx context.Context, obj *{{.Type | ref}}) (*{{.Type | ref}}, error) { {{ if .Directives }} cObj, err := chainFieldMiddleware( []graphql.FieldMiddleware{ @@ -51,9 +51,9 @@ if err != nil || cObj == nil { return nil ,err } - obj, ok := cObj.(*{{.Definition.GoType | ref}}) + obj, ok := cObj.(*{{.Type | ref}}) if !ok { - return nil, errors.New("expect {{.Definition.GoType | ref}}") + return nil, errors.New("expect {{.Type | ref}}") } {{ end }} @@ -86,7 +86,7 @@ } {{ if $field.IsPtr }} - if data, ok := c{{$field.GoFieldName}}.({{ $field.Definition.GoType | ref }}); ok { + if data, ok := c{{$field.GoFieldName}}.({{ $field.Type | ref }}); ok { obj.{{$field.GoFieldName}} = &data } else { return obj, errors.New("expect {{ $field.GoType | ref }}") diff --git a/codegen/object.go b/codegen/object.go index ef0a7964032..d9be8e9b344 100644 --- a/codegen/object.go +++ b/codegen/object.go @@ -2,14 +2,18 @@ package codegen import ( "bytes" + "go/types" + "log" "strconv" "strings" "text/template" "unicode" - "go/types" + "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/codegen/templates" + "github.com/pkg/errors" + "github.com/vektah/gqlparser/ast" ) type GoFieldType int @@ -21,22 +25,106 @@ const ( ) type Object struct { - Definition *TypeDefinition - Fields []*Field - Implements []*TypeDefinition + *ast.Definition + + Type types.Type ResolverInterface types.Type Root bool + Fields []*Field + Implements []*ast.Definition DisableConcurrency bool Stream bool Directives []*Directive - InTypemap bool +} + +func (b *builder) buildObject(typ *ast.Definition) (*Object, error) { + dirs, err := b.getDirectives(typ.Directives) + if err != nil { + return nil, errors.Wrap(err, typ.Name) + } + + obj := &Object{ + Definition: typ, + Root: b.Schema.Query == typ || b.Schema.Mutation == typ || b.Schema.Subscription == typ, + DisableConcurrency: typ == b.Schema.Mutation, + Stream: typ == b.Schema.Subscription, + Directives: dirs, + ResolverInterface: types.NewNamed( + types.NewTypeName(0, b.Config.Exec.Pkg(), typ.Name+"Resolver", nil), + nil, + nil, + ), + } + + if !obj.Root { + goObject, err := b.Binder.FindUserObject(typ.Name) + if err != nil { + return nil, err + } + obj.Type = goObject + } + + for _, intf := range b.Schema.GetImplements(typ) { + obj.Implements = append(obj.Implements, b.Schema.Types[intf.Name]) + } + + for _, field := range typ.Fields { + if strings.HasPrefix(field.Name, "__") { + continue + } + + var f *Field + f, err = b.buildField(obj, field) + if err != nil { + return nil, errors.Wrap(err, typ.Name+"."+field.Name) + } + + if typ.Kind == ast.InputObject && !f.TypeReference.Definition.GQLDefinition.IsInputType() { + return nil, errors.Errorf( + "%s.%s: cannot use %s because %s is not a valid input type", + typ.Name, + field.Name, + f.Definition.GQLDefinition.Name, + f.TypeReference.Definition.GQLDefinition.Kind, + ) + } + + obj.Fields = append(obj.Fields, f) + + if obj.Root { + f.IsResolver = true + } else if !f.IsResolver { + // first try binding to a method + methodErr := b.bindMethod(obj.Type, f) + if methodErr == nil { + continue + } + + // otherwise try binding to a var + varErr := b.bindVar(obj.Type, f) + + // if both failed, add a resolver + if varErr != nil { + f.IsResolver = true + + log.Printf("\nadding resolver method for %s.%s to %s\n %s\n %s", + obj.Name, + field.Name, + obj.Type.String(), + methodErr.Error(), + varErr.Error()) + } + } + } + + return obj, nil } type Objects []*Object func (o *Object) Implementors() string { - satisfiedBy := strconv.Quote(o.Definition.GQLDefinition.Name) - for _, s := range o.Definition.GQLDefinition.Interfaces { + satisfiedBy := strconv.Quote(o.Name) + for _, s := range o.Definition.Interfaces { satisfiedBy += ", " + strconv.Quote(s) } return "[]string{" + satisfiedBy + "}" @@ -50,6 +138,20 @@ func (o *Object) HasResolvers() bool { } return false } + +func (o *Object) HasUnmarshal() bool { + if o.Type == config.MapType { + return true + } + for i := 0; i < o.Type.(*types.Named).NumMethods(); i++ { + switch o.Type.(*types.Named).Method(i).Name() { + case "UnmarshalGQL": + return true + } + } + return false +} + func (o *Object) HasDirectives() bool { if len(o.Directives) > 0 { return true @@ -73,16 +175,16 @@ func (o *Object) IsConcurrent() bool { } func (o *Object) IsReserved() bool { - return strings.HasPrefix(o.Definition.GQLDefinition.Name, "__") + return strings.HasPrefix(o.Definition.Name, "__") } func (o *Object) Description() string { - return o.Definition.GQLDefinition.Description + return o.Definition.Description } func (os Objects) ByName(name string) *Object { for i, o := range os { - if strings.EqualFold(o.Definition.GQLDefinition.Name, name) { + if strings.EqualFold(o.Definition.Name, name) { return os[i] } } diff --git a/codegen/object.gotpl b/codegen/object.gotpl index 7babd8c4cc6..cb39699d0f8 100644 --- a/codegen/object.gotpl +++ b/codegen/object.gotpl @@ -1,13 +1,13 @@ {{- range $object := .Objects }} -var {{ $object.Definition.GQLDefinition.Name|lcFirst}}Implementors = {{$object.Implementors}} +var {{ $object.Name|lcFirst}}Implementors = {{$object.Implementors}} // nolint: gocyclo, errcheck, gas, goconst {{- if .Stream }} -func (ec *executionContext) _{{$object.Definition.GQLDefinition.Name}}(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, {{$object.Definition.GQLDefinition.Name|lcFirst}}Implementors) +func (ec *executionContext) _{{$object.Name}}(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, {{$object.Name|lcFirst}}Implementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: {{$object.Definition.GQLDefinition.Name|quote}}, + Object: {{$object.Name|quote}}, }) if len(fields) != 1 { ec.Errorf(ctx, "must subscribe to exactly one stream") @@ -17,18 +17,18 @@ func (ec *executionContext) _{{$object.Definition.GQLDefinition.Name}}(ctx conte switch fields[0].Name { {{- range $field := $object.Fields }} case "{{$field.GQLName}}": - return ec._{{$object.Definition.GQLDefinition.Name}}_{{$field.GQLName}}(ctx, fields[0]) + return ec._{{$object.Name}}_{{$field.GQLName}}(ctx, fields[0]) {{- end }} default: panic("unknown field " + strconv.Quote(fields[0].Name)) } } {{- else }} -func (ec *executionContext) _{{$object.Definition.GQLDefinition.Name}}(ctx context.Context, sel ast.SelectionSet{{if not $object.Root}}, obj *{{$object.Definition.GoType | ref }} {{end}}) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, {{$object.Definition.GQLDefinition.Name|lcFirst}}Implementors) +func (ec *executionContext) _{{$object.Name}}(ctx context.Context, sel ast.SelectionSet{{ if not $object.Root }},obj *{{$object.Type | ref }}{{ end }}) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, {{$object.Name|lcFirst}}Implementors) {{if $object.Root}} ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ - Object: {{$object.Definition.GQLDefinition.Name|quote}}, + Object: {{$object.Name|quote}}, }) {{end}} @@ -37,13 +37,13 @@ func (ec *executionContext) _{{$object.Definition.GQLDefinition.Name}}(ctx conte for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString({{$object.Definition.GQLDefinition.Name|quote}}) + out.Values[i] = graphql.MarshalString({{$object.Name|quote}}) {{- range $field := $object.Fields }} case "{{$field.GQLName}}": {{- if $field.IsConcurrent }} field := field out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._{{$object.Definition.GQLDefinition.Name}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}}) + res = ec._{{$object.Name}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}}) {{- if $field.ASTType.NonNull }} if res == graphql.Null { invalid = true @@ -52,7 +52,7 @@ func (ec *executionContext) _{{$object.Definition.GQLDefinition.Name}}(ctx conte return res }) {{- else }} - out.Values[i] = ec._{{$object.Definition.GQLDefinition.Name}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}}) + out.Values[i] = ec._{{$object.Name}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}}) {{- if $field.ASTType.NonNull }} if out.Values[i] == graphql.Null { invalid = true diff --git a/codegen/schema_test.go b/codegen/schema_test.go index 1cb9f9a481d..7cf7dce3fce 100644 --- a/codegen/schema_test.go +++ b/codegen/schema_test.go @@ -24,6 +24,10 @@ func generate(name string, schemaFilename string) error { SchemaFilename: config.SchemaFilenames{schemaFilename}, Exec: config.PackageConfig{Filename: "gen/" + name + "/exec.go"}, Model: config.PackageConfig{Filename: "gen/" + name + "/model.go"}, + Models: map[string]config.TypeMapEntry{ + "Item": {Model: "map[string]interface{}"}, + "Bookmarkable": {Model: "interface{}"}, + }, }) return err diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 71817f4aec8..a6bc9122d3e 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -11,10 +11,10 @@ import ( "strconv" "sync" - "github.com/99designs/gqlgen/codegen/testserver/introspection" + introspection1 "github.com/99designs/gqlgen/codegen/testserver/introspection" "github.com/99designs/gqlgen/codegen/testserver/invalid-packagename" "github.com/99designs/gqlgen/graphql" - introspection1 "github.com/99designs/gqlgen/graphql/introspection" + "github.com/99designs/gqlgen/graphql/introspection" "github.com/vektah/gqlparser" "github.com/vektah/gqlparser/ast" ) @@ -140,7 +140,7 @@ type ModelMethodsResolver interface { } type QueryResolver interface { InvalidIdentifier(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) - Collision(ctx context.Context) (*introspection.It, error) + Collision(ctx context.Context) (*introspection1.It, error) MapInput(ctx context.Context, input *map[string]interface{}) (*bool, error) Recursive(ctx context.Context, input *RecursiveInputSlice) (*bool, error) NestedInputs(ctx context.Context, input [][]*OuterInput) (*bool, error) @@ -538,7 +538,8 @@ func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinitio return &graphql.Response{ Data: buf, Errors: ec.Errors, - Extensions: ec.Extensions} + Extensions: ec.Extensions, + } } func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { @@ -1820,7 +1821,7 @@ func (ec *executionContext) _InvalidIdentifier_id(ctx context.Context, field gra } // nolint: vetshadow -func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedField, obj *introspection.It) graphql.Marshaler { +func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedField, obj *introspection1.It) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -2002,7 +2003,7 @@ func (ec *executionContext) _Query_collision(ctx context.Context, field graphql. if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.It) + res := resTmp.(*introspection1.It) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -2655,7 +2656,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection1.Type) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -2684,7 +2685,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection1.Schema) + res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -2915,7 +2916,7 @@ func (ec *executionContext) _User_friends(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection1.Directive) graphql.Marshaler { +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -2942,7 +2943,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql } // nolint: vetshadow -func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection1.Directive) graphql.Marshaler { +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -2966,7 +2967,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field } // nolint: vetshadow -func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection1.Directive) graphql.Marshaler { +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3002,7 +3003,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr } // nolint: vetshadow -func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection1.Directive) graphql.Marshaler { +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3022,7 +3023,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.([]introspection1.InputValue) + res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -3062,7 +3063,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection1.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3089,7 +3090,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection1.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3113,7 +3114,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection1.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3140,7 +3141,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field } // nolint: vetshadow -func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection1.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3168,7 +3169,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, } // nolint: vetshadow -func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection1.Field) graphql.Marshaler { +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3195,7 +3196,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection1.Field) graphql.Marshaler { +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3219,7 +3220,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap } // nolint: vetshadow -func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection1.Field) graphql.Marshaler { +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3239,7 +3240,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.([]introspection1.InputValue) + res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -3279,7 +3280,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection1.Field) graphql.Marshaler { +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3299,7 +3300,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(*introspection1.Type) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -3314,7 +3315,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col } // nolint: vetshadow -func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection1.Field) graphql.Marshaler { +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3341,7 +3342,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra } // nolint: vetshadow -func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection1.Field) graphql.Marshaler { +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3369,7 +3370,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel } // nolint: vetshadow -func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection1.InputValue) graphql.Marshaler { +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3396,7 +3397,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } // nolint: vetshadow -func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection1.InputValue) graphql.Marshaler { +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3420,7 +3421,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field } // nolint: vetshadow -func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection1.InputValue) graphql.Marshaler { +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3440,7 +3441,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.(*introspection1.Type) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -3455,7 +3456,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq } // nolint: vetshadow -func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection1.InputValue) graphql.Marshaler { +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3483,7 +3484,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel } // nolint: vetshadow -func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection1.Schema) graphql.Marshaler { +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3503,7 +3504,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.([]introspection1.Type) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -3543,7 +3544,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } // nolint: vetshadow -func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection1.Schema) graphql.Marshaler { +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3563,7 +3564,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } return graphql.Null } - res := resTmp.(*introspection1.Type) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -3578,7 +3579,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } // nolint: vetshadow -func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection1.Schema) graphql.Marshaler { +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3595,7 +3596,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection1.Type) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -3607,7 +3608,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr } // nolint: vetshadow -func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection1.Schema) graphql.Marshaler { +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3624,7 +3625,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection1.Type) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -3636,7 +3637,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel } // nolint: vetshadow -func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection1.Schema) graphql.Marshaler { +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3656,7 +3657,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap } return graphql.Null } - res := resTmp.([]introspection1.Directive) + res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -3696,7 +3697,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap } // nolint: vetshadow -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3723,7 +3724,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll } // nolint: vetshadow -func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3751,7 +3752,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll } // nolint: vetshadow -func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3775,7 +3776,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph } // nolint: vetshadow -func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3799,7 +3800,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection1.Field) + res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -3839,7 +3840,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } // nolint: vetshadow -func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3856,7 +3857,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection1.Type) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -3896,7 +3897,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq } // nolint: vetshadow -func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3913,7 +3914,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection1.Type) + res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -3953,7 +3954,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra } // nolint: vetshadow -func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3977,7 +3978,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection1.EnumValue) + res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -4017,7 +4018,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } // nolint: vetshadow -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -4034,7 +4035,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph if resTmp == nil { return graphql.Null } - res := resTmp.([]introspection1.InputValue) + res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -4074,7 +4075,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph } // nolint: vetshadow -func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection1.Type) graphql.Marshaler { +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -4091,7 +4092,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection1.Type) + res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) @@ -4702,7 +4703,7 @@ func (ec *executionContext) _InvalidIdentifier(ctx context.Context, sel ast.Sele var itImplementors = []string{"It"} // nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _It(ctx context.Context, sel ast.SelectionSet, obj *introspection.It) graphql.Marshaler { +func (ec *executionContext) _It(ctx context.Context, sel ast.SelectionSet, obj *introspection1.It) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, itImplementors) out := graphql.NewFieldSet(fields) @@ -5044,7 +5045,7 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj var __DirectiveImplementors = []string{"__Directive"} // nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection1.Directive) graphql.Marshaler { +func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) @@ -5084,7 +5085,7 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS var __EnumValueImplementors = []string{"__EnumValue"} // nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection1.EnumValue) graphql.Marshaler { +func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) out := graphql.NewFieldSet(fields) @@ -5121,7 +5122,7 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS var __FieldImplementors = []string{"__Field"} // nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection1.Field) graphql.Marshaler { +func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __FieldImplementors) out := graphql.NewFieldSet(fields) @@ -5168,7 +5169,7 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, var __InputValueImplementors = []string{"__InputValue"} // nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection1.InputValue) graphql.Marshaler { +func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) out := graphql.NewFieldSet(fields) @@ -5205,7 +5206,7 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection var __SchemaImplementors = []string{"__Schema"} // nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection1.Schema) graphql.Marshaler { +func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) out := graphql.NewFieldSet(fields) @@ -5247,7 +5248,7 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, var __TypeImplementors = []string{"__Type"} // nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection1.Type) graphql.Marshaler { +func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __TypeImplementors) out := graphql.NewFieldSet(fields) diff --git a/codegen/testserver/generated_test.go b/codegen/testserver/generated_test.go index 2f60be2300e..a660f20d8bc 100644 --- a/codegen/testserver/generated_test.go +++ b/codegen/testserver/generated_test.go @@ -15,13 +15,11 @@ import ( "testing" "time" - "github.com/pkg/errors" - - "github.com/99designs/gqlgen/graphql/introspection" - "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql/introspection" "github.com/99designs/gqlgen/handler" + "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/example/chat/generated.go b/example/chat/generated.go index 324f2079748..a02847d554e 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -187,7 +187,8 @@ func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinitio return &graphql.Response{ Data: buf, Errors: ec.Errors, - Extensions: ec.Extensions} + Extensions: ec.Extensions, + } } func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { diff --git a/example/config/generated.go b/example/config/generated.go index 89f256aea33..3234f879ff4 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -172,7 +172,8 @@ func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinitio return &graphql.Response{ Data: buf, Errors: ec.Errors, - Extensions: ec.Extensions} + Extensions: ec.Extensions, + } } func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index a5a7072c089..b3ea0258208 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -232,7 +232,8 @@ func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinitio return &graphql.Response{ Data: buf, Errors: ec.Errors, - Extensions: ec.Extensions} + Extensions: ec.Extensions, + } } func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { diff --git a/example/scalars/generated.go b/example/scalars/generated.go index 31002a068fc..6738f8be817 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -199,7 +199,8 @@ func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinitio return &graphql.Response{ Data: buf, Errors: ec.Errors, - Extensions: ec.Extensions} + Extensions: ec.Extensions, + } } func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { diff --git a/example/selection/generated.go b/example/selection/generated.go index 6663f40235f..b6f98048816 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -158,7 +158,8 @@ func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinitio return &graphql.Response{ Data: buf, Errors: ec.Errors, - Extensions: ec.Extensions} + Extensions: ec.Extensions, + } } func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { diff --git a/example/starwars/generated.go b/example/starwars/generated.go index 8fd27e66cf4..e21a910cf3f 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -499,7 +499,8 @@ func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinitio return &graphql.Response{ Data: buf, Errors: ec.Errors, - Extensions: ec.Extensions} + Extensions: ec.Extensions, + } } func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { diff --git a/example/todo/generated.go b/example/todo/generated.go index 078b2e623d9..e6353a857bf 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -171,7 +171,8 @@ func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinitio return &graphql.Response{ Data: buf, Errors: ec.Errors, - Extensions: ec.Extensions} + Extensions: ec.Extensions, + } } func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index 9494e01f41e..44c0b0d27df 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -169,7 +169,8 @@ func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinitio return &graphql.Response{ Data: buf, Errors: ec.Errors, - Extensions: ec.Extensions} + Extensions: ec.Extensions, + } } func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { diff --git a/graphql/root.go b/graphql/root.go new file mode 100644 index 00000000000..3405d18054d --- /dev/null +++ b/graphql/root.go @@ -0,0 +1,7 @@ +package graphql + +type Query struct{} + +type Mutation struct{} + +type Subscription struct{} diff --git a/integration/generated.go b/integration/generated.go index 4e3fcf406e5..0b7a6da6d25 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -202,7 +202,8 @@ func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinitio return &graphql.Response{ Data: buf, Errors: ec.Errors, - Extensions: ec.Extensions} + Extensions: ec.Extensions, + } } func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { diff --git a/plugin/modelgen/models.go b/plugin/modelgen/models.go index b2a92bcfa7f..c41645dde2b 100644 --- a/plugin/modelgen/models.go +++ b/plugin/modelgen/models.go @@ -71,6 +71,8 @@ func (m *Plugin) MutateConfig(cfg *config.Config) error { return err } + cfg.InjectBuiltins(schema) + binder, err := cfg.NewBinder() if err != nil { return err diff --git a/plugin/resolvergen/resolver.gotpl b/plugin/resolvergen/resolver.gotpl index c61bb5f36e2..65625f51a5e 100644 --- a/plugin/resolvergen/resolver.gotpl +++ b/plugin/resolvergen/resolver.gotpl @@ -19,19 +19,19 @@ type {{.ResolverType}} struct {} {{ range $object := .Objects -}} {{- if $object.HasResolvers -}} - func (r *{{$.ResolverType}}) {{$object.Definition.GQLDefinition.Name}}() {{ $object.ResolverInterface | ref }} { - return &{{lcFirst $object.Definition.GQLDefinition.Name}}Resolver{r} + func (r *{{$.ResolverType}}) {{$object.Name}}() {{ $object.ResolverInterface | ref }} { + return &{{lcFirst $object.Name}}Resolver{r} } {{ end -}} {{ end }} {{ range $object := .Objects -}} {{- if $object.HasResolvers -}} - type {{lcFirst $object.Definition.GQLDefinition.Name}}Resolver struct { *Resolver } + type {{lcFirst $object.Name}}Resolver struct { *Resolver } {{ range $field := $object.Fields -}} {{- if $field.IsResolver -}} - func (r *{{lcFirst $object.Definition.GQLDefinition.Name}}Resolver) {{ $field.ShortResolverDeclaration }} { + func (r *{{lcFirst $object.Name}}Resolver) {{ $field.ShortResolverDeclaration }} { panic("not implemented") } {{ end -}} From 44aabbd3e92bc7582f92e74d1d657a626b0a1962 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Mon, 4 Feb 2019 15:12:37 +1100 Subject: [PATCH 054/147] Move all build steps back into file containing defs --- codegen/args.go | 64 +++ codegen/build_bind.go | 365 ------------------ codegen/build_directive.go | 92 ----- codegen/build_enum.go | 31 -- codegen/build_interface.go | 39 -- codegen/build_object.go | 86 ----- codegen/directive.go | 84 ++++ codegen/enum.go | 30 ++ codegen/field.go | 215 +++++++++++ codegen/{build_bind_test.go => field_test.go} | 81 ---- codegen/interface.go | 38 ++ codegen/object.go | 1 - codegen/util.go | 5 - internal/code/compare.go | 163 ++++++++ internal/code/compare_test.go | 85 ++++ internal/code/util_test.go | 15 + 16 files changed, 694 insertions(+), 700 deletions(-) delete mode 100644 codegen/build_bind.go delete mode 100644 codegen/build_directive.go delete mode 100644 codegen/build_enum.go delete mode 100644 codegen/build_interface.go delete mode 100644 codegen/build_object.go rename codegen/{build_bind_test.go => field_test.go} (57%) create mode 100644 internal/code/compare.go create mode 100644 internal/code/compare_test.go create mode 100644 internal/code/util_test.go diff --git a/codegen/args.go b/codegen/args.go index 6f5fc61e9a8..130439dcb25 100644 --- a/codegen/args.go +++ b/codegen/args.go @@ -1,10 +1,74 @@ package codegen +import ( + "fmt" + "go/types" + "strings" + + "github.com/99designs/gqlgen/codegen/templates" + "github.com/pkg/errors" + "github.com/vektah/gqlparser/ast" +) + type ArgSet struct { Args []*FieldArgument FuncDecl string } +func (b *builder) buildArg(obj *Object, arg *ast.ArgumentDefinition) (*FieldArgument, error) { + argDirs, err := b.getDirectives(arg.Directives) + if err != nil { + return nil, err + } + newArg := FieldArgument{ + GQLName: arg.Name, + TypeReference: b.NamedTypes.getType(arg.Type), + Object: obj, + GoVarName: templates.ToGoPrivate(arg.Name), + Directives: argDirs, + } + + if !newArg.TypeReference.Definition.GQLDefinition.IsInputType() { + return nil, errors.Errorf( + "cannot use %s as argument %s because %s is not a valid input type", + newArg.Definition.GQLDefinition.Name, + arg.Name, + newArg.TypeReference.Definition.GQLDefinition.Kind, + ) + } + + if arg.DefaultValue != nil { + newArg.Default, err = arg.DefaultValue.Value(nil) + if err != nil { + return nil, errors.Errorf("default value is not valid: %s", err.Error()) + } + } + + return &newArg, nil +} + +func (b *builder) bindArgs(field *Field, params *types.Tuple) error { + var newArgs []*FieldArgument + +nextArg: + for j := 0; j < params.Len(); j++ { + param := params.At(j) + for _, oldArg := range field.Args { + if strings.EqualFold(oldArg.GQLName, param.Name()) { + oldArg.TypeReference.GoType = param.Type() + newArgs = append(newArgs, oldArg) + continue nextArg + } + } + + // no matching arg found, abort + return fmt.Errorf("arg %s not found on method", param.Name()) + } + + field.Args = newArgs + return nil +} + func (a *Data) Args() map[string][]*FieldArgument { ret := map[string][]*FieldArgument{} for _, o := range a.Objects { diff --git a/codegen/build_bind.go b/codegen/build_bind.go deleted file mode 100644 index bb6b9e0e28a..00000000000 --- a/codegen/build_bind.go +++ /dev/null @@ -1,365 +0,0 @@ -package codegen - -import ( - "fmt" - "go/types" - "reflect" - "regexp" - "strings" - - "github.com/pkg/errors" -) - -func (b *builder) bindMethod(t types.Type, field *Field) error { - namedType, err := findGoNamedType(t) - if err != nil { - return err - } - - method := b.findMethod(namedType, field.GoFieldName) - if method == nil { - return fmt.Errorf("no method named %s", field.GoFieldName) - } - sig := method.Type().(*types.Signature) - - if sig.Results().Len() == 1 { - field.NoErr = true - } else if sig.Results().Len() != 2 { - return fmt.Errorf("method has wrong number of args") - } - params := sig.Params() - // If the first argument is the context, remove it from the comparison and set - // the MethodHasContext flag so that the context will be passed to this model's method - if params.Len() > 0 && params.At(0).Type().String() == "context.Context" { - field.MethodHasContext = true - vars := make([]*types.Var, params.Len()-1) - for i := 1; i < params.Len(); i++ { - vars[i-1] = params.At(i) - } - params = types.NewTuple(vars...) - } - - if err := b.bindArgs(field, params); err != nil { - return err - } - - result := sig.Results().At(0) - if err := compatibleTypes(field.TypeReference.GoType, result.Type()); err != nil { - return errors.Wrapf(err, "%s is not compatible with %s", field.TypeReference.GoType.String(), result.String()) - } - - // success, args and return type match. Bind to method - field.GoFieldType = GoFieldMethod - field.GoReceiverName = "obj" - field.GoFieldName = method.Name() - field.TypeReference.GoType = result.Type() - return nil -} - -func (b *builder) bindVar(t types.Type, field *Field) error { - underlying, ok := t.Underlying().(*types.Struct) - if !ok { - return fmt.Errorf("not a struct") - } - - structField, err := b.findField(underlying, field.GoFieldName) - if err != nil { - return err - } - - if err := compatibleTypes(field.TypeReference.GoType, structField.Type()); err != nil { - return errors.Wrapf(err, "%s is not compatible with %s", field.TypeReference.GoType.String(), field.TypeReference.GoType.String()) - } - - // success, bind to var - field.GoFieldType = GoFieldVariable - field.GoReceiverName = "obj" - field.GoFieldName = structField.Name() - field.TypeReference.GoType = structField.Type() - return nil -} - -func (b *builder) bindArgs(field *Field, params *types.Tuple) error { - var newArgs []*FieldArgument - -nextArg: - for j := 0; j < params.Len(); j++ { - param := params.At(j) - for _, oldArg := range field.Args { - if strings.EqualFold(oldArg.GQLName, param.Name()) { - oldArg.TypeReference.GoType = param.Type() - newArgs = append(newArgs, oldArg) - continue nextArg - } - } - - // no matching arg found, abort - return fmt.Errorf("arg %s not found on method", param.Name()) - } - - field.Args = newArgs - return nil -} - -// compatibleTypes isnt a strict comparison, it allows for pointer differences -func compatibleTypes(expected types.Type, actual types.Type) error { - //fmt.Println("Comparing ", expected.String(), actual.String()) - - // Special case to deal with pointer mismatches - { - expectedPtr, expectedIsPtr := expected.(*types.Pointer) - actualPtr, actualIsPtr := actual.(*types.Pointer) - - if expectedIsPtr && actualIsPtr { - return compatibleTypes(expectedPtr.Elem(), actualPtr.Elem()) - } - if expectedIsPtr && !actualIsPtr { - return compatibleTypes(expectedPtr.Elem(), actual) - } - if !expectedIsPtr && actualIsPtr { - return compatibleTypes(expected, actualPtr.Elem()) - } - } - - switch expected := expected.(type) { - case *types.Slice: - if actual, ok := actual.(*types.Slice); ok { - return compatibleTypes(expected.Elem(), actual.Elem()) - } - - case *types.Array: - if actual, ok := actual.(*types.Array); ok { - if expected.Len() != actual.Len() { - return fmt.Errorf("array length differs") - } - - return compatibleTypes(expected.Elem(), actual.Elem()) - } - - case *types.Basic: - if actual, ok := actual.(*types.Basic); ok { - if actual.Kind() != expected.Kind() { - return fmt.Errorf("basic kind differs, %s != %s", expected.Name(), actual.Name()) - } - - return nil - } - - case *types.Struct: - if actual, ok := actual.(*types.Struct); ok { - if expected.NumFields() != actual.NumFields() { - return fmt.Errorf("number of struct fields differ") - } - - for i := 0; i < expected.NumFields(); i++ { - if expected.Field(i).Name() != actual.Field(i).Name() { - return fmt.Errorf("struct field %d name differs, %s != %s", i, expected.Field(i).Name(), actual.Field(i).Name()) - } - if err := compatibleTypes(expected.Field(i).Type(), actual.Field(i).Type()); err != nil { - return err - } - } - return nil - } - - case *types.Tuple: - if actual, ok := actual.(*types.Tuple); ok { - if expected.Len() != actual.Len() { - return fmt.Errorf("tuple length differs, %d != %d", expected.Len(), actual.Len()) - } - - for i := 0; i < expected.Len(); i++ { - if err := compatibleTypes(expected.At(i).Type(), actual.At(i).Type()); err != nil { - return err - } - } - - return nil - } - - case *types.Signature: - if actual, ok := actual.(*types.Signature); ok { - if err := compatibleTypes(expected.Params(), actual.Params()); err != nil { - return err - } - if err := compatibleTypes(expected.Results(), actual.Results()); err != nil { - return err - } - - return nil - } - case *types.Interface: - if actual, ok := actual.(*types.Interface); ok { - if expected.NumMethods() != actual.NumMethods() { - return fmt.Errorf("interface method count differs, %d != %d", expected.NumMethods(), actual.NumMethods()) - } - - for i := 0; i < expected.NumMethods(); i++ { - if expected.Method(i).Name() != actual.Method(i).Name() { - return fmt.Errorf("interface method %d name differs, %s != %s", i, expected.Method(i).Name(), actual.Method(i).Name()) - } - if err := compatibleTypes(expected.Method(i).Type(), actual.Method(i).Type()); err != nil { - return err - } - } - - return nil - } - - case *types.Map: - if actual, ok := actual.(*types.Map); ok { - if err := compatibleTypes(expected.Key(), actual.Key()); err != nil { - return err - } - - if err := compatibleTypes(expected.Elem(), actual.Elem()); err != nil { - return err - } - - return nil - } - - case *types.Chan: - if actual, ok := actual.(*types.Chan); ok { - return compatibleTypes(expected.Elem(), actual.Elem()) - } - - case *types.Named: - if actual, ok := actual.(*types.Named); ok { - if normalizeVendor(expected.Obj().Pkg().Path()) != normalizeVendor(actual.Obj().Pkg().Path()) { - return fmt.Errorf( - "package name of named type differs, %s != %s", - normalizeVendor(expected.Obj().Pkg().Path()), - normalizeVendor(actual.Obj().Pkg().Path()), - ) - } - - if expected.Obj().Name() != actual.Obj().Name() { - return fmt.Errorf( - "named type name differs, %s != %s", - normalizeVendor(expected.Obj().Name()), - normalizeVendor(actual.Obj().Name()), - ) - } - - return nil - } - - // Before models are generated all missing references will be Invalid Basic references. - // lets assume these are valid too. - if actual, ok := actual.(*types.Basic); ok && actual.Kind() == types.Invalid { - return nil - } - - default: - return fmt.Errorf("missing support for %T", expected) - } - - return fmt.Errorf("type mismatch %T != %T", expected, actual) -} - -var modsRegex = regexp.MustCompile(`^(\*|\[\])*`) - -func normalizeVendor(pkg string) string { - modifiers := modsRegex.FindAllString(pkg, 1)[0] - pkg = strings.TrimPrefix(pkg, modifiers) - parts := strings.Split(pkg, "/vendor/") - return modifiers + parts[len(parts)-1] -} - -func (b *builder) findMethod(typ *types.Named, name string) *types.Func { - for i := 0; i < typ.NumMethods(); i++ { - method := typ.Method(i) - if !method.Exported() { - continue - } - - if strings.EqualFold(method.Name(), name) { - return method - } - } - - if s, ok := typ.Underlying().(*types.Struct); ok { - for i := 0; i < s.NumFields(); i++ { - field := s.Field(i) - if !field.Anonymous() { - continue - } - - if named, ok := field.Type().(*types.Named); ok { - if f := b.findMethod(named, name); f != nil { - return f - } - } - } - } - - return nil -} - -// findField attempts to match the name to a struct field with the following -// priorites: -// 1. If struct tag is passed then struct tag has highest priority -// 2. Actual Field name -// 3. Field in an embedded struct -func (b *builder) findField(typ *types.Struct, name string) (*types.Var, error) { - if b.Config.StructTag != "" { - var foundField *types.Var - for i := 0; i < typ.NumFields(); i++ { - field := typ.Field(i) - if !field.Exported() { - continue - } - tags := reflect.StructTag(typ.Tag(i)) - if val, ok := tags.Lookup(b.Config.StructTag); ok && equalFieldName(val, name) { - if foundField != nil { - return nil, errors.Errorf("tag %s is ambigious; multiple fields have the same tag value of %s", b.Config.StructTag, val) - } - - foundField = field - } - } - if foundField != nil { - return foundField, nil - } - } - - for i := 0; i < typ.NumFields(); i++ { - field := typ.Field(i) - if !field.Exported() { - continue - } - if equalFieldName(field.Name(), name) { // aqui! - return field, nil - } - } - - for i := 0; i < typ.NumFields(); i++ { - field := typ.Field(i) - if !field.Exported() { - continue - } - - if field.Anonymous() { - fieldType := field.Type() - - if ptr, ok := fieldType.(*types.Pointer); ok { - fieldType = ptr.Elem() - } - - // Type.Underlying() returns itself for all types except types.Named, where it returns a struct type. - // It should be safe to always call. - if named, ok := fieldType.Underlying().(*types.Struct); ok { - f, err := b.findField(named, name) - if err != nil && !strings.HasPrefix(err.Error(), "no field named") { - return nil, err - } - if f != nil { - return f, nil - } - } - } - } - - return nil, fmt.Errorf("no field named %s", name) -} diff --git a/codegen/build_directive.go b/codegen/build_directive.go deleted file mode 100644 index e1e82a4abd9..00000000000 --- a/codegen/build_directive.go +++ /dev/null @@ -1,92 +0,0 @@ -package codegen - -import ( - "fmt" - - "github.com/99designs/gqlgen/codegen/templates" - - "github.com/pkg/errors" - "github.com/vektah/gqlparser/ast" -) - -func (b *builder) buildDirectives() (map[string]*Directive, error) { - directives := make(map[string]*Directive, len(b.Schema.Directives)) - - for name, dir := range b.Schema.Directives { - if _, ok := directives[name]; ok { - return nil, errors.Errorf("directive with name %s already exists", name) - } - if name == "skip" || name == "include" || name == "deprecated" { - continue - } - - var args []*FieldArgument - for _, arg := range dir.Arguments { - - newArg := &FieldArgument{ - GQLName: arg.Name, - TypeReference: b.NamedTypes.getType(arg.Type), - GoVarName: templates.ToGoPrivate(arg.Name), - } - - if !newArg.TypeReference.Definition.GQLDefinition.IsInputType() { - return nil, errors.Errorf("%s cannot be used as argument of directive %s(%s) only input and scalar types are allowed", arg.Type, dir.Name, arg.Name) - } - - if arg.DefaultValue != nil { - var err error - newArg.Default, err = arg.DefaultValue.Value(nil) - if err != nil { - return nil, errors.Errorf("default value for directive argument %s(%s) is not valid: %s", dir.Name, arg.Name, err.Error()) - } - } - args = append(args, newArg) - } - - directives[name] = &Directive{ - Name: name, - Args: args, - } - } - - return directives, nil -} - -func (b *builder) getDirectives(list ast.DirectiveList) ([]*Directive, error) { - dirs := make([]*Directive, len(list)) - for i, d := range list { - argValues := make(map[string]interface{}, len(d.Arguments)) - for _, da := range d.Arguments { - val, err := da.Value.Value(nil) - if err != nil { - return nil, err - } - argValues[da.Name] = val - } - def, ok := b.Directives[d.Name] - if !ok { - return nil, fmt.Errorf("directive %s not found", d.Name) - } - - var args []*FieldArgument - for _, a := range def.Args { - value := a.Default - if argValue, ok := argValues[a.GQLName]; ok { - value = argValue - } - args = append(args, &FieldArgument{ - GQLName: a.GQLName, - Value: value, - GoVarName: a.GoVarName, - TypeReference: a.TypeReference, - }) - } - dirs[i] = &Directive{ - Name: d.Name, - Args: args, - } - - } - - return dirs, nil -} diff --git a/codegen/build_enum.go b/codegen/build_enum.go deleted file mode 100644 index 552fa8c4255..00000000000 --- a/codegen/build_enum.go +++ /dev/null @@ -1,31 +0,0 @@ -package codegen - -import ( - "go/types" - "strings" - - "github.com/99designs/gqlgen/codegen/templates" - "github.com/vektah/gqlparser/ast" -) - -func (b *builder) buildEnum(typ *ast.Definition) *Enum { - namedType := b.NamedTypes[typ.Name] - if typ.Kind != ast.Enum || strings.HasPrefix(typ.Name, "__") || b.Config.Models.UserDefined(typ.Name) { - return nil - } - - var values []EnumValue - for _, v := range typ.EnumValues { - values = append(values, EnumValue{v.Name, v.Description}) - } - - enum := Enum{ - Definition: namedType, - Values: values, - InTypemap: b.Config.Models.UserDefined(typ.Name), - } - - enum.Definition.GoType = types.NewNamed(types.NewTypeName(0, b.Config.Model.Pkg(), templates.ToCamel(enum.Definition.GQLDefinition.Name), nil), nil, nil) - - return &enum -} diff --git a/codegen/build_interface.go b/codegen/build_interface.go deleted file mode 100644 index 1e0578620a4..00000000000 --- a/codegen/build_interface.go +++ /dev/null @@ -1,39 +0,0 @@ -package codegen - -import ( - "go/types" - - "github.com/vektah/gqlparser/ast" -) - -func (b *builder) buildInterface(typ *ast.Definition) *Interface { - i := &Interface{ - Definition: b.NamedTypes[typ.Name], - InTypemap: b.Config.Models.UserDefined(typ.Name), - } - - for _, implementor := range b.Schema.GetPossibleTypes(typ) { - t := b.NamedTypes[implementor.Name] - - i.Implementors = append(i.Implementors, InterfaceImplementor{ - Definition: t, - ValueReceiver: b.isValueReceiver(b.NamedTypes[typ.Name], t), - }) - } - - return i -} - -func (b *builder) isValueReceiver(intf *TypeDefinition, implementor *TypeDefinition) bool { - interfaceType, err := findGoInterface(intf.GoType) - if interfaceType == nil || err != nil { - return true - } - - implementorType, err := findGoNamedType(implementor.GoType) - if implementorType == nil || err != nil { - return true - } - - return types.Implements(implementorType, interfaceType) -} diff --git a/codegen/build_object.go b/codegen/build_object.go deleted file mode 100644 index 5154a018041..00000000000 --- a/codegen/build_object.go +++ /dev/null @@ -1,86 +0,0 @@ -package codegen - -import ( - "github.com/99designs/gqlgen/codegen/templates" - "github.com/pkg/errors" - "github.com/vektah/gqlparser/ast" -) - -func (b *builder) buildField(obj *Object, field *ast.FieldDefinition) (*Field, error) { - dirs, err := b.getDirectives(field.Directives) - if err != nil { - return nil, err - } - - f := Field{ - GQLName: field.Name, - TypeReference: b.NamedTypes.getType(field.Type), - Object: obj, - Directives: dirs, - GoFieldName: templates.ToGo(field.Name), - GoFieldType: GoFieldVariable, - GoReceiverName: "obj", - } - - if field.DefaultValue != nil { - var err error - f.Default, err = field.DefaultValue.Value(nil) - if err != nil { - return nil, errors.Errorf("default value %s is not valid: %s", field.Name, err.Error()) - } - } - - typeEntry, entryExists := b.Config.Models[obj.Definition.Name] - if entryExists { - if typeField, ok := typeEntry.Fields[field.Name]; ok { - if typeField.Resolver { - f.IsResolver = true - } - if typeField.FieldName != "" { - f.GoFieldName = templates.ToGo(typeField.FieldName) - } - } - } - - for _, arg := range field.Arguments { - newArg, err := b.buildArg(obj, arg) - if err != nil { - return nil, err - } - f.Args = append(f.Args, newArg) - } - return &f, nil -} - -func (b *builder) buildArg(obj *Object, arg *ast.ArgumentDefinition) (*FieldArgument, error) { - argDirs, err := b.getDirectives(arg.Directives) - if err != nil { - return nil, err - } - newArg := FieldArgument{ - GQLName: arg.Name, - TypeReference: b.NamedTypes.getType(arg.Type), - Object: obj, - GoVarName: templates.ToGoPrivate(arg.Name), - Directives: argDirs, - } - - if !newArg.TypeReference.Definition.GQLDefinition.IsInputType() { - return nil, errors.Errorf( - "cannot use %s as argument %s because %s is not a valid input type", - newArg.Definition.GQLDefinition.Name, - arg.Name, - newArg.TypeReference.Definition.GQLDefinition.Kind, - ) - } - - if arg.DefaultValue != nil { - var err error - newArg.Default, err = arg.DefaultValue.Value(nil) - if err != nil { - return nil, errors.Errorf("default value is not valid: %s", err.Error()) - } - } - - return &newArg, nil -} diff --git a/codegen/directive.go b/codegen/directive.go index 6744daf3dcd..5897c68774a 100644 --- a/codegen/directive.go +++ b/codegen/directive.go @@ -6,6 +6,8 @@ import ( "strings" "github.com/99designs/gqlgen/codegen/templates" + "github.com/pkg/errors" + "github.com/vektah/gqlparser/ast" ) type Directive struct { @@ -13,6 +15,88 @@ type Directive struct { Args []*FieldArgument } +func (b *builder) buildDirectives() (map[string]*Directive, error) { + directives := make(map[string]*Directive, len(b.Schema.Directives)) + + for name, dir := range b.Schema.Directives { + if _, ok := directives[name]; ok { + return nil, errors.Errorf("directive with name %s already exists", name) + } + if name == "skip" || name == "include" || name == "deprecated" { + continue + } + + var args []*FieldArgument + for _, arg := range dir.Arguments { + + newArg := &FieldArgument{ + GQLName: arg.Name, + TypeReference: b.NamedTypes.getType(arg.Type), + GoVarName: templates.ToGoPrivate(arg.Name), + } + + if !newArg.TypeReference.Definition.GQLDefinition.IsInputType() { + return nil, errors.Errorf("%s cannot be used as argument of directive %s(%s) only input and scalar types are allowed", arg.Type, dir.Name, arg.Name) + } + + if arg.DefaultValue != nil { + var err error + newArg.Default, err = arg.DefaultValue.Value(nil) + if err != nil { + return nil, errors.Errorf("default value for directive argument %s(%s) is not valid: %s", dir.Name, arg.Name, err.Error()) + } + } + args = append(args, newArg) + } + + directives[name] = &Directive{ + Name: name, + Args: args, + } + } + + return directives, nil +} + +func (b *builder) getDirectives(list ast.DirectiveList) ([]*Directive, error) { + dirs := make([]*Directive, len(list)) + for i, d := range list { + argValues := make(map[string]interface{}, len(d.Arguments)) + for _, da := range d.Arguments { + val, err := da.Value.Value(nil) + if err != nil { + return nil, err + } + argValues[da.Name] = val + } + def, ok := b.Directives[d.Name] + if !ok { + return nil, fmt.Errorf("directive %s not found", d.Name) + } + + var args []*FieldArgument + for _, a := range def.Args { + value := a.Default + if argValue, ok := argValues[a.GQLName]; ok { + value = argValue + } + args = append(args, &FieldArgument{ + GQLName: a.GQLName, + Value: value, + GoVarName: a.GoVarName, + TypeReference: a.TypeReference, + }) + } + dirs[i] = &Directive{ + Name: d.Name, + Args: args, + } + + } + + return dirs, nil +} + func (d *Directive) ArgsFunc() string { if len(d.Args) == 0 { return "" diff --git a/codegen/enum.go b/codegen/enum.go index 526e9aa9f0f..3a4a92c7282 100644 --- a/codegen/enum.go +++ b/codegen/enum.go @@ -1,5 +1,13 @@ package codegen +import ( + "go/types" + "strings" + + "github.com/99designs/gqlgen/codegen/templates" + "github.com/vektah/gqlparser/ast" +) + type Enum struct { Definition *TypeDefinition Values []EnumValue @@ -10,3 +18,25 @@ type EnumValue struct { Name string Description string } + +func (b *builder) buildEnum(typ *ast.Definition) *Enum { + namedType := b.NamedTypes[typ.Name] + if typ.Kind != ast.Enum || strings.HasPrefix(typ.Name, "__") || b.Config.Models.UserDefined(typ.Name) { + return nil + } + + var values []EnumValue + for _, v := range typ.EnumValues { + values = append(values, EnumValue{v.Name, v.Description}) + } + + enum := Enum{ + Definition: namedType, + Values: values, + InTypemap: b.Config.Models.UserDefined(typ.Name), + } + + enum.Definition.GoType = types.NewNamed(types.NewTypeName(0, b.Config.Model.Pkg(), templates.ToCamel(enum.Definition.GQLDefinition.Name), nil), nil, nil) + + return &enum +} diff --git a/codegen/field.go b/codegen/field.go index 7a03df14a24..1cf30f27857 100644 --- a/codegen/field.go +++ b/codegen/field.go @@ -3,10 +3,13 @@ package codegen import ( "fmt" "go/types" + "reflect" "strconv" "strings" "github.com/99designs/gqlgen/codegen/templates" + "github.com/99designs/gqlgen/internal/code" + "github.com/pkg/errors" "github.com/vektah/gqlparser/ast" ) @@ -25,6 +28,218 @@ type Field struct { Directives []*Directive } +func (b *builder) buildField(obj *Object, field *ast.FieldDefinition) (*Field, error) { + dirs, err := b.getDirectives(field.Directives) + if err != nil { + return nil, err + } + + f := Field{ + GQLName: field.Name, + TypeReference: b.NamedTypes.getType(field.Type), + Object: obj, + Directives: dirs, + GoFieldName: templates.ToGo(field.Name), + GoFieldType: GoFieldVariable, + GoReceiverName: "obj", + } + + if field.DefaultValue != nil { + var err error + f.Default, err = field.DefaultValue.Value(nil) + if err != nil { + return nil, errors.Errorf("default value %s is not valid: %s", field.Name, err.Error()) + } + } + + typeEntry, entryExists := b.Config.Models[obj.Definition.Name] + if entryExists { + if typeField, ok := typeEntry.Fields[field.Name]; ok { + if typeField.Resolver { + f.IsResolver = true + } + if typeField.FieldName != "" { + f.GoFieldName = templates.ToGo(typeField.FieldName) + } + } + } + + for _, arg := range field.Arguments { + newArg, err := b.buildArg(obj, arg) + if err != nil { + return nil, err + } + f.Args = append(f.Args, newArg) + } + return &f, nil +} + +func (b *builder) bindMethod(t types.Type, field *Field) error { + namedType, err := findGoNamedType(t) + if err != nil { + return err + } + + method := b.findMethod(namedType, field.GoFieldName) + if method == nil { + return fmt.Errorf("no method named %s", field.GoFieldName) + } + sig := method.Type().(*types.Signature) + + if sig.Results().Len() == 1 { + field.NoErr = true + } else if sig.Results().Len() != 2 { + return fmt.Errorf("method has wrong number of args") + } + params := sig.Params() + // If the first argument is the context, remove it from the comparison and set + // the MethodHasContext flag so that the context will be passed to this model's method + if params.Len() > 0 && params.At(0).Type().String() == "context.Context" { + field.MethodHasContext = true + vars := make([]*types.Var, params.Len()-1) + for i := 1; i < params.Len(); i++ { + vars[i-1] = params.At(i) + } + params = types.NewTuple(vars...) + } + + if err := b.bindArgs(field, params); err != nil { + return err + } + + result := sig.Results().At(0) + if err := code.CompatibleTypes(field.TypeReference.GoType, result.Type()); err != nil { + return errors.Wrapf(err, "%s is not compatible with %s", field.TypeReference.GoType.String(), result.String()) + } + + // success, args and return type match. Bind to method + field.GoFieldType = GoFieldMethod + field.GoReceiverName = "obj" + field.GoFieldName = method.Name() + field.TypeReference.GoType = result.Type() + return nil +} + +func (b *builder) bindVar(t types.Type, field *Field) error { + underlying, ok := t.Underlying().(*types.Struct) + if !ok { + return fmt.Errorf("not a struct") + } + + structField, err := b.findField(underlying, field.GoFieldName) + if err != nil { + return err + } + + if err := code.CompatibleTypes(field.TypeReference.GoType, structField.Type()); err != nil { + return errors.Wrapf(err, "%s is not compatible with %s", field.TypeReference.GoType.String(), field.TypeReference.GoType.String()) + } + + // success, bind to var + field.GoFieldType = GoFieldVariable + field.GoReceiverName = "obj" + field.GoFieldName = structField.Name() + field.TypeReference.GoType = structField.Type() + return nil +} + +// findField attempts to match the name to a struct field with the following +// priorites: +// 1. If struct tag is passed then struct tag has highest priority +// 2. Actual Field name +// 3. Field in an embedded struct +func (b *builder) findField(typ *types.Struct, name string) (*types.Var, error) { + if b.Config.StructTag != "" { + var foundField *types.Var + for i := 0; i < typ.NumFields(); i++ { + field := typ.Field(i) + if !field.Exported() { + continue + } + tags := reflect.StructTag(typ.Tag(i)) + if val, ok := tags.Lookup(b.Config.StructTag); ok && equalFieldName(val, name) { + if foundField != nil { + return nil, errors.Errorf("tag %s is ambigious; multiple fields have the same tag value of %s", b.Config.StructTag, val) + } + + foundField = field + } + } + if foundField != nil { + return foundField, nil + } + } + + for i := 0; i < typ.NumFields(); i++ { + field := typ.Field(i) + if !field.Exported() { + continue + } + if equalFieldName(field.Name(), name) { // aqui! + return field, nil + } + } + + for i := 0; i < typ.NumFields(); i++ { + field := typ.Field(i) + if !field.Exported() { + continue + } + + if field.Anonymous() { + fieldType := field.Type() + + if ptr, ok := fieldType.(*types.Pointer); ok { + fieldType = ptr.Elem() + } + + // Type.Underlying() returns itself for all types except types.Named, where it returns a struct type. + // It should be safe to always call. + if named, ok := fieldType.Underlying().(*types.Struct); ok { + f, err := b.findField(named, name) + if err != nil && !strings.HasPrefix(err.Error(), "no field named") { + return nil, err + } + if f != nil { + return f, nil + } + } + } + } + + return nil, fmt.Errorf("no field named %s", name) +} + +func (b *builder) findMethod(typ *types.Named, name string) *types.Func { + for i := 0; i < typ.NumMethods(); i++ { + method := typ.Method(i) + if !method.Exported() { + continue + } + + if strings.EqualFold(method.Name(), name) { + return method + } + } + + if s, ok := typ.Underlying().(*types.Struct); ok { + for i := 0; i < s.NumFields(); i++ { + field := s.Field(i) + if !field.Anonymous() { + continue + } + + if named, ok := field.Type().(*types.Named); ok { + if f := b.findMethod(named, name); f != nil { + return f + } + } + } + } + + return nil +} + func (f *Field) HasDirectives() bool { return len(f.Directives) > 0 } diff --git a/codegen/build_bind_test.go b/codegen/field_test.go similarity index 57% rename from codegen/build_bind_test.go rename to codegen/field_test.go index ef4d6564b77..cdd9a21f3fd 100644 --- a/codegen/build_bind_test.go +++ b/codegen/field_test.go @@ -12,14 +12,6 @@ import ( "github.com/stretchr/testify/require" ) -func TestNormalizeVendor(t *testing.T) { - require.Equal(t, "bar/baz", normalizeVendor("foo/vendor/bar/baz")) - require.Equal(t, "[]bar/baz", normalizeVendor("[]foo/vendor/bar/baz")) - require.Equal(t, "*bar/baz", normalizeVendor("*foo/vendor/bar/baz")) - require.Equal(t, "*[]*bar/baz", normalizeVendor("*[]*foo/vendor/bar/baz")) - require.Equal(t, "[]*bar/baz", normalizeVendor("[]*foo/vendor/bar/baz")) -} - func TestFindField(t *testing.T) { input := ` package test @@ -122,76 +114,3 @@ func TestEqualFieldName(t *testing.T) { }) } } - -func TestEqualTypes(t *testing.T) { - valid := []struct { - expected string - actual string - }{ - {"string", "string"}, - {"*string", "string"}, - {"string", "*string"}, - {"*string", "*string"}, - {"[]string", "[]string"}, - {"*[]string", "[]string"}, - {"*[]string", "[]*string"}, - {"*[]*[]*[]string", "[][][]string"}, - {"map[string]interface{}", "map[string]interface{}"}, - {"map[string]string", "map[string]string"}, - {"Bar", "Bar"}, - {"interface{}", "interface{}"}, - {"interface{Foo() bool}", "interface{Foo() bool}"}, - {"struct{Foo bool}", "struct{Foo bool}"}, - } - - for _, tc := range valid { - t.Run(tc.expected+"="+tc.actual, func(t *testing.T) { - expectedType := parseTypeStr(t, tc.expected) - actualType := parseTypeStr(t, tc.actual) - require.NoError(t, compatibleTypes(expectedType, actualType)) - }) - } - - invalid := []struct { - expected string - actual string - }{ - {"string", "int"}, - {"*string", "[]string"}, - {"[]string", "[][]string"}, - {"Bar", "Baz"}, - {"map[string]interface{}", "map[string]string"}, - {"map[string]string", "[]string"}, - {"interface{Foo() bool}", "interface{}"}, - {"struct{Foo bool}", "struct{Bar bool}"}, - } - - for _, tc := range invalid { - t.Run(tc.expected+"!="+tc.actual, func(t *testing.T) { - expectedType := parseTypeStr(t, tc.expected) - actualType := parseTypeStr(t, tc.actual) - require.Error(t, compatibleTypes(expectedType, actualType)) - }) - } -} - -func parseTypeStr(t *testing.T, s string) types.Type { - t.Helper() - - fset := token.NewFileSet() - f, err := parser.ParseFile(fset, "test.go", `package test - type Bar string - type Baz string - - type Foo struct { - Field `+s+` - } - `, 0) - require.NoError(t, err) - - conf := types.Config{Importer: importer.Default()} - pkg, err := conf.Check("test", fset, []*ast.File{f}, nil) - require.NoError(t, err) - - return pkg.Scope().Lookup("Foo").Type().(*types.Named).Underlying().(*types.Struct).Field(0).Type() -} diff --git a/codegen/interface.go b/codegen/interface.go index a8e422d5efb..1c7a3f1ccad 100644 --- a/codegen/interface.go +++ b/codegen/interface.go @@ -1,5 +1,11 @@ package codegen +import ( + "go/types" + + "github.com/vektah/gqlparser/ast" +) + type Interface struct { Definition *TypeDefinition Implementors []InterfaceImplementor @@ -10,3 +16,35 @@ type InterfaceImplementor struct { ValueReceiver bool Definition *TypeDefinition } + +func (b *builder) buildInterface(typ *ast.Definition) *Interface { + i := &Interface{ + Definition: b.NamedTypes[typ.Name], + InTypemap: b.Config.Models.UserDefined(typ.Name), + } + + for _, implementor := range b.Schema.GetPossibleTypes(typ) { + t := b.NamedTypes[implementor.Name] + + i.Implementors = append(i.Implementors, InterfaceImplementor{ + Definition: t, + ValueReceiver: b.isValueReceiver(b.NamedTypes[typ.Name], t), + }) + } + + return i +} + +func (b *builder) isValueReceiver(intf *TypeDefinition, implementor *TypeDefinition) bool { + interfaceType, err := findGoInterface(intf.GoType) + if interfaceType == nil || err != nil { + return true + } + + implementorType, err := findGoNamedType(implementor.GoType) + if implementorType == nil || err != nil { + return true + } + + return types.Implements(implementorType, interfaceType) +} diff --git a/codegen/object.go b/codegen/object.go index d9be8e9b344..6d5cbe6487f 100644 --- a/codegen/object.go +++ b/codegen/object.go @@ -10,7 +10,6 @@ import ( "unicode" "github.com/99designs/gqlgen/codegen/config" - "github.com/99designs/gqlgen/codegen/templates" "github.com/pkg/errors" "github.com/vektah/gqlparser/ast" diff --git a/codegen/util.go b/codegen/util.go index cf9304e0fbd..59dfde08cdc 100644 --- a/codegen/util.go +++ b/codegen/util.go @@ -45,8 +45,3 @@ func equalFieldName(source, target string) bool { target = strings.Replace(target, "_", "", -1) return strings.EqualFold(source, target) } - -func isMap(t types.Type) bool { - _, isMap := t.(*types.Map) - return isMap -} diff --git a/internal/code/compare.go b/internal/code/compare.go new file mode 100644 index 00000000000..dce9aea558f --- /dev/null +++ b/internal/code/compare.go @@ -0,0 +1,163 @@ +package code + +import ( + "fmt" + "go/types" +) + +// CompatibleTypes isnt a strict comparison, it allows for pointer differences +func CompatibleTypes(expected types.Type, actual types.Type) error { + //fmt.Println("Comparing ", expected.String(), actual.String()) + + // Special case to deal with pointer mismatches + { + expectedPtr, expectedIsPtr := expected.(*types.Pointer) + actualPtr, actualIsPtr := actual.(*types.Pointer) + + if expectedIsPtr && actualIsPtr { + return CompatibleTypes(expectedPtr.Elem(), actualPtr.Elem()) + } + if expectedIsPtr && !actualIsPtr { + return CompatibleTypes(expectedPtr.Elem(), actual) + } + if !expectedIsPtr && actualIsPtr { + return CompatibleTypes(expected, actualPtr.Elem()) + } + } + + switch expected := expected.(type) { + case *types.Slice: + if actual, ok := actual.(*types.Slice); ok { + return CompatibleTypes(expected.Elem(), actual.Elem()) + } + + case *types.Array: + if actual, ok := actual.(*types.Array); ok { + if expected.Len() != actual.Len() { + return fmt.Errorf("array length differs") + } + + return CompatibleTypes(expected.Elem(), actual.Elem()) + } + + case *types.Basic: + if actual, ok := actual.(*types.Basic); ok { + if actual.Kind() != expected.Kind() { + return fmt.Errorf("basic kind differs, %s != %s", expected.Name(), actual.Name()) + } + + return nil + } + + case *types.Struct: + if actual, ok := actual.(*types.Struct); ok { + if expected.NumFields() != actual.NumFields() { + return fmt.Errorf("number of struct fields differ") + } + + for i := 0; i < expected.NumFields(); i++ { + if expected.Field(i).Name() != actual.Field(i).Name() { + return fmt.Errorf("struct field %d name differs, %s != %s", i, expected.Field(i).Name(), actual.Field(i).Name()) + } + if err := CompatibleTypes(expected.Field(i).Type(), actual.Field(i).Type()); err != nil { + return err + } + } + return nil + } + + case *types.Tuple: + if actual, ok := actual.(*types.Tuple); ok { + if expected.Len() != actual.Len() { + return fmt.Errorf("tuple length differs, %d != %d", expected.Len(), actual.Len()) + } + + for i := 0; i < expected.Len(); i++ { + if err := CompatibleTypes(expected.At(i).Type(), actual.At(i).Type()); err != nil { + return err + } + } + + return nil + } + + case *types.Signature: + if actual, ok := actual.(*types.Signature); ok { + if err := CompatibleTypes(expected.Params(), actual.Params()); err != nil { + return err + } + if err := CompatibleTypes(expected.Results(), actual.Results()); err != nil { + return err + } + + return nil + } + case *types.Interface: + if actual, ok := actual.(*types.Interface); ok { + if expected.NumMethods() != actual.NumMethods() { + return fmt.Errorf("interface method count differs, %d != %d", expected.NumMethods(), actual.NumMethods()) + } + + for i := 0; i < expected.NumMethods(); i++ { + if expected.Method(i).Name() != actual.Method(i).Name() { + return fmt.Errorf("interface method %d name differs, %s != %s", i, expected.Method(i).Name(), actual.Method(i).Name()) + } + if err := CompatibleTypes(expected.Method(i).Type(), actual.Method(i).Type()); err != nil { + return err + } + } + + return nil + } + + case *types.Map: + if actual, ok := actual.(*types.Map); ok { + if err := CompatibleTypes(expected.Key(), actual.Key()); err != nil { + return err + } + + if err := CompatibleTypes(expected.Elem(), actual.Elem()); err != nil { + return err + } + + return nil + } + + case *types.Chan: + if actual, ok := actual.(*types.Chan); ok { + return CompatibleTypes(expected.Elem(), actual.Elem()) + } + + case *types.Named: + if actual, ok := actual.(*types.Named); ok { + if NormalizeVendor(expected.Obj().Pkg().Path()) != NormalizeVendor(actual.Obj().Pkg().Path()) { + return fmt.Errorf( + "package name of named type differs, %s != %s", + NormalizeVendor(expected.Obj().Pkg().Path()), + NormalizeVendor(actual.Obj().Pkg().Path()), + ) + } + + if expected.Obj().Name() != actual.Obj().Name() { + return fmt.Errorf( + "named type name differs, %s != %s", + NormalizeVendor(expected.Obj().Name()), + NormalizeVendor(actual.Obj().Name()), + ) + } + + return nil + } + + // Before models are generated all missing references will be Invalid Basic references. + // lets assume these are valid too. + if actual, ok := actual.(*types.Basic); ok && actual.Kind() == types.Invalid { + return nil + } + + default: + return fmt.Errorf("missing support for %T", expected) + } + + return fmt.Errorf("type mismatch %T != %T", expected, actual) +} diff --git a/internal/code/compare_test.go b/internal/code/compare_test.go new file mode 100644 index 00000000000..0100d574237 --- /dev/null +++ b/internal/code/compare_test.go @@ -0,0 +1,85 @@ +package code + +import ( + "go/ast" + "go/importer" + "go/parser" + "go/token" + "go/types" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestCompatibleTypes(t *testing.T) { + valid := []struct { + expected string + actual string + }{ + {"string", "string"}, + {"*string", "string"}, + {"string", "*string"}, + {"*string", "*string"}, + {"[]string", "[]string"}, + {"*[]string", "[]string"}, + {"*[]string", "[]*string"}, + {"*[]*[]*[]string", "[][][]string"}, + {"map[string]interface{}", "map[string]interface{}"}, + {"map[string]string", "map[string]string"}, + {"Bar", "Bar"}, + {"interface{}", "interface{}"}, + {"interface{Foo() bool}", "interface{Foo() bool}"}, + {"struct{Foo bool}", "struct{Foo bool}"}, + } + + for _, tc := range valid { + t.Run(tc.expected+"="+tc.actual, func(t *testing.T) { + expectedType := parseTypeStr(t, tc.expected) + actualType := parseTypeStr(t, tc.actual) + require.NoError(t, CompatibleTypes(expectedType, actualType)) + }) + } + + invalid := []struct { + expected string + actual string + }{ + {"string", "int"}, + {"*string", "[]string"}, + {"[]string", "[][]string"}, + {"Bar", "Baz"}, + {"map[string]interface{}", "map[string]string"}, + {"map[string]string", "[]string"}, + {"interface{Foo() bool}", "interface{}"}, + {"struct{Foo bool}", "struct{Bar bool}"}, + } + + for _, tc := range invalid { + t.Run(tc.expected+"!="+tc.actual, func(t *testing.T) { + expectedType := parseTypeStr(t, tc.expected) + actualType := parseTypeStr(t, tc.actual) + require.Error(t, CompatibleTypes(expectedType, actualType)) + }) + } +} + +func parseTypeStr(t *testing.T, s string) types.Type { + t.Helper() + + fset := token.NewFileSet() + f, err := parser.ParseFile(fset, "test.go", `package test + type Bar string + type Baz string + + type Foo struct { + Field `+s+` + } + `, 0) + require.NoError(t, err) + + conf := types.Config{Importer: importer.Default()} + pkg, err := conf.Check("test", fset, []*ast.File{f}, nil) + require.NoError(t, err) + + return pkg.Scope().Lookup("Foo").Type().(*types.Named).Underlying().(*types.Struct).Field(0).Type() +} diff --git a/internal/code/util_test.go b/internal/code/util_test.go new file mode 100644 index 00000000000..6aa7ce68b20 --- /dev/null +++ b/internal/code/util_test.go @@ -0,0 +1,15 @@ +package code + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestNormalizeVendor(t *testing.T) { + require.Equal(t, "bar/baz", NormalizeVendor("foo/vendor/bar/baz")) + require.Equal(t, "[]bar/baz", NormalizeVendor("[]foo/vendor/bar/baz")) + require.Equal(t, "*bar/baz", NormalizeVendor("*foo/vendor/bar/baz")) + require.Equal(t, "*[]*bar/baz", NormalizeVendor("*[]*foo/vendor/bar/baz")) + require.Equal(t, "[]*bar/baz", NormalizeVendor("[]*foo/vendor/bar/baz")) +} From c1b50cecda176fadfb98f8b84205058f8d1c7a5b Mon Sep 17 00:00:00 2001 From: Luke Cawood Date: Mon, 4 Feb 2019 13:31:00 +1100 Subject: [PATCH 055/147] Stop GetResolverContext from panicking when missing --- graphql/context.go | 14 +++++++------- graphql/context_test.go | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/graphql/context.go b/graphql/context.go index 39393cb27fc..e0f8d816477 100644 --- a/graphql/context.go +++ b/graphql/context.go @@ -71,12 +71,10 @@ const ( ) func GetRequestContext(ctx context.Context) *RequestContext { - val := ctx.Value(request) - if val == nil { - return nil + if val, ok := ctx.Value(request).(*RequestContext); ok { + return val } - - return val.(*RequestContext) + return nil } func WithRequestContext(ctx context.Context, rc *RequestContext) context.Context { @@ -117,8 +115,10 @@ func (r *ResolverContext) Path() []interface{} { } func GetResolverContext(ctx context.Context) *ResolverContext { - val, _ := ctx.Value(resolver).(*ResolverContext) - return val + if val, ok := ctx.Value(resolver).(*ResolverContext); ok { + return val + } + return nil } func WithResolverContext(ctx context.Context, rc *ResolverContext) context.Context { diff --git a/graphql/context_test.go b/graphql/context_test.go index 78683bfd312..65bd6193f31 100644 --- a/graphql/context_test.go +++ b/graphql/context_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/vektah/gqlparser/ast" ) @@ -63,3 +64,17 @@ func TestRequestContext_GetErrors(t *testing.T) { }) } } + +func TestGetRequestContext(t *testing.T) { + require.Nil(t, GetRequestContext(context.Background())) + + rc := &RequestContext{} + require.Equal(t, rc, GetRequestContext(WithRequestContext(context.Background(), rc))) +} + +func TestGetResolverContext(t *testing.T) { + require.Nil(t, GetResolverContext(context.Background())) + + rc := &ResolverContext{} + require.Equal(t, rc, GetResolverContext(WithResolverContext(context.Background(), rc))) +} From 5e1bcfaf71d81d8e119758e3ec47e1cdfb0bf092 Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Mon, 4 Feb 2019 15:19:08 +1100 Subject: [PATCH 056/147] Remove parent check in directive This should always be true, and currently has a bug when comparing pointers to structs. Can just be removed. --- example/todo/todo.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/example/todo/todo.go b/example/todo/todo.go index 899f1ac3e6e..40e0402bf9a 100644 --- a/example/todo/todo.go +++ b/example/todo/todo.go @@ -33,10 +33,6 @@ func New() Config { // No admin for you! return nil, nil case RoleOwner: - // This is also available in context - if obj != graphql.GetResolverContext(ctx).Parent.Result { - return nil, fmt.Errorf("parent type mismatch") - } ownable, isOwnable := obj.(Ownable) if !isOwnable { return nil, fmt.Errorf("obj cant be owned") From 162afad73b653d9456d21ec38d00c3476ab2dde4 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Tue, 5 Feb 2019 11:03:08 +1100 Subject: [PATCH 057/147] enums dont exist in runtime --- codegen/data.go | 9 --------- codegen/enum.go | 42 ------------------------------------------ 2 files changed, 51 deletions(-) delete mode 100644 codegen/enum.go diff --git a/codegen/data.go b/codegen/data.go index d81a92d9aa8..bd3697e5492 100644 --- a/codegen/data.go +++ b/codegen/data.go @@ -20,7 +20,6 @@ type Data struct { Objects Objects Inputs Objects Interfaces []*Interface - Enums []Enum QueryRoot *Object MutationRoot *Object @@ -100,10 +99,6 @@ func BuildData(cfg *config.Config) (*Data, error) { case ast.Union, ast.Interface: s.Interfaces = append(s.Interfaces, b.buildInterface(schemaType)) - case ast.Enum: - if enum := b.buildEnum(schemaType); enum != nil { - s.Enums = append(s.Enums, *enum) - } } } @@ -137,10 +132,6 @@ func BuildData(cfg *config.Config) (*Data, error) { return s.Interfaces[i].Definition.GQLDefinition.Name < s.Interfaces[j].Definition.GQLDefinition.Name }) - sort.Slice(s.Enums, func(i, j int) bool { - return s.Enums[i].Definition.GQLDefinition.Name < s.Enums[j].Definition.GQLDefinition.Name - }) - return &s, nil } diff --git a/codegen/enum.go b/codegen/enum.go deleted file mode 100644 index 3a4a92c7282..00000000000 --- a/codegen/enum.go +++ /dev/null @@ -1,42 +0,0 @@ -package codegen - -import ( - "go/types" - "strings" - - "github.com/99designs/gqlgen/codegen/templates" - "github.com/vektah/gqlparser/ast" -) - -type Enum struct { - Definition *TypeDefinition - Values []EnumValue - InTypemap bool -} - -type EnumValue struct { - Name string - Description string -} - -func (b *builder) buildEnum(typ *ast.Definition) *Enum { - namedType := b.NamedTypes[typ.Name] - if typ.Kind != ast.Enum || strings.HasPrefix(typ.Name, "__") || b.Config.Models.UserDefined(typ.Name) { - return nil - } - - var values []EnumValue - for _, v := range typ.EnumValues { - values = append(values, EnumValue{v.Name, v.Description}) - } - - enum := Enum{ - Definition: namedType, - Values: values, - InTypemap: b.Config.Models.UserDefined(typ.Name), - } - - enum.Definition.GoType = types.NewNamed(types.NewTypeName(0, b.Config.Model.Pkg(), templates.ToCamel(enum.Definition.GQLDefinition.Name), nil), nil, nil) - - return &enum -} From 693753fcc69329fba282ad5f1d69c02979cbce08 Mon Sep 17 00:00:00 2001 From: Paul Leitmanis Date: Mon, 4 Feb 2019 15:26:04 +1100 Subject: [PATCH 058/147] Add websocket keepalive support --- handler/graphql.go | 28 ++++++++++++++------- handler/websocket.go | 52 +++++++++++++++++++++++++++++++++------ handler/websocket_test.go | 36 +++++++++++++++++++++++++++ 3 files changed, 99 insertions(+), 17 deletions(-) diff --git a/handler/graphql.go b/handler/graphql.go index 918671a9a22..94188fd7393 100644 --- a/handler/graphql.go +++ b/handler/graphql.go @@ -7,6 +7,7 @@ import ( "io" "net/http" "strings" + "time" "github.com/99designs/gqlgen/complexity" "github.com/99designs/gqlgen/graphql" @@ -25,15 +26,16 @@ type params struct { } type Config struct { - cacheSize int - upgrader websocket.Upgrader - recover graphql.RecoverFunc - errorPresenter graphql.ErrorPresenterFunc - resolverHook graphql.FieldMiddleware - requestHook graphql.RequestMiddleware - tracer graphql.Tracer - complexityLimit int - disableIntrospection bool + cacheSize int + upgrader websocket.Upgrader + recover graphql.RecoverFunc + errorPresenter graphql.ErrorPresenterFunc + resolverHook graphql.FieldMiddleware + requestHook graphql.RequestMiddleware + tracer graphql.Tracer + complexityLimit int + disableIntrospection bool + connectionKeepAliveTimeout time.Duration } func (c *Config) newRequestContext(es graphql.ExecutableSchema, doc *ast.QueryDocument, op *ast.OperationDefinition, query string, variables map[string]interface{}) *graphql.RequestContext { @@ -241,6 +243,14 @@ func CacheSize(size int) Option { const DefaultCacheSize = 1000 +// WebsocketKeepAliveDuration allows you to reconfigure the keepAlive behavior. +// By default, keep-alive is disabled. +func WebsocketKeepAliveDuration(duration time.Duration) Option { + return func(cfg *Config) { + cfg.connectionKeepAliveTimeout = duration + } +} + func GraphQL(exec graphql.ExecutableSchema, options ...Option) http.HandlerFunc { cfg := &Config{ cacheSize: DefaultCacheSize, diff --git a/handler/websocket.go b/handler/websocket.go index c3dc38e0ead..579c22ba4f0 100644 --- a/handler/websocket.go +++ b/handler/websocket.go @@ -8,6 +8,7 @@ import ( "log" "net/http" "sync" + "time" "github.com/99designs/gqlgen/graphql" "github.com/gorilla/websocket" @@ -28,7 +29,7 @@ const ( dataMsg = "data" // Server -> Client errorMsg = "error" // Server -> Client completeMsg = "complete" // Server -> Client - //connectionKeepAliveMsg = "ka" // Server -> Client TODO: keepalives + connectionKeepAliveMsg = "ka" // Server -> Client ) type operationMessage struct { @@ -38,13 +39,14 @@ type operationMessage struct { } type wsConnection struct { - ctx context.Context - conn *websocket.Conn - exec graphql.ExecutableSchema - active map[string]context.CancelFunc - mu sync.Mutex - cfg *Config - cache *lru.Cache + ctx context.Context + conn *websocket.Conn + exec graphql.ExecutableSchema + active map[string]context.CancelFunc + mu sync.Mutex + cfg *Config + cache *lru.Cache + keepAliveTimer *time.Timer initPayload InitPayload } @@ -108,10 +110,28 @@ func (c *wsConnection) init() bool { func (c *wsConnection) write(msg *operationMessage) { c.mu.Lock() c.conn.WriteJSON(msg) + if c.cfg.connectionKeepAliveTimeout != 0 && c.keepAliveTimer != nil { + c.keepAliveTimer.Reset(c.cfg.connectionKeepAliveTimeout) + } c.mu.Unlock() } func (c *wsConnection) run() { + // We create a cancellation that will shutdown the keep-alive when we leave + // this function. + ctx, cancel := context.WithCancel(c.ctx) + defer cancel() + + // Create a timer that will fire every interval if a write hasn't been made + // to keep the connection alive. + if c.cfg.connectionKeepAliveTimeout != 0 { + c.mu.Lock() + c.keepAliveTimer = time.NewTimer(c.cfg.connectionKeepAliveTimeout) + c.mu.Unlock() + + go c.keepAlive(ctx) + } + for { message := c.readOp() if message == nil { @@ -144,6 +164,22 @@ func (c *wsConnection) run() { } } +func (c *wsConnection) keepAlive(ctx context.Context) { + for { + select { + case <-ctx.Done(): + if !c.keepAliveTimer.Stop() { + <-c.keepAliveTimer.C + } + return + case <-c.keepAliveTimer.C: + // We don't reset the timer here, because the `c.write` command + // will reset the timer anyways. + c.write(&operationMessage{Type: connectionKeepAliveMsg}) + } + } +} + func (c *wsConnection) subscribe(message *operationMessage) bool { var reqParams params if err := jsonDecode(bytes.NewReader(message.Payload), &reqParams); err != nil { diff --git a/handler/websocket_test.go b/handler/websocket_test.go index 0b64df95668..f8675475c94 100644 --- a/handler/websocket_test.go +++ b/handler/websocket_test.go @@ -5,6 +5,7 @@ import ( "net/http/httptest" "strings" "testing" + "time" "github.com/gorilla/websocket" "github.com/stretchr/testify/require" @@ -122,6 +123,41 @@ func TestWebsocket(t *testing.T) { }) } +func TestWebsocketWithKeepAlive(t *testing.T) { + next := make(chan struct{}) + h := GraphQL(&executableSchemaStub{next}, WebsocketKeepAliveDuration(10*time.Millisecond)) + + srv := httptest.NewServer(h) + defer srv.Close() + + t.Run("client must receive keepalive", func(t *testing.T) { + c := wsConnect(srv.URL) + defer c.Close() + + require.NoError(t, c.WriteJSON(&operationMessage{Type: connectionInitMsg})) + require.Equal(t, connectionAckMsg, readOp(c).Type) + + require.NoError(t, c.WriteJSON(&operationMessage{ + Type: startMsg, + ID: "test_1", + Payload: json.RawMessage(`{"query": "subscription { user { title } }"}`), + })) + + // keepalive + msg := readOp(c) + require.Equal(t, connectionKeepAliveMsg, msg.Type) + + // server message + next <- struct{}{} + msg = readOp(c) + require.Equal(t, dataMsg, msg.Type) + + // keepalive + msg = readOp(c) + require.Equal(t, connectionKeepAliveMsg, msg.Type) + }) +} + func wsConnect(url string) *websocket.Conn { c, _, err := websocket.DefaultDialer.Dial(strings.Replace(url, "http://", "ws://", -1), nil) if err != nil { From c5b9b5a812e5b87b4504a64ac201f3f8f0d27d37 Mon Sep 17 00:00:00 2001 From: Paul Leitmanis Date: Mon, 4 Feb 2019 16:45:27 +1100 Subject: [PATCH 059/147] Use constant tick rate for websocket keepalive Some clients (e.g. apollographql/subscriptions-transport-ws) expect a constant tick rate for the keepalive, not just a keepalive after x duration of inactivity. --- handler/graphql.go | 22 +++++++++++----------- handler/websocket.go | 34 +++++++++++++--------------------- 2 files changed, 24 insertions(+), 32 deletions(-) diff --git a/handler/graphql.go b/handler/graphql.go index 94188fd7393..8c83dc08e91 100644 --- a/handler/graphql.go +++ b/handler/graphql.go @@ -26,16 +26,16 @@ type params struct { } type Config struct { - cacheSize int - upgrader websocket.Upgrader - recover graphql.RecoverFunc - errorPresenter graphql.ErrorPresenterFunc - resolverHook graphql.FieldMiddleware - requestHook graphql.RequestMiddleware - tracer graphql.Tracer - complexityLimit int - disableIntrospection bool - connectionKeepAliveTimeout time.Duration + cacheSize int + upgrader websocket.Upgrader + recover graphql.RecoverFunc + errorPresenter graphql.ErrorPresenterFunc + resolverHook graphql.FieldMiddleware + requestHook graphql.RequestMiddleware + tracer graphql.Tracer + complexityLimit int + disableIntrospection bool + connectionKeepAlivePingInterval time.Duration } func (c *Config) newRequestContext(es graphql.ExecutableSchema, doc *ast.QueryDocument, op *ast.OperationDefinition, query string, variables map[string]interface{}) *graphql.RequestContext { @@ -247,7 +247,7 @@ const DefaultCacheSize = 1000 // By default, keep-alive is disabled. func WebsocketKeepAliveDuration(duration time.Duration) Option { return func(cfg *Config) { - cfg.connectionKeepAliveTimeout = duration + cfg.connectionKeepAlivePingInterval = duration } } diff --git a/handler/websocket.go b/handler/websocket.go index 579c22ba4f0..58f38e5d48d 100644 --- a/handler/websocket.go +++ b/handler/websocket.go @@ -39,14 +39,14 @@ type operationMessage struct { } type wsConnection struct { - ctx context.Context - conn *websocket.Conn - exec graphql.ExecutableSchema - active map[string]context.CancelFunc - mu sync.Mutex - cfg *Config - cache *lru.Cache - keepAliveTimer *time.Timer + ctx context.Context + conn *websocket.Conn + exec graphql.ExecutableSchema + active map[string]context.CancelFunc + mu sync.Mutex + cfg *Config + cache *lru.Cache + keepAliveTicker *time.Ticker initPayload InitPayload } @@ -110,9 +110,6 @@ func (c *wsConnection) init() bool { func (c *wsConnection) write(msg *operationMessage) { c.mu.Lock() c.conn.WriteJSON(msg) - if c.cfg.connectionKeepAliveTimeout != 0 && c.keepAliveTimer != nil { - c.keepAliveTimer.Reset(c.cfg.connectionKeepAliveTimeout) - } c.mu.Unlock() } @@ -122,11 +119,10 @@ func (c *wsConnection) run() { ctx, cancel := context.WithCancel(c.ctx) defer cancel() - // Create a timer that will fire every interval if a write hasn't been made - // to keep the connection alive. - if c.cfg.connectionKeepAliveTimeout != 0 { + // Create a timer that will fire every interval to keep the connection alive. + if c.cfg.connectionKeepAlivePingInterval != 0 { c.mu.Lock() - c.keepAliveTimer = time.NewTimer(c.cfg.connectionKeepAliveTimeout) + c.keepAliveTicker = time.NewTicker(c.cfg.connectionKeepAlivePingInterval) c.mu.Unlock() go c.keepAlive(ctx) @@ -168,13 +164,9 @@ func (c *wsConnection) keepAlive(ctx context.Context) { for { select { case <-ctx.Done(): - if !c.keepAliveTimer.Stop() { - <-c.keepAliveTimer.C - } + c.keepAliveTicker.Stop() return - case <-c.keepAliveTimer.C: - // We don't reset the timer here, because the `c.write` command - // will reset the timer anyways. + case <-c.keepAliveTicker.C: c.write(&operationMessage{Type: connectionKeepAliveMsg}) } } From cfa012de44b74987653560296ac9571a385c31dd Mon Sep 17 00:00:00 2001 From: Paul Leitmanis Date: Mon, 4 Feb 2019 16:52:55 +1100 Subject: [PATCH 060/147] Enable websocket connection keepalive by default --- handler/graphql.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/handler/graphql.go b/handler/graphql.go index 8c83dc08e91..e5e1bccd9c4 100644 --- a/handler/graphql.go +++ b/handler/graphql.go @@ -241,19 +241,23 @@ func CacheSize(size int) Option { } } -const DefaultCacheSize = 1000 - -// WebsocketKeepAliveDuration allows you to reconfigure the keepAlive behavior. -// By default, keep-alive is disabled. +// WebsocketKeepAliveDuration allows you to reconfigure the keepalive behavior. +// By default, keepalive is enabled with a DefaultConnectionKeepAlivePingInterval +// duration. Set handler.connectionKeepAlivePingInterval = 0 to disable keepalive +// altogether. func WebsocketKeepAliveDuration(duration time.Duration) Option { return func(cfg *Config) { cfg.connectionKeepAlivePingInterval = duration } } +const DefaultCacheSize = 1000 +const DefaultConnectionKeepAlivePingInterval = 25 * time.Second + func GraphQL(exec graphql.ExecutableSchema, options ...Option) http.HandlerFunc { cfg := &Config{ - cacheSize: DefaultCacheSize, + cacheSize: DefaultCacheSize, + connectionKeepAlivePingInterval: DefaultConnectionKeepAlivePingInterval, upgrader: websocket.Upgrader{ ReadBufferSize: 1024, WriteBufferSize: 1024, From 555d7468922e2a27411e688f783dcda5c450554c Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Tue, 5 Feb 2019 11:13:22 +1100 Subject: [PATCH 061/147] Remove TypeDefinition from interface building --- codegen/data.go | 10 +++------- codegen/interface.go | 33 +++++++++++++++++++++++---------- codegen/interface.gotpl | 10 +++++----- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/codegen/data.go b/codegen/data.go index bd3697e5492..1d0c6660da5 100644 --- a/codegen/data.go +++ b/codegen/data.go @@ -19,7 +19,7 @@ type Data struct { Directives map[string]*Directive Objects Objects Inputs Objects - Interfaces []*Interface + Interfaces map[string]*Interface QueryRoot *Object MutationRoot *Object @@ -77,6 +77,7 @@ func BuildData(cfg *config.Config) (*Data, error) { Directives: b.Directives, Schema: b.Schema, SchemaStr: b.SchemaStr, + Interfaces: map[string]*Interface{}, } for _, schemaType := range b.Schema.Types { @@ -97,8 +98,7 @@ func BuildData(cfg *config.Config) (*Data, error) { s.Inputs = append(s.Inputs, input) case ast.Union, ast.Interface: - s.Interfaces = append(s.Interfaces, b.buildInterface(schemaType)) - + s.Interfaces[schemaType.Name] = b.buildInterface(schemaType) } } @@ -128,10 +128,6 @@ func BuildData(cfg *config.Config) (*Data, error) { return s.Inputs[i].Definition.Name < s.Inputs[j].Definition.Name }) - sort.Slice(s.Interfaces, func(i, j int) bool { - return s.Interfaces[i].Definition.GQLDefinition.Name < s.Interfaces[j].Definition.GQLDefinition.Name - }) - return &s, nil } diff --git a/codegen/interface.go b/codegen/interface.go index 1c7a3f1ccad..ee67592508c 100644 --- a/codegen/interface.go +++ b/codegen/interface.go @@ -7,41 +7,54 @@ import ( ) type Interface struct { - Definition *TypeDefinition + *ast.Definition + Type types.Type Implementors []InterfaceImplementor InTypemap bool } type InterfaceImplementor struct { - ValueReceiver bool - Definition *TypeDefinition + *ast.Definition + + Interface *Interface + Type types.Type } func (b *builder) buildInterface(typ *ast.Definition) *Interface { + obj, err := b.Binder.FindUserObject(typ.Name) + if err != nil { + panic(err) + } + i := &Interface{ - Definition: b.NamedTypes[typ.Name], + Definition: typ, + Type: obj, InTypemap: b.Config.Models.UserDefined(typ.Name), } for _, implementor := range b.Schema.GetPossibleTypes(typ) { - t := b.NamedTypes[implementor.Name] + obj, err := b.Binder.FindUserObject(implementor.Name) + if err != nil { + panic(err) + } i.Implementors = append(i.Implementors, InterfaceImplementor{ - Definition: t, - ValueReceiver: b.isValueReceiver(b.NamedTypes[typ.Name], t), + Definition: implementor, + Type: obj, + Interface: i, }) } return i } -func (b *builder) isValueReceiver(intf *TypeDefinition, implementor *TypeDefinition) bool { - interfaceType, err := findGoInterface(intf.GoType) +func (i *InterfaceImplementor) ValueReceiver() bool { + interfaceType, err := findGoInterface(i.Interface.Type) if interfaceType == nil || err != nil { return true } - implementorType, err := findGoNamedType(implementor.GoType) + implementorType, err := findGoNamedType(i.Type) if implementorType == nil || err != nil { return true } diff --git a/codegen/interface.gotpl b/codegen/interface.gotpl index 57d6c6f06ed..81a5807653c 100644 --- a/codegen/interface.gotpl +++ b/codegen/interface.gotpl @@ -1,16 +1,16 @@ {{- range $interface := .Interfaces }} -func (ec *executionContext) _{{$interface.Definition.GQLDefinition.Name}}(ctx context.Context, sel ast.SelectionSet, obj *{{$interface.Definition.GoType | ref}}) graphql.Marshaler { +func (ec *executionContext) _{{$interface.Name}}(ctx context.Context, sel ast.SelectionSet, obj *{{$interface.Type | ref}}) graphql.Marshaler { switch obj := (*obj).(type) { case nil: return graphql.Null {{- range $implementor := $interface.Implementors }} {{- if $implementor.ValueReceiver }} - case {{$implementor.Definition.GoType | ref}}: - return ec._{{$implementor.Definition.GQLDefinition.Name}}(ctx, sel, &obj) + case {{$implementor.Type | ref}}: + return ec._{{$implementor.Name}}(ctx, sel, &obj) {{- end}} - case *{{$implementor.Definition.GoType | ref}}: - return ec._{{$implementor.Definition.GQLDefinition.Name}}(ctx, sel, obj) + case *{{$implementor.Type | ref}}: + return ec._{{$implementor.Name}}(ctx, sel, obj) {{- end }} default: panic(fmt.Errorf("unexpected type %T", obj)) From 60473555e7668de29c188448558123d9dc8edb3b Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Tue, 5 Feb 2019 19:00:21 +1100 Subject: [PATCH 062/147] Shared arg unmarshaling logic --- codegen/args.go | 53 ++- codegen/args.gotpl | 49 +- codegen/build_typedef.go | 2 +- codegen/config/binder.go | 100 +++- codegen/data.go | 36 +- codegen/directive.go | 35 +- codegen/{schema_test.go => errors_test.go} | 7 +- codegen/field.go | 8 +- codegen/fieldarg.go | 16 - codegen/generate.go | 2 +- codegen/input.gotpl | 6 +- codegen/schema.go | 1 - codegen/templates/import_test.go | 20 - codegen/templates/templates.go | 41 ++ codegen/testserver/generated.go | 518 ++++++++++----------- codegen/testserver/resolver.go | 2 +- codegen/type.go | 38 ++ codegen/type.gotpl | 38 ++ example/chat/generated.go | 51 +- example/config/generated.go | 42 +- example/dataloader/generated.go | 112 +++-- example/scalars/generated.go | 64 ++- example/selection/generated.go | 28 +- example/starwars/generated.go | 200 ++++---- example/todo/generated.go | 71 ++- example/type-system-extension/generated.go | 50 +- integration/generated.go | 83 ++-- plugin/modelgen/models.go | 2 +- 28 files changed, 1006 insertions(+), 669 deletions(-) rename codegen/{schema_test.go => errors_test.go} (78%) delete mode 100644 codegen/fieldarg.go delete mode 100644 codegen/schema.go create mode 100644 codegen/type.go create mode 100644 codegen/type.gotpl diff --git a/codegen/args.go b/codegen/args.go index 130439dcb25..8ae1e097b35 100644 --- a/codegen/args.go +++ b/codegen/args.go @@ -5,6 +5,7 @@ import ( "go/types" "strings" + "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/codegen/templates" "github.com/pkg/errors" "github.com/vektah/gqlparser/ast" @@ -15,26 +16,46 @@ type ArgSet struct { FuncDecl string } +type FieldArgument struct { + *ast.ArgumentDefinition + TypeReference *config.TypeReference + VarName string // The name of the var in go + Object *Object // A link back to the parent object + Default interface{} // The default value + Directives []*Directive + Value interface{} // value set in Data +} + +func (f *FieldArgument) Stream() bool { + return f.Object != nil && f.Object.Stream +} + func (b *builder) buildArg(obj *Object, arg *ast.ArgumentDefinition) (*FieldArgument, error) { + def := b.Schema.Types[arg.Type.Name()] + if !def.IsInputType() { + return nil, errors.Errorf( + "cannot use %s as argument %s because %s is not a valid input type", + arg.Type.String(), + arg.Name, + def.Kind, + ) + } + + tr, err := b.Binder.TypeReference(arg.Type) + if err != nil { + return nil, err + } + argDirs, err := b.getDirectives(arg.Directives) if err != nil { return nil, err } newArg := FieldArgument{ - GQLName: arg.Name, - TypeReference: b.NamedTypes.getType(arg.Type), - Object: obj, - GoVarName: templates.ToGoPrivate(arg.Name), - Directives: argDirs, - } - - if !newArg.TypeReference.Definition.GQLDefinition.IsInputType() { - return nil, errors.Errorf( - "cannot use %s as argument %s because %s is not a valid input type", - newArg.Definition.GQLDefinition.Name, - arg.Name, - newArg.TypeReference.Definition.GQLDefinition.Kind, - ) + ArgumentDefinition: arg, + TypeReference: tr, + Object: obj, + VarName: templates.ToGoPrivate(arg.Name), + Directives: argDirs, } if arg.DefaultValue != nil { @@ -54,8 +75,8 @@ nextArg: for j := 0; j < params.Len(); j++ { param := params.At(j) for _, oldArg := range field.Args { - if strings.EqualFold(oldArg.GQLName, param.Name()) { - oldArg.TypeReference.GoType = param.Type() + if strings.EqualFold(oldArg.Name, param.Name()) { + oldArg.TypeReference.GO = param.Type() newArgs = append(newArgs, oldArg) continue nextArg } diff --git a/codegen/args.gotpl b/codegen/args.gotpl index 254ee6fcf43..0a789aa7221 100644 --- a/codegen/args.gotpl +++ b/codegen/args.gotpl @@ -1,49 +1,46 @@ {{ range $name, $args := .Args }} func (e *executableSchema){{ $name }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} {{- range $i, $arg := . }} - var arg{{$i}} {{$arg.GoType | ref }} - if tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok { + var arg{{$i}} {{ $arg.TypeReference.GO | ref}} + if tmp, ok := rawArgs[{{$arg.Name|quote}}]; ok { {{- if $arg.Directives }} - argm{{$i}}, err := chainFieldMiddleware([]graphql.FieldMiddleware{ - {{- range $directive := $arg.Directives }} - func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { - {{- range $dArg := $directive.Args }} - {{- if and $dArg.IsPtr ( notNil "Value" $dArg ) }} - {{ $dArg.GoVarName }} := {{ $dArg.Value | dump }} + getArg0 := func(ctx context.Context) (interface{}, error) { return unmarshal{{$arg.TypeReference.GQL.Name}}2{{ $arg.TypeReference.GO | ts }}(tmp) } + + {{- range $i, $directive := $arg.Directives }} + getArg{{add $i 1}} := func(ctx context.Context) (res interface{}, err error) { + {{- range $dArg := $directive.Args }} + {{- if and $dArg.TypeReference.IsPtr ( notNil "Value" $dArg ) }} + {{ $dArg.VarName }} := {{ $dArg.Value | dump }} + {{- end }} {{- end }} - {{- end }} + n := getArg{{$i}} return e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs "tmp" "n" }}) - }, - {{- end }} - }...)(ctx, func(ctx2 context.Context) (interface{}, error) { - var err error - {{$arg.Unmarshal (print "arg" $i) "tmp" }} - if err != nil { - return nil, err } - return arg{{ $i }}, nil - }) + {{- end }} + + tmp, err = getArg{{$arg.Directives|len}}(ctx) if err != nil { return nil, err } - if data, ok := argm{{$i}}.({{$arg.GoType | ref }}); ok { + if data, ok := tmp.({{ $arg.TypeReference.GO }}) ; ok { arg{{$i}} = data } else { - return nil, errors.New("expect {{$arg.GoType | ref }}") + return nil, fmt.Errorf(`unexpected type %T from directive, should be {{ $arg.TypeReference.GO }}`, tmp) } {{- else }} - var err error - {{ $arg.Unmarshal (print "arg" $i) "tmp" }} + arg{{$i}}, err = unmarshal{{$arg.TypeReference.GQL.Name}}2{{ $arg.TypeReference.GO | ts }}(tmp) if err != nil { return nil, err } {{- end }} - {{- if eq $arg.Definition.GQLDefinition.Kind "INPUT_OBJECT" }} - {{ $arg.Middleware (print "arg" $i) (print "arg" $i) }} - {{- end }} + + {{/*{{- if eq $arg.TypeReference.Definition.Kind "INPUT_OBJECT" }}*/}} + {{/*{{ $arg.Middleware (print "arg" $i) (print "arg" $i) }}*/}} + {{/*{{- end }}*/}} } - args[{{$arg.GQLName|quote}}] = arg{{$i}} + args[{{$arg.Name|quote}}] = arg{{$i}} {{- end }} return args, nil } diff --git a/codegen/build_typedef.go b/codegen/build_typedef.go index 989ced94803..bf234bd5ff0 100644 --- a/codegen/build_typedef.go +++ b/codegen/build_typedef.go @@ -83,7 +83,7 @@ func (b *builder) buildTypeDef(schemaType *ast.Definition) (*TypeDefinition, err // Special case to reference generated unmarshal functions if !hasUnmarshal { - t.Unmarshaler = types.NewFunc(0, b.Config.Exec.Pkg(), "Unmarshal"+schemaType.Name, nil) + t.Unmarshaler = types.NewFunc(0, b.Config.Exec.Pkg(), "unmarshalInput"+schemaType.Name, nil) } return t, nil diff --git a/codegen/config/binder.go b/codegen/config/binder.go index 3878f4701f7..69bd20ea3ce 100644 --- a/codegen/config/binder.go +++ b/codegen/config/binder.go @@ -14,19 +14,22 @@ import ( // Binder connects graphql types to golang types using static analysis type Binder struct { - pkgs []*packages.Package - types TypeMap + pkgs []*packages.Package + schema *ast.Schema + cfg *Config + References []*TypeReference } -func (c *Config) NewBinder() (*Binder, error) { +func (c *Config) NewBinder(s *ast.Schema) (*Binder, error) { pkgs, err := packages.Load(&packages.Config{Mode: packages.LoadTypes | packages.LoadSyntax}, c.Models.ReferencedPackages()...) if err != nil { return nil, err } return &Binder{ - pkgs: pkgs, - types: c.Models, + pkgs: pkgs, + schema: s, + cfg: c, }, nil } @@ -55,7 +58,7 @@ var MapType = types.NewMap(types.Typ[types.String], types.NewInterfaceType(nil, var InterfaceType = types.NewInterfaceType(nil, nil) func (b *Binder) FindUserObject(name string) (types.Type, error) { - userEntry, ok := b.types[name] + userEntry, ok := b.cfg.Models[name] if !ok { return nil, fmt.Errorf(name + " not found") } @@ -118,17 +121,58 @@ func normalizeVendor(pkg string) string { return modifiers + parts[len(parts)-1] } -func (b *Binder) FindBackingType(schemaType *ast.Type) (types.Type, error) { +// TypeReference is used by args and field types. The Definition can refer to both input and output types. +type TypeReference struct { + Definition *ast.Definition + GQL *ast.Type + GO types.Type + Marshaler *types.Func // When using external marshalling functions this will point to the Marshal function + Unmarshaler *types.Func // When using external marshalling functions this will point to the Unmarshal function +} + +func (t TypeReference) IsPtr() bool { + _, isPtr := t.GO.(*types.Pointer) + return isPtr +} + +func (t TypeReference) IsSlice() bool { + _, isSlice := t.GO.(*types.Slice) + return isSlice +} + +func (t TypeReference) IsNamed() bool { + _, isSlice := t.GO.(*types.Named) + return isSlice +} + +func (b *Binder) PushRef(ret *TypeReference) { + b.References = append(b.References, ret) +} + +func (b *Binder) TypeReference(schemaType *ast.Type) (ret *TypeReference, err error) { var pkgName, typeName string + def := b.schema.Types[schemaType.Name()] + defer func() { + if err == nil && ret != nil { + b.PushRef(ret) + } + }() - if userEntry, ok := b.types[schemaType.Name()]; ok && userEntry.Model != "" { - // special case for maps + if userEntry, ok := b.cfg.Models[schemaType.Name()]; ok && userEntry.Model != "" { if userEntry.Model == "map[string]interface{}" { - return MapType, nil + return &TypeReference{ + Definition: def, + GQL: schemaType, + GO: MapType, + }, nil } if userEntry.Model == "interface{}" { - return InterfaceType, nil + return &TypeReference{ + Definition: def, + GQL: schemaType, + GO: InterfaceType, + }, nil } pkgName, typeName = code.PkgAndType(userEntry.Model) @@ -141,12 +185,42 @@ func (b *Binder) FindBackingType(schemaType *ast.Type) (types.Type, error) { typeName = "String" } - t, err := b.FindType(pkgName, typeName) + ref := &TypeReference{ + Definition: def, + GQL: schemaType, + } + + obj, err := b.FindObject(pkgName, typeName) if err != nil { return nil, err } - return b.CopyModifiersFromAst(schemaType, true, t), nil + if fun, isFunc := obj.(*types.Func); isFunc { + ref.GO = fun.Type().(*types.Signature).Params().At(0).Type() + ref.Marshaler = fun + ref.Unmarshaler = types.NewFunc(0, fun.Pkg(), "Unmarshal"+typeName, nil) + } else { + ref.GO = obj.Type() + } + + if namedType, ok := ref.GO.(*types.Named); ok && ref.Unmarshaler == nil { + hasUnmarshal := false + for i := 0; i < namedType.NumMethods(); i++ { + switch namedType.Method(i).Name() { + case "UnmarshalGQL": + hasUnmarshal = true + } + } + + // Special case to reference generated unmarshal functions + if !hasUnmarshal { + ref.Unmarshaler = types.NewFunc(0, b.cfg.Exec.Pkg(), "unmarshalInput"+schemaType.Name(), nil) + } + } + + ref.GO = b.CopyModifiersFromAst(schemaType, true, ref.GO) + + return ref, nil } func (b *Binder) CopyModifiersFromAst(t *ast.Type, usePtr bool, base types.Type) types.Type { diff --git a/codegen/data.go b/codegen/data.go index 1d0c6660da5..eabd43f6062 100644 --- a/codegen/data.go +++ b/codegen/data.go @@ -13,13 +13,14 @@ import ( // Data is a unified model of the code to be generated. Plugins may modify this structure to do things like implement // resolvers or directives automatically (eg grpc, validation) type Data struct { - Config *config.Config - Schema *ast.Schema - SchemaStr map[string]string - Directives map[string]*Directive - Objects Objects - Inputs Objects - Interfaces map[string]*Interface + Config *config.Config + Schema *ast.Schema + SchemaStr map[string]string + Directives map[string]*Directive + Objects Objects + Inputs Objects + Interfaces map[string]*Interface + ReferencedTypes map[string]*config.TypeReference QueryRoot *Object MutationRoot *Object @@ -53,7 +54,7 @@ func BuildData(cfg *config.Config) (*Data, error) { cfg.InjectBuiltins(b.Schema) - b.Binder, err = b.Config.NewBinder() + b.Binder, err = b.Config.NewBinder(b.Schema) if err != nil { return nil, err } @@ -120,6 +121,11 @@ func BuildData(cfg *config.Config) (*Data, error) { return nil, err } + s.ReferencedTypes, err = b.buildTypes() + if err != nil { + return nil, err + } + sort.Slice(s.Objects, func(i, j int) bool { return s.Objects[i].Definition.Name < s.Objects[j].Definition.Name }) @@ -141,6 +147,10 @@ func (b *builder) injectIntrospectionRoots(s *Data) error { if err != nil { return errors.Wrap(err, "unable to find root Type introspection type") } + stringRef, err := b.Binder.TypeReference(ast.NonNullNamedType("String", nil)) + if err != nil { + return errors.Wrap(err, "unable to find root string type reference") + } obj.Fields = append(obj.Fields, &Field{ TypeReference: &TypeReference{b.NamedTypes["__Type"], types.NewPointer(typeType.Type()), ast.NamedType("__Schema", nil)}, @@ -150,13 +160,11 @@ func (b *builder) injectIntrospectionRoots(s *Data) error { GoFieldName: "introspectType", Args: []*FieldArgument{ { - GQLName: "name", - TypeReference: &TypeReference{ - b.NamedTypes["String"], - types.Typ[types.String], - ast.NamedType("String", nil), + ArgumentDefinition: &ast.ArgumentDefinition{ + Name: "name", }, - Object: &Object{}, + TypeReference: stringRef, + Object: &Object{}, }, }, Object: obj, diff --git a/codegen/directive.go b/codegen/directive.go index 5897c68774a..d13ae4fee5b 100644 --- a/codegen/directive.go +++ b/codegen/directive.go @@ -28,15 +28,20 @@ func (b *builder) buildDirectives() (map[string]*Directive, error) { var args []*FieldArgument for _, arg := range dir.Arguments { + def := b.Schema.Types[arg.Type.Name()] + if !def.IsInputType() { + return nil, errors.Errorf("%s cannot be used as argument of directive %s(%s) only input and scalar types are allowed", arg.Type, dir.Name, arg.Name) + } - newArg := &FieldArgument{ - GQLName: arg.Name, - TypeReference: b.NamedTypes.getType(arg.Type), - GoVarName: templates.ToGoPrivate(arg.Name), + tr, err := b.Binder.TypeReference(arg.Type) + if err != nil { + return nil, err } - if !newArg.TypeReference.Definition.GQLDefinition.IsInputType() { - return nil, errors.Errorf("%s cannot be used as argument of directive %s(%s) only input and scalar types are allowed", arg.Type, dir.Name, arg.Name) + newArg := &FieldArgument{ + ArgumentDefinition: arg, + TypeReference: tr, + VarName: templates.ToGoPrivate(arg.Name), } if arg.DefaultValue != nil { @@ -77,14 +82,14 @@ func (b *builder) getDirectives(list ast.DirectiveList) ([]*Directive, error) { var args []*FieldArgument for _, a := range def.Args { value := a.Default - if argValue, ok := argValues[a.GQLName]; ok { + if argValue, ok := argValues[a.Name]; ok { value = argValue } args = append(args, &FieldArgument{ - GQLName: a.GQLName, - Value: value, - GoVarName: a.GoVarName, - TypeReference: a.TypeReference, + ArgumentDefinition: a.ArgumentDefinition, + Value: value, + VarName: a.VarName, + TypeReference: a.TypeReference, }) } dirs[i] = &Directive{ @@ -109,7 +114,7 @@ func (d *Directive) CallArgs() string { args := []string{"ctx", "obj", "n"} for _, arg := range d.Args { - args = append(args, "args["+strconv.Quote(arg.GQLName)+"].("+templates.CurrentImports.LookupType(arg.GoType)+")") + args = append(args, "args["+strconv.Quote(arg.Name)+"].("+templates.CurrentImports.LookupType(arg.TypeReference.GO)+")") } return strings.Join(args, ", ") @@ -119,8 +124,8 @@ func (d *Directive) ResolveArgs(obj string, next string) string { args := []string{"ctx", obj, next} for _, arg := range d.Args { - dArg := "&" + arg.GoVarName - if !arg.IsPtr() { + dArg := "&" + arg.VarName + if !arg.TypeReference.IsPtr() { if arg.Value != nil { dArg = templates.Dump(arg.Value) } else { @@ -140,7 +145,7 @@ func (d *Directive) Declaration() string { res := ucFirst(d.Name) + " func(ctx context.Context, obj interface{}, next graphql.Resolver" for _, arg := range d.Args { - res += fmt.Sprintf(", %s %s", arg.GoVarName, templates.CurrentImports.LookupType(arg.GoType)) + res += fmt.Sprintf(", %s %s", arg.Name, templates.CurrentImports.LookupType(arg.TypeReference.GO)) } res += ") (res interface{}, err error)" diff --git a/codegen/schema_test.go b/codegen/errors_test.go similarity index 78% rename from codegen/schema_test.go rename to codegen/errors_test.go index 7cf7dce3fce..2cd16b593bd 100644 --- a/codegen/schema_test.go +++ b/codegen/errors_test.go @@ -10,7 +10,7 @@ import ( func TestTypeUnionAsInput(t *testing.T) { err := generate("inputunion", `testdata/unioninput.graphqls`) - require.EqualError(t, err, "unable to build object definition: Query.addBookmark: cannot use Bookmarkable as argument b because UNION is not a valid input type") + require.EqualError(t, err, "unable to build object definition: Query.addBookmark: cannot use Bookmarkable! as argument b because UNION is not a valid input type") } func TestTypeInInput(t *testing.T) { @@ -25,8 +25,9 @@ func generate(name string, schemaFilename string) error { Exec: config.PackageConfig{Filename: "gen/" + name + "/exec.go"}, Model: config.PackageConfig{Filename: "gen/" + name + "/model.go"}, Models: map[string]config.TypeMapEntry{ - "Item": {Model: "map[string]interface{}"}, - "Bookmarkable": {Model: "interface{}"}, + "Item": {Model: "map[string]interface{}"}, + "Bookmarkable": {Model: "interface{}"}, + "BookmarkableInput": {Model: "interface{}"}, }, }) diff --git a/codegen/field.go b/codegen/field.go index 1cf30f27857..413ea3eb54c 100644 --- a/codegen/field.go +++ b/codegen/field.go @@ -297,7 +297,7 @@ func (f *Field) ShortResolverDeclaration() string { res += fmt.Sprintf(", obj *%s", templates.CurrentImports.LookupType(f.Object.Type)) } for _, arg := range f.Args { - res += fmt.Sprintf(", %s %s", arg.GoVarName, templates.CurrentImports.LookupType(arg.GoType)) + res += fmt.Sprintf(", %s %s", arg.VarName, templates.CurrentImports.LookupType(arg.TypeReference.GO)) } result := templates.CurrentImports.LookupType(f.GoType) @@ -312,7 +312,7 @@ func (f *Field) ShortResolverDeclaration() string { func (f *Field) ComplexitySignature() string { res := fmt.Sprintf("func(childComplexity int") for _, arg := range f.Args { - res += fmt.Sprintf(", %s %s", arg.GoVarName, templates.CurrentImports.LookupType(arg.GoType)) + res += fmt.Sprintf(", %s %s", arg.VarName, templates.CurrentImports.LookupType(arg.TypeReference.GO)) } res += ") int" return res @@ -321,7 +321,7 @@ func (f *Field) ComplexitySignature() string { func (f *Field) ComplexityArgs() string { var args []string for _, arg := range f.Args { - args = append(args, "args["+strconv.Quote(arg.GQLName)+"].("+templates.CurrentImports.LookupType(arg.GoType)+")") + args = append(args, "args["+strconv.Quote(arg.Name)+"].("+templates.CurrentImports.LookupType(arg.TypeReference.GO)+")") } return strings.Join(args, ", ") @@ -343,7 +343,7 @@ func (f *Field) CallArgs() string { } for _, arg := range f.Args { - args = append(args, "args["+strconv.Quote(arg.GQLName)+"].("+templates.CurrentImports.LookupType(arg.GoType)+")") + args = append(args, "args["+strconv.Quote(arg.Name)+"].("+templates.CurrentImports.LookupType(arg.TypeReference.GO)+")") } return strings.Join(args, ", ") diff --git a/codegen/fieldarg.go b/codegen/fieldarg.go deleted file mode 100644 index d85feb3dd63..00000000000 --- a/codegen/fieldarg.go +++ /dev/null @@ -1,16 +0,0 @@ -package codegen - -type FieldArgument struct { - *TypeReference - - GQLName string // The name of the argument in graphql - GoVarName string // The name of the var in go - Object *Object // A link back to the parent object - Default interface{} // The default value - Directives []*Directive - Value interface{} // value set in Data -} - -func (f *FieldArgument) Stream() bool { - return f.Object != nil && f.Object.Stream -} diff --git a/codegen/generate.go b/codegen/generate.go index eafa3f87434..a32e329e60c 100644 --- a/codegen/generate.go +++ b/codegen/generate.go @@ -10,6 +10,6 @@ func GenerateCode(data *Data) error { Filename: data.Config.Exec.Filename, Data: data, RegionTags: true, - GeneratedHeader: true, + GeneratedHeader: false, }) } diff --git a/codegen/input.gotpl b/codegen/input.gotpl index 1e8e01fca64..c09c949fa00 100644 --- a/codegen/input.gotpl +++ b/codegen/input.gotpl @@ -1,6 +1,6 @@ {{- range $input := .Inputs }} {{- if not .HasUnmarshal }} - func Unmarshal{{ .Name }}(v interface{}) ({{.Type | ref}}, error) { + func unmarshalInput{{ .Name }}(v interface{}) ({{.Type | ref}}, error) { var it {{.Type | ref}} var asMap = v.(map[string]interface{}) {{ range $field := .Fields}} @@ -65,8 +65,8 @@ func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { {{- if $directive.Args }} {{- range $arg := $directive.Args }} - {{- if and $arg.IsPtr ( notNil "Value" $arg ) }} - {{ $arg.GoVarName }} := {{ $arg.Value | dump }} + {{- if and $arg.TypeReference.IsPtr ( notNil "Value" $arg ) }} + {{ $arg.VarName }} := {{ $arg.Value | dump }} {{- end }} {{- end }} {{- end }} diff --git a/codegen/schema.go b/codegen/schema.go deleted file mode 100644 index c4d47b51af4..00000000000 --- a/codegen/schema.go +++ /dev/null @@ -1 +0,0 @@ -package codegen diff --git a/codegen/templates/import_test.go b/codegen/templates/import_test.go index a8dd39d4bfc..437bf7438b0 100644 --- a/codegen/templates/import_test.go +++ b/codegen/templates/import_test.go @@ -65,26 +65,6 @@ bar1 "github.com/99designs/gqlgen/codegen/templates/testdata/b/bar" ) }) - t.Run("reserved collisions on path will panic", func(t *testing.T) { - a := Imports{destDir: wd} - - a.Reserve(aBar) - - require.Panics(t, func() { - a.Reserve(aBar) - }) - }) - - t.Run("reserved collisions on alias will panic", func(t *testing.T) { - a := Imports{destDir: wd} - - a.Reserve(aBar) - - require.Panics(t, func() { - a.Reserve(bBar) - }) - }) - t.Run("aliased imports will not collide", func(t *testing.T) { a := Imports{destDir: wd} diff --git a/codegen/templates/templates.go b/codegen/templates/templates.go index 50099b60f9e..9cf65eeed8b 100644 --- a/codegen/templates/templates.go +++ b/codegen/templates/templates.go @@ -129,6 +129,7 @@ func Funcs() template.FuncMap { "toCamel": ToCamel, "dump": Dump, "ref": ref, + "ts": TypeIdentifier, "call": Call, "prefixLines": prefixLines, "notNil": notNil, @@ -136,6 +137,9 @@ func Funcs() template.FuncMap { "lookupImport": CurrentImports.Lookup, "go": ToGo, "goPrivate": ToGoPrivate, + "add": func(a, b int) int { + return a + b + }, "render": func(filename string, tpldata interface{}) (*bytes.Buffer, error) { return render(resolveName(filename, 0), tpldata) }, @@ -169,6 +173,43 @@ func ref(p types.Type) string { return CurrentImports.LookupType(p) } +var pkgReplacer = strings.NewReplacer( + "/", "ᚋ", + ".", "ᚗ", + "-", "ᚑ", +) + +func TypeIdentifier(t types.Type) string { + res := "" + for { + switch it := t.(type) { + case *types.Pointer: + t.Underlying() + res += "ᚖ" + t = it.Elem() + case *types.Slice: + res += "ᚕ" + t = it.Elem() + case *types.Named: + res += pkgReplacer.Replace(it.Obj().Pkg().Path()) + res += "ᚐ" + res += it.Obj().Name() + return res + case *types.Basic: + res += it.Name() + return res + case *types.Map: + res += "map" + return res + case *types.Interface: + res += "interface" + return res + default: + panic(fmt.Errorf("unexpected type %T", it)) + } + } +} + func Call(p *types.Func) string { pkg := CurrentImports.Lookup(p.Pkg().Path()) diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index a6bc9122d3e..3feab2595c4 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -1,5 +1,3 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - package testserver import ( @@ -97,7 +95,7 @@ type ComplexityRoot struct { Query struct { InvalidIdentifier func(childComplexity int) int Collision func(childComplexity int) int - MapInput func(childComplexity int, input *map[string]interface{}) int + MapInput func(childComplexity int, input map[string]interface{}) int Recursive func(childComplexity int, input *RecursiveInputSlice) int NestedInputs func(childComplexity int, input [][]*OuterInput) int NestedOutputs func(childComplexity int) int @@ -141,7 +139,7 @@ type ModelMethodsResolver interface { type QueryResolver interface { InvalidIdentifier(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) Collision(ctx context.Context) (*introspection1.It, error) - MapInput(ctx context.Context, input *map[string]interface{}) (*bool, error) + MapInput(ctx context.Context, input map[string]interface{}) (*bool, error) Recursive(ctx context.Context, input *RecursiveInputSlice) (*bool, error) NestedInputs(ctx context.Context, input [][]*OuterInput) (*bool, error) NestedOutputs(ctx context.Context) ([][]*OuterObject, error) @@ -315,7 +313,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Query.MapInput(childComplexity, args["input"].(*map[string]interface{})), true + return e.complexity.Query.MapInput(childComplexity, args["input"].(map[string]interface{})), true case "Query.recursive": if e.complexity.Query.Recursive == nil { @@ -862,664 +860,537 @@ func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMi // region ***************************** args.gotpl ***************************** func (e *executableSchema) dir_length_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 int if tmp, ok := rawArgs["min"]; ok { - var err error - arg0, err = graphql.UnmarshalInt(tmp) + arg0, err = unmarshalInt2int(tmp) if err != nil { return nil, err } + } args["min"] = arg0 var arg1 *int if tmp, ok := rawArgs["max"]; ok { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg1 = &ptr1 - } - + arg1, err = unmarshalInt2ᚖint(tmp) if err != nil { return nil, err } + } args["max"] = arg1 var arg2 string if tmp, ok := rawArgs["message"]; ok { - var err error - arg2, err = graphql.UnmarshalString(tmp) + arg2, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["message"] = arg2 return args, nil } func (e *executableSchema) dir_range_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["min"]; ok { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg0 = &ptr1 - } - + arg0, err = unmarshalInt2ᚖint(tmp) if err != nil { return nil, err } + } args["min"] = arg0 var arg1 *int if tmp, ok := rawArgs["max"]; ok { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg1 = &ptr1 - } - + arg1, err = unmarshalInt2ᚖint(tmp) if err != nil { return nil, err } + } args["max"] = arg1 var arg2 *string if tmp, ok := rawArgs["message"]; ok { - var err error - var ptr1 string - if tmp != nil { - ptr1, err = graphql.UnmarshalString(tmp) - arg2 = &ptr1 - } - + arg2, err = unmarshalString2ᚖstring(tmp) if err != nil { return nil, err } + } args["message"] = arg2 return args, nil } func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) + arg0, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["name"] = arg0 return args, nil } func (e *executableSchema) field_Query_directiveArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["arg"]; ok { - argm0, err := chainFieldMiddleware([]graphql.FieldMiddleware{ - func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { - max := 255 - return e.directives.Length(ctx, tmp, n, 1, &max, "invalid length") - }, - }...)(ctx, func(ctx2 context.Context) (interface{}, error) { - var err error - arg0, err = graphql.UnmarshalString(tmp) - if err != nil { - return nil, err - } - return arg0, nil - }) + getArg0 := func(ctx context.Context) (interface{}, error) { return unmarshalString2string(tmp) } + getArg1 := func(ctx context.Context) (res interface{}, err error) { + max := 255 + n := getArg0 + return e.directives.Length(ctx, tmp, n, 1, &max, "invalid length") + } + + tmp, err = getArg1(ctx) if err != nil { return nil, err } - if data, ok := argm0.(string); ok { + if data, ok := tmp.(string); ok { arg0 = data } else { - return nil, errors.New("expect string") + return nil, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp) } + } args["arg"] = arg0 return args, nil } func (e *executableSchema) field_Query_directiveInputNullable_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 *InputDirectives if tmp, ok := rawArgs["arg"]; ok { - var err error - var ptr1 InputDirectives - if tmp != nil { - ptr1, err = UnmarshalInputDirectives(tmp) - arg0 = &ptr1 - } - + arg0, err = unmarshalInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(tmp) if err != nil { return nil, err } - if arg0 != nil { - var err error - arg0, err = e.InputDirectivesMiddleware(ctx, arg0) - if err != nil { - return nil, err - } - } } args["arg"] = arg0 return args, nil } func (e *executableSchema) field_Query_directiveInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 InputDirectives if tmp, ok := rawArgs["arg"]; ok { - var err error - arg0, err = UnmarshalInputDirectives(tmp) + arg0, err = unmarshalInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(tmp) if err != nil { return nil, err } - mInputDirectives1, err := e.InputDirectivesMiddleware(ctx, &arg0) - if err != nil { - return nil, err - } - arg0 = *mInputDirectives1 } args["arg"] = arg0 return args, nil } func (e *executableSchema) field_Query_directiveNullableArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["arg"]; ok { - argm0, err := chainFieldMiddleware([]graphql.FieldMiddleware{ - func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { - min := 0 - return e.directives.Range(ctx, tmp, n, &min, nil, nil) - }, - }...)(ctx, func(ctx2 context.Context) (interface{}, error) { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg0 = &ptr1 - } + getArg0 := func(ctx context.Context) (interface{}, error) { return unmarshalInt2ᚖint(tmp) } + getArg1 := func(ctx context.Context) (res interface{}, err error) { + min := 0 + n := getArg0 + return e.directives.Range(ctx, tmp, n, &min, nil, nil) + } - if err != nil { - return nil, err - } - return arg0, nil - }) + tmp, err = getArg1(ctx) if err != nil { return nil, err } - if data, ok := argm0.(*int); ok { + if data, ok := tmp.(*int); ok { arg0 = data } else { - return nil, errors.New("expect *int") + return nil, fmt.Errorf(`unexpected type %T from directive, should be *int`, tmp) } + } args["arg"] = arg0 var arg1 *int if tmp, ok := rawArgs["arg2"]; ok { - argm1, err := chainFieldMiddleware([]graphql.FieldMiddleware{ - func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { - min := 0 - return e.directives.Range(ctx, tmp, n, &min, nil, nil) - }, - }...)(ctx, func(ctx2 context.Context) (interface{}, error) { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg1 = &ptr1 - } + getArg0 := func(ctx context.Context) (interface{}, error) { return unmarshalInt2ᚖint(tmp) } + getArg1 := func(ctx context.Context) (res interface{}, err error) { + min := 0 + n := getArg0 + return e.directives.Range(ctx, tmp, n, &min, nil, nil) + } - if err != nil { - return nil, err - } - return arg1, nil - }) + tmp, err = getArg1(ctx) if err != nil { return nil, err } - if data, ok := argm1.(*int); ok { + if data, ok := tmp.(*int); ok { arg1 = data } else { - return nil, errors.New("expect *int") + return nil, fmt.Errorf(`unexpected type %T from directive, should be *int`, tmp) } + } args["arg2"] = arg1 return args, nil } func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["break"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) + arg0, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["break"] = arg0 var arg1 string if tmp, ok := rawArgs["default"]; ok { - var err error - arg1, err = graphql.UnmarshalString(tmp) + arg1, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["default"] = arg1 var arg2 string if tmp, ok := rawArgs["func"]; ok { - var err error - arg2, err = graphql.UnmarshalString(tmp) + arg2, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["func"] = arg2 var arg3 string if tmp, ok := rawArgs["interface"]; ok { - var err error - arg3, err = graphql.UnmarshalString(tmp) + arg3, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["interface"] = arg3 var arg4 string if tmp, ok := rawArgs["select"]; ok { - var err error - arg4, err = graphql.UnmarshalString(tmp) + arg4, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["select"] = arg4 var arg5 string if tmp, ok := rawArgs["case"]; ok { - var err error - arg5, err = graphql.UnmarshalString(tmp) + arg5, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["case"] = arg5 var arg6 string if tmp, ok := rawArgs["defer"]; ok { - var err error - arg6, err = graphql.UnmarshalString(tmp) + arg6, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["defer"] = arg6 var arg7 string if tmp, ok := rawArgs["go"]; ok { - var err error - arg7, err = graphql.UnmarshalString(tmp) + arg7, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["go"] = arg7 var arg8 string if tmp, ok := rawArgs["map"]; ok { - var err error - arg8, err = graphql.UnmarshalString(tmp) + arg8, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["map"] = arg8 var arg9 string if tmp, ok := rawArgs["struct"]; ok { - var err error - arg9, err = graphql.UnmarshalString(tmp) + arg9, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["struct"] = arg9 var arg10 string if tmp, ok := rawArgs["chan"]; ok { - var err error - arg10, err = graphql.UnmarshalString(tmp) + arg10, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["chan"] = arg10 var arg11 string if tmp, ok := rawArgs["else"]; ok { - var err error - arg11, err = graphql.UnmarshalString(tmp) + arg11, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["else"] = arg11 var arg12 string if tmp, ok := rawArgs["goto"]; ok { - var err error - arg12, err = graphql.UnmarshalString(tmp) + arg12, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["goto"] = arg12 var arg13 string if tmp, ok := rawArgs["package"]; ok { - var err error - arg13, err = graphql.UnmarshalString(tmp) + arg13, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["package"] = arg13 var arg14 string if tmp, ok := rawArgs["switch"]; ok { - var err error - arg14, err = graphql.UnmarshalString(tmp) + arg14, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["switch"] = arg14 var arg15 string if tmp, ok := rawArgs["const"]; ok { - var err error - arg15, err = graphql.UnmarshalString(tmp) + arg15, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["const"] = arg15 var arg16 string if tmp, ok := rawArgs["fallthrough"]; ok { - var err error - arg16, err = graphql.UnmarshalString(tmp) + arg16, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["fallthrough"] = arg16 var arg17 string if tmp, ok := rawArgs["if"]; ok { - var err error - arg17, err = graphql.UnmarshalString(tmp) + arg17, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["if"] = arg17 var arg18 string if tmp, ok := rawArgs["range"]; ok { - var err error - arg18, err = graphql.UnmarshalString(tmp) + arg18, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["range"] = arg18 var arg19 string if tmp, ok := rawArgs["type"]; ok { - var err error - arg19, err = graphql.UnmarshalString(tmp) + arg19, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["type"] = arg19 var arg20 string if tmp, ok := rawArgs["continue"]; ok { - var err error - arg20, err = graphql.UnmarshalString(tmp) + arg20, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["continue"] = arg20 var arg21 string if tmp, ok := rawArgs["for"]; ok { - var err error - arg21, err = graphql.UnmarshalString(tmp) + arg21, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["for"] = arg21 var arg22 string if tmp, ok := rawArgs["import"]; ok { - var err error - arg22, err = graphql.UnmarshalString(tmp) + arg22, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["import"] = arg22 var arg23 string if tmp, ok := rawArgs["return"]; ok { - var err error - arg23, err = graphql.UnmarshalString(tmp) + arg23, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["return"] = arg23 var arg24 string if tmp, ok := rawArgs["var"]; ok { - var err error - arg24, err = graphql.UnmarshalString(tmp) + arg24, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["var"] = arg24 return args, nil } func (e *executableSchema) field_Query_keywords_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 *Keywords if tmp, ok := rawArgs["input"]; ok { - var err error - var ptr1 Keywords - if tmp != nil { - ptr1, err = UnmarshalKeywords(tmp) - arg0 = &ptr1 - } - + arg0, err = unmarshalKeywords2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(tmp) if err != nil { return nil, err } - if arg0 != nil { - var err error - arg0, err = e.KeywordsMiddleware(ctx, arg0) - if err != nil { - return nil, err - } - } } args["input"] = arg0 return args, nil } func (e *executableSchema) field_Query_mapInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} - var arg0 *map[string]interface{} + var arg0 map[string]interface{} if tmp, ok := rawArgs["input"]; ok { - var err error - var ptr1 map[string]interface{} - if tmp != nil { - ptr1 = tmp.(map[string]interface{}) - arg0 = &ptr1 - } - + arg0, err = unmarshalChanges2map(tmp) if err != nil { return nil, err } - if arg0 != nil { - var err error - arg0, err = e.ChangesMiddleware(ctx, arg0) - if err != nil { - return nil, err - } - } } args["input"] = arg0 return args, nil } func (e *executableSchema) field_Query_nestedInputs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 [][]*OuterInput if tmp, ok := rawArgs["input"]; ok { - var err error - var rawIf1 []interface{} - if tmp != nil { - if tmp1, ok := tmp.([]interface{}); ok { - rawIf1 = tmp1 - } else { - rawIf1 = []interface{}{tmp} - } - } - arg0 = make([][]*OuterInput, len(rawIf1)) - for idx1 := range rawIf1 { - var rawIf2 []interface{} - if rawIf1[idx1] != nil { - if tmp1, ok := rawIf1[idx1].([]interface{}); ok { - rawIf2 = tmp1 - } else { - rawIf2 = []interface{}{rawIf1[idx1]} - } - } - arg0[idx1] = make([]*OuterInput, len(rawIf2)) - for idx2 := range rawIf2 { - var ptr3 OuterInput - if rawIf2[idx2] != nil { - ptr3, err = UnmarshalOuterInput(rawIf2[idx2]) - arg0[idx1][idx2] = &ptr3 - } - } - } + arg0, err = unmarshalOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(tmp) if err != nil { return nil, err } - for idx1 := range arg0 { - for idx2 := range arg0[idx1] { - if arg0[idx1][idx2] != nil { - var err error - arg0[idx1][idx2], err = e.OuterInputMiddleware(ctx, arg0[idx1][idx2]) - if err != nil { - return nil, err - } - } - } - } } args["input"] = arg0 return args, nil } func (e *executableSchema) field_Query_nullableArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["arg"]; ok { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg0 = &ptr1 - } - + arg0, err = unmarshalInt2ᚖint(tmp) if err != nil { return nil, err } + } args["arg"] = arg0 return args, nil } func (e *executableSchema) field_Query_recursive_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 *RecursiveInputSlice if tmp, ok := rawArgs["input"]; ok { - var err error - var ptr1 RecursiveInputSlice - if tmp != nil { - ptr1, err = UnmarshalRecursiveInputSlice(tmp) - arg0 = &ptr1 - } - + arg0, err = unmarshalRecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(tmp) if err != nil { return nil, err } - if arg0 != nil { - var err error - arg0, err = e.RecursiveInputSliceMiddleware(ctx, arg0) - if err != nil { - return nil, err - } - } } args["input"] = arg0 return args, nil } func (e *executableSchema) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 int if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalInt(tmp) + arg0, err = unmarshalInt2int(tmp) if err != nil { return nil, err } + } args["id"] = arg0 return args, nil } func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) + arg0, err = unmarshalBoolean2bool(tmp) if err != nil { return nil, err } + } args["includeDeprecated"] = arg0 return args, nil } func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) + arg0, err = unmarshalBoolean2bool(tmp) if err != nil { return nil, err } + } args["includeDeprecated"] = arg0 return args, nil @@ -2034,7 +1905,7 @@ func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().MapInput(rctx, args["input"].(*map[string]interface{})) + return ec.resolvers.Query().MapInput(rctx, args["input"].(map[string]interface{})) }) if resTmp == nil { return graphql.Null @@ -4112,7 +3983,7 @@ func (e *executableSchema) ChangesMiddleware(ctx context.Context, obj *map[strin return obj, nil } -func UnmarshalInnerDirectives(v interface{}) (InnerDirectives, error) { +func unmarshalInputInnerDirectives(v interface{}) (InnerDirectives, error) { var it InnerDirectives var asMap = v.(map[string]interface{}) @@ -4154,7 +4025,7 @@ func (e *executableSchema) InnerDirectivesMiddleware(ctx context.Context, obj *I return obj, nil } -func UnmarshalInnerInput(v interface{}) (InnerInput, error) { +func unmarshalInputInnerInput(v interface{}) (InnerInput, error) { var it InnerInput var asMap = v.(map[string]interface{}) @@ -4177,7 +4048,7 @@ func (e *executableSchema) InnerInputMiddleware(ctx context.Context, obj *InnerI return obj, nil } -func UnmarshalInputDirectives(v interface{}) (InputDirectives, error) { +func unmarshalInputInputDirectives(v interface{}) (InputDirectives, error) { var it InputDirectives var asMap = v.(map[string]interface{}) @@ -4191,7 +4062,7 @@ func UnmarshalInputDirectives(v interface{}) (InputDirectives, error) { } case "inner": var err error - it.Inner, err = UnmarshalInnerDirectives(v) + it.Inner, err = unmarshalInputInnerDirectives(v) if err != nil { return it, err } @@ -4199,7 +4070,7 @@ func UnmarshalInputDirectives(v interface{}) (InputDirectives, error) { var err error var ptr1 InnerDirectives if v != nil { - ptr1, err = UnmarshalInnerDirectives(v) + ptr1, err = unmarshalInputInnerDirectives(v) it.InnerNullable = &ptr1 } @@ -4250,7 +4121,7 @@ func (e *executableSchema) InputDirectivesMiddleware(ctx context.Context, obj *I return obj, nil } -func UnmarshalKeywords(v interface{}) (Keywords, error) { +func unmarshalInputKeywords(v interface{}) (Keywords, error) { var it Keywords var asMap = v.(map[string]interface{}) @@ -4417,7 +4288,7 @@ func (e *executableSchema) KeywordsMiddleware(ctx context.Context, obj *Keywords return obj, nil } -func UnmarshalOuterInput(v interface{}) (OuterInput, error) { +func unmarshalInputOuterInput(v interface{}) (OuterInput, error) { var it OuterInput var asMap = v.(map[string]interface{}) @@ -4425,7 +4296,7 @@ func UnmarshalOuterInput(v interface{}) (OuterInput, error) { switch k { case "inner": var err error - it.Inner, err = UnmarshalInnerInput(v) + it.Inner, err = unmarshalInputInnerInput(v) if err != nil { return it, err } @@ -4445,7 +4316,7 @@ func (e *executableSchema) OuterInputMiddleware(ctx context.Context, obj *OuterI return obj, nil } -func UnmarshalRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { +func unmarshalInputRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { var it RecursiveInputSlice var asMap = v.(map[string]interface{}) @@ -4463,7 +4334,7 @@ func UnmarshalRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { } it.Self = make([]RecursiveInputSlice, len(rawIf1)) for idx1 := range rawIf1 { - it.Self[idx1], err = UnmarshalRecursiveInputSlice(rawIf1[idx1]) + it.Self[idx1], err = unmarshalInputRecursiveInputSlice(rawIf1[idx1]) } if err != nil { return it, err @@ -5290,3 +5161,112 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o } // endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func unmarshalInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v interface{}) (*InputDirectives, error) { + if v == nil { + return nil, nil + } + res, err := unmarshalInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v) + return &res, err +} +func unmarshalKeywords2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(v interface{}) (*Keywords, error) { + if v == nil { + return nil, nil + } + res, err := unmarshalKeywords2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(v) + return &res, err +} +func unmarshalOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) (*OuterInput, error) { + if v == nil { + return nil, nil + } + res, err := unmarshalOuterInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v) + return &res, err +} +func unmarshalRecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v interface{}) (*RecursiveInputSlice, error) { + if v == nil { + return nil, nil + } + res, err := unmarshalRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v) + return &res, err +} +func unmarshalInt2ᚖint(v interface{}) (*int, error) { + if v == nil { + return nil, nil + } + res, err := unmarshalInt2int(v) + return &res, err +} +func unmarshalString2ᚖstring(v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := unmarshalString2string(v) + return &res, err +} +func unmarshalOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) ([]*OuterInput, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]*OuterInput, len(vSlice)) + for i := range vSlice { + res[i], err = unmarshalOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} +func unmarshalOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) ([][]*OuterInput, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([][]*OuterInput, len(vSlice)) + for i := range vSlice { + res[i], err = unmarshalOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} +func unmarshalBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) +} +func unmarshalInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v interface{}) (InputDirectives, error) { + return unmarshalInputInputDirectives(v) +} +func unmarshalKeywords2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(v interface{}) (Keywords, error) { + return unmarshalInputKeywords(v) +} +func unmarshalOuterInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) (OuterInput, error) { + return unmarshalInputOuterInput(v) +} +func unmarshalRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { + return unmarshalInputRecursiveInputSlice(v) +} +func unmarshalInt2int(v interface{}) (int, error) { + return graphql.UnmarshalInt(v) +} +func unmarshalChanges2map(v interface{}) (map[string]interface{}, error) { + return v.(map[string]interface{}), nil +} +func unmarshalString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +// endregion ***************************** type.gotpl ***************************** diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index 9e0bf4b3d63..3aecb553fa2 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -47,7 +47,7 @@ func (r *queryResolver) InvalidIdentifier(ctx context.Context) (*invalid_package func (r *queryResolver) Collision(ctx context.Context) (*introspection1.It, error) { panic("not implemented") } -func (r *queryResolver) MapInput(ctx context.Context, input *map[string]interface{}) (*bool, error) { +func (r *queryResolver) MapInput(ctx context.Context, input map[string]interface{}) (*bool, error) { panic("not implemented") } func (r *queryResolver) Recursive(ctx context.Context, input *RecursiveInputSlice) (*bool, error) { diff --git a/codegen/type.go b/codegen/type.go new file mode 100644 index 00000000000..a650405b537 --- /dev/null +++ b/codegen/type.go @@ -0,0 +1,38 @@ +package codegen + +import ( + "go/types" + + "github.com/99designs/gqlgen/codegen/config" +) + +func (b *builder) buildTypes() (map[string]*config.TypeReference, error) { + ret := map[string]*config.TypeReference{} + + for _, ref := range b.Binder.References { + for { + ret[ref.GO.String()+ref.GQL.Name()] = ref + + if p, isPtr := ref.GO.(*types.Pointer); isPtr { + ref = &config.TypeReference{ + GO: p.Elem(), + GQL: ref.GQL, + Definition: ref.Definition, + Unmarshaler: ref.Unmarshaler, + Marshaler: ref.Marshaler, + } + } else if s, isSlice := ref.GO.(*types.Slice); isSlice { + ref = &config.TypeReference{ + GO: s.Elem(), + GQL: ref.GQL, + Definition: ref.Definition, + Unmarshaler: ref.Unmarshaler, + Marshaler: ref.Marshaler, + } + } else { + break + } + } + } + return ret, nil +} diff --git a/codegen/type.gotpl b/codegen/type.gotpl new file mode 100644 index 00000000000..59466f0deb8 --- /dev/null +++ b/codegen/type.gotpl @@ -0,0 +1,38 @@ +{{- range $type := .ReferencedTypes }} + {{- if $type.Definition.IsInputType }} + func unmarshal{{ $type.Definition.Name }}2{{ $type.GO | ts }}(v interface{}) ({{ $type.GO | ref }}, error) { + {{- if $type.IsPtr }} + if v == nil { return nil, nil } + res, err := unmarshal{{ $type.Definition.Name }}2{{ $type.GO.Elem | ts }}(v) + return &res, err + {{- else if $type.IsSlice }} + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{ v } + } + } + var err error + res := make([]{{$type.GO.Elem | ref}}, len(vSlice)) + for i := range vSlice { + res[i], err = unmarshal{{ $type.Definition.Name }}2{{ $type.GO.Elem | ts }}(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil + {{- else }} + {{- if $type.Unmarshaler }} + return {{ $type.Unmarshaler | call }}(v) + {{- else if eq ($type.GO | ref) "map[string]interface{}" }} + return v.(map[string]interface{}), nil + {{- else -}} + var res {{ $type.GO | ref }} + return res, res.UnmarshalGQL(v) + {{- end }} + {{- end }} + } + {{- end }} +{{- end }} diff --git a/example/chat/generated.go b/example/chat/generated.go index a02847d554e..cb227e8b000 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -1,5 +1,3 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - package chat import ( @@ -344,102 +342,108 @@ func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMi // region ***************************** args.gotpl ***************************** func (e *executableSchema) field_Mutation_post_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["text"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) + arg0, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["text"] = arg0 var arg1 string if tmp, ok := rawArgs["username"]; ok { - var err error - arg1, err = graphql.UnmarshalString(tmp) + arg1, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["username"] = arg1 var arg2 string if tmp, ok := rawArgs["roomName"]; ok { - var err error - arg2, err = graphql.UnmarshalString(tmp) + arg2, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["roomName"] = arg2 return args, nil } func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) + arg0, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["name"] = arg0 return args, nil } func (e *executableSchema) field_Query_room_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) + arg0, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["name"] = arg0 return args, nil } func (e *executableSchema) field_Subscription_messageAdded_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["roomName"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) + arg0, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["roomName"] = arg0 return args, nil } func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) + arg0, err = unmarshalBoolean2bool(tmp) if err != nil { return nil, err } + } args["includeDeprecated"] = arg0 return args, nil } func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) + arg0, err = unmarshalBoolean2bool(tmp) if err != nil { return nil, err } + } args["includeDeprecated"] = arg0 return args, nil @@ -2431,3 +2435,14 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o } // endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func unmarshalBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) +} +func unmarshalString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +// endregion ***************************** type.gotpl ***************************** diff --git a/example/config/generated.go b/example/config/generated.go index 3234f879ff4..43f4a288b90 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -1,5 +1,3 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - package config import ( @@ -301,62 +299,60 @@ func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMi // region ***************************** args.gotpl ***************************** func (e *executableSchema) field_Mutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 NewTodo if tmp, ok := rawArgs["input"]; ok { - var err error - arg0, err = UnmarshalNewTodo(tmp) + arg0, err = unmarshalNewTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐNewTodo(tmp) if err != nil { return nil, err } - mNewTodo1, err := e.NewTodoMiddleware(ctx, &arg0) - if err != nil { - return nil, err - } - arg0 = *mNewTodo1 } args["input"] = arg0 return args, nil } func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) + arg0, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["name"] = arg0 return args, nil } func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) + arg0, err = unmarshalBoolean2bool(tmp) if err != nil { return nil, err } + } args["includeDeprecated"] = arg0 return args, nil } func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) + arg0, err = unmarshalBoolean2bool(tmp) if err != nil { return nil, err } + } args["includeDeprecated"] = arg0 return args, nil @@ -1908,7 +1904,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co // region **************************** input.gotpl ***************************** -func UnmarshalNewTodo(v interface{}) (NewTodo, error) { +func unmarshalInputNewTodo(v interface{}) (NewTodo, error) { var it NewTodo var asMap = v.(map[string]interface{}) @@ -2350,3 +2346,17 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o } // endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func unmarshalBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) +} +func unmarshalNewTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐNewTodo(v interface{}) (NewTodo, error) { + return unmarshalInputNewTodo(v) +} +func unmarshalString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +// endregion ***************************** type.gotpl ***************************** diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index b3ea0258208..7e7e562e88c 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -1,5 +1,3 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - package dataloader import ( @@ -354,103 +352,75 @@ func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMi // region ***************************** args.gotpl ***************************** func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) + arg0, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["name"] = arg0 return args, nil } func (e *executableSchema) field_Query_torture1d_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 []int if tmp, ok := rawArgs["customerIds"]; ok { - var err error - var rawIf1 []interface{} - if tmp != nil { - if tmp1, ok := tmp.([]interface{}); ok { - rawIf1 = tmp1 - } else { - rawIf1 = []interface{}{tmp} - } - } - arg0 = make([]int, len(rawIf1)) - for idx1 := range rawIf1 { - arg0[idx1], err = graphql.UnmarshalInt(rawIf1[idx1]) - } + arg0, err = unmarshalInt2ᚕint(tmp) if err != nil { return nil, err } + } args["customerIds"] = arg0 return args, nil } func (e *executableSchema) field_Query_torture2d_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 [][]int if tmp, ok := rawArgs["customerIds"]; ok { - var err error - var rawIf1 []interface{} - if tmp != nil { - if tmp1, ok := tmp.([]interface{}); ok { - rawIf1 = tmp1 - } else { - rawIf1 = []interface{}{tmp} - } - } - arg0 = make([][]int, len(rawIf1)) - for idx1 := range rawIf1 { - var rawIf2 []interface{} - if rawIf1[idx1] != nil { - if tmp1, ok := rawIf1[idx1].([]interface{}); ok { - rawIf2 = tmp1 - } else { - rawIf2 = []interface{}{rawIf1[idx1]} - } - } - arg0[idx1] = make([]int, len(rawIf2)) - for idx2 := range rawIf2 { - arg0[idx1][idx2], err = graphql.UnmarshalInt(rawIf2[idx2]) - } - } + arg0, err = unmarshalInt2ᚕᚕint(tmp) if err != nil { return nil, err } + } args["customerIds"] = arg0 return args, nil } func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) + arg0, err = unmarshalBoolean2bool(tmp) if err != nil { return nil, err } + } args["includeDeprecated"] = arg0 return args, nil } func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) + arg0, err = unmarshalBoolean2bool(tmp) if err != nil { return nil, err } + } args["includeDeprecated"] = arg0 return args, nil @@ -2779,3 +2749,55 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o } // endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func unmarshalInt2ᚕᚕint(v interface{}) ([][]int, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([][]int, len(vSlice)) + for i := range vSlice { + res[i], err = unmarshalInt2ᚕint(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} +func unmarshalInt2ᚕint(v interface{}) ([]int, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]int, len(vSlice)) + for i := range vSlice { + res[i], err = unmarshalInt2int(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} +func unmarshalBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) +} +func unmarshalInt2int(v interface{}) (int, error) { + return graphql.UnmarshalInt(v) +} +func unmarshalString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +// endregion ***************************** type.gotpl ***************************** diff --git a/example/scalars/generated.go b/example/scalars/generated.go index 6738f8be817..5b7e09b0ee4 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -1,5 +1,3 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - package scalars import ( @@ -325,83 +323,75 @@ func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMi // region ***************************** args.gotpl ***************************** func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) + arg0, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["name"] = arg0 return args, nil } func (e *executableSchema) field_Query_search_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 *model.SearchArgs if tmp, ok := rawArgs["input"]; ok { - var err error - var ptr1 model.SearchArgs - if tmp != nil { - ptr1, err = UnmarshalSearchArgs(tmp) - arg0 = &ptr1 - } - + arg0, err = unmarshalSearchArgs2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(tmp) if err != nil { return nil, err } - if arg0 != nil { - var err error - arg0, err = e.SearchArgsMiddleware(ctx, arg0) - if err != nil { - return nil, err - } - } } args["input"] = arg0 return args, nil } func (e *executableSchema) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 external.ObjectID if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = model.UnmarshalID(tmp) + arg0, err = unmarshalID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(tmp) if err != nil { return nil, err } + } args["id"] = arg0 return args, nil } func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) + arg0, err = unmarshalBoolean2bool(tmp) if err != nil { return nil, err } + } args["includeDeprecated"] = arg0 return args, nil } func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) + arg0, err = unmarshalBoolean2bool(tmp) if err != nil { return nil, err } + } args["includeDeprecated"] = arg0 return args, nil @@ -2034,7 +2024,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co // region **************************** input.gotpl ***************************** -func UnmarshalSearchArgs(v interface{}) (model.SearchArgs, error) { +func unmarshalInputSearchArgs(v interface{}) (model.SearchArgs, error) { var it model.SearchArgs var asMap = v.(map[string]interface{}) @@ -2473,3 +2463,27 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o } // endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func unmarshalSearchArgs2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v interface{}) (*model.SearchArgs, error) { + if v == nil { + return nil, nil + } + res, err := unmarshalSearchArgs2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v) + return &res, err +} +func unmarshalBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) +} +func unmarshalID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(v interface{}) (external.ObjectID, error) { + return model.UnmarshalID(v) +} +func unmarshalSearchArgs2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v interface{}) (model.SearchArgs, error) { + return unmarshalInputSearchArgs(v) +} +func unmarshalString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +// endregion ***************************** type.gotpl ***************************** diff --git a/example/selection/generated.go b/example/selection/generated.go index b6f98048816..c9f7d60ee8f 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -1,5 +1,3 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - package selection import ( @@ -272,42 +270,45 @@ func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMi // region ***************************** args.gotpl ***************************** func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) + arg0, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["name"] = arg0 return args, nil } func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) + arg0, err = unmarshalBoolean2bool(tmp) if err != nil { return nil, err } + } args["includeDeprecated"] = arg0 return args, nil } func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) + arg0, err = unmarshalBoolean2bool(tmp) if err != nil { return nil, err } + } args["includeDeprecated"] = arg0 return args, nil @@ -2255,3 +2256,14 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o } // endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func unmarshalBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) +} +func unmarshalString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +// endregion ***************************** type.gotpl ***************************** diff --git a/example/starwars/generated.go b/example/starwars/generated.go index e21a910cf3f..a04b78244d1 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -1,5 +1,3 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - package starwars import ( @@ -733,287 +731,261 @@ func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMi // region ***************************** args.gotpl ***************************** func (e *executableSchema) field_Droid_friendsConnection_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["first"]; ok { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg0 = &ptr1 - } - + arg0, err = unmarshalInt2ᚖint(tmp) if err != nil { return nil, err } + } args["first"] = arg0 var arg1 *string if tmp, ok := rawArgs["after"]; ok { - var err error - var ptr1 string - if tmp != nil { - ptr1, err = graphql.UnmarshalID(tmp) - arg1 = &ptr1 - } - + arg1, err = unmarshalID2ᚖstring(tmp) if err != nil { return nil, err } + } args["after"] = arg1 return args, nil } func (e *executableSchema) field_Human_friendsConnection_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["first"]; ok { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg0 = &ptr1 - } - + arg0, err = unmarshalInt2ᚖint(tmp) if err != nil { return nil, err } + } args["first"] = arg0 var arg1 *string if tmp, ok := rawArgs["after"]; ok { - var err error - var ptr1 string - if tmp != nil { - ptr1, err = graphql.UnmarshalID(tmp) - arg1 = &ptr1 - } - + arg1, err = unmarshalID2ᚖstring(tmp) if err != nil { return nil, err } + } args["after"] = arg1 return args, nil } func (e *executableSchema) field_Human_height_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 LengthUnit if tmp, ok := rawArgs["unit"]; ok { - var err error - err = (&arg0).UnmarshalGQL(tmp) + arg0, err = unmarshalLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(tmp) if err != nil { return nil, err } + } args["unit"] = arg0 return args, nil } func (e *executableSchema) field_Mutation_createReview_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 Episode if tmp, ok := rawArgs["episode"]; ok { - var err error - err = (&arg0).UnmarshalGQL(tmp) + arg0, err = unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(tmp) if err != nil { return nil, err } + } args["episode"] = arg0 var arg1 Review if tmp, ok := rawArgs["review"]; ok { - var err error - arg1, err = UnmarshalReviewInput(tmp) + arg1, err = unmarshalReviewInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(tmp) if err != nil { return nil, err } - mReviewInput1, err := e.ReviewInputMiddleware(ctx, &arg1) - if err != nil { - return nil, err - } - arg1 = *mReviewInput1 } args["review"] = arg1 return args, nil } func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) + arg0, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["name"] = arg0 return args, nil } func (e *executableSchema) field_Query_character_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalID(tmp) + arg0, err = unmarshalID2string(tmp) if err != nil { return nil, err } + } args["id"] = arg0 return args, nil } func (e *executableSchema) field_Query_droid_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalID(tmp) + arg0, err = unmarshalID2string(tmp) if err != nil { return nil, err } + } args["id"] = arg0 return args, nil } func (e *executableSchema) field_Query_hero_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 *Episode if tmp, ok := rawArgs["episode"]; ok { - var err error - var ptr1 Episode - if tmp != nil { - err = (&ptr1).UnmarshalGQL(tmp) - arg0 = &ptr1 - } - + arg0, err = unmarshalEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(tmp) if err != nil { return nil, err } + } args["episode"] = arg0 return args, nil } func (e *executableSchema) field_Query_human_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalID(tmp) + arg0, err = unmarshalID2string(tmp) if err != nil { return nil, err } + } args["id"] = arg0 return args, nil } func (e *executableSchema) field_Query_reviews_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 Episode if tmp, ok := rawArgs["episode"]; ok { - var err error - err = (&arg0).UnmarshalGQL(tmp) + arg0, err = unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(tmp) if err != nil { return nil, err } + } args["episode"] = arg0 var arg1 *time.Time if tmp, ok := rawArgs["since"]; ok { - var err error - var ptr1 time.Time - if tmp != nil { - ptr1, err = graphql.UnmarshalTime(tmp) - arg1 = &ptr1 - } - + arg1, err = unmarshalTime2ᚖtimeᚐTime(tmp) if err != nil { return nil, err } + } args["since"] = arg1 return args, nil } func (e *executableSchema) field_Query_search_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["text"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) + arg0, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["text"] = arg0 return args, nil } func (e *executableSchema) field_Query_starship_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalID(tmp) + arg0, err = unmarshalID2string(tmp) if err != nil { return nil, err } + } args["id"] = arg0 return args, nil } func (e *executableSchema) field_Starship_length_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 *LengthUnit if tmp, ok := rawArgs["unit"]; ok { - var err error - var ptr1 LengthUnit - if tmp != nil { - err = (&ptr1).UnmarshalGQL(tmp) - arg0 = &ptr1 - } - + arg0, err = unmarshalLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(tmp) if err != nil { return nil, err } + } args["unit"] = arg0 return args, nil } func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) + arg0, err = unmarshalBoolean2bool(tmp) if err != nil { return nil, err } + } args["includeDeprecated"] = arg0 return args, nil } func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) + arg0, err = unmarshalBoolean2bool(tmp) if err != nil { return nil, err } + } args["includeDeprecated"] = arg0 return args, nil @@ -3639,7 +3611,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co // region **************************** input.gotpl ***************************** -func UnmarshalReviewInput(v interface{}) (Review, error) { +func unmarshalInputReviewInput(v interface{}) (Review, error) { var it Review var asMap = v.(map[string]interface{}) @@ -4394,3 +4366,69 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o } // endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func unmarshalEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v interface{}) (*Episode, error) { + if v == nil { + return nil, nil + } + res, err := unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v) + return &res, err +} +func unmarshalLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(v interface{}) (*LengthUnit, error) { + if v == nil { + return nil, nil + } + res, err := unmarshalLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(v) + return &res, err +} +func unmarshalInt2ᚖint(v interface{}) (*int, error) { + if v == nil { + return nil, nil + } + res, err := unmarshalInt2int(v) + return &res, err +} +func unmarshalID2ᚖstring(v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := unmarshalID2string(v) + return &res, err +} +func unmarshalTime2ᚖtimeᚐTime(v interface{}) (*time.Time, error) { + if v == nil { + return nil, nil + } + res, err := unmarshalTime2timeᚐTime(v) + return &res, err +} +func unmarshalBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) +} +func unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v interface{}) (Episode, error) { + var res Episode + return res, res.UnmarshalGQL(v) +} +func unmarshalLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(v interface{}) (LengthUnit, error) { + var res LengthUnit + return res, res.UnmarshalGQL(v) +} +func unmarshalReviewInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(v interface{}) (Review, error) { + return unmarshalInputReviewInput(v) +} +func unmarshalInt2int(v interface{}) (int, error) { + return graphql.UnmarshalInt(v) +} +func unmarshalID2string(v interface{}) (string, error) { + return graphql.UnmarshalID(v) +} +func unmarshalString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} +func unmarshalTime2timeᚐTime(v interface{}) (time.Time, error) { + return graphql.UnmarshalTime(v) +} + +// endregion ***************************** type.gotpl ***************************** diff --git a/example/todo/generated.go b/example/todo/generated.go index e6353a857bf..31c49124f8e 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -1,5 +1,3 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - package todo import ( @@ -331,113 +329,114 @@ func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMi // region ***************************** args.gotpl ***************************** func (e *executableSchema) dir_hasRole_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 Role if tmp, ok := rawArgs["role"]; ok { - var err error - err = (&arg0).UnmarshalGQL(tmp) + arg0, err = unmarshalRole2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐRole(tmp) if err != nil { return nil, err } + } args["role"] = arg0 return args, nil } func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 TodoInput if tmp, ok := rawArgs["todo"]; ok { - var err error - arg0, err = UnmarshalTodoInput(tmp) + arg0, err = unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodoInput(tmp) if err != nil { return nil, err } - mTodoInput1, err := e.TodoInputMiddleware(ctx, &arg0) - if err != nil { - return nil, err - } - arg0 = *mTodoInput1 } args["todo"] = arg0 return args, nil } func (e *executableSchema) field_MyMutation_updateTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 int if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalInt(tmp) + arg0, err = unmarshalInt2int(tmp) if err != nil { return nil, err } + } args["id"] = arg0 var arg1 map[string]interface{} if tmp, ok := rawArgs["changes"]; ok { - var err error - arg1 = tmp.(map[string]interface{}) + arg1, err = unmarshalMap2map(tmp) if err != nil { return nil, err } + } args["changes"] = arg1 return args, nil } func (e *executableSchema) field_MyQuery___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) + arg0, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["name"] = arg0 return args, nil } func (e *executableSchema) field_MyQuery_todo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 int if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalInt(tmp) + arg0, err = unmarshalInt2int(tmp) if err != nil { return nil, err } + } args["id"] = arg0 return args, nil } func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) + arg0, err = unmarshalBoolean2bool(tmp) if err != nil { return nil, err } + } args["includeDeprecated"] = arg0 return args, nil } func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) + arg0, err = unmarshalBoolean2bool(tmp) if err != nil { return nil, err } + } args["includeDeprecated"] = arg0 return args, nil @@ -1981,7 +1980,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co // region **************************** input.gotpl ***************************** -func UnmarshalTodoInput(v interface{}) (TodoInput, error) { +func unmarshalInputTodoInput(v interface{}) (TodoInput, error) { var it TodoInput var asMap = v.(map[string]interface{}) @@ -2395,3 +2394,27 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o } // endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func unmarshalBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) +} +func unmarshalRole2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐRole(v interface{}) (Role, error) { + var res Role + return res, res.UnmarshalGQL(v) +} +func unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodoInput(v interface{}) (TodoInput, error) { + return unmarshalInputTodoInput(v) +} +func unmarshalInt2int(v interface{}) (int, error) { + return graphql.UnmarshalInt(v) +} +func unmarshalMap2map(v interface{}) (map[string]interface{}, error) { + return graphql.UnmarshalMap(v) +} +func unmarshalString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +// endregion ***************************** type.gotpl ***************************** diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index 44c0b0d27df..93ba19e73e1 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -1,5 +1,3 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - package type_system_extension import ( @@ -400,76 +398,75 @@ func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMi // region ***************************** args.gotpl ***************************** func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 TodoInput if tmp, ok := rawArgs["todo"]; ok { - var err error - arg0, err = UnmarshalTodoInput(tmp) + arg0, err = unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodoInput(tmp) if err != nil { return nil, err } - mTodoInput1, err := e.TodoInputMiddleware(ctx, &arg0) - if err != nil { - return nil, err - } - arg0 = *mTodoInput1 } args["todo"] = arg0 return args, nil } func (e *executableSchema) field_MyQuery___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) + arg0, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["name"] = arg0 return args, nil } func (e *executableSchema) field_MyQuery_todo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["id"]; ok { - var err error - arg0, err = graphql.UnmarshalID(tmp) + arg0, err = unmarshalID2string(tmp) if err != nil { return nil, err } + } args["id"] = arg0 return args, nil } func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) + arg0, err = unmarshalBoolean2bool(tmp) if err != nil { return nil, err } + } args["includeDeprecated"] = arg0 return args, nil } func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) + arg0, err = unmarshalBoolean2bool(tmp) if err != nil { return nil, err } + } args["includeDeprecated"] = arg0 return args, nil @@ -1975,7 +1972,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co // region **************************** input.gotpl ***************************** -func UnmarshalTodoInput(v interface{}) (TodoInput, error) { +func unmarshalInputTodoInput(v interface{}) (TodoInput, error) { var it TodoInput var asMap = v.(map[string]interface{}) @@ -2418,3 +2415,20 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o } // endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func unmarshalBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) +} +func unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodoInput(v interface{}) (TodoInput, error) { + return unmarshalInputTodoInput(v) +} +func unmarshalID2string(v interface{}) (string, error) { + return graphql.UnmarshalID(v) +} +func unmarshalString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +// endregion ***************************** type.gotpl ***************************** diff --git a/integration/generated.go b/integration/generated.go index 0b7a6da6d25..bbe0853f30b 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -1,5 +1,3 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - package integration import ( @@ -360,100 +358,90 @@ func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMi // region ***************************** args.gotpl ***************************** func (e *executableSchema) dir_magic_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["kind"]; ok { - var err error - var ptr1 int - if tmp != nil { - ptr1, err = graphql.UnmarshalInt(tmp) - arg0 = &ptr1 - } - + arg0, err = unmarshalInt2ᚖint(tmp) if err != nil { return nil, err } + } args["kind"] = arg0 return args, nil } func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - var err error - arg0, err = graphql.UnmarshalString(tmp) + arg0, err = unmarshalString2string(tmp) if err != nil { return nil, err } + } args["name"] = arg0 return args, nil } func (e *executableSchema) field_Query_date_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 models.DateFilter if tmp, ok := rawArgs["filter"]; ok { - var err error - arg0, err = UnmarshalDateFilter(tmp) + arg0, err = unmarshalDateFilter2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilter(tmp) if err != nil { return nil, err } - mDateFilter1, err := e.DateFilterMiddleware(ctx, &arg0) - if err != nil { - return nil, err - } - arg0 = *mDateFilter1 } args["filter"] = arg0 return args, nil } func (e *executableSchema) field_Query_error_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 *models.ErrorType if tmp, ok := rawArgs["type"]; ok { - var err error - var ptr1 models.ErrorType - if tmp != nil { - err = (&ptr1).UnmarshalGQL(tmp) - arg0 = &ptr1 - } - + arg0, err = unmarshalErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(tmp) if err != nil { return nil, err } + } args["type"] = arg0 return args, nil } func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) + arg0, err = unmarshalBoolean2bool(tmp) if err != nil { return nil, err } + } args["includeDeprecated"] = arg0 return args, nil } func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - var err error - arg0, err = graphql.UnmarshalBoolean(tmp) + arg0, err = unmarshalBoolean2bool(tmp) if err != nil { return nil, err } + } args["includeDeprecated"] = arg0 return args, nil @@ -2085,7 +2073,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co // region **************************** input.gotpl ***************************** -func UnmarshalDateFilter(v interface{}) (models.DateFilter, error) { +func unmarshalInputDateFilter(v interface{}) (models.DateFilter, error) { var it models.DateFilter var asMap = v.(map[string]interface{}) @@ -2572,3 +2560,38 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o } // endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func unmarshalErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(v interface{}) (*models.ErrorType, error) { + if v == nil { + return nil, nil + } + res, err := unmarshalErrorType2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(v) + return &res, err +} +func unmarshalInt2ᚖint(v interface{}) (*int, error) { + if v == nil { + return nil, nil + } + res, err := unmarshalInt2int(v) + return &res, err +} +func unmarshalBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) +} +func unmarshalDateFilter2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilter(v interface{}) (models.DateFilter, error) { + return unmarshalInputDateFilter(v) +} +func unmarshalErrorType2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(v interface{}) (models.ErrorType, error) { + var res models.ErrorType + return res, res.UnmarshalGQL(v) +} +func unmarshalInt2int(v interface{}) (int, error) { + return graphql.UnmarshalInt(v) +} +func unmarshalString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +// endregion ***************************** type.gotpl ***************************** diff --git a/plugin/modelgen/models.go b/plugin/modelgen/models.go index c41645dde2b..62a53ad1915 100644 --- a/plugin/modelgen/models.go +++ b/plugin/modelgen/models.go @@ -73,7 +73,7 @@ func (m *Plugin) MutateConfig(cfg *config.Config) error { cfg.InjectBuiltins(schema) - binder, err := cfg.NewBinder() + binder, err := cfg.NewBinder(schema) if err != nil { return err } From 533b08b698ae8254d97091ec9e6e0087f7ccaa30 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Tue, 5 Feb 2019 20:32:25 +1100 Subject: [PATCH 063/147] remove wonky input directives --- codegen/args.gotpl | 10 +- codegen/build_typedef.go | 2 +- codegen/config/binder.go | 2 +- codegen/input.gotpl | 82 +----- codegen/testserver/generated.go | 311 ++++++--------------- codegen/type.gotpl | 6 +- example/chat/generated.go | 28 +- example/config/generated.go | 27 +- example/dataloader/addressloader_gen.go | 23 +- example/dataloader/generated.go | 29 +- example/dataloader/itemsliceloader_gen.go | 23 +- example/dataloader/ordersliceloader_gen.go | 23 +- example/scalars/generated.go | 36 +-- example/selection/generated.go | 13 +- example/starwars/generated.go | 102 +++---- example/todo/generated.go | 45 ++- example/type-system-extension/generated.go | 49 +--- integration/generated.go | 45 ++- 18 files changed, 290 insertions(+), 566 deletions(-) diff --git a/codegen/args.gotpl b/codegen/args.gotpl index 0a789aa7221..2d7689bf79f 100644 --- a/codegen/args.gotpl +++ b/codegen/args.gotpl @@ -1,12 +1,12 @@ {{ range $name, $args := .Args }} -func (e *executableSchema){{ $name }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (e *executableSchema) {{ $name }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} {{- range $i, $arg := . }} var arg{{$i}} {{ $arg.TypeReference.GO | ref}} if tmp, ok := rawArgs[{{$arg.Name|quote}}]; ok { {{- if $arg.Directives }} - getArg0 := func(ctx context.Context) (interface{}, error) { return unmarshal{{$arg.TypeReference.GQL.Name}}2{{ $arg.TypeReference.GO | ts }}(tmp) } + getArg0 := func(ctx context.Context) (interface{}, error) { return e.unmarshal{{$arg.TypeReference.GQL.Name}}2{{ $arg.TypeReference.GO | ts }}(tmp) } {{- range $i, $directive := $arg.Directives }} getArg{{add $i 1}} := func(ctx context.Context) (res interface{}, err error) { @@ -30,15 +30,11 @@ func (e *executableSchema){{ $name }}(ctx context.Context, rawArgs map[string]in return nil, fmt.Errorf(`unexpected type %T from directive, should be {{ $arg.TypeReference.GO }}`, tmp) } {{- else }} - arg{{$i}}, err = unmarshal{{$arg.TypeReference.GQL.Name}}2{{ $arg.TypeReference.GO | ts }}(tmp) + arg{{$i}}, err = e.unmarshal{{$arg.TypeReference.GQL.Name}}2{{ $arg.TypeReference.GO | ts }}(tmp) if err != nil { return nil, err } {{- end }} - - {{/*{{- if eq $arg.TypeReference.Definition.Kind "INPUT_OBJECT" }}*/}} - {{/*{{ $arg.Middleware (print "arg" $i) (print "arg" $i) }}*/}} - {{/*{{- end }}*/}} } args[{{$arg.Name|quote}}] = arg{{$i}} {{- end }} diff --git a/codegen/build_typedef.go b/codegen/build_typedef.go index bf234bd5ff0..3ac1b0241ba 100644 --- a/codegen/build_typedef.go +++ b/codegen/build_typedef.go @@ -83,7 +83,7 @@ func (b *builder) buildTypeDef(schemaType *ast.Definition) (*TypeDefinition, err // Special case to reference generated unmarshal functions if !hasUnmarshal { - t.Unmarshaler = types.NewFunc(0, b.Config.Exec.Pkg(), "unmarshalInput"+schemaType.Name, nil) + t.Unmarshaler = types.NewFunc(0, b.Config.Exec.Pkg(), "e.unmarshalInput"+schemaType.Name, nil) } return t, nil diff --git a/codegen/config/binder.go b/codegen/config/binder.go index 69bd20ea3ce..7781f11b794 100644 --- a/codegen/config/binder.go +++ b/codegen/config/binder.go @@ -214,7 +214,7 @@ func (b *Binder) TypeReference(schemaType *ast.Type) (ret *TypeReference, err er // Special case to reference generated unmarshal functions if !hasUnmarshal { - ref.Unmarshaler = types.NewFunc(0, b.cfg.Exec.Pkg(), "unmarshalInput"+schemaType.Name(), nil) + ref.Unmarshaler = types.NewFunc(0, b.cfg.Exec.Pkg(), "e.unmarshalInput"+schemaType.Name(), nil) } } diff --git a/codegen/input.gotpl b/codegen/input.gotpl index c09c949fa00..5a0d7c4158e 100644 --- a/codegen/input.gotpl +++ b/codegen/input.gotpl @@ -1,6 +1,6 @@ {{- range $input := .Inputs }} {{- if not .HasUnmarshal }} - func unmarshalInput{{ .Name }}(v interface{}) ({{.Type | ref}}, error) { + func (e *executableSchema) unmarshalInput{{ .Name }}(v interface{}) ({{.Type | ref}}, error) { var it {{.Type | ref}} var asMap = v.(map[string]interface{}) {{ range $field := .Fields}} @@ -27,84 +27,4 @@ return it, nil } {{- end }} - - func (e *executableSchema) {{ .Name }}Middleware(ctx context.Context, obj *{{.Type | ref}}) (*{{.Type | ref}}, error) { - {{ if .Directives }} - cObj, err := chainFieldMiddleware( - []graphql.FieldMiddleware{ - {{- range $directive := .Directives }} - func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { - {{- if $directive.Args }} - {{- range $arg := $directive.Args }} - {{- if and $arg.IsPtr ( notNil "Value" $arg ) }} - {{ $arg.GoVarName }} := {{ $arg.Value | dump }} - {{- end }} - {{- end }} - {{- end -}} - return e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs "obj" "n"}}) - }, - {{ end }} - }... - )(ctx, func(ctx context.Context)(interface{}, error){ - return obj, nil - }) - if err != nil || cObj == nil { - return nil ,err - } - obj, ok := cObj.(*{{.Type | ref}}) - if !ok { - return nil, errors.New("expect {{.Type | ref}}") - } - {{ end }} - - {{- range $field := .Fields }} - {{ if $field.HasDirectives }} - c{{$field.GoFieldName}}, err := chainFieldMiddleware( - []graphql.FieldMiddleware{ - {{- range $directive := $field.Directives }} - func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { - {{- if $directive.Args }} - {{- range $arg := $directive.Args }} - {{- if and $arg.TypeReference.IsPtr ( notNil "Value" $arg ) }} - {{ $arg.VarName }} := {{ $arg.Value | dump }} - {{- end }} - {{- end }} - {{- end }} - {{ if $field.IsPtr -}} - return e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print "*obj." $field.GoFieldName ) "n"}}) - {{- else -}} - return e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs ( print "obj." $field.GoFieldName ) "n"}}) - {{- end }} - }, - {{ end }} - }... - )(ctx, func(ctx context.Context)(interface{}, error){ - return {{ if $field.IsPtr }}*{{end}}obj.{{$field.GoFieldName}}, nil - }) - if err != nil { - return obj ,err - } - - {{ if $field.IsPtr }} - if data, ok := c{{$field.GoFieldName}}.({{ $field.Type | ref }}); ok { - obj.{{$field.GoFieldName}} = &data - } else { - return obj, errors.New("expect {{ $field.GoType | ref }}") - } - {{else}} - if data, ok := c{{$field.GoFieldName}}.({{ $field.GoType | ref }}); ok{ - obj.{{$field.GoFieldName}} = data - } else { - return obj, errors.New("expected {{$field.GoFieldName}} to be {{$field.GoType | ref }}") - } - {{ end }} - - {{- end }} - - {{ if eq $field.Definition.GQLDefinition.Kind "INPUT_OBJECT" }} - {{ $field.Middleware (print "obj." $field.GoFieldName ) (print "obj." $field.GoFieldName ) }} - {{- end }} - {{- end }} - return obj, nil - } {{ end }} diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 3feab2595c4..1b79e555cc4 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -864,29 +864,26 @@ func (e *executableSchema) dir_length_args(ctx context.Context, rawArgs map[stri args := map[string]interface{}{} var arg0 int if tmp, ok := rawArgs["min"]; ok { - arg0, err = unmarshalInt2int(tmp) + arg0, err = e.unmarshalInt2int(tmp) if err != nil { return nil, err } - } args["min"] = arg0 var arg1 *int if tmp, ok := rawArgs["max"]; ok { - arg1, err = unmarshalInt2ᚖint(tmp) + arg1, err = e.unmarshalInt2ᚖint(tmp) if err != nil { return nil, err } - } args["max"] = arg1 var arg2 string if tmp, ok := rawArgs["message"]; ok { - arg2, err = unmarshalString2string(tmp) + arg2, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["message"] = arg2 return args, nil @@ -897,29 +894,26 @@ func (e *executableSchema) dir_range_args(ctx context.Context, rawArgs map[strin args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["min"]; ok { - arg0, err = unmarshalInt2ᚖint(tmp) + arg0, err = e.unmarshalInt2ᚖint(tmp) if err != nil { return nil, err } - } args["min"] = arg0 var arg1 *int if tmp, ok := rawArgs["max"]; ok { - arg1, err = unmarshalInt2ᚖint(tmp) + arg1, err = e.unmarshalInt2ᚖint(tmp) if err != nil { return nil, err } - } args["max"] = arg1 var arg2 *string if tmp, ok := rawArgs["message"]; ok { - arg2, err = unmarshalString2ᚖstring(tmp) + arg2, err = e.unmarshalString2ᚖstring(tmp) if err != nil { return nil, err } - } args["message"] = arg2 return args, nil @@ -930,11 +924,10 @@ func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = unmarshalString2string(tmp) + arg0, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["name"] = arg0 return args, nil @@ -945,7 +938,7 @@ func (e *executableSchema) field_Query_directiveArg_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["arg"]; ok { - getArg0 := func(ctx context.Context) (interface{}, error) { return unmarshalString2string(tmp) } + getArg0 := func(ctx context.Context) (interface{}, error) { return e.unmarshalString2string(tmp) } getArg1 := func(ctx context.Context) (res interface{}, err error) { max := 255 n := getArg0 @@ -961,7 +954,6 @@ func (e *executableSchema) field_Query_directiveArg_args(ctx context.Context, ra } else { return nil, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp) } - } args["arg"] = arg0 return args, nil @@ -972,11 +964,10 @@ func (e *executableSchema) field_Query_directiveInputNullable_args(ctx context.C args := map[string]interface{}{} var arg0 *InputDirectives if tmp, ok := rawArgs["arg"]; ok { - arg0, err = unmarshalInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(tmp) + arg0, err = e.unmarshalInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(tmp) if err != nil { return nil, err } - } args["arg"] = arg0 return args, nil @@ -987,11 +978,10 @@ func (e *executableSchema) field_Query_directiveInput_args(ctx context.Context, args := map[string]interface{}{} var arg0 InputDirectives if tmp, ok := rawArgs["arg"]; ok { - arg0, err = unmarshalInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(tmp) + arg0, err = e.unmarshalInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(tmp) if err != nil { return nil, err } - } args["arg"] = arg0 return args, nil @@ -1002,7 +992,7 @@ func (e *executableSchema) field_Query_directiveNullableArg_args(ctx context.Con args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["arg"]; ok { - getArg0 := func(ctx context.Context) (interface{}, error) { return unmarshalInt2ᚖint(tmp) } + getArg0 := func(ctx context.Context) (interface{}, error) { return e.unmarshalInt2ᚖint(tmp) } getArg1 := func(ctx context.Context) (res interface{}, err error) { min := 0 n := getArg0 @@ -1018,12 +1008,11 @@ func (e *executableSchema) field_Query_directiveNullableArg_args(ctx context.Con } else { return nil, fmt.Errorf(`unexpected type %T from directive, should be *int`, tmp) } - } args["arg"] = arg0 var arg1 *int if tmp, ok := rawArgs["arg2"]; ok { - getArg0 := func(ctx context.Context) (interface{}, error) { return unmarshalInt2ᚖint(tmp) } + getArg0 := func(ctx context.Context) (interface{}, error) { return e.unmarshalInt2ᚖint(tmp) } getArg1 := func(ctx context.Context) (res interface{}, err error) { min := 0 n := getArg0 @@ -1039,7 +1028,6 @@ func (e *executableSchema) field_Query_directiveNullableArg_args(ctx context.Con } else { return nil, fmt.Errorf(`unexpected type %T from directive, should be *int`, tmp) } - } args["arg2"] = arg1 return args, nil @@ -1050,227 +1038,202 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["break"]; ok { - arg0, err = unmarshalString2string(tmp) + arg0, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["break"] = arg0 var arg1 string if tmp, ok := rawArgs["default"]; ok { - arg1, err = unmarshalString2string(tmp) + arg1, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["default"] = arg1 var arg2 string if tmp, ok := rawArgs["func"]; ok { - arg2, err = unmarshalString2string(tmp) + arg2, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["func"] = arg2 var arg3 string if tmp, ok := rawArgs["interface"]; ok { - arg3, err = unmarshalString2string(tmp) + arg3, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["interface"] = arg3 var arg4 string if tmp, ok := rawArgs["select"]; ok { - arg4, err = unmarshalString2string(tmp) + arg4, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["select"] = arg4 var arg5 string if tmp, ok := rawArgs["case"]; ok { - arg5, err = unmarshalString2string(tmp) + arg5, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["case"] = arg5 var arg6 string if tmp, ok := rawArgs["defer"]; ok { - arg6, err = unmarshalString2string(tmp) + arg6, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["defer"] = arg6 var arg7 string if tmp, ok := rawArgs["go"]; ok { - arg7, err = unmarshalString2string(tmp) + arg7, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["go"] = arg7 var arg8 string if tmp, ok := rawArgs["map"]; ok { - arg8, err = unmarshalString2string(tmp) + arg8, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["map"] = arg8 var arg9 string if tmp, ok := rawArgs["struct"]; ok { - arg9, err = unmarshalString2string(tmp) + arg9, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["struct"] = arg9 var arg10 string if tmp, ok := rawArgs["chan"]; ok { - arg10, err = unmarshalString2string(tmp) + arg10, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["chan"] = arg10 var arg11 string if tmp, ok := rawArgs["else"]; ok { - arg11, err = unmarshalString2string(tmp) + arg11, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["else"] = arg11 var arg12 string if tmp, ok := rawArgs["goto"]; ok { - arg12, err = unmarshalString2string(tmp) + arg12, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["goto"] = arg12 var arg13 string if tmp, ok := rawArgs["package"]; ok { - arg13, err = unmarshalString2string(tmp) + arg13, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["package"] = arg13 var arg14 string if tmp, ok := rawArgs["switch"]; ok { - arg14, err = unmarshalString2string(tmp) + arg14, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["switch"] = arg14 var arg15 string if tmp, ok := rawArgs["const"]; ok { - arg15, err = unmarshalString2string(tmp) + arg15, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["const"] = arg15 var arg16 string if tmp, ok := rawArgs["fallthrough"]; ok { - arg16, err = unmarshalString2string(tmp) + arg16, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["fallthrough"] = arg16 var arg17 string if tmp, ok := rawArgs["if"]; ok { - arg17, err = unmarshalString2string(tmp) + arg17, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["if"] = arg17 var arg18 string if tmp, ok := rawArgs["range"]; ok { - arg18, err = unmarshalString2string(tmp) + arg18, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["range"] = arg18 var arg19 string if tmp, ok := rawArgs["type"]; ok { - arg19, err = unmarshalString2string(tmp) + arg19, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["type"] = arg19 var arg20 string if tmp, ok := rawArgs["continue"]; ok { - arg20, err = unmarshalString2string(tmp) + arg20, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["continue"] = arg20 var arg21 string if tmp, ok := rawArgs["for"]; ok { - arg21, err = unmarshalString2string(tmp) + arg21, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["for"] = arg21 var arg22 string if tmp, ok := rawArgs["import"]; ok { - arg22, err = unmarshalString2string(tmp) + arg22, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["import"] = arg22 var arg23 string if tmp, ok := rawArgs["return"]; ok { - arg23, err = unmarshalString2string(tmp) + arg23, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["return"] = arg23 var arg24 string if tmp, ok := rawArgs["var"]; ok { - arg24, err = unmarshalString2string(tmp) + arg24, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["var"] = arg24 return args, nil @@ -1281,11 +1244,10 @@ func (e *executableSchema) field_Query_keywords_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 *Keywords if tmp, ok := rawArgs["input"]; ok { - arg0, err = unmarshalKeywords2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(tmp) + arg0, err = e.unmarshalKeywords2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(tmp) if err != nil { return nil, err } - } args["input"] = arg0 return args, nil @@ -1296,11 +1258,10 @@ func (e *executableSchema) field_Query_mapInput_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 map[string]interface{} if tmp, ok := rawArgs["input"]; ok { - arg0, err = unmarshalChanges2map(tmp) + arg0, err = e.unmarshalChanges2map(tmp) if err != nil { return nil, err } - } args["input"] = arg0 return args, nil @@ -1311,11 +1272,10 @@ func (e *executableSchema) field_Query_nestedInputs_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 [][]*OuterInput if tmp, ok := rawArgs["input"]; ok { - arg0, err = unmarshalOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(tmp) + arg0, err = e.unmarshalOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(tmp) if err != nil { return nil, err } - } args["input"] = arg0 return args, nil @@ -1326,11 +1286,10 @@ func (e *executableSchema) field_Query_nullableArg_args(ctx context.Context, raw args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["arg"]; ok { - arg0, err = unmarshalInt2ᚖint(tmp) + arg0, err = e.unmarshalInt2ᚖint(tmp) if err != nil { return nil, err } - } args["arg"] = arg0 return args, nil @@ -1341,11 +1300,10 @@ func (e *executableSchema) field_Query_recursive_args(ctx context.Context, rawAr args := map[string]interface{}{} var arg0 *RecursiveInputSlice if tmp, ok := rawArgs["input"]; ok { - arg0, err = unmarshalRecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(tmp) + arg0, err = e.unmarshalRecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(tmp) if err != nil { return nil, err } - } args["input"] = arg0 return args, nil @@ -1356,11 +1314,10 @@ func (e *executableSchema) field_Query_user_args(ctx context.Context, rawArgs ma args := map[string]interface{}{} var arg0 int if tmp, ok := rawArgs["id"]; ok { - arg0, err = unmarshalInt2int(tmp) + arg0, err = e.unmarshalInt2int(tmp) if err != nil { return nil, err } - } args["id"] = arg0 return args, nil @@ -1371,11 +1328,10 @@ func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, raw args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = unmarshalBoolean2bool(tmp) + arg0, err = e.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } - } args["includeDeprecated"] = arg0 return args, nil @@ -1386,11 +1342,10 @@ func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = unmarshalBoolean2bool(tmp) + arg0, err = e.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } - } args["includeDeprecated"] = arg0 return args, nil @@ -3978,12 +3933,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co // region **************************** input.gotpl ***************************** -func (e *executableSchema) ChangesMiddleware(ctx context.Context, obj *map[string]interface{}) (*map[string]interface{}, error) { - - return obj, nil -} - -func unmarshalInputInnerDirectives(v interface{}) (InnerDirectives, error) { +func (e *executableSchema) unmarshalInputInnerDirectives(v interface{}) (InnerDirectives, error) { var it InnerDirectives var asMap = v.(map[string]interface{}) @@ -4001,31 +3951,7 @@ func unmarshalInputInnerDirectives(v interface{}) (InnerDirectives, error) { return it, nil } -func (e *executableSchema) InnerDirectivesMiddleware(ctx context.Context, obj *InnerDirectives) (*InnerDirectives, error) { - - cMessage, err := chainFieldMiddleware( - []graphql.FieldMiddleware{ - func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { - return e.directives.Length(ctx, obj.Message, n, 1, nil, "not valid") - }, - }..., - )(ctx, func(ctx context.Context) (interface{}, error) { - return obj.Message, nil - }) - if err != nil { - return obj, err - } - - if data, ok := cMessage.(string); ok { - obj.Message = data - } else { - return obj, errors.New("expected Message to be string") - } - - return obj, nil -} - -func unmarshalInputInnerInput(v interface{}) (InnerInput, error) { +func (e *executableSchema) unmarshalInputInnerInput(v interface{}) (InnerInput, error) { var it InnerInput var asMap = v.(map[string]interface{}) @@ -4043,12 +3969,7 @@ func unmarshalInputInnerInput(v interface{}) (InnerInput, error) { return it, nil } -func (e *executableSchema) InnerInputMiddleware(ctx context.Context, obj *InnerInput) (*InnerInput, error) { - - return obj, nil -} - -func unmarshalInputInputDirectives(v interface{}) (InputDirectives, error) { +func (e *executableSchema) unmarshalInputInputDirectives(v interface{}) (InputDirectives, error) { var it InputDirectives var asMap = v.(map[string]interface{}) @@ -4062,7 +3983,7 @@ func unmarshalInputInputDirectives(v interface{}) (InputDirectives, error) { } case "inner": var err error - it.Inner, err = unmarshalInputInnerDirectives(v) + it.Inner, err = e.unmarshalInputInnerDirectives(v) if err != nil { return it, err } @@ -4070,7 +3991,7 @@ func unmarshalInputInputDirectives(v interface{}) (InputDirectives, error) { var err error var ptr1 InnerDirectives if v != nil { - ptr1, err = unmarshalInputInnerDirectives(v) + ptr1, err = e.unmarshalInputInnerDirectives(v) it.InnerNullable = &ptr1 } @@ -4083,45 +4004,7 @@ func unmarshalInputInputDirectives(v interface{}) (InputDirectives, error) { return it, nil } -func (e *executableSchema) InputDirectivesMiddleware(ctx context.Context, obj *InputDirectives) (*InputDirectives, error) { - - cText, err := chainFieldMiddleware( - []graphql.FieldMiddleware{ - func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { - max := 7 - return e.directives.Length(ctx, obj.Text, n, 0, &max, "not valid") - }, - }..., - )(ctx, func(ctx context.Context) (interface{}, error) { - return obj.Text, nil - }) - if err != nil { - return obj, err - } - - if data, ok := cText.(string); ok { - obj.Text = data - } else { - return obj, errors.New("expected Text to be string") - } - - mInnerDirectives1, err := e.InnerDirectivesMiddleware(ctx, &obj.Inner) - if err != nil { - return nil, err - } - obj.Inner = *mInnerDirectives1 - - if obj.InnerNullable != nil { - var err error - obj.InnerNullable, err = e.InnerDirectivesMiddleware(ctx, obj.InnerNullable) - if err != nil { - return nil, err - } - } - return obj, nil -} - -func unmarshalInputKeywords(v interface{}) (Keywords, error) { +func (e *executableSchema) unmarshalInputKeywords(v interface{}) (Keywords, error) { var it Keywords var asMap = v.(map[string]interface{}) @@ -4283,12 +4166,7 @@ func unmarshalInputKeywords(v interface{}) (Keywords, error) { return it, nil } -func (e *executableSchema) KeywordsMiddleware(ctx context.Context, obj *Keywords) (*Keywords, error) { - - return obj, nil -} - -func unmarshalInputOuterInput(v interface{}) (OuterInput, error) { +func (e *executableSchema) unmarshalInputOuterInput(v interface{}) (OuterInput, error) { var it OuterInput var asMap = v.(map[string]interface{}) @@ -4296,7 +4174,7 @@ func unmarshalInputOuterInput(v interface{}) (OuterInput, error) { switch k { case "inner": var err error - it.Inner, err = unmarshalInputInnerInput(v) + it.Inner, err = e.unmarshalInputInnerInput(v) if err != nil { return it, err } @@ -4306,17 +4184,7 @@ func unmarshalInputOuterInput(v interface{}) (OuterInput, error) { return it, nil } -func (e *executableSchema) OuterInputMiddleware(ctx context.Context, obj *OuterInput) (*OuterInput, error) { - - mInnerInput1, err := e.InnerInputMiddleware(ctx, &obj.Inner) - if err != nil { - return nil, err - } - obj.Inner = *mInnerInput1 - return obj, nil -} - -func unmarshalInputRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { +func (e *executableSchema) unmarshalInputRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { var it RecursiveInputSlice var asMap = v.(map[string]interface{}) @@ -4334,7 +4202,7 @@ func unmarshalInputRecursiveInputSlice(v interface{}) (RecursiveInputSlice, erro } it.Self = make([]RecursiveInputSlice, len(rawIf1)) for idx1 := range rawIf1 { - it.Self[idx1], err = unmarshalInputRecursiveInputSlice(rawIf1[idx1]) + it.Self[idx1], err = e.unmarshalInputRecursiveInputSlice(rawIf1[idx1]) } if err != nil { return it, err @@ -4345,19 +4213,6 @@ func unmarshalInputRecursiveInputSlice(v interface{}) (RecursiveInputSlice, erro return it, nil } -func (e *executableSchema) RecursiveInputSliceMiddleware(ctx context.Context, obj *RecursiveInputSlice) (*RecursiveInputSlice, error) { - - for idx1 := range obj.Self { - - mRecursiveInputSlice2, err := e.RecursiveInputSliceMiddleware(ctx, &obj.Self[idx1]) - if err != nil { - return nil, err - } - obj.Self[idx1] = *mRecursiveInputSlice2 - } - return obj, nil -} - // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** @@ -5164,49 +5019,49 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func unmarshalInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v interface{}) (*InputDirectives, error) { +func (e *executableSchema) unmarshalInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v interface{}) (*InputDirectives, error) { if v == nil { return nil, nil } - res, err := unmarshalInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v) + res, err := e.unmarshalInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v) return &res, err } -func unmarshalKeywords2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(v interface{}) (*Keywords, error) { +func (e *executableSchema) unmarshalKeywords2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(v interface{}) (*Keywords, error) { if v == nil { return nil, nil } - res, err := unmarshalKeywords2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(v) + res, err := e.unmarshalKeywords2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(v) return &res, err } -func unmarshalOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) (*OuterInput, error) { +func (e *executableSchema) unmarshalOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) (*OuterInput, error) { if v == nil { return nil, nil } - res, err := unmarshalOuterInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v) + res, err := e.unmarshalOuterInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v) return &res, err } -func unmarshalRecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v interface{}) (*RecursiveInputSlice, error) { +func (e *executableSchema) unmarshalRecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v interface{}) (*RecursiveInputSlice, error) { if v == nil { return nil, nil } - res, err := unmarshalRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v) + res, err := e.unmarshalRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v) return &res, err } -func unmarshalInt2ᚖint(v interface{}) (*int, error) { +func (e *executableSchema) unmarshalInt2ᚖint(v interface{}) (*int, error) { if v == nil { return nil, nil } - res, err := unmarshalInt2int(v) + res, err := e.unmarshalInt2int(v) return &res, err } -func unmarshalString2ᚖstring(v interface{}) (*string, error) { +func (e *executableSchema) unmarshalString2ᚖstring(v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := unmarshalString2string(v) + res, err := e.unmarshalString2string(v) return &res, err } -func unmarshalOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) ([]*OuterInput, error) { +func (e *executableSchema) unmarshalOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) ([]*OuterInput, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -5218,14 +5073,14 @@ func unmarshalOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtes var err error res := make([]*OuterInput, len(vSlice)) for i := range vSlice { - res[i], err = unmarshalOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(vSlice[i]) + res[i], err = e.unmarshalOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(vSlice[i]) if err != nil { return nil, err } } return res, nil } -func unmarshalOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) ([][]*OuterInput, error) { +func (e *executableSchema) unmarshalOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) ([][]*OuterInput, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -5237,35 +5092,35 @@ func unmarshalOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋ var err error res := make([][]*OuterInput, len(vSlice)) for i := range vSlice { - res[i], err = unmarshalOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(vSlice[i]) + res[i], err = e.unmarshalOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(vSlice[i]) if err != nil { return nil, err } } return res, nil } -func unmarshalBoolean2bool(v interface{}) (bool, error) { +func (e *executableSchema) unmarshalBoolean2bool(v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } -func unmarshalInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v interface{}) (InputDirectives, error) { - return unmarshalInputInputDirectives(v) +func (e *executableSchema) unmarshalInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v interface{}) (InputDirectives, error) { + return e.unmarshalInputInputDirectives(v) } -func unmarshalKeywords2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(v interface{}) (Keywords, error) { - return unmarshalInputKeywords(v) +func (e *executableSchema) unmarshalKeywords2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(v interface{}) (Keywords, error) { + return e.unmarshalInputKeywords(v) } -func unmarshalOuterInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) (OuterInput, error) { - return unmarshalInputOuterInput(v) +func (e *executableSchema) unmarshalOuterInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) (OuterInput, error) { + return e.unmarshalInputOuterInput(v) } -func unmarshalRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { - return unmarshalInputRecursiveInputSlice(v) +func (e *executableSchema) unmarshalRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { + return e.unmarshalInputRecursiveInputSlice(v) } -func unmarshalInt2int(v interface{}) (int, error) { +func (e *executableSchema) unmarshalInt2int(v interface{}) (int, error) { return graphql.UnmarshalInt(v) } -func unmarshalChanges2map(v interface{}) (map[string]interface{}, error) { +func (e *executableSchema) unmarshalChanges2map(v interface{}) (map[string]interface{}, error) { return v.(map[string]interface{}), nil } -func unmarshalString2string(v interface{}) (string, error) { +func (e *executableSchema) unmarshalString2string(v interface{}) (string, error) { return graphql.UnmarshalString(v) } diff --git a/codegen/type.gotpl b/codegen/type.gotpl index 59466f0deb8..27e94d75ec9 100644 --- a/codegen/type.gotpl +++ b/codegen/type.gotpl @@ -1,9 +1,9 @@ {{- range $type := .ReferencedTypes }} {{- if $type.Definition.IsInputType }} - func unmarshal{{ $type.Definition.Name }}2{{ $type.GO | ts }}(v interface{}) ({{ $type.GO | ref }}, error) { + func (e *executableSchema) unmarshal{{ $type.Definition.Name }}2{{ $type.GO | ts }}(v interface{}) ({{ $type.GO | ref }}, error) { {{- if $type.IsPtr }} if v == nil { return nil, nil } - res, err := unmarshal{{ $type.Definition.Name }}2{{ $type.GO.Elem | ts }}(v) + res, err := e.unmarshal{{ $type.Definition.Name }}2{{ $type.GO.Elem | ts }}(v) return &res, err {{- else if $type.IsSlice }} var vSlice []interface{} @@ -17,7 +17,7 @@ var err error res := make([]{{$type.GO.Elem | ref}}, len(vSlice)) for i := range vSlice { - res[i], err = unmarshal{{ $type.Definition.Name }}2{{ $type.GO.Elem | ts }}(vSlice[i]) + res[i], err = e.unmarshal{{ $type.Definition.Name }}2{{ $type.GO.Elem | ts }}(vSlice[i]) if err != nil { return nil, err } diff --git a/example/chat/generated.go b/example/chat/generated.go index cb227e8b000..ba0e7013071 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -346,29 +346,26 @@ func (e *executableSchema) field_Mutation_post_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["text"]; ok { - arg0, err = unmarshalString2string(tmp) + arg0, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["text"] = arg0 var arg1 string if tmp, ok := rawArgs["username"]; ok { - arg1, err = unmarshalString2string(tmp) + arg1, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["username"] = arg1 var arg2 string if tmp, ok := rawArgs["roomName"]; ok { - arg2, err = unmarshalString2string(tmp) + arg2, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["roomName"] = arg2 return args, nil @@ -379,11 +376,10 @@ func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = unmarshalString2string(tmp) + arg0, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["name"] = arg0 return args, nil @@ -394,11 +390,10 @@ func (e *executableSchema) field_Query_room_args(ctx context.Context, rawArgs ma args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = unmarshalString2string(tmp) + arg0, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["name"] = arg0 return args, nil @@ -409,11 +404,10 @@ func (e *executableSchema) field_Subscription_messageAdded_args(ctx context.Cont args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["roomName"]; ok { - arg0, err = unmarshalString2string(tmp) + arg0, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["roomName"] = arg0 return args, nil @@ -424,11 +418,10 @@ func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, raw args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = unmarshalBoolean2bool(tmp) + arg0, err = e.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } - } args["includeDeprecated"] = arg0 return args, nil @@ -439,11 +432,10 @@ func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = unmarshalBoolean2bool(tmp) + arg0, err = e.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } - } args["includeDeprecated"] = arg0 return args, nil @@ -2438,10 +2430,10 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func unmarshalBoolean2bool(v interface{}) (bool, error) { +func (e *executableSchema) unmarshalBoolean2bool(v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } -func unmarshalString2string(v interface{}) (string, error) { +func (e *executableSchema) unmarshalString2string(v interface{}) (string, error) { return graphql.UnmarshalString(v) } diff --git a/example/config/generated.go b/example/config/generated.go index 43f4a288b90..81687954215 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -303,11 +303,10 @@ func (e *executableSchema) field_Mutation_createTodo_args(ctx context.Context, r args := map[string]interface{}{} var arg0 NewTodo if tmp, ok := rawArgs["input"]; ok { - arg0, err = unmarshalNewTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐNewTodo(tmp) + arg0, err = e.unmarshalNewTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐNewTodo(tmp) if err != nil { return nil, err } - } args["input"] = arg0 return args, nil @@ -318,11 +317,10 @@ func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = unmarshalString2string(tmp) + arg0, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["name"] = arg0 return args, nil @@ -333,11 +331,10 @@ func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, raw args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = unmarshalBoolean2bool(tmp) + arg0, err = e.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } - } args["includeDeprecated"] = arg0 return args, nil @@ -348,11 +345,10 @@ func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = unmarshalBoolean2bool(tmp) + arg0, err = e.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } - } args["includeDeprecated"] = arg0 return args, nil @@ -1904,7 +1900,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co // region **************************** input.gotpl ***************************** -func unmarshalInputNewTodo(v interface{}) (NewTodo, error) { +func (e *executableSchema) unmarshalInputNewTodo(v interface{}) (NewTodo, error) { var it NewTodo var asMap = v.(map[string]interface{}) @@ -1928,11 +1924,6 @@ func unmarshalInputNewTodo(v interface{}) (NewTodo, error) { return it, nil } -func (e *executableSchema) NewTodoMiddleware(ctx context.Context, obj *NewTodo) (*NewTodo, error) { - - return obj, nil -} - // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** @@ -2349,13 +2340,13 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func unmarshalBoolean2bool(v interface{}) (bool, error) { +func (e *executableSchema) unmarshalBoolean2bool(v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } -func unmarshalNewTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐNewTodo(v interface{}) (NewTodo, error) { - return unmarshalInputNewTodo(v) +func (e *executableSchema) unmarshalNewTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐNewTodo(v interface{}) (NewTodo, error) { + return e.unmarshalInputNewTodo(v) } -func unmarshalString2string(v interface{}) (string, error) { +func (e *executableSchema) unmarshalString2string(v interface{}) (string, error) { return graphql.UnmarshalString(v) } diff --git a/example/dataloader/addressloader_gen.go b/example/dataloader/addressloader_gen.go index 0465446faa7..90e1d433fc5 100644 --- a/example/dataloader/addressloader_gen.go +++ b/example/dataloader/addressloader_gen.go @@ -1,4 +1,4 @@ -// generated by github.com/vektah/dataloaden ; DO NOT EDIT +// Code generated by github.com/vektah/dataloaden, DO NOT EDIT. package dataloader @@ -7,6 +7,27 @@ import ( "time" ) +// AddressLoaderConfig captures the config to create a new AddressLoader +type AddressLoaderConfig struct { + // Fetch is a method that provides the data for the loader + Fetch func(keys []int) ([]*Address, []error) + + // Wait is how long wait before sending a batch + Wait time.Duration + + // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit + MaxBatch int +} + +// NewAddressLoader creates a new AddressLoader given a fetch, wait, and maxBatch +func NewAddressLoader(config AddressLoaderConfig) *AddressLoader { + return &AddressLoader{ + fetch: config.Fetch, + wait: config.Wait, + maxBatch: config.MaxBatch, + } +} + // AddressLoader batches and caches requests type AddressLoader struct { // this method provides the data for the loader diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index 7e7e562e88c..27aae23e17b 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -356,11 +356,10 @@ func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = unmarshalString2string(tmp) + arg0, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["name"] = arg0 return args, nil @@ -371,11 +370,10 @@ func (e *executableSchema) field_Query_torture1d_args(ctx context.Context, rawAr args := map[string]interface{}{} var arg0 []int if tmp, ok := rawArgs["customerIds"]; ok { - arg0, err = unmarshalInt2ᚕint(tmp) + arg0, err = e.unmarshalInt2ᚕint(tmp) if err != nil { return nil, err } - } args["customerIds"] = arg0 return args, nil @@ -386,11 +384,10 @@ func (e *executableSchema) field_Query_torture2d_args(ctx context.Context, rawAr args := map[string]interface{}{} var arg0 [][]int if tmp, ok := rawArgs["customerIds"]; ok { - arg0, err = unmarshalInt2ᚕᚕint(tmp) + arg0, err = e.unmarshalInt2ᚕᚕint(tmp) if err != nil { return nil, err } - } args["customerIds"] = arg0 return args, nil @@ -401,11 +398,10 @@ func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, raw args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = unmarshalBoolean2bool(tmp) + arg0, err = e.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } - } args["includeDeprecated"] = arg0 return args, nil @@ -416,11 +412,10 @@ func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = unmarshalBoolean2bool(tmp) + arg0, err = e.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } - } args["includeDeprecated"] = arg0 return args, nil @@ -2752,7 +2747,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func unmarshalInt2ᚕᚕint(v interface{}) ([][]int, error) { +func (e *executableSchema) unmarshalInt2ᚕᚕint(v interface{}) ([][]int, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -2764,14 +2759,14 @@ func unmarshalInt2ᚕᚕint(v interface{}) ([][]int, error) { var err error res := make([][]int, len(vSlice)) for i := range vSlice { - res[i], err = unmarshalInt2ᚕint(vSlice[i]) + res[i], err = e.unmarshalInt2ᚕint(vSlice[i]) if err != nil { return nil, err } } return res, nil } -func unmarshalInt2ᚕint(v interface{}) ([]int, error) { +func (e *executableSchema) unmarshalInt2ᚕint(v interface{}) ([]int, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -2783,20 +2778,20 @@ func unmarshalInt2ᚕint(v interface{}) ([]int, error) { var err error res := make([]int, len(vSlice)) for i := range vSlice { - res[i], err = unmarshalInt2int(vSlice[i]) + res[i], err = e.unmarshalInt2int(vSlice[i]) if err != nil { return nil, err } } return res, nil } -func unmarshalBoolean2bool(v interface{}) (bool, error) { +func (e *executableSchema) unmarshalBoolean2bool(v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } -func unmarshalInt2int(v interface{}) (int, error) { +func (e *executableSchema) unmarshalInt2int(v interface{}) (int, error) { return graphql.UnmarshalInt(v) } -func unmarshalString2string(v interface{}) (string, error) { +func (e *executableSchema) unmarshalString2string(v interface{}) (string, error) { return graphql.UnmarshalString(v) } diff --git a/example/dataloader/itemsliceloader_gen.go b/example/dataloader/itemsliceloader_gen.go index 55f21b4cae5..5fa10078401 100644 --- a/example/dataloader/itemsliceloader_gen.go +++ b/example/dataloader/itemsliceloader_gen.go @@ -1,4 +1,4 @@ -// generated by github.com/vektah/dataloaden ; DO NOT EDIT +// Code generated by github.com/vektah/dataloaden, DO NOT EDIT. package dataloader @@ -7,6 +7,27 @@ import ( "time" ) +// ItemSliceLoaderConfig captures the config to create a new ItemSliceLoader +type ItemSliceLoaderConfig struct { + // Fetch is a method that provides the data for the loader + Fetch func(keys []int) ([][]Item, []error) + + // Wait is how long wait before sending a batch + Wait time.Duration + + // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit + MaxBatch int +} + +// NewItemSliceLoader creates a new ItemSliceLoader given a fetch, wait, and maxBatch +func NewItemSliceLoader(config ItemSliceLoaderConfig) *ItemSliceLoader { + return &ItemSliceLoader{ + fetch: config.Fetch, + wait: config.Wait, + maxBatch: config.MaxBatch, + } +} + // ItemSliceLoader batches and caches requests type ItemSliceLoader struct { // this method provides the data for the loader diff --git a/example/dataloader/ordersliceloader_gen.go b/example/dataloader/ordersliceloader_gen.go index 6b168ec1fb4..e76e24d31f0 100644 --- a/example/dataloader/ordersliceloader_gen.go +++ b/example/dataloader/ordersliceloader_gen.go @@ -1,4 +1,4 @@ -// generated by github.com/vektah/dataloaden ; DO NOT EDIT +// Code generated by github.com/vektah/dataloaden, DO NOT EDIT. package dataloader @@ -7,6 +7,27 @@ import ( "time" ) +// OrderSliceLoaderConfig captures the config to create a new OrderSliceLoader +type OrderSliceLoaderConfig struct { + // Fetch is a method that provides the data for the loader + Fetch func(keys []int) ([][]Order, []error) + + // Wait is how long wait before sending a batch + Wait time.Duration + + // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit + MaxBatch int +} + +// NewOrderSliceLoader creates a new OrderSliceLoader given a fetch, wait, and maxBatch +func NewOrderSliceLoader(config OrderSliceLoaderConfig) *OrderSliceLoader { + return &OrderSliceLoader{ + fetch: config.Fetch, + wait: config.Wait, + maxBatch: config.MaxBatch, + } +} + // OrderSliceLoader batches and caches requests type OrderSliceLoader struct { // this method provides the data for the loader diff --git a/example/scalars/generated.go b/example/scalars/generated.go index 5b7e09b0ee4..a0e54a4770a 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -327,11 +327,10 @@ func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = unmarshalString2string(tmp) + arg0, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["name"] = arg0 return args, nil @@ -342,11 +341,10 @@ func (e *executableSchema) field_Query_search_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 *model.SearchArgs if tmp, ok := rawArgs["input"]; ok { - arg0, err = unmarshalSearchArgs2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(tmp) + arg0, err = e.unmarshalSearchArgs2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(tmp) if err != nil { return nil, err } - } args["input"] = arg0 return args, nil @@ -357,11 +355,10 @@ func (e *executableSchema) field_Query_user_args(ctx context.Context, rawArgs ma args := map[string]interface{}{} var arg0 external.ObjectID if tmp, ok := rawArgs["id"]; ok { - arg0, err = unmarshalID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(tmp) + arg0, err = e.unmarshalID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(tmp) if err != nil { return nil, err } - } args["id"] = arg0 return args, nil @@ -372,11 +369,10 @@ func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, raw args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = unmarshalBoolean2bool(tmp) + arg0, err = e.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } - } args["includeDeprecated"] = arg0 return args, nil @@ -387,11 +383,10 @@ func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = unmarshalBoolean2bool(tmp) + arg0, err = e.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } - } args["includeDeprecated"] = arg0 return args, nil @@ -2024,7 +2019,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co // region **************************** input.gotpl ***************************** -func unmarshalInputSearchArgs(v interface{}) (model.SearchArgs, error) { +func (e *executableSchema) unmarshalInputSearchArgs(v interface{}) (model.SearchArgs, error) { var it model.SearchArgs var asMap = v.(map[string]interface{}) @@ -2064,11 +2059,6 @@ func unmarshalInputSearchArgs(v interface{}) (model.SearchArgs, error) { return it, nil } -func (e *executableSchema) SearchArgsMiddleware(ctx context.Context, obj *model.SearchArgs) (*model.SearchArgs, error) { - - return obj, nil -} - // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** @@ -2466,23 +2456,23 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func unmarshalSearchArgs2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v interface{}) (*model.SearchArgs, error) { +func (e *executableSchema) unmarshalSearchArgs2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v interface{}) (*model.SearchArgs, error) { if v == nil { return nil, nil } - res, err := unmarshalSearchArgs2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v) + res, err := e.unmarshalSearchArgs2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v) return &res, err } -func unmarshalBoolean2bool(v interface{}) (bool, error) { +func (e *executableSchema) unmarshalBoolean2bool(v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } -func unmarshalID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(v interface{}) (external.ObjectID, error) { +func (e *executableSchema) unmarshalID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(v interface{}) (external.ObjectID, error) { return model.UnmarshalID(v) } -func unmarshalSearchArgs2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v interface{}) (model.SearchArgs, error) { - return unmarshalInputSearchArgs(v) +func (e *executableSchema) unmarshalSearchArgs2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v interface{}) (model.SearchArgs, error) { + return e.unmarshalInputSearchArgs(v) } -func unmarshalString2string(v interface{}) (string, error) { +func (e *executableSchema) unmarshalString2string(v interface{}) (string, error) { return graphql.UnmarshalString(v) } diff --git a/example/selection/generated.go b/example/selection/generated.go index c9f7d60ee8f..0d275b873a3 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -274,11 +274,10 @@ func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = unmarshalString2string(tmp) + arg0, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["name"] = arg0 return args, nil @@ -289,11 +288,10 @@ func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, raw args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = unmarshalBoolean2bool(tmp) + arg0, err = e.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } - } args["includeDeprecated"] = arg0 return args, nil @@ -304,11 +302,10 @@ func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = unmarshalBoolean2bool(tmp) + arg0, err = e.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } - } args["includeDeprecated"] = arg0 return args, nil @@ -2259,10 +2256,10 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func unmarshalBoolean2bool(v interface{}) (bool, error) { +func (e *executableSchema) unmarshalBoolean2bool(v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } -func unmarshalString2string(v interface{}) (string, error) { +func (e *executableSchema) unmarshalString2string(v interface{}) (string, error) { return graphql.UnmarshalString(v) } diff --git a/example/starwars/generated.go b/example/starwars/generated.go index a04b78244d1..ebaccfb121d 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -735,20 +735,18 @@ func (e *executableSchema) field_Droid_friendsConnection_args(ctx context.Contex args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["first"]; ok { - arg0, err = unmarshalInt2ᚖint(tmp) + arg0, err = e.unmarshalInt2ᚖint(tmp) if err != nil { return nil, err } - } args["first"] = arg0 var arg1 *string if tmp, ok := rawArgs["after"]; ok { - arg1, err = unmarshalID2ᚖstring(tmp) + arg1, err = e.unmarshalID2ᚖstring(tmp) if err != nil { return nil, err } - } args["after"] = arg1 return args, nil @@ -759,20 +757,18 @@ func (e *executableSchema) field_Human_friendsConnection_args(ctx context.Contex args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["first"]; ok { - arg0, err = unmarshalInt2ᚖint(tmp) + arg0, err = e.unmarshalInt2ᚖint(tmp) if err != nil { return nil, err } - } args["first"] = arg0 var arg1 *string if tmp, ok := rawArgs["after"]; ok { - arg1, err = unmarshalID2ᚖstring(tmp) + arg1, err = e.unmarshalID2ᚖstring(tmp) if err != nil { return nil, err } - } args["after"] = arg1 return args, nil @@ -783,11 +779,10 @@ func (e *executableSchema) field_Human_height_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 LengthUnit if tmp, ok := rawArgs["unit"]; ok { - arg0, err = unmarshalLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(tmp) + arg0, err = e.unmarshalLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(tmp) if err != nil { return nil, err } - } args["unit"] = arg0 return args, nil @@ -798,20 +793,18 @@ func (e *executableSchema) field_Mutation_createReview_args(ctx context.Context, args := map[string]interface{}{} var arg0 Episode if tmp, ok := rawArgs["episode"]; ok { - arg0, err = unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(tmp) + arg0, err = e.unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(tmp) if err != nil { return nil, err } - } args["episode"] = arg0 var arg1 Review if tmp, ok := rawArgs["review"]; ok { - arg1, err = unmarshalReviewInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(tmp) + arg1, err = e.unmarshalReviewInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(tmp) if err != nil { return nil, err } - } args["review"] = arg1 return args, nil @@ -822,11 +815,10 @@ func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = unmarshalString2string(tmp) + arg0, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["name"] = arg0 return args, nil @@ -837,11 +829,10 @@ func (e *executableSchema) field_Query_character_args(ctx context.Context, rawAr args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["id"]; ok { - arg0, err = unmarshalID2string(tmp) + arg0, err = e.unmarshalID2string(tmp) if err != nil { return nil, err } - } args["id"] = arg0 return args, nil @@ -852,11 +843,10 @@ func (e *executableSchema) field_Query_droid_args(ctx context.Context, rawArgs m args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["id"]; ok { - arg0, err = unmarshalID2string(tmp) + arg0, err = e.unmarshalID2string(tmp) if err != nil { return nil, err } - } args["id"] = arg0 return args, nil @@ -867,11 +857,10 @@ func (e *executableSchema) field_Query_hero_args(ctx context.Context, rawArgs ma args := map[string]interface{}{} var arg0 *Episode if tmp, ok := rawArgs["episode"]; ok { - arg0, err = unmarshalEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(tmp) + arg0, err = e.unmarshalEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(tmp) if err != nil { return nil, err } - } args["episode"] = arg0 return args, nil @@ -882,11 +871,10 @@ func (e *executableSchema) field_Query_human_args(ctx context.Context, rawArgs m args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["id"]; ok { - arg0, err = unmarshalID2string(tmp) + arg0, err = e.unmarshalID2string(tmp) if err != nil { return nil, err } - } args["id"] = arg0 return args, nil @@ -897,20 +885,18 @@ func (e *executableSchema) field_Query_reviews_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 Episode if tmp, ok := rawArgs["episode"]; ok { - arg0, err = unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(tmp) + arg0, err = e.unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(tmp) if err != nil { return nil, err } - } args["episode"] = arg0 var arg1 *time.Time if tmp, ok := rawArgs["since"]; ok { - arg1, err = unmarshalTime2ᚖtimeᚐTime(tmp) + arg1, err = e.unmarshalTime2ᚖtimeᚐTime(tmp) if err != nil { return nil, err } - } args["since"] = arg1 return args, nil @@ -921,11 +907,10 @@ func (e *executableSchema) field_Query_search_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["text"]; ok { - arg0, err = unmarshalString2string(tmp) + arg0, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["text"] = arg0 return args, nil @@ -936,11 +921,10 @@ func (e *executableSchema) field_Query_starship_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["id"]; ok { - arg0, err = unmarshalID2string(tmp) + arg0, err = e.unmarshalID2string(tmp) if err != nil { return nil, err } - } args["id"] = arg0 return args, nil @@ -951,11 +935,10 @@ func (e *executableSchema) field_Starship_length_args(ctx context.Context, rawAr args := map[string]interface{}{} var arg0 *LengthUnit if tmp, ok := rawArgs["unit"]; ok { - arg0, err = unmarshalLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(tmp) + arg0, err = e.unmarshalLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(tmp) if err != nil { return nil, err } - } args["unit"] = arg0 return args, nil @@ -966,11 +949,10 @@ func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, raw args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = unmarshalBoolean2bool(tmp) + arg0, err = e.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } - } args["includeDeprecated"] = arg0 return args, nil @@ -981,11 +963,10 @@ func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = unmarshalBoolean2bool(tmp) + arg0, err = e.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } - } args["includeDeprecated"] = arg0 return args, nil @@ -3611,7 +3592,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co // region **************************** input.gotpl ***************************** -func unmarshalInputReviewInput(v interface{}) (Review, error) { +func (e *executableSchema) unmarshalInputReviewInput(v interface{}) (Review, error) { var it Review var asMap = v.(map[string]interface{}) @@ -3646,11 +3627,6 @@ func unmarshalInputReviewInput(v interface{}) (Review, error) { return it, nil } -func (e *executableSchema) ReviewInputMiddleware(ctx context.Context, obj *Review) (*Review, error) { - - return obj, nil -} - // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** @@ -4369,65 +4345,65 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func unmarshalEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v interface{}) (*Episode, error) { +func (e *executableSchema) unmarshalEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v interface{}) (*Episode, error) { if v == nil { return nil, nil } - res, err := unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v) + res, err := e.unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v) return &res, err } -func unmarshalLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(v interface{}) (*LengthUnit, error) { +func (e *executableSchema) unmarshalLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(v interface{}) (*LengthUnit, error) { if v == nil { return nil, nil } - res, err := unmarshalLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(v) + res, err := e.unmarshalLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(v) return &res, err } -func unmarshalInt2ᚖint(v interface{}) (*int, error) { +func (e *executableSchema) unmarshalInt2ᚖint(v interface{}) (*int, error) { if v == nil { return nil, nil } - res, err := unmarshalInt2int(v) + res, err := e.unmarshalInt2int(v) return &res, err } -func unmarshalID2ᚖstring(v interface{}) (*string, error) { +func (e *executableSchema) unmarshalID2ᚖstring(v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := unmarshalID2string(v) + res, err := e.unmarshalID2string(v) return &res, err } -func unmarshalTime2ᚖtimeᚐTime(v interface{}) (*time.Time, error) { +func (e *executableSchema) unmarshalTime2ᚖtimeᚐTime(v interface{}) (*time.Time, error) { if v == nil { return nil, nil } - res, err := unmarshalTime2timeᚐTime(v) + res, err := e.unmarshalTime2timeᚐTime(v) return &res, err } -func unmarshalBoolean2bool(v interface{}) (bool, error) { +func (e *executableSchema) unmarshalBoolean2bool(v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } -func unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v interface{}) (Episode, error) { +func (e *executableSchema) unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v interface{}) (Episode, error) { var res Episode return res, res.UnmarshalGQL(v) } -func unmarshalLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(v interface{}) (LengthUnit, error) { +func (e *executableSchema) unmarshalLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(v interface{}) (LengthUnit, error) { var res LengthUnit return res, res.UnmarshalGQL(v) } -func unmarshalReviewInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(v interface{}) (Review, error) { - return unmarshalInputReviewInput(v) +func (e *executableSchema) unmarshalReviewInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(v interface{}) (Review, error) { + return e.unmarshalInputReviewInput(v) } -func unmarshalInt2int(v interface{}) (int, error) { +func (e *executableSchema) unmarshalInt2int(v interface{}) (int, error) { return graphql.UnmarshalInt(v) } -func unmarshalID2string(v interface{}) (string, error) { +func (e *executableSchema) unmarshalID2string(v interface{}) (string, error) { return graphql.UnmarshalID(v) } -func unmarshalString2string(v interface{}) (string, error) { +func (e *executableSchema) unmarshalString2string(v interface{}) (string, error) { return graphql.UnmarshalString(v) } -func unmarshalTime2timeᚐTime(v interface{}) (time.Time, error) { +func (e *executableSchema) unmarshalTime2timeᚐTime(v interface{}) (time.Time, error) { return graphql.UnmarshalTime(v) } diff --git a/example/todo/generated.go b/example/todo/generated.go index 31c49124f8e..b6935928e40 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -333,11 +333,10 @@ func (e *executableSchema) dir_hasRole_args(ctx context.Context, rawArgs map[str args := map[string]interface{}{} var arg0 Role if tmp, ok := rawArgs["role"]; ok { - arg0, err = unmarshalRole2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐRole(tmp) + arg0, err = e.unmarshalRole2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐRole(tmp) if err != nil { return nil, err } - } args["role"] = arg0 return args, nil @@ -348,11 +347,10 @@ func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, args := map[string]interface{}{} var arg0 TodoInput if tmp, ok := rawArgs["todo"]; ok { - arg0, err = unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodoInput(tmp) + arg0, err = e.unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodoInput(tmp) if err != nil { return nil, err } - } args["todo"] = arg0 return args, nil @@ -363,20 +361,18 @@ func (e *executableSchema) field_MyMutation_updateTodo_args(ctx context.Context, args := map[string]interface{}{} var arg0 int if tmp, ok := rawArgs["id"]; ok { - arg0, err = unmarshalInt2int(tmp) + arg0, err = e.unmarshalInt2int(tmp) if err != nil { return nil, err } - } args["id"] = arg0 var arg1 map[string]interface{} if tmp, ok := rawArgs["changes"]; ok { - arg1, err = unmarshalMap2map(tmp) + arg1, err = e.unmarshalMap2map(tmp) if err != nil { return nil, err } - } args["changes"] = arg1 return args, nil @@ -387,11 +383,10 @@ func (e *executableSchema) field_MyQuery___type_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = unmarshalString2string(tmp) + arg0, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["name"] = arg0 return args, nil @@ -402,11 +397,10 @@ func (e *executableSchema) field_MyQuery_todo_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 int if tmp, ok := rawArgs["id"]; ok { - arg0, err = unmarshalInt2int(tmp) + arg0, err = e.unmarshalInt2int(tmp) if err != nil { return nil, err } - } args["id"] = arg0 return args, nil @@ -417,11 +411,10 @@ func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, raw args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = unmarshalBoolean2bool(tmp) + arg0, err = e.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } - } args["includeDeprecated"] = arg0 return args, nil @@ -432,11 +425,10 @@ func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = unmarshalBoolean2bool(tmp) + arg0, err = e.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } - } args["includeDeprecated"] = arg0 return args, nil @@ -1980,7 +1972,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co // region **************************** input.gotpl ***************************** -func unmarshalInputTodoInput(v interface{}) (TodoInput, error) { +func (e *executableSchema) unmarshalInputTodoInput(v interface{}) (TodoInput, error) { var it TodoInput var asMap = v.(map[string]interface{}) @@ -2009,11 +2001,6 @@ func unmarshalInputTodoInput(v interface{}) (TodoInput, error) { return it, nil } -func (e *executableSchema) TodoInputMiddleware(ctx context.Context, obj *TodoInput) (*TodoInput, error) { - - return obj, nil -} - // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** @@ -2397,23 +2384,23 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func unmarshalBoolean2bool(v interface{}) (bool, error) { +func (e *executableSchema) unmarshalBoolean2bool(v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } -func unmarshalRole2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐRole(v interface{}) (Role, error) { +func (e *executableSchema) unmarshalRole2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐRole(v interface{}) (Role, error) { var res Role return res, res.UnmarshalGQL(v) } -func unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodoInput(v interface{}) (TodoInput, error) { - return unmarshalInputTodoInput(v) +func (e *executableSchema) unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodoInput(v interface{}) (TodoInput, error) { + return e.unmarshalInputTodoInput(v) } -func unmarshalInt2int(v interface{}) (int, error) { +func (e *executableSchema) unmarshalInt2int(v interface{}) (int, error) { return graphql.UnmarshalInt(v) } -func unmarshalMap2map(v interface{}) (map[string]interface{}, error) { +func (e *executableSchema) unmarshalMap2map(v interface{}) (map[string]interface{}, error) { return graphql.UnmarshalMap(v) } -func unmarshalString2string(v interface{}) (string, error) { +func (e *executableSchema) unmarshalString2string(v interface{}) (string, error) { return graphql.UnmarshalString(v) } diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index 93ba19e73e1..aec26931601 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -402,11 +402,10 @@ func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, args := map[string]interface{}{} var arg0 TodoInput if tmp, ok := rawArgs["todo"]; ok { - arg0, err = unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodoInput(tmp) + arg0, err = e.unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodoInput(tmp) if err != nil { return nil, err } - } args["todo"] = arg0 return args, nil @@ -417,11 +416,10 @@ func (e *executableSchema) field_MyQuery___type_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = unmarshalString2string(tmp) + arg0, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["name"] = arg0 return args, nil @@ -432,11 +430,10 @@ func (e *executableSchema) field_MyQuery_todo_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["id"]; ok { - arg0, err = unmarshalID2string(tmp) + arg0, err = e.unmarshalID2string(tmp) if err != nil { return nil, err } - } args["id"] = arg0 return args, nil @@ -447,11 +444,10 @@ func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, raw args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = unmarshalBoolean2bool(tmp) + arg0, err = e.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } - } args["includeDeprecated"] = arg0 return args, nil @@ -462,11 +458,10 @@ func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = unmarshalBoolean2bool(tmp) + arg0, err = e.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } - } args["includeDeprecated"] = arg0 return args, nil @@ -1972,7 +1967,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co // region **************************** input.gotpl ***************************** -func unmarshalInputTodoInput(v interface{}) (TodoInput, error) { +func (e *executableSchema) unmarshalInputTodoInput(v interface{}) (TodoInput, error) { var it TodoInput var asMap = v.(map[string]interface{}) @@ -1990,28 +1985,6 @@ func unmarshalInputTodoInput(v interface{}) (TodoInput, error) { return it, nil } -func (e *executableSchema) TodoInputMiddleware(ctx context.Context, obj *TodoInput) (*TodoInput, error) { - - cObj, err := chainFieldMiddleware( - []graphql.FieldMiddleware{ - func(ctx context.Context, n graphql.Resolver) (res interface{}, err error) { - return e.directives.InputLogging(ctx, obj, n) - }, - }..., - )(ctx, func(ctx context.Context) (interface{}, error) { - return obj, nil - }) - if err != nil || cObj == nil { - return nil, err - } - obj, ok := cObj.(*TodoInput) - if !ok { - return nil, errors.New("expect TodoInput") - } - - return obj, nil -} - // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** @@ -2418,16 +2391,16 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func unmarshalBoolean2bool(v interface{}) (bool, error) { +func (e *executableSchema) unmarshalBoolean2bool(v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } -func unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodoInput(v interface{}) (TodoInput, error) { - return unmarshalInputTodoInput(v) +func (e *executableSchema) unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodoInput(v interface{}) (TodoInput, error) { + return e.unmarshalInputTodoInput(v) } -func unmarshalID2string(v interface{}) (string, error) { +func (e *executableSchema) unmarshalID2string(v interface{}) (string, error) { return graphql.UnmarshalID(v) } -func unmarshalString2string(v interface{}) (string, error) { +func (e *executableSchema) unmarshalString2string(v interface{}) (string, error) { return graphql.UnmarshalString(v) } diff --git a/integration/generated.go b/integration/generated.go index bbe0853f30b..ce09e2eeff1 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -362,11 +362,10 @@ func (e *executableSchema) dir_magic_args(ctx context.Context, rawArgs map[strin args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["kind"]; ok { - arg0, err = unmarshalInt2ᚖint(tmp) + arg0, err = e.unmarshalInt2ᚖint(tmp) if err != nil { return nil, err } - } args["kind"] = arg0 return args, nil @@ -377,11 +376,10 @@ func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = unmarshalString2string(tmp) + arg0, err = e.unmarshalString2string(tmp) if err != nil { return nil, err } - } args["name"] = arg0 return args, nil @@ -392,11 +390,10 @@ func (e *executableSchema) field_Query_date_args(ctx context.Context, rawArgs ma args := map[string]interface{}{} var arg0 models.DateFilter if tmp, ok := rawArgs["filter"]; ok { - arg0, err = unmarshalDateFilter2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilter(tmp) + arg0, err = e.unmarshalDateFilter2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilter(tmp) if err != nil { return nil, err } - } args["filter"] = arg0 return args, nil @@ -407,11 +404,10 @@ func (e *executableSchema) field_Query_error_args(ctx context.Context, rawArgs m args := map[string]interface{}{} var arg0 *models.ErrorType if tmp, ok := rawArgs["type"]; ok { - arg0, err = unmarshalErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(tmp) + arg0, err = e.unmarshalErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(tmp) if err != nil { return nil, err } - } args["type"] = arg0 return args, nil @@ -422,11 +418,10 @@ func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, raw args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = unmarshalBoolean2bool(tmp) + arg0, err = e.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } - } args["includeDeprecated"] = arg0 return args, nil @@ -437,11 +432,10 @@ func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = unmarshalBoolean2bool(tmp) + arg0, err = e.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } - } args["includeDeprecated"] = arg0 return args, nil @@ -2073,7 +2067,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co // region **************************** input.gotpl ***************************** -func unmarshalInputDateFilter(v interface{}) (models.DateFilter, error) { +func (e *executableSchema) unmarshalInputDateFilter(v interface{}) (models.DateFilter, error) { var it models.DateFilter var asMap = v.(map[string]interface{}) @@ -2120,11 +2114,6 @@ func unmarshalInputDateFilter(v interface{}) (models.DateFilter, error) { return it, nil } -func (e *executableSchema) DateFilterMiddleware(ctx context.Context, obj *models.DateFilter) (*models.DateFilter, error) { - - return obj, nil -} - // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** @@ -2563,34 +2552,34 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func unmarshalErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(v interface{}) (*models.ErrorType, error) { +func (e *executableSchema) unmarshalErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(v interface{}) (*models.ErrorType, error) { if v == nil { return nil, nil } - res, err := unmarshalErrorType2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(v) + res, err := e.unmarshalErrorType2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(v) return &res, err } -func unmarshalInt2ᚖint(v interface{}) (*int, error) { +func (e *executableSchema) unmarshalInt2ᚖint(v interface{}) (*int, error) { if v == nil { return nil, nil } - res, err := unmarshalInt2int(v) + res, err := e.unmarshalInt2int(v) return &res, err } -func unmarshalBoolean2bool(v interface{}) (bool, error) { +func (e *executableSchema) unmarshalBoolean2bool(v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } -func unmarshalDateFilter2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilter(v interface{}) (models.DateFilter, error) { - return unmarshalInputDateFilter(v) +func (e *executableSchema) unmarshalDateFilter2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilter(v interface{}) (models.DateFilter, error) { + return e.unmarshalInputDateFilter(v) } -func unmarshalErrorType2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(v interface{}) (models.ErrorType, error) { +func (e *executableSchema) unmarshalErrorType2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(v interface{}) (models.ErrorType, error) { var res models.ErrorType return res, res.UnmarshalGQL(v) } -func unmarshalInt2int(v interface{}) (int, error) { +func (e *executableSchema) unmarshalInt2int(v interface{}) (int, error) { return graphql.UnmarshalInt(v) } -func unmarshalString2string(v interface{}) (string, error) { +func (e *executableSchema) unmarshalString2string(v interface{}) (string, error) { return graphql.UnmarshalString(v) } From b4c5a074b8250cb6470efbe18e5f2b028437fa37 Mon Sep 17 00:00:00 2001 From: Alex Sonneveld Date: Wed, 6 Feb 2019 10:28:07 +1100 Subject: [PATCH 064/147] Fix set header to JSON earlier in GraphQL response Update the GraphQL handler to set the Response Header to JSON earlier for error messages to be returned as JSON and not text/html. Fixes https://github.com/99designs/gqlgen/issues/519 == Notes: - Add checks for JSON Content-Type checks in decode bad queries tests --- handler/graphql.go | 2 +- handler/graphql_test.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/handler/graphql.go b/handler/graphql.go index e5e1bccd9c4..585897a9248 100644 --- a/handler/graphql.go +++ b/handler/graphql.go @@ -311,6 +311,7 @@ func (gh *graphqlHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } + w.Header().Set("Content-Type", "application/json") var reqParams params switch r.Method { case http.MethodGet: @@ -332,7 +333,6 @@ func (gh *graphqlHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusMethodNotAllowed) return } - w.Header().Set("Content-Type", "application/json") ctx := r.Context() diff --git a/handler/graphql_test.go b/handler/graphql_test.go index 377b773f901..4ea8cb58088 100644 --- a/handler/graphql_test.go +++ b/handler/graphql_test.go @@ -45,30 +45,35 @@ func TestHandlerPOST(t *testing.T) { t.Run("decode failure", func(t *testing.T) { resp := doRequest(h, "POST", "/graphql", "notjson") assert.Equal(t, http.StatusBadRequest, resp.Code) + assert.Equal(t, resp.HeaderMap.Get("Content-Type"), "application/json") assert.Equal(t, `{"errors":[{"message":"json body could not be decoded: invalid character 'o' in literal null (expecting 'u')"}],"data":null}`, resp.Body.String()) }) t.Run("parse failure", func(t *testing.T) { resp := doRequest(h, "POST", "/graphql", `{"query": "!"}`) assert.Equal(t, http.StatusUnprocessableEntity, resp.Code) + assert.Equal(t, resp.HeaderMap.Get("Content-Type"), "application/json") assert.Equal(t, `{"errors":[{"message":"Unexpected !","locations":[{"line":1,"column":1}]}],"data":null}`, resp.Body.String()) }) t.Run("validation failure", func(t *testing.T) { resp := doRequest(h, "POST", "/graphql", `{"query": "{ me { title }}"}`) assert.Equal(t, http.StatusUnprocessableEntity, resp.Code) + assert.Equal(t, resp.HeaderMap.Get("Content-Type"), "application/json") assert.Equal(t, `{"errors":[{"message":"Cannot query field \"title\" on type \"User\".","locations":[{"line":1,"column":8}]}],"data":null}`, resp.Body.String()) }) t.Run("invalid variable", func(t *testing.T) { resp := doRequest(h, "POST", "/graphql", `{"query": "query($id:Int!){user(id:$id){name}}","variables":{"id":false}}`) assert.Equal(t, http.StatusUnprocessableEntity, resp.Code) + assert.Equal(t, resp.HeaderMap.Get("Content-Type"), "application/json") assert.Equal(t, `{"errors":[{"message":"cannot use bool as Int","path":["variable","id"]}],"data":null}`, resp.Body.String()) }) t.Run("execution failure", func(t *testing.T) { resp := doRequest(h, "POST", "/graphql", `{"query": "mutation { me { name } }"}`) assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, resp.HeaderMap.Get("Content-Type"), "application/json") assert.Equal(t, `{"errors":[{"message":"mutations are not supported"}],"data":null}`, resp.Body.String()) }) } From cf94d3ba6a4a7cd513454a8cb4b250f1db68ee53 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Wed, 6 Feb 2019 10:59:23 +1100 Subject: [PATCH 065/147] Removed named types --- codegen/args.gotpl | 8 +- codegen/build_typedef.go | 116 -- codegen/config/binder.go | 41 +- codegen/config/config.go | 6 +- codegen/data.go | 27 +- codegen/field.go | 150 +- codegen/field.gotpl | 15 +- codegen/generated!.gotpl | 49 +- codegen/input.gotpl | 10 +- codegen/object.go | 18 +- codegen/object.gotpl | 15 +- codegen/testserver/generated.go | 1812 +++++++++---------- codegen/type.gotpl | 72 +- codegen/type_definition.go | 27 - codegen/type_reference.go | 154 -- example/chat/generated.go | 1002 +++++------ example/config/generated.go | 981 +++++----- example/dataloader/addressloader_gen.go | 23 +- example/dataloader/generated.go | 1316 ++++++-------- example/dataloader/itemsliceloader_gen.go | 23 +- example/dataloader/ordersliceloader_gen.go | 23 +- example/scalars/generated.go | 1098 ++++++------ example/selection/generated.go | 1013 +++++------ example/starwars/generated.go | 1864 ++++++++++---------- example/todo/generated.go | 1058 +++++------ example/type-system-extension/generated.go | 987 +++++------ integration/generated.go | 1158 ++++++------ plugin/modelgen/models.go | 2 +- 28 files changed, 5791 insertions(+), 7277 deletions(-) delete mode 100644 codegen/build_typedef.go delete mode 100644 codegen/type_definition.go delete mode 100644 codegen/type_reference.go diff --git a/codegen/args.gotpl b/codegen/args.gotpl index 2d7689bf79f..030b415510f 100644 --- a/codegen/args.gotpl +++ b/codegen/args.gotpl @@ -1,12 +1,12 @@ {{ range $name, $args := .Args }} -func (e *executableSchema) {{ $name }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) {{ $name }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} {{- range $i, $arg := . }} var arg{{$i}} {{ $arg.TypeReference.GO | ref}} if tmp, ok := rawArgs[{{$arg.Name|quote}}]; ok { {{- if $arg.Directives }} - getArg0 := func(ctx context.Context) (interface{}, error) { return e.unmarshal{{$arg.TypeReference.GQL.Name}}2{{ $arg.TypeReference.GO | ts }}(tmp) } + getArg0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshal{{$arg.TypeReference.GQL.Name}}2{{ $arg.TypeReference.GO | ts }}(tmp) } {{- range $i, $directive := $arg.Directives }} getArg{{add $i 1}} := func(ctx context.Context) (res interface{}, err error) { @@ -16,7 +16,7 @@ func (e *executableSchema) {{ $name }}(ctx context.Context, rawArgs map[string]i {{- end }} {{- end }} n := getArg{{$i}} - return e.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs "tmp" "n" }}) + return ec.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs "tmp" "n" }}) } {{- end }} @@ -30,7 +30,7 @@ func (e *executableSchema) {{ $name }}(ctx context.Context, rawArgs map[string]i return nil, fmt.Errorf(`unexpected type %T from directive, should be {{ $arg.TypeReference.GO }}`, tmp) } {{- else }} - arg{{$i}}, err = e.unmarshal{{$arg.TypeReference.GQL.Name}}2{{ $arg.TypeReference.GO | ts }}(tmp) + arg{{$i}}, err = ec.unmarshal{{$arg.TypeReference.GQL.Name}}2{{ $arg.TypeReference.GO | ts }}(tmp) if err != nil { return nil, err } diff --git a/codegen/build_typedef.go b/codegen/build_typedef.go deleted file mode 100644 index 3ac1b0241ba..00000000000 --- a/codegen/build_typedef.go +++ /dev/null @@ -1,116 +0,0 @@ -package codegen - -import ( - "fmt" - "go/types" - - "github.com/99designs/gqlgen/codegen/config" - "github.com/99designs/gqlgen/codegen/templates" - "github.com/99designs/gqlgen/internal/code" - "github.com/pkg/errors" - "github.com/vektah/gqlparser/ast" -) - -func (b *builder) buildTypeDef(schemaType *ast.Definition) (*TypeDefinition, error) { - t := &TypeDefinition{ - GQLDefinition: schemaType, - } - - var pkgName, typeName string - if userEntry, ok := b.Config.Models[t.GQLDefinition.Name]; ok && userEntry.Model != "" { - // special case for maps - if userEntry.Model == "map[string]interface{}" { - t.GoType = config.MapType - - return t, nil - } - - if userEntry.Model == "interface{}" { - t.GoType = config.InterfaceType - - return t, nil - } - - pkgName, typeName = code.PkgAndType(userEntry.Model) - if pkgName == "" { - return nil, fmt.Errorf("missing package name for %s", schemaType.Name) - } - - } else if t.GQLDefinition.Kind == ast.Scalar { - pkgName = "github.com/99designs/gqlgen/graphql" - typeName = "String" - } else { - // Missing models, but we need to set up the types so any references will point to the code that will - // get generated - t.GoType = types.NewNamed(types.NewTypeName(0, b.Config.Model.Pkg(), templates.ToCamel(t.GQLDefinition.Name), nil), nil, nil) - - if t.GQLDefinition.Kind != ast.Enum { - t.Unmarshaler = types.NewFunc(0, b.Config.Exec.Pkg(), "Unmarshal"+schemaType.Name, nil) - } - - return t, nil - } - - // External marshal functions - def, err := b.Binder.FindObject(pkgName, typeName) - if err != nil { - return nil, err - } - if f, isFunc := def.(*types.Func); isFunc { - sig := def.Type().(*types.Signature) - t.GoType = sig.Params().At(0).Type() - t.Marshaler = f - - unmarshal, err := b.Binder.FindObject(pkgName, "Unmarshal"+typeName) - if err != nil { - return nil, errors.Wrapf(err, "unable to find unmarshal func for %s.%s", pkgName, typeName) - } - t.Unmarshaler = unmarshal.(*types.Func) - return t, nil - } - - // Normal object binding - t.GoType = def.Type() - - namedType := def.Type().(*types.Named) - hasUnmarshal := false - for i := 0; i < namedType.NumMethods(); i++ { - switch namedType.Method(i).Name() { - case "UnmarshalGQL": - hasUnmarshal = true - } - } - - // Special case to reference generated unmarshal functions - if !hasUnmarshal { - t.Unmarshaler = types.NewFunc(0, b.Config.Exec.Pkg(), "e.unmarshalInput"+schemaType.Name, nil) - } - - return t, nil -} - -func (n NamedTypes) goTypeForAst(t *ast.Type) types.Type { - if t.Elem != nil { - return types.NewSlice(n.goTypeForAst(t.Elem)) - } - - nt := n[t.NamedType] - gt := nt.GoType - if gt == nil { - panic("missing type " + t.NamedType) - } - - if !t.NonNull && nt.GQLDefinition.Kind != ast.Interface { - return types.NewPointer(gt) - } - - return gt -} - -func (n NamedTypes) getType(t *ast.Type) *TypeReference { - return &TypeReference{ - Definition: n[t.Name()], - GoType: n.goTypeForAst(t), - ASTType: t, - } -} diff --git a/codegen/config/binder.go b/codegen/config/binder.go index 7781f11b794..29f23cfa8a4 100644 --- a/codegen/config/binder.go +++ b/codegen/config/binder.go @@ -145,6 +145,43 @@ func (t TypeReference) IsNamed() bool { return isSlice } +func (t TypeReference) IsScalar() bool { + return t.Definition.Kind == ast.Scalar +} + +func (t TypeReference) SelfMarshalling() bool { + it := t.GO + if ptr, isPtr := it.(*types.Pointer); isPtr { + it = ptr.Elem() + } + namedType, ok := it.(*types.Named) + if !ok { + return false + } + + for i := 0; i < namedType.NumMethods(); i++ { + switch namedType.Method(i).Name() { + case "MarshalGQL": + return true + } + } + return false +} + +func (t TypeReference) NeedsUnmarshaler() bool { + if t.Definition == nil { + panic(errors.New("Definition missing for " + t.GQL.Name())) + } + return t.Definition.IsInputType() +} + +func (t TypeReference) NeedsMarshaler() bool { + if t.Definition == nil { + panic(errors.New("Definition missing for " + t.GQL.Name())) + } + return t.Definition.Kind != ast.InputObject +} + func (b *Binder) PushRef(ret *TypeReference) { b.References = append(b.References, ret) } @@ -214,11 +251,11 @@ func (b *Binder) TypeReference(schemaType *ast.Type) (ret *TypeReference, err er // Special case to reference generated unmarshal functions if !hasUnmarshal { - ref.Unmarshaler = types.NewFunc(0, b.cfg.Exec.Pkg(), "e.unmarshalInput"+schemaType.Name(), nil) + ref.Unmarshaler = types.NewFunc(0, b.cfg.Exec.Pkg(), "ec.unmarshalInput"+schemaType.Name(), nil) } } - ref.GO = b.CopyModifiersFromAst(schemaType, true, ref.GO) + ref.GO = b.CopyModifiersFromAst(schemaType, def.Kind != ast.Interface, ref.GO) return ref, nil } diff --git a/codegen/config/config.go b/codegen/config/config.go index 5e07ef02ba8..4673c65c78f 100644 --- a/codegen/config/config.go +++ b/codegen/config/config.go @@ -230,10 +230,10 @@ func (tm TypeMap) ReferencedPackages() []string { return pkgs } -func (tm TypeMap) Add(gqlName string, goType string) { - modelCfg := tm[gqlName] +func (tm TypeMap) Add(Name string, goType string) { + modelCfg := tm[Name] modelCfg.Model = goType - tm[gqlName] = modelCfg + tm[Name] = modelCfg } func inStrSlice(haystack []string, needle string) bool { diff --git a/codegen/data.go b/codegen/data.go index eabd43f6062..e390f588bf2 100644 --- a/codegen/data.go +++ b/codegen/data.go @@ -2,7 +2,6 @@ package codegen import ( "fmt" - "go/types" "sort" "github.com/99designs/gqlgen/codegen/config" @@ -33,7 +32,6 @@ type builder struct { SchemaStr map[string]string Binder *config.Binder Directives map[string]*Directive - NamedTypes NamedTypes } func BuildData(cfg *config.Config) (*Data, error) { @@ -59,15 +57,6 @@ func BuildData(cfg *config.Config) (*Data, error) { return nil, err } - b.NamedTypes = NamedTypes{} - - for _, schemaType := range b.Schema.Types { - b.NamedTypes[schemaType.Name], err = b.buildTypeDef(schemaType) - if err != nil { - return nil, errors.Wrap(err, "unable to build type definition") - } - } - b.Directives, err = b.buildDirectives() if err != nil { return nil, err @@ -143,7 +132,7 @@ func (b *builder) injectIntrospectionRoots(s *Data) error { return fmt.Errorf("root query type must be defined") } - typeType, err := b.Binder.FindObject("github.com/99designs/gqlgen/graphql/introspection", "Type") + typeType, err := b.Binder.TypeReference(ast.NamedType("__Type", nil)) if err != nil { return errors.Wrap(err, "unable to find root Type introspection type") } @@ -153,8 +142,10 @@ func (b *builder) injectIntrospectionRoots(s *Data) error { } obj.Fields = append(obj.Fields, &Field{ - TypeReference: &TypeReference{b.NamedTypes["__Type"], types.NewPointer(typeType.Type()), ast.NamedType("__Schema", nil)}, - GQLName: "__type", + TypeReference: typeType, + FieldDefinition: &ast.FieldDefinition{ + Name: "__type", + }, GoFieldType: GoFieldMethod, GoReceiverName: "ec", GoFieldName: "introspectType", @@ -170,14 +161,16 @@ func (b *builder) injectIntrospectionRoots(s *Data) error { Object: obj, }) - schemaType, err := b.Binder.FindObject("github.com/99designs/gqlgen/graphql/introspection", "Schema") + schemaType, err := b.Binder.TypeReference(ast.NamedType("__Schema", nil)) if err != nil { return errors.Wrap(err, "unable to find root Schema introspection type") } obj.Fields = append(obj.Fields, &Field{ - TypeReference: &TypeReference{b.NamedTypes["__Schema"], types.NewPointer(schemaType.Type()), ast.NamedType("__Schema", nil)}, - GQLName: "__schema", + TypeReference: schemaType, + FieldDefinition: &ast.FieldDefinition{ + Name: "__schema", + }, GoFieldType: GoFieldMethod, GoReceiverName: "ec", GoFieldName: "introspectSchema", diff --git a/codegen/field.go b/codegen/field.go index 413ea3eb54c..057aa7265ac 100644 --- a/codegen/field.go +++ b/codegen/field.go @@ -7,6 +7,7 @@ import ( "strconv" "strings" + "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/codegen/templates" "github.com/99designs/gqlgen/internal/code" "github.com/pkg/errors" @@ -14,8 +15,9 @@ import ( ) type Field struct { - *TypeReference - GQLName string // The name of the field in graphql + *ast.FieldDefinition + + TypeReference *config.TypeReference GoFieldType GoFieldType // The field type in go, if any GoReceiverName string // The name of method & var receiver in go, if any GoFieldName string // The name of the method or var in go, if any @@ -34,14 +36,19 @@ func (b *builder) buildField(obj *Object, field *ast.FieldDefinition) (*Field, e return nil, err } + tr, err := b.Binder.TypeReference(field.Type) + if err != nil { + return nil, err + } + f := Field{ - GQLName: field.Name, - TypeReference: b.NamedTypes.getType(field.Type), - Object: obj, - Directives: dirs, - GoFieldName: templates.ToGo(field.Name), - GoFieldType: GoFieldVariable, - GoReceiverName: "obj", + FieldDefinition: field, + TypeReference: tr, + Object: obj, + Directives: dirs, + GoFieldName: templates.ToGo(field.Name), + GoFieldType: GoFieldVariable, + GoReceiverName: "obj", } if field.DefaultValue != nil { @@ -108,15 +115,15 @@ func (b *builder) bindMethod(t types.Type, field *Field) error { } result := sig.Results().At(0) - if err := code.CompatibleTypes(field.TypeReference.GoType, result.Type()); err != nil { - return errors.Wrapf(err, "%s is not compatible with %s", field.TypeReference.GoType.String(), result.String()) + if err = code.CompatibleTypes(field.TypeReference.GO, result.Type()); err != nil { + return errors.Wrapf(err, "%s is not compatible with %s", field.TypeReference.GO.String(), result.String()) } // success, args and return type match. Bind to method field.GoFieldType = GoFieldMethod field.GoReceiverName = "obj" field.GoFieldName = method.Name() - field.TypeReference.GoType = result.Type() + field.TypeReference.GO = result.Type() return nil } @@ -131,15 +138,15 @@ func (b *builder) bindVar(t types.Type, field *Field) error { return err } - if err := code.CompatibleTypes(field.TypeReference.GoType, structField.Type()); err != nil { - return errors.Wrapf(err, "%s is not compatible with %s", field.TypeReference.GoType.String(), field.TypeReference.GoType.String()) + if err = code.CompatibleTypes(field.TypeReference.GO, structField.Type()); err != nil { + return errors.Wrapf(err, "%s is not compatible with %s", field.TypeReference.GO.String(), field.TypeReference.GO.String()) } // success, bind to var field.GoFieldType = GoFieldVariable field.GoReceiverName = "obj" field.GoFieldName = structField.Name() - field.TypeReference.GoType = structField.Type() + field.TypeReference.GO = structField.Type() return nil } @@ -245,7 +252,7 @@ func (f *Field) HasDirectives() bool { } func (f *Field) IsReserved() bool { - return strings.HasPrefix(f.GQLName, "__") + return strings.HasPrefix(f.Name, "__") } func (f *Field) IsMethod() bool { @@ -264,7 +271,7 @@ func (f *Field) IsConcurrent() bool { } func (f *Field) GoNameUnexported() string { - return templates.ToGoPrivate(f.GQLName) + return templates.ToGoPrivate(f.Name) } func (f *Field) ShortInvocation() string { @@ -276,7 +283,7 @@ func (f *Field) ArgsFunc() string { return "" } - return "field_" + f.Object.Definition.Name + "_" + f.GQLName + "_args" + return "field_" + f.Object.Definition.Name + "_" + f.Name + "_args" } func (f *Field) ResolverType() string { @@ -300,7 +307,7 @@ func (f *Field) ShortResolverDeclaration() string { res += fmt.Sprintf(", %s %s", arg.VarName, templates.CurrentImports.LookupType(arg.TypeReference.GO)) } - result := templates.CurrentImports.LookupType(f.GoType) + result := templates.CurrentImports.LookupType(f.TypeReference.GO) if f.Object.Stream { result = "<-chan " + result } @@ -348,108 +355,3 @@ func (f *Field) CallArgs() string { return strings.Join(args, ", ") } - -// should be in the template, but its recursive and has a bunch of args -func (f *Field) WriteJson() string { - return f.doWriteJson("res", f.GoType, f.ASTType, false, 1) -} - -func (f *Field) doWriteJson(val string, destType types.Type, astType *ast.Type, isPtr bool, depth int) string { - switch destType := destType.(type) { - case *types.Pointer: - return tpl(` - if {{.val}} == nil { - {{- if .nonNull }} - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - {{- end }} - return graphql.Null - } - {{.next }}`, map[string]interface{}{ - "val": val, - "nonNull": astType.NonNull, - "next": f.doWriteJson(val, destType.Elem(), astType, true, depth+1), - }) - - case *types.Slice: - if isPtr { - val = "*" + val - } - var arr = "arr" + strconv.Itoa(depth) - var index = "idx" + strconv.Itoa(depth) - var usePtr bool - if !isPtr { - switch destType.Elem().(type) { - case *types.Pointer, *types.Array: - default: - usePtr = true - } - } - - return tpl(` - {{.arr}} := make(graphql.Array, len({{.val}})) - {{ if and .top (not .isScalar) }} var wg sync.WaitGroup {{ end }} - {{ if not .isScalar }} - isLen1 := len({{.val}}) == 1 - if !isLen1 { - wg.Add(len({{.val}})) - } - {{ end }} - for {{.index}} := range {{.val}} { - {{- if not .isScalar }} - {{.index}} := {{.index}} - rctx := &graphql.ResolverContext{ - Index: &{{.index}}, - Result: {{ if .usePtr }}&{{end}}{{.val}}[{{.index}}], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func({{.index}} int) { - if !isLen1 { - defer wg.Done() - } - {{.arr}}[{{.index}}] = func() graphql.Marshaler { - {{ .next }} - }() - } - if isLen1 { - f({{.index}}) - } else { - go f({{.index}}) - } - {{ else }} - {{.arr}}[{{.index}}] = func() graphql.Marshaler { - {{ .next }} - }() - {{- end}} - } - {{ if and .top (not .isScalar) }} wg.Wait() {{ end }} - return {{.arr}}`, map[string]interface{}{ - "val": val, - "arr": arr, - "index": index, - "top": depth == 1, - "arrayLen": len(val), - "isScalar": f.Definition.GQLDefinition.Kind == ast.Scalar || f.Definition.GQLDefinition.Kind == ast.Enum, - "usePtr": usePtr, - "next": f.doWriteJson(val+"["+index+"]", destType.Elem(), astType.Elem, false, depth+1), - }) - - default: - if f.Definition.GQLDefinition.Kind == ast.Scalar || f.Definition.GQLDefinition.Kind == ast.Enum { - if isPtr { - val = "*" + val - } - return f.Marshal(val) - } - - if !isPtr { - val = "&" + val - } - return tpl(` - return ec._{{.type}}(ctx, field.Selections, {{.val}})`, map[string]interface{}{ - "type": f.Definition.GQLDefinition.Name, - "val": val, - }) - } -} diff --git a/codegen/field.gotpl b/codegen/field.gotpl index 0a4792d0099..41617ed5574 100644 --- a/codegen/field.gotpl +++ b/codegen/field.gotpl @@ -1,7 +1,7 @@ {{- range $object := .Objects }}{{- range $field := $object.Fields }} {{- if $object.Stream }} - func (ec *executionContext) _{{$object.Name}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { + func (ec *executionContext) _{{$object.Name}}_{{$field.Name}}(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Field: field, Args: nil, @@ -31,16 +31,13 @@ w.Write([]byte{'{'}) graphql.MarshalString(field.Alias).MarshalGQL(w) w.Write([]byte{':'}) - func() graphql.Marshaler { - {{ $field.WriteJson }} - }().MarshalGQL(w) + ec.marshal{{ $field.TypeReference.Definition.Name }}2{{ $field.TypeReference.GO | ts }}(ctx, field.Selections, res).MarshalGQL(w) w.Write([]byte{'}'}) }) } } {{ else }} - // nolint: vetshadow - func (ec *executionContext) _{{$object.Name}}_{{$field.GQLName}}(ctx context.Context, field graphql.CollectedField{{ if not $object.Root }}, obj *{{$object.Type | ref}}{{end}}) graphql.Marshaler { + func (ec *executionContext) _{{$object.Name}}_{{$field.Name}}(ctx context.Context, field graphql.CollectedField{{ if not $object.Root }}, obj *{{$object.Type | ref}}{{end}}) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func () { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -74,17 +71,17 @@ {{- end }} }) if resTmp == nil { - {{- if $field.ASTType.NonNull }} + {{- if $field.TypeReference.GQL.NonNull }} if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } {{- end }} return graphql.Null } - res := resTmp.({{$field.GoType | ref}}) + res := resTmp.({{$field.TypeReference.GO | ref}}) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - {{ $field.WriteJson }} + return ec.marshal{{ $field.TypeReference.Definition.Name }}2{{ $field.TypeReference.GO | ts }}(ctx, field.Selections, res) } {{ end }} diff --git a/codegen/generated!.gotpl b/codegen/generated!.gotpl index 9f9f53be8b1..5833ee61c3e 100644 --- a/codegen/generated!.gotpl +++ b/codegen/generated!.gotpl @@ -48,7 +48,7 @@ type ComplexityRoot struct { {{ $object.Name|toCamel }} struct { {{ range $field := $object.Fields -}} {{ if not $field.IsReserved -}} - {{ $field.GQLName|toCamel }} {{ $field.ComplexitySignature }} + {{ $field.Name|toCamel }} {{ $field.ComplexitySignature }} {{ end }} {{- end }} } @@ -77,22 +77,24 @@ func (e *executableSchema) Schema() *ast.Schema { } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e} + _ = ec switch typeName + "." + field { {{ range $object := .Objects }} {{ if not $object.IsReserved }} {{ range $field := $object.Fields }} {{ if not $field.IsReserved }} - case "{{$object.Name}}.{{$field.GQLName}}": - if e.complexity.{{$object.Name|toCamel}}.{{$field.GQLName|toCamel}} == nil { + case "{{$object.Name}}.{{$field.Name}}": + if e.complexity.{{$object.Name|toCamel}}.{{$field.Name|toCamel}} == nil { break } {{ if $field.Args }} - args, err := e.{{ $field.ArgsFunc }}(context.TODO(),rawArgs) + args, err := ec.{{ $field.ArgsFunc }}(context.TODO(),rawArgs) if err != nil { return 0, false } {{ end }} - return e.complexity.{{$object.Name|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true + return e.complexity.{{$object.Name|toCamel}}.{{$field.Name|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true {{ end }} {{ end }} {{ end }} @@ -243,40 +245,3 @@ var parsedSchema = gqlparser.MustLoadSchema( &ast.Source{Name: {{$filename|quote}}, Input: {{$schema|rawQuote}}}, {{- end }} ) - - - -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) - - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err - - } - return handleFunc[0](ctx, chainHandler) - } - } - - if n == 1 { - return handleFunc[0] - } - - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) - } -} diff --git a/codegen/input.gotpl b/codegen/input.gotpl index 5a0d7c4158e..2c5efeb0039 100644 --- a/codegen/input.gotpl +++ b/codegen/input.gotpl @@ -1,12 +1,12 @@ {{- range $input := .Inputs }} {{- if not .HasUnmarshal }} - func (e *executableSchema) unmarshalInput{{ .Name }}(v interface{}) ({{.Type | ref}}, error) { + func (ec *executionContext) unmarshalInput{{ .Name }}(v interface{}) ({{.Type | ref}}, error) { var it {{.Type | ref}} var asMap = v.(map[string]interface{}) {{ range $field := .Fields}} {{- if $field.Default}} - if _, present := asMap[{{$field.GQLName|quote}}] ; !present { - asMap[{{$field.GQLName|quote}}] = {{ $field.Default | dump }} + if _, present := asMap[{{$field.Name|quote}}] ; !present { + asMap[{{$field.Name|quote}}] = {{ $field.Default | dump }} } {{- end}} {{- end }} @@ -14,9 +14,9 @@ for k, v := range asMap { switch k { {{- range $field := .Fields }} - case {{$field.GQLName|quote}}: + case {{$field.Name|quote}}: var err error - {{ $field.Unmarshal (print "it." $field.GoFieldName) "v" }} + it.{{$field.GoFieldName}}, err = ec.unmarshal{{$field.TypeReference.GQL.Name}}2{{ $field.TypeReference.GO | ts }}(v) if err != nil { return it, err } diff --git a/codegen/object.go b/codegen/object.go index 6d5cbe6487f..20e5533a375 100644 --- a/codegen/object.go +++ b/codegen/object.go @@ -1,16 +1,13 @@ package codegen import ( - "bytes" "go/types" "log" "strconv" "strings" - "text/template" "unicode" "github.com/99designs/gqlgen/codegen/config" - "github.com/99designs/gqlgen/codegen/templates" "github.com/pkg/errors" "github.com/vektah/gqlparser/ast" ) @@ -78,13 +75,13 @@ func (b *builder) buildObject(typ *ast.Definition) (*Object, error) { return nil, errors.Wrap(err, typ.Name+"."+field.Name) } - if typ.Kind == ast.InputObject && !f.TypeReference.Definition.GQLDefinition.IsInputType() { + if typ.Kind == ast.InputObject && !f.TypeReference.Definition.IsInputType() { return nil, errors.Errorf( "%s.%s: cannot use %s because %s is not a valid input type", typ.Name, field.Name, - f.Definition.GQLDefinition.Name, - f.TypeReference.Definition.GQLDefinition.Kind, + f.TypeReference.Definition.Name, + f.TypeReference.Definition.Kind, ) } @@ -190,15 +187,6 @@ func (os Objects) ByName(name string) *Object { return nil } -func tpl(tpl string, vars map[string]interface{}) string { - b := &bytes.Buffer{} - err := template.Must(template.New("inline").Funcs(templates.Funcs()).Parse(tpl)).Execute(b, vars) - if err != nil { - panic(err) - } - return b.String() -} - func ucFirst(s string) string { if s == "" { return "" diff --git a/codegen/object.gotpl b/codegen/object.gotpl index cb39699d0f8..8966ff77a05 100644 --- a/codegen/object.gotpl +++ b/codegen/object.gotpl @@ -2,7 +2,6 @@ var {{ $object.Name|lcFirst}}Implementors = {{$object.Implementors}} -// nolint: gocyclo, errcheck, gas, goconst {{- if .Stream }} func (ec *executionContext) _{{$object.Name}}(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, {{$object.Name|lcFirst}}Implementors) @@ -16,8 +15,8 @@ func (ec *executionContext) _{{$object.Name}}(ctx context.Context, sel ast.Selec switch fields[0].Name { {{- range $field := $object.Fields }} - case "{{$field.GQLName}}": - return ec._{{$object.Name}}_{{$field.GQLName}}(ctx, fields[0]) + case "{{$field.Name}}": + return ec._{{$object.Name}}_{{$field.Name}}(ctx, fields[0]) {{- end }} default: panic("unknown field " + strconv.Quote(fields[0].Name)) @@ -39,12 +38,12 @@ func (ec *executionContext) _{{$object.Name}}(ctx context.Context, sel ast.Selec case "__typename": out.Values[i] = graphql.MarshalString({{$object.Name|quote}}) {{- range $field := $object.Fields }} - case "{{$field.GQLName}}": + case "{{$field.Name}}": {{- if $field.IsConcurrent }} field := field out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._{{$object.Name}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}}) - {{- if $field.ASTType.NonNull }} + res = ec._{{$object.Name}}_{{$field.Name}}(ctx, field{{if not $object.Root}}, obj{{end}}) + {{- if $field.TypeReference.GQL.NonNull }} if res == graphql.Null { invalid = true } @@ -52,8 +51,8 @@ func (ec *executionContext) _{{$object.Name}}(ctx context.Context, sel ast.Selec return res }) {{- else }} - out.Values[i] = ec._{{$object.Name}}_{{$field.GQLName}}(ctx, field{{if not $object.Root}}, obj{{end}}) - {{- if $field.ASTType.NonNull }} + out.Values[i] = ec._{{$object.Name}}_{{$field.Name}}(ctx, field{{if not $object.Root}}, obj{{end}}) + {{- if $field.TypeReference.GQL.NonNull }} if out.Values[i] == graphql.Null { invalid = true } diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 1b79e555cc4..10749ed35e7 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -175,6 +175,8 @@ func (e *executableSchema) Schema() *ast.Schema { } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e} + _ = ec switch typeName + "." + field { case "Circle.radius": @@ -308,7 +310,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Query_mapInput_args(context.TODO(), rawArgs) + args, err := ec.field_Query_mapInput_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -320,7 +322,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Query_recursive_args(context.TODO(), rawArgs) + args, err := ec.field_Query_recursive_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -332,7 +334,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Query_nestedInputs_args(context.TODO(), rawArgs) + args, err := ec.field_Query_nestedInputs_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -351,7 +353,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Query_keywords_args(context.TODO(), rawArgs) + args, err := ec.field_Query_keywords_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -391,7 +393,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Query_user_args(context.TODO(), rawArgs) + args, err := ec.field_Query_user_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -403,7 +405,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Query_nullableArg_args(context.TODO(), rawArgs) + args, err := ec.field_Query_nullableArg_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -415,7 +417,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Query_directiveArg_args(context.TODO(), rawArgs) + args, err := ec.field_Query_directiveArg_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -427,7 +429,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Query_directiveNullableArg_args(context.TODO(), rawArgs) + args, err := ec.field_Query_directiveNullableArg_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -439,7 +441,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Query_directiveInputNullable_args(context.TODO(), rawArgs) + args, err := ec.field_Query_directiveInputNullable_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -451,7 +453,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Query_directiveInput_args(context.TODO(), rawArgs) + args, err := ec.field_Query_directiveInput_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -463,7 +465,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Query_keywordArgs_args(context.TODO(), rawArgs) + args, err := ec.field_Query_keywordArgs_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -820,51 +822,16 @@ enum Status { `}, ) -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) - - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err - - } - return handleFunc[0](ctx, chainHandler) - } - } - - if n == 1 { - return handleFunc[0] - } - - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) - } -} - // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** -func (e *executableSchema) dir_length_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) dir_length_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 int if tmp, ok := rawArgs["min"]; ok { - arg0, err = e.unmarshalInt2int(tmp) + arg0, err = ec.unmarshalInt2int(tmp) if err != nil { return nil, err } @@ -872,7 +839,7 @@ func (e *executableSchema) dir_length_args(ctx context.Context, rawArgs map[stri args["min"] = arg0 var arg1 *int if tmp, ok := rawArgs["max"]; ok { - arg1, err = e.unmarshalInt2ᚖint(tmp) + arg1, err = ec.unmarshalInt2ᚖint(tmp) if err != nil { return nil, err } @@ -880,7 +847,7 @@ func (e *executableSchema) dir_length_args(ctx context.Context, rawArgs map[stri args["max"] = arg1 var arg2 string if tmp, ok := rawArgs["message"]; ok { - arg2, err = e.unmarshalString2string(tmp) + arg2, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -889,12 +856,12 @@ func (e *executableSchema) dir_length_args(ctx context.Context, rawArgs map[stri return args, nil } -func (e *executableSchema) dir_range_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) dir_range_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["min"]; ok { - arg0, err = e.unmarshalInt2ᚖint(tmp) + arg0, err = ec.unmarshalInt2ᚖint(tmp) if err != nil { return nil, err } @@ -902,7 +869,7 @@ func (e *executableSchema) dir_range_args(ctx context.Context, rawArgs map[strin args["min"] = arg0 var arg1 *int if tmp, ok := rawArgs["max"]; ok { - arg1, err = e.unmarshalInt2ᚖint(tmp) + arg1, err = ec.unmarshalInt2ᚖint(tmp) if err != nil { return nil, err } @@ -910,7 +877,7 @@ func (e *executableSchema) dir_range_args(ctx context.Context, rawArgs map[strin args["max"] = arg1 var arg2 *string if tmp, ok := rawArgs["message"]; ok { - arg2, err = e.unmarshalString2ᚖstring(tmp) + arg2, err = ec.unmarshalString2ᚖstring(tmp) if err != nil { return nil, err } @@ -919,12 +886,12 @@ func (e *executableSchema) dir_range_args(ctx context.Context, rawArgs map[strin return args, nil } -func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = e.unmarshalString2string(tmp) + arg0, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -933,16 +900,16 @@ func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs return args, nil } -func (e *executableSchema) field_Query_directiveArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_directiveArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["arg"]; ok { - getArg0 := func(ctx context.Context) (interface{}, error) { return e.unmarshalString2string(tmp) } + getArg0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalString2string(tmp) } getArg1 := func(ctx context.Context) (res interface{}, err error) { max := 255 n := getArg0 - return e.directives.Length(ctx, tmp, n, 1, &max, "invalid length") + return ec.directives.Length(ctx, tmp, n, 1, &max, "invalid length") } tmp, err = getArg1(ctx) @@ -959,12 +926,12 @@ func (e *executableSchema) field_Query_directiveArg_args(ctx context.Context, ra return args, nil } -func (e *executableSchema) field_Query_directiveInputNullable_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_directiveInputNullable_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 *InputDirectives if tmp, ok := rawArgs["arg"]; ok { - arg0, err = e.unmarshalInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(tmp) + arg0, err = ec.unmarshalInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(tmp) if err != nil { return nil, err } @@ -973,12 +940,12 @@ func (e *executableSchema) field_Query_directiveInputNullable_args(ctx context.C return args, nil } -func (e *executableSchema) field_Query_directiveInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_directiveInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 InputDirectives if tmp, ok := rawArgs["arg"]; ok { - arg0, err = e.unmarshalInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(tmp) + arg0, err = ec.unmarshalInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(tmp) if err != nil { return nil, err } @@ -987,16 +954,16 @@ func (e *executableSchema) field_Query_directiveInput_args(ctx context.Context, return args, nil } -func (e *executableSchema) field_Query_directiveNullableArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_directiveNullableArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["arg"]; ok { - getArg0 := func(ctx context.Context) (interface{}, error) { return e.unmarshalInt2ᚖint(tmp) } + getArg0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalInt2ᚖint(tmp) } getArg1 := func(ctx context.Context) (res interface{}, err error) { min := 0 n := getArg0 - return e.directives.Range(ctx, tmp, n, &min, nil, nil) + return ec.directives.Range(ctx, tmp, n, &min, nil, nil) } tmp, err = getArg1(ctx) @@ -1012,11 +979,11 @@ func (e *executableSchema) field_Query_directiveNullableArg_args(ctx context.Con args["arg"] = arg0 var arg1 *int if tmp, ok := rawArgs["arg2"]; ok { - getArg0 := func(ctx context.Context) (interface{}, error) { return e.unmarshalInt2ᚖint(tmp) } + getArg0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalInt2ᚖint(tmp) } getArg1 := func(ctx context.Context) (res interface{}, err error) { min := 0 n := getArg0 - return e.directives.Range(ctx, tmp, n, &min, nil, nil) + return ec.directives.Range(ctx, tmp, n, &min, nil, nil) } tmp, err = getArg1(ctx) @@ -1033,12 +1000,12 @@ func (e *executableSchema) field_Query_directiveNullableArg_args(ctx context.Con return args, nil } -func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["break"]; ok { - arg0, err = e.unmarshalString2string(tmp) + arg0, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -1046,7 +1013,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["break"] = arg0 var arg1 string if tmp, ok := rawArgs["default"]; ok { - arg1, err = e.unmarshalString2string(tmp) + arg1, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -1054,7 +1021,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["default"] = arg1 var arg2 string if tmp, ok := rawArgs["func"]; ok { - arg2, err = e.unmarshalString2string(tmp) + arg2, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -1062,7 +1029,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["func"] = arg2 var arg3 string if tmp, ok := rawArgs["interface"]; ok { - arg3, err = e.unmarshalString2string(tmp) + arg3, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -1070,7 +1037,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["interface"] = arg3 var arg4 string if tmp, ok := rawArgs["select"]; ok { - arg4, err = e.unmarshalString2string(tmp) + arg4, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -1078,7 +1045,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["select"] = arg4 var arg5 string if tmp, ok := rawArgs["case"]; ok { - arg5, err = e.unmarshalString2string(tmp) + arg5, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -1086,7 +1053,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["case"] = arg5 var arg6 string if tmp, ok := rawArgs["defer"]; ok { - arg6, err = e.unmarshalString2string(tmp) + arg6, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -1094,7 +1061,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["defer"] = arg6 var arg7 string if tmp, ok := rawArgs["go"]; ok { - arg7, err = e.unmarshalString2string(tmp) + arg7, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -1102,7 +1069,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["go"] = arg7 var arg8 string if tmp, ok := rawArgs["map"]; ok { - arg8, err = e.unmarshalString2string(tmp) + arg8, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -1110,7 +1077,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["map"] = arg8 var arg9 string if tmp, ok := rawArgs["struct"]; ok { - arg9, err = e.unmarshalString2string(tmp) + arg9, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -1118,7 +1085,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["struct"] = arg9 var arg10 string if tmp, ok := rawArgs["chan"]; ok { - arg10, err = e.unmarshalString2string(tmp) + arg10, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -1126,7 +1093,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["chan"] = arg10 var arg11 string if tmp, ok := rawArgs["else"]; ok { - arg11, err = e.unmarshalString2string(tmp) + arg11, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -1134,7 +1101,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["else"] = arg11 var arg12 string if tmp, ok := rawArgs["goto"]; ok { - arg12, err = e.unmarshalString2string(tmp) + arg12, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -1142,7 +1109,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["goto"] = arg12 var arg13 string if tmp, ok := rawArgs["package"]; ok { - arg13, err = e.unmarshalString2string(tmp) + arg13, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -1150,7 +1117,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["package"] = arg13 var arg14 string if tmp, ok := rawArgs["switch"]; ok { - arg14, err = e.unmarshalString2string(tmp) + arg14, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -1158,7 +1125,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["switch"] = arg14 var arg15 string if tmp, ok := rawArgs["const"]; ok { - arg15, err = e.unmarshalString2string(tmp) + arg15, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -1166,7 +1133,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["const"] = arg15 var arg16 string if tmp, ok := rawArgs["fallthrough"]; ok { - arg16, err = e.unmarshalString2string(tmp) + arg16, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -1174,7 +1141,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["fallthrough"] = arg16 var arg17 string if tmp, ok := rawArgs["if"]; ok { - arg17, err = e.unmarshalString2string(tmp) + arg17, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -1182,7 +1149,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["if"] = arg17 var arg18 string if tmp, ok := rawArgs["range"]; ok { - arg18, err = e.unmarshalString2string(tmp) + arg18, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -1190,7 +1157,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["range"] = arg18 var arg19 string if tmp, ok := rawArgs["type"]; ok { - arg19, err = e.unmarshalString2string(tmp) + arg19, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -1198,7 +1165,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["type"] = arg19 var arg20 string if tmp, ok := rawArgs["continue"]; ok { - arg20, err = e.unmarshalString2string(tmp) + arg20, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -1206,7 +1173,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["continue"] = arg20 var arg21 string if tmp, ok := rawArgs["for"]; ok { - arg21, err = e.unmarshalString2string(tmp) + arg21, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -1214,7 +1181,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["for"] = arg21 var arg22 string if tmp, ok := rawArgs["import"]; ok { - arg22, err = e.unmarshalString2string(tmp) + arg22, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -1222,7 +1189,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["import"] = arg22 var arg23 string if tmp, ok := rawArgs["return"]; ok { - arg23, err = e.unmarshalString2string(tmp) + arg23, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -1230,7 +1197,7 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw args["return"] = arg23 var arg24 string if tmp, ok := rawArgs["var"]; ok { - arg24, err = e.unmarshalString2string(tmp) + arg24, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -1239,12 +1206,12 @@ func (e *executableSchema) field_Query_keywordArgs_args(ctx context.Context, raw return args, nil } -func (e *executableSchema) field_Query_keywords_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_keywords_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 *Keywords if tmp, ok := rawArgs["input"]; ok { - arg0, err = e.unmarshalKeywords2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(tmp) + arg0, err = ec.unmarshalKeywords2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(tmp) if err != nil { return nil, err } @@ -1253,12 +1220,12 @@ func (e *executableSchema) field_Query_keywords_args(ctx context.Context, rawArg return args, nil } -func (e *executableSchema) field_Query_mapInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_mapInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 map[string]interface{} if tmp, ok := rawArgs["input"]; ok { - arg0, err = e.unmarshalChanges2map(tmp) + arg0, err = ec.unmarshalChanges2map(tmp) if err != nil { return nil, err } @@ -1267,12 +1234,12 @@ func (e *executableSchema) field_Query_mapInput_args(ctx context.Context, rawArg return args, nil } -func (e *executableSchema) field_Query_nestedInputs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_nestedInputs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 [][]*OuterInput if tmp, ok := rawArgs["input"]; ok { - arg0, err = e.unmarshalOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(tmp) + arg0, err = ec.unmarshalOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(tmp) if err != nil { return nil, err } @@ -1281,12 +1248,12 @@ func (e *executableSchema) field_Query_nestedInputs_args(ctx context.Context, ra return args, nil } -func (e *executableSchema) field_Query_nullableArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_nullableArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["arg"]; ok { - arg0, err = e.unmarshalInt2ᚖint(tmp) + arg0, err = ec.unmarshalInt2ᚖint(tmp) if err != nil { return nil, err } @@ -1295,12 +1262,12 @@ func (e *executableSchema) field_Query_nullableArg_args(ctx context.Context, raw return args, nil } -func (e *executableSchema) field_Query_recursive_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_recursive_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 *RecursiveInputSlice if tmp, ok := rawArgs["input"]; ok { - arg0, err = e.unmarshalRecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(tmp) + arg0, err = ec.unmarshalRecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(tmp) if err != nil { return nil, err } @@ -1309,12 +1276,12 @@ func (e *executableSchema) field_Query_recursive_args(ctx context.Context, rawAr return args, nil } -func (e *executableSchema) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 int if tmp, ok := rawArgs["id"]; ok { - arg0, err = e.unmarshalInt2int(tmp) + arg0, err = ec.unmarshalInt2int(tmp) if err != nil { return nil, err } @@ -1323,12 +1290,12 @@ func (e *executableSchema) field_Query_user_args(ctx context.Context, rawArgs ma return args, nil } -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = e.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } @@ -1337,12 +1304,12 @@ func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, raw return args, nil } -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = e.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } @@ -1355,7 +1322,6 @@ func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs // region **************************** field.gotpl ***************************** -// nolint: vetshadow func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.CollectedField, obj *Circle) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1376,10 +1342,9 @@ func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.Co res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) + return ec.marshalFloat2float64(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.CollectedField, obj *Circle) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1400,10 +1365,9 @@ func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.Coll res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) + return ec.marshalFloat2float64(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _EmbeddedPointer_ID(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1424,10 +1388,9 @@ func (ec *executionContext) _EmbeddedPointer_ID(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _EmbeddedPointer_Title(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1448,10 +1411,9 @@ func (ec *executionContext) _EmbeddedPointer_Title(ctx context.Context, field gr res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Error_id(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1475,10 +1437,9 @@ func (ec *executionContext) _Error_id(ctx context.Context, field graphql.Collect res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + return ec.marshalID2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Error_errorOnNonRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1499,10 +1460,9 @@ func (ec *executionContext) _Error_errorOnNonRequiredField(ctx context.Context, res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1526,10 +1486,9 @@ func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, fie res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Error_nilOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1553,17 +1512,9 @@ func (ec *executionContext) _Error_nilOnRequiredField(ctx context.Context, field res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field graphql.CollectedField, obj *ForcedResolver) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1584,15 +1535,9 @@ func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field gra res := resTmp.(*Circle) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec._Circle(ctx, field.Selections, res) + return ec.marshalCircle2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCircle(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _InnerObject_id(ctx context.Context, field graphql.CollectedField, obj *InnerObject) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1616,10 +1561,9 @@ func (ec *executionContext) _InnerObject_id(ctx context.Context, field graphql.C res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) + return ec.marshalInt2int(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _InvalidIdentifier_id(ctx context.Context, field graphql.CollectedField, obj *invalid_packagename.InvalidIdentifier) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1643,10 +1587,9 @@ func (ec *executionContext) _InvalidIdentifier_id(ctx context.Context, field gra res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) + return ec.marshalInt2int(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedField, obj *introspection1.It) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1670,10 +1613,9 @@ func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedF res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + return ec.marshalID2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _ModelMethods_resolverField(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1697,10 +1639,9 @@ func (ec *executionContext) _ModelMethods_resolverField(ctx context.Context, fie res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _ModelMethods_noContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1724,10 +1665,9 @@ func (ec *executionContext) _ModelMethods_noContext(ctx context.Context, field g res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _ModelMethods_withContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1751,10 +1691,9 @@ func (ec *executionContext) _ModelMethods_withContext(ctx context.Context, field res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphql.CollectedField, obj *OuterObject) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1778,11 +1717,9 @@ func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphq res := resTmp.(InnerObject) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._InnerObject(ctx, field.Selections, &res) + return ec.marshalInnerObject2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerObject(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1803,15 +1740,9 @@ func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field res := resTmp.(*invalid_packagename.InvalidIdentifier) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec._InvalidIdentifier(ctx, field.Selections, res) + return ec.marshalInvalidIdentifier2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_collision(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1832,15 +1763,9 @@ func (ec *executionContext) _Query_collision(ctx context.Context, field graphql. res := resTmp.(*introspection1.It) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec._It(ctx, field.Selections, res) + return ec.marshalIt2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋintrospectionᚐIt(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1868,14 +1793,9 @@ func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.C res := resTmp.(*bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalBoolean(*res) + return ec.marshalBoolean2ᚖbool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1903,14 +1823,9 @@ func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql. res := resTmp.(*bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalBoolean(*res) + return ec.marshalBoolean2ᚖbool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1938,14 +1853,9 @@ func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graph res := resTmp.(*bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalBoolean(*res) + return ec.marshalBoolean2ᚖbool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1966,78 +1876,9 @@ func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field grap res := resTmp.([][]*OuterObject) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - arr2 := make(graphql.Array, len(res[idx1])) - - isLen1 := len(res[idx1]) == 1 - if !isLen1 { - wg.Add(len(res[idx1])) - } - - for idx2 := range res[idx1] { - idx2 := idx2 - rctx := &graphql.ResolverContext{ - Index: &idx2, - Result: res[idx1][idx2], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx2 int) { - if !isLen1 { - defer wg.Done() - } - arr2[idx2] = func() graphql.Marshaler { - - if res[idx1][idx2] == nil { - return graphql.Null - } - - return ec._OuterObject(ctx, field.Selections, res[idx1][idx2]) - }() - } - if isLen1 { - f(idx2) - } else { - go f(idx2) - } - - } - - return arr2 - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshalOuterObject2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_keywords(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2068,10 +1909,9 @@ func (ec *executionContext) _Query_keywords(ctx context.Context, field graphql.C res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2092,43 +1932,9 @@ func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.Col res := resTmp.([]Shape) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._Shape(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshalShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_errorBubble(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2149,15 +1955,9 @@ func (ec *executionContext) _Query_errorBubble(ctx context.Context, field graphq res := resTmp.(*Error) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec._Error(ctx, field.Selections, res) + return ec.marshalError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_modelMethods(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2178,15 +1978,9 @@ func (ec *executionContext) _Query_modelMethods(ctx context.Context, field graph res := resTmp.(*ModelMethods) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec._ModelMethods(ctx, field.Selections, res) + return ec.marshalModelMethods2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐModelMethods(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2210,10 +2004,9 @@ func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.Coll res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2244,11 +2037,9 @@ func (ec *executionContext) _Query_user(ctx context.Context, field graphql.Colle res := resTmp.(User) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._User(ctx, field.Selections, &res) + return ec.marshalUser2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_nullableArg(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2276,14 +2067,9 @@ func (ec *executionContext) _Query_nullableArg(ctx context.Context, field graphq res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_directiveArg(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2311,14 +2097,9 @@ func (ec *executionContext) _Query_directiveArg(ctx context.Context, field graph res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_directiveNullableArg(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2346,14 +2127,9 @@ func (ec *executionContext) _Query_directiveNullableArg(ctx context.Context, fie res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_directiveInputNullable(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2381,14 +2157,9 @@ func (ec *executionContext) _Query_directiveInputNullable(ctx context.Context, f res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_directiveInput(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2416,14 +2187,9 @@ func (ec *executionContext) _Query_directiveInput(ctx context.Context, field gra res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_keywordArgs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2454,10 +2220,9 @@ func (ec *executionContext) _Query_keywordArgs(ctx context.Context, field graphq res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2485,15 +2250,9 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2514,15 +2273,9 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Schema(ctx, field.Selections, res) + return ec.marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2543,10 +2296,9 @@ func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) + return ec.marshalFloat2float64(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2567,10 +2319,9 @@ func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql. res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) + return ec.marshalFloat2float64(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2591,7 +2342,7 @@ func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.C res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) + return ec.marshalFloat2float64(ctx, field.Selections, res) } func (ec *executionContext) _Subscription_updated(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { @@ -2616,9 +2367,7 @@ func (ec *executionContext) _Subscription_updated(ctx context.Context, field gra w.Write([]byte{'{'}) graphql.MarshalString(field.Alias).MarshalGQL(w) w.Write([]byte{':'}) - func() graphql.Marshaler { - return graphql.MarshalString(res) - }().MarshalGQL(w) + ec.marshalString2string(ctx, field.Selections, res).MarshalGQL(w) w.Write([]byte{'}'}) }) } @@ -2646,15 +2395,12 @@ func (ec *executionContext) _Subscription_initPayload(ctx context.Context, field w.Write([]byte{'{'}) graphql.MarshalString(field.Alias).MarshalGQL(w) w.Write([]byte{':'}) - func() graphql.Marshaler { - return graphql.MarshalString(res) - }().MarshalGQL(w) + ec.marshalString2string(ctx, field.Selections, res).MarshalGQL(w) w.Write([]byte{'}'}) }) } } -// nolint: vetshadow func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2678,10 +2424,9 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) + return ec.marshalInt2int(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _User_friends(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2705,43 +2450,9 @@ func (ec *executionContext) _User_friends(ctx context.Context, field graphql.Col res := resTmp.([]User) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._User(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshalUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2765,10 +2476,9 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2789,10 +2499,9 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2816,19 +2525,9 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 + return ec.marshal__DirectiveLocation2ᚕstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2852,43 +2551,9 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2912,10 +2577,9 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2936,10 +2600,9 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2963,10 +2626,9 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2987,14 +2649,9 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3018,10 +2675,9 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3042,10 +2698,9 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3069,43 +2724,9 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3129,18 +2750,9 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3164,10 +2776,9 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3188,14 +2799,9 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3219,10 +2825,9 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3243,10 +2848,9 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3270,18 +2874,9 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3302,14 +2897,9 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3333,43 +2923,9 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3393,18 +2949,9 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3425,15 +2972,9 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3454,15 +2995,9 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3486,50 +3021,16 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) +} - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Directive(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3546,10 +3047,9 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshal__TypeKind2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3570,14 +3070,9 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3598,10 +3093,9 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3629,43 +3123,9 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Field(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3686,43 +3146,9 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3743,43 +3169,9 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3807,43 +3199,9 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3864,43 +3222,9 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3921,19 +3245,14 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** -func (e *executableSchema) unmarshalInputInnerDirectives(v interface{}) (InnerDirectives, error) { +func (ec *executionContext) unmarshalInputInnerDirectives(v interface{}) (InnerDirectives, error) { var it InnerDirectives var asMap = v.(map[string]interface{}) @@ -3941,7 +3260,7 @@ func (e *executableSchema) unmarshalInputInnerDirectives(v interface{}) (InnerDi switch k { case "message": var err error - it.Message, err = graphql.UnmarshalString(v) + it.Message, err = ec.unmarshalString2string(v) if err != nil { return it, err } @@ -3951,7 +3270,7 @@ func (e *executableSchema) unmarshalInputInnerDirectives(v interface{}) (InnerDi return it, nil } -func (e *executableSchema) unmarshalInputInnerInput(v interface{}) (InnerInput, error) { +func (ec *executionContext) unmarshalInputInnerInput(v interface{}) (InnerInput, error) { var it InnerInput var asMap = v.(map[string]interface{}) @@ -3959,7 +3278,7 @@ func (e *executableSchema) unmarshalInputInnerInput(v interface{}) (InnerInput, switch k { case "id": var err error - it.ID, err = graphql.UnmarshalInt(v) + it.ID, err = ec.unmarshalInt2int(v) if err != nil { return it, err } @@ -3969,7 +3288,7 @@ func (e *executableSchema) unmarshalInputInnerInput(v interface{}) (InnerInput, return it, nil } -func (e *executableSchema) unmarshalInputInputDirectives(v interface{}) (InputDirectives, error) { +func (ec *executionContext) unmarshalInputInputDirectives(v interface{}) (InputDirectives, error) { var it InputDirectives var asMap = v.(map[string]interface{}) @@ -3977,24 +3296,19 @@ func (e *executableSchema) unmarshalInputInputDirectives(v interface{}) (InputDi switch k { case "text": var err error - it.Text, err = graphql.UnmarshalString(v) + it.Text, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "inner": var err error - it.Inner, err = e.unmarshalInputInnerDirectives(v) + it.Inner, err = ec.unmarshalInnerDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(v) if err != nil { return it, err } case "innerNullable": var err error - var ptr1 InnerDirectives - if v != nil { - ptr1, err = e.unmarshalInputInnerDirectives(v) - it.InnerNullable = &ptr1 - } - + it.InnerNullable, err = ec.unmarshalInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(v) if err != nil { return it, err } @@ -4004,7 +3318,7 @@ func (e *executableSchema) unmarshalInputInputDirectives(v interface{}) (InputDi return it, nil } -func (e *executableSchema) unmarshalInputKeywords(v interface{}) (Keywords, error) { +func (ec *executionContext) unmarshalInputKeywords(v interface{}) (Keywords, error) { var it Keywords var asMap = v.(map[string]interface{}) @@ -4012,151 +3326,151 @@ func (e *executableSchema) unmarshalInputKeywords(v interface{}) (Keywords, erro switch k { case "break": var err error - it.Break, err = graphql.UnmarshalString(v) + it.Break, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "default": var err error - it.Default, err = graphql.UnmarshalString(v) + it.Default, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "func": var err error - it.Func, err = graphql.UnmarshalString(v) + it.Func, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "interface": var err error - it.Interface, err = graphql.UnmarshalString(v) + it.Interface, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "select": var err error - it.Select, err = graphql.UnmarshalString(v) + it.Select, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "case": var err error - it.Case, err = graphql.UnmarshalString(v) + it.Case, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "defer": var err error - it.Defer, err = graphql.UnmarshalString(v) + it.Defer, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "go": var err error - it.Go, err = graphql.UnmarshalString(v) + it.Go, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "map": var err error - it.Map, err = graphql.UnmarshalString(v) + it.Map, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "struct": var err error - it.Struct, err = graphql.UnmarshalString(v) + it.Struct, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "chan": var err error - it.Chan, err = graphql.UnmarshalString(v) + it.Chan, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "else": var err error - it.Else, err = graphql.UnmarshalString(v) + it.Else, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "goto": var err error - it.Goto, err = graphql.UnmarshalString(v) + it.Goto, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "package": var err error - it.Package, err = graphql.UnmarshalString(v) + it.Package, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "switch": var err error - it.Switch, err = graphql.UnmarshalString(v) + it.Switch, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "const": var err error - it.Const, err = graphql.UnmarshalString(v) + it.Const, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "fallthrough": var err error - it.Fallthrough, err = graphql.UnmarshalString(v) + it.Fallthrough, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "if": var err error - it.If, err = graphql.UnmarshalString(v) + it.If, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "range": var err error - it.Range, err = graphql.UnmarshalString(v) + it.Range, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "type": var err error - it.Type, err = graphql.UnmarshalString(v) + it.Type, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "continue": var err error - it.Continue, err = graphql.UnmarshalString(v) + it.Continue, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "for": var err error - it.For, err = graphql.UnmarshalString(v) + it.For, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "import": var err error - it.Import, err = graphql.UnmarshalString(v) + it.Import, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "return": var err error - it.Return, err = graphql.UnmarshalString(v) + it.Return, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "var": var err error - it.Var, err = graphql.UnmarshalString(v) + it.Var, err = ec.unmarshalString2string(v) if err != nil { return it, err } @@ -4166,7 +3480,7 @@ func (e *executableSchema) unmarshalInputKeywords(v interface{}) (Keywords, erro return it, nil } -func (e *executableSchema) unmarshalInputOuterInput(v interface{}) (OuterInput, error) { +func (ec *executionContext) unmarshalInputOuterInput(v interface{}) (OuterInput, error) { var it OuterInput var asMap = v.(map[string]interface{}) @@ -4174,7 +3488,7 @@ func (e *executableSchema) unmarshalInputOuterInput(v interface{}) (OuterInput, switch k { case "inner": var err error - it.Inner, err = e.unmarshalInputInnerInput(v) + it.Inner, err = ec.unmarshalInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerInput(v) if err != nil { return it, err } @@ -4184,7 +3498,7 @@ func (e *executableSchema) unmarshalInputOuterInput(v interface{}) (OuterInput, return it, nil } -func (e *executableSchema) unmarshalInputRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { +func (ec *executionContext) unmarshalInputRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { var it RecursiveInputSlice var asMap = v.(map[string]interface{}) @@ -4192,18 +3506,7 @@ func (e *executableSchema) unmarshalInputRecursiveInputSlice(v interface{}) (Rec switch k { case "self": var err error - var rawIf1 []interface{} - if v != nil { - if tmp1, ok := v.([]interface{}); ok { - rawIf1 = tmp1 - } else { - rawIf1 = []interface{}{v} - } - } - it.Self = make([]RecursiveInputSlice, len(rawIf1)) - for idx1 := range rawIf1 { - it.Self[idx1], err = e.unmarshalInputRecursiveInputSlice(rawIf1[idx1]) - } + it.Self, err = ec.unmarshalRecursiveInputSlice2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v) if err != nil { return it, err } @@ -4249,7 +3552,6 @@ func (ec *executionContext) _ShapeUnion(ctx context.Context, sel ast.SelectionSe var circleImplementors = []string{"Circle", "Shape"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Circle(ctx context.Context, sel ast.SelectionSet, obj *Circle) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, circleImplementors) @@ -4276,7 +3578,6 @@ func (ec *executionContext) _Circle(ctx context.Context, sel ast.SelectionSet, o var embeddedPointerImplementors = []string{"EmbeddedPointer"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _EmbeddedPointer(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedPointerModel) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, embeddedPointerImplementors) @@ -4303,7 +3604,6 @@ func (ec *executionContext) _EmbeddedPointer(ctx context.Context, sel ast.Select var errorImplementors = []string{"Error"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Error(ctx context.Context, sel ast.SelectionSet, obj *Error) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, errorImplementors) @@ -4343,7 +3643,6 @@ func (ec *executionContext) _Error(ctx context.Context, sel ast.SelectionSet, ob var forcedResolverImplementors = []string{"ForcedResolver"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _ForcedResolver(ctx context.Context, sel ast.SelectionSet, obj *ForcedResolver) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, forcedResolverImplementors) @@ -4372,7 +3671,6 @@ func (ec *executionContext) _ForcedResolver(ctx context.Context, sel ast.Selecti var innerObjectImplementors = []string{"InnerObject"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _InnerObject(ctx context.Context, sel ast.SelectionSet, obj *InnerObject) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, innerObjectImplementors) @@ -4400,7 +3698,6 @@ func (ec *executionContext) _InnerObject(ctx context.Context, sel ast.SelectionS var invalidIdentifierImplementors = []string{"InvalidIdentifier"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _InvalidIdentifier(ctx context.Context, sel ast.SelectionSet, obj *invalid_packagename.InvalidIdentifier) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, invalidIdentifierImplementors) @@ -4428,7 +3725,6 @@ func (ec *executionContext) _InvalidIdentifier(ctx context.Context, sel ast.Sele var itImplementors = []string{"It"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _It(ctx context.Context, sel ast.SelectionSet, obj *introspection1.It) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, itImplementors) @@ -4456,7 +3752,6 @@ func (ec *executionContext) _It(ctx context.Context, sel ast.SelectionSet, obj * var modelMethodsImplementors = []string{"ModelMethods"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _ModelMethods(ctx context.Context, sel ast.SelectionSet, obj *ModelMethods) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, modelMethodsImplementors) @@ -4502,7 +3797,6 @@ func (ec *executionContext) _ModelMethods(ctx context.Context, sel ast.Selection var outerObjectImplementors = []string{"OuterObject"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _OuterObject(ctx context.Context, sel ast.SelectionSet, obj *OuterObject) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, outerObjectImplementors) @@ -4530,7 +3824,6 @@ func (ec *executionContext) _OuterObject(ctx context.Context, sel ast.SelectionS var queryImplementors = []string{"Query"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, queryImplementors) @@ -4681,7 +3974,6 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr var rectangleImplementors = []string{"Rectangle", "Shape"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Rectangle(ctx context.Context, sel ast.SelectionSet, obj *Rectangle) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, rectangleImplementors) @@ -4710,7 +4002,6 @@ func (ec *executionContext) _Rectangle(ctx context.Context, sel ast.SelectionSet var subscriptionImplementors = []string{"Subscription"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Subscription(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, subscriptionImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ @@ -4733,7 +4024,6 @@ func (ec *executionContext) _Subscription(ctx context.Context, sel ast.Selection var userImplementors = []string{"User"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *User) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, userImplementors) @@ -4770,7 +4060,6 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj var __DirectiveImplementors = []string{"__Directive"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) @@ -4810,7 +4099,6 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS var __EnumValueImplementors = []string{"__EnumValue"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) @@ -4847,7 +4135,6 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS var __FieldImplementors = []string{"__Field"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __FieldImplementors) @@ -4894,7 +4181,6 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, var __InputValueImplementors = []string{"__InputValue"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) @@ -4931,7 +4217,6 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection var __SchemaImplementors = []string{"__Schema"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) @@ -4973,7 +4258,6 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, var __TypeImplementors = []string{"__Type"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __TypeImplementors) @@ -5019,49 +4303,170 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (e *executableSchema) unmarshalInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v interface{}) (*InputDirectives, error) { +func (ec *executionContext) unmarshalBoolean2ᚖbool(v interface{}) (*bool, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalBoolean2bool(v) + return &res, err +} + +func (ec *executionContext) marshalBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.marshalBoolean2bool(ctx, sel, *v) +} + +func (ec *executionContext) marshalCircle2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCircle(ctx context.Context, sel ast.SelectionSet, v *Circle) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec._Circle(ctx, sel, v) +} + +func (ec *executionContext) marshalError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx context.Context, sel ast.SelectionSet, v *Error) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec._Error(ctx, sel, v) +} + +func (ec *executionContext) unmarshalInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(v interface{}) (*InnerDirectives, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInnerDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(v) + return &res, err +} + +func (ec *executionContext) unmarshalInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v interface{}) (*InputDirectives, error) { if v == nil { return nil, nil } - res, err := e.unmarshalInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v) + res, err := ec.unmarshalInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v) return &res, err } -func (e *executableSchema) unmarshalKeywords2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(v interface{}) (*Keywords, error) { + +func (ec *executionContext) unmarshalKeywords2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(v interface{}) (*Keywords, error) { if v == nil { return nil, nil } - res, err := e.unmarshalKeywords2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(v) + res, err := ec.unmarshalKeywords2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(v) return &res, err } -func (e *executableSchema) unmarshalOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) (*OuterInput, error) { + +func (ec *executionContext) marshalModelMethods2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐModelMethods(ctx context.Context, sel ast.SelectionSet, v *ModelMethods) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec._ModelMethods(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) (*OuterInput, error) { if v == nil { return nil, nil } - res, err := e.unmarshalOuterInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v) + res, err := ec.unmarshalOuterInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v) return &res, err } -func (e *executableSchema) unmarshalRecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v interface{}) (*RecursiveInputSlice, error) { + +func (ec *executionContext) marshalOuterObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v *OuterObject) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec._OuterObject(ctx, sel, v) +} + +func (ec *executionContext) unmarshalRecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v interface{}) (*RecursiveInputSlice, error) { if v == nil { return nil, nil } - res, err := e.unmarshalRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v) + res, err := ec.unmarshalRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v) return &res, err } -func (e *executableSchema) unmarshalInt2ᚖint(v interface{}) (*int, error) { + +func (ec *executionContext) marshalIt2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋintrospectionᚐIt(ctx context.Context, sel ast.SelectionSet, v *introspection1.It) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec._It(ctx, sel, v) +} + +func (ec *executionContext) marshalInvalidIdentifier2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx context.Context, sel ast.SelectionSet, v *invalid_packagename.InvalidIdentifier) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec._InvalidIdentifier(ctx, sel, v) +} + +func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.___Schema(ctx, sel, v) +} + +func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.___Type(ctx, sel, v) +} + +func (ec *executionContext) unmarshalInt2ᚖint(v interface{}) (*int, error) { if v == nil { return nil, nil } - res, err := e.unmarshalInt2int(v) + res, err := ec.unmarshalInt2int(v) return &res, err } -func (e *executableSchema) unmarshalString2ᚖstring(v interface{}) (*string, error) { + +func (ec *executionContext) marshalInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.marshalInt2int(ctx, sel, *v) +} + +func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := e.unmarshalString2string(v) + res, err := ec.unmarshalString2string(v) return &res, err } -func (e *executableSchema) unmarshalOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) ([]*OuterInput, error) { + +func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.marshalString2string(ctx, sel, *v) +} + +func (ec *executionContext) unmarshalOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) ([]*OuterInput, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -5073,14 +4478,47 @@ func (e *executableSchema) unmarshalOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋ var err error res := make([]*OuterInput, len(vSlice)) for i := range vSlice { - res[i], err = e.unmarshalOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(vSlice[i]) + res[i], err = ec.unmarshalOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(vSlice[i]) if err != nil { return nil, err } } return res, nil } -func (e *executableSchema) unmarshalOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) ([][]*OuterInput, error) { + +func (ec *executionContext) marshalOuterObject2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v []*OuterObject) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalOuterObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) unmarshalOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) ([][]*OuterInput, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -5092,36 +4530,506 @@ func (e *executableSchema) unmarshalOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designs var err error res := make([][]*OuterInput, len(vSlice)) for i := range vSlice { - res[i], err = e.unmarshalOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(vSlice[i]) + res[i], err = ec.unmarshalOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(vSlice[i]) if err != nil { return nil, err } } return res, nil } -func (e *executableSchema) unmarshalBoolean2bool(v interface{}) (bool, error) { - return graphql.UnmarshalBoolean(v) -} -func (e *executableSchema) unmarshalInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v interface{}) (InputDirectives, error) { - return e.unmarshalInputInputDirectives(v) -} -func (e *executableSchema) unmarshalKeywords2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(v interface{}) (Keywords, error) { - return e.unmarshalInputKeywords(v) -} -func (e *executableSchema) unmarshalOuterInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) (OuterInput, error) { - return e.unmarshalInputOuterInput(v) -} -func (e *executableSchema) unmarshalRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { - return e.unmarshalInputRecursiveInputSlice(v) -} -func (e *executableSchema) unmarshalInt2int(v interface{}) (int, error) { - return graphql.UnmarshalInt(v) -} -func (e *executableSchema) unmarshalChanges2map(v interface{}) (map[string]interface{}, error) { - return v.(map[string]interface{}), nil -} -func (e *executableSchema) unmarshalString2string(v interface{}) (string, error) { + +func (ec *executionContext) marshalOuterObject2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v [][]*OuterObject) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalOuterObject2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) unmarshalRecursiveInputSlice2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v interface{}) ([]RecursiveInputSlice, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]RecursiveInputSlice, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshalRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx context.Context, sel ast.SelectionSet, v []Shape) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshalUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx context.Context, sel ast.SelectionSet, v []User) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalUser2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshal__DirectiveLocation2string(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__DirectiveLocation2string(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) +} + +func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + + return graphql.MarshalBoolean(v) +} + +func (ec *executionContext) unmarshalFloat2float64(v interface{}) (float64, error) { + return graphql.UnmarshalFloat(v) +} + +func (ec *executionContext) marshalFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { + + return graphql.MarshalFloat(v) +} + +func (ec *executionContext) marshalCircle2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCircle(ctx context.Context, sel ast.SelectionSet, v Circle) graphql.Marshaler { + + return ec._Circle(ctx, sel, &v) +} + +func (ec *executionContext) marshalError2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx context.Context, sel ast.SelectionSet, v Error) graphql.Marshaler { + + return ec._Error(ctx, sel, &v) +} + +func (ec *executionContext) unmarshalInnerDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(v interface{}) (InnerDirectives, error) { + return ec.unmarshalInputInnerDirectives(v) +} + +func (ec *executionContext) unmarshalInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerInput(v interface{}) (InnerInput, error) { + return ec.unmarshalInputInnerInput(v) +} + +func (ec *executionContext) marshalInnerObject2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerObject(ctx context.Context, sel ast.SelectionSet, v InnerObject) graphql.Marshaler { + + return ec._InnerObject(ctx, sel, &v) +} + +func (ec *executionContext) unmarshalInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v interface{}) (InputDirectives, error) { + return ec.unmarshalInputInputDirectives(v) +} + +func (ec *executionContext) unmarshalKeywords2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(v interface{}) (Keywords, error) { + return ec.unmarshalInputKeywords(v) +} + +func (ec *executionContext) marshalModelMethods2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐModelMethods(ctx context.Context, sel ast.SelectionSet, v ModelMethods) graphql.Marshaler { + + return ec._ModelMethods(ctx, sel, &v) +} + +func (ec *executionContext) unmarshalOuterInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) (OuterInput, error) { + return ec.unmarshalInputOuterInput(v) +} + +func (ec *executionContext) marshalOuterObject2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v OuterObject) graphql.Marshaler { + + return ec._OuterObject(ctx, sel, &v) +} + +func (ec *executionContext) unmarshalRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { + return ec.unmarshalInputRecursiveInputSlice(v) +} + +func (ec *executionContext) marshalShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx context.Context, sel ast.SelectionSet, v Shape) graphql.Marshaler { + + return ec._Shape(ctx, sel, &v) +} + +func (ec *executionContext) marshalUser2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler { + + return ec._User(ctx, sel, &v) +} + +func (ec *executionContext) marshalIt2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋintrospectionᚐIt(ctx context.Context, sel ast.SelectionSet, v introspection1.It) graphql.Marshaler { + + return ec._It(ctx, sel, &v) +} + +func (ec *executionContext) marshalInvalidIdentifier2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx context.Context, sel ast.SelectionSet, v invalid_packagename.InvalidIdentifier) graphql.Marshaler { + + return ec._InvalidIdentifier(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { + + return ec.___Directive(ctx, sel, &v) +} + +func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { + + return ec.___EnumValue(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { + + return ec.___Field(ctx, sel, &v) +} + +func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { + + return ec.___InputValue(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { + + return ec.___Schema(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + + return ec.___Type(ctx, sel, &v) +} + +func (ec *executionContext) unmarshalInt2int(v interface{}) (int, error) { + return graphql.UnmarshalInt(v) +} + +func (ec *executionContext) marshalInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { + + return graphql.MarshalInt(v) +} + +func (ec *executionContext) unmarshalChanges2map(v interface{}) (map[string]interface{}, error) { + return v.(map[string]interface{}), nil +} + +func (ec *executionContext) unmarshalID2string(v interface{}) (string, error) { + return graphql.UnmarshalID(v) +} + +func (ec *executionContext) marshalID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalID(v) +} + +func (ec *executionContext) unmarshalString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) (string, error) { return graphql.UnmarshalString(v) } +func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + // endregion ***************************** type.gotpl ***************************** diff --git a/codegen/type.gotpl b/codegen/type.gotpl index 27e94d75ec9..c96bf844f6a 100644 --- a/codegen/type.gotpl +++ b/codegen/type.gotpl @@ -1,9 +1,9 @@ {{- range $type := .ReferencedTypes }} - {{- if $type.Definition.IsInputType }} - func (e *executableSchema) unmarshal{{ $type.Definition.Name }}2{{ $type.GO | ts }}(v interface{}) ({{ $type.GO | ref }}, error) { + {{ if $type.NeedsUnmarshaler }} + func (ec *executionContext) unmarshal{{ $type.Definition.Name }}2{{ $type.GO | ts }}(v interface{}) ({{ $type.GO | ref }}, error) { {{- if $type.IsPtr }} if v == nil { return nil, nil } - res, err := e.unmarshal{{ $type.Definition.Name }}2{{ $type.GO.Elem | ts }}(v) + res, err := ec.unmarshal{{ $type.Definition.Name }}2{{ $type.GO.Elem | ts }}(v) return &res, err {{- else if $type.IsSlice }} var vSlice []interface{} @@ -17,7 +17,7 @@ var err error res := make([]{{$type.GO.Elem | ref}}, len(vSlice)) for i := range vSlice { - res[i], err = e.unmarshal{{ $type.Definition.Name }}2{{ $type.GO.Elem | ts }}(vSlice[i]) + res[i], err = ec.unmarshal{{ $type.Definition.Name }}2{{ $type.GO.Elem | ts }}(vSlice[i]) if err != nil { return nil, err } @@ -35,4 +35,68 @@ {{- end }} } {{- end }} + + {{ if $type.NeedsMarshaler }} + func (ec *executionContext) marshal{{ $type.Definition.Name }}2{{ $type.GO | ts }}(ctx context.Context, sel ast.SelectionSet, v {{ $type.GO | ref }}) graphql.Marshaler { + {{- if $type.IsPtr }} + if v == nil { + {{- if $type.GQL.NonNull }} + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + {{- end }} + return graphql.Null + } + {{- end }} + + {{- if $type.SelfMarshalling }} + return v + {{- else if $type.IsSlice }} + ret := make(graphql.Array, len(v)) + {{- if not .IsScalar }} + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + {{- end }} + for i := range v { + {{- if not .IsScalar }} + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal{{ $type.Definition.Name }}2{{ $type.GO.Elem | ts }}(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + {{ else }} + ret[i] = ec.marshal{{ $type.Definition.Name }}2{{ $type.GO.Elem | ts }}(ctx, sel, v[i]) + {{- end}} + } + {{ if not .IsScalar }} wg.Wait() {{ end }} + return ret + {{- else }} + + {{- if $type.Marshaler }} + {{- if $type.IsPtr }} + return ec.marshal{{ $type.Definition.Name }}2{{ $type.GO.Elem | ts }}(ctx, sel, *v) + {{- else }} + return {{ $type.Marshaler | call }}(v) + {{- end }} + {{- else }} + return ec._{{$type.Definition.Name}}(ctx, sel, {{ if not $type.IsPtr}}&{{end}} v) + {{- end }} + {{- end }} + } + {{- end }} {{- end }} diff --git a/codegen/type_definition.go b/codegen/type_definition.go deleted file mode 100644 index 90655ea2e49..00000000000 --- a/codegen/type_definition.go +++ /dev/null @@ -1,27 +0,0 @@ -package codegen - -import ( - "go/types" - - "github.com/vektah/gqlparser/ast" -) - -type NamedTypes map[string]*TypeDefinition - -// TypeDefinition is the static reference to a graphql type. It can be referenced by many TypeReferences, -// and has one or more backing implementations in go. -type TypeDefinition struct { - GQLDefinition *ast.Definition - GoType types.Type // The backing go type, may be nil until after model generation - Marshaler *types.Func // When using external marshalling functions this will point to the Marshal function - Unmarshaler *types.Func // When using external marshalling functions this will point to the Unmarshal function -} - -func (t TypeDefinition) IsMarshaled() bool { - return t.Marshaler != nil || t.Unmarshaler != nil -} - -func (t TypeDefinition) IsEmptyInterface() bool { - i, isInterface := t.GoType.(*types.Interface) - return isInterface && i.NumMethods() == 0 -} diff --git a/codegen/type_reference.go b/codegen/type_reference.go deleted file mode 100644 index 107c62647f4..00000000000 --- a/codegen/type_reference.go +++ /dev/null @@ -1,154 +0,0 @@ -package codegen - -import ( - "go/types" - "strconv" - - "github.com/99designs/gqlgen/codegen/templates" - "github.com/vektah/gqlparser/ast" -) - -// TypeReference represents the type of a field or arg, referencing an underlying TypeDefinition (type, input, scalar) -type TypeReference struct { - Definition *TypeDefinition - - GoType types.Type - ASTType *ast.Type -} - -// todo @vektah: This should probably go away, its too easy to conflate gql required vs go pointer -func (t TypeReference) IsPtr() bool { - _, isPtr := t.GoType.(*types.Pointer) - return isPtr -} - -func (t TypeReference) Unmarshal(result, raw string) string { - return t.unmarshal(result, raw, t.GoType, 1) -} - -func (t TypeReference) unmarshal(result, raw string, destType types.Type, depth int) string { - switch destType := destType.(type) { - case *types.Pointer: - ptr := "ptr" + strconv.Itoa(depth) - return tpl(`var {{.ptr}} {{.destType | ref }} - if {{.raw}} != nil { - {{.next}} - {{.result}} = &{{.ptr -}} - } - `, map[string]interface{}{ - "ptr": ptr, - "t": t, - "raw": raw, - "result": result, - "destType": destType.Elem(), - "next": t.unmarshal(ptr, raw, destType.Elem(), depth+1), - }) - - case *types.Slice: - var rawIf = "rawIf" + strconv.Itoa(depth) - var index = "idx" + strconv.Itoa(depth) - - return tpl(`var {{.rawSlice}} []interface{} - if {{.raw}} != nil { - if tmp1, ok := {{.raw}}.([]interface{}); ok { - {{.rawSlice}} = tmp1 - } else { - {{.rawSlice}} = []interface{}{ {{.raw}} } - } - } - {{.result}} = make({{.destType | ref}}, len({{.rawSlice}})) - for {{.index}} := range {{.rawSlice}} { - {{ .next -}} - }`, map[string]interface{}{ - "raw": raw, - "rawSlice": rawIf, - "index": index, - "result": result, - "destType": destType, - "next": t.unmarshal(result+"["+index+"]", rawIf+"["+index+"]", destType.Elem(), depth+1), - }) - } - - realResult := result - - return tpl(` - {{- if eq (.t.Definition.GoType | ref) "map[string]interface{}" }} - {{- .result }} = {{.raw}}.(map[string]interface{}) - {{- else if .t.Definition.Unmarshaler }} - {{- .result }}, err = {{ .t.Definition.Unmarshaler | call }}({{.raw}}) - {{- else -}} - err = (&{{.result}}).UnmarshalGQL({{.raw}}) - {{- end }}`, map[string]interface{}{ - "realResult": realResult, - "result": result, - "raw": raw, - "t": t, - }) -} - -func (t TypeReference) Middleware(result, raw string) string { - return t.middleware(result, raw, t.GoType, 1) -} - -func (t TypeReference) middleware(result, raw string, destType types.Type, depth int) string { - switch destType := destType.(type) { - case *types.Pointer: - switch destType.Elem().(type) { - case *types.Pointer, *types.Slice: - return tpl(`if {{.raw}} != nil { - {{.next}} - }`, map[string]interface{}{ - "t": t, - "raw": raw, - "result": result, - "next": t.middleware(result, raw, destType.Elem(), depth+1), - }) - default: - return tpl(` - if {{.raw}} != nil { - var err error - {{.result}}, err = e.{{ .t.Definition.GQLDefinition.Name }}Middleware(ctx, {{.raw}}) - if err != nil { - return nil, err - } - }`, map[string]interface{}{ - "result": result, - "raw": raw, - "t": t, - }) - } - - case *types.Slice: - var index = "idx" + strconv.Itoa(depth) - - return tpl(`for {{.index}} := range {{.raw}} { - {{ .next -}} - }`, map[string]interface{}{ - "raw": raw, - "index": index, - "result": result, - "next": t.middleware(result+"["+index+"]", raw+"["+index+"]", destType.Elem(), depth+1), - }) - } - - ptr := "m" + t.Definition.GQLDefinition.Name + strconv.Itoa(depth) - return tpl(` - {{.ptr}}, err := e.{{ .t.Definition.GQLDefinition.Name }}Middleware(ctx, &{{.raw}}) - if err != nil { - return nil, err - } - {{ .result }} = *{{.ptr}}`, map[string]interface{}{ - "result": result, - "raw": raw, - "ptr": ptr, - "t": t, - }) -} - -func (t TypeReference) Marshal(val string) string { - if t.Definition.Marshaler != nil { - return "return " + templates.Call(t.Definition.Marshaler) + "(" + val + ")" - } - - return "return " + val -} diff --git a/example/chat/generated.go b/example/chat/generated.go index ba0e7013071..e2dbf7c4a7c 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -88,6 +88,8 @@ func (e *executableSchema) Schema() *ast.Schema { } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e} + _ = ec switch typeName + "." + field { case "Chatroom.name": @@ -137,7 +139,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Mutation_post_args(context.TODO(), rawArgs) + args, err := ec.field_Mutation_post_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -149,7 +151,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Query_room_args(context.TODO(), rawArgs) + args, err := ec.field_Query_room_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -161,7 +163,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Subscription_messageAdded_args(context.TODO(), rawArgs) + args, err := ec.field_Subscription_messageAdded_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -302,51 +304,16 @@ scalar Time `}, ) -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) - - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err - - } - return handleFunc[0](ctx, chainHandler) - } - } - - if n == 1 { - return handleFunc[0] - } - - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) - } -} - // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** -func (e *executableSchema) field_Mutation_post_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Mutation_post_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["text"]; ok { - arg0, err = e.unmarshalString2string(tmp) + arg0, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -354,7 +321,7 @@ func (e *executableSchema) field_Mutation_post_args(ctx context.Context, rawArgs args["text"] = arg0 var arg1 string if tmp, ok := rawArgs["username"]; ok { - arg1, err = e.unmarshalString2string(tmp) + arg1, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -362,7 +329,7 @@ func (e *executableSchema) field_Mutation_post_args(ctx context.Context, rawArgs args["username"] = arg1 var arg2 string if tmp, ok := rawArgs["roomName"]; ok { - arg2, err = e.unmarshalString2string(tmp) + arg2, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -371,12 +338,12 @@ func (e *executableSchema) field_Mutation_post_args(ctx context.Context, rawArgs return args, nil } -func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = e.unmarshalString2string(tmp) + arg0, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -385,12 +352,12 @@ func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs return args, nil } -func (e *executableSchema) field_Query_room_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_room_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = e.unmarshalString2string(tmp) + arg0, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -399,12 +366,12 @@ func (e *executableSchema) field_Query_room_args(ctx context.Context, rawArgs ma return args, nil } -func (e *executableSchema) field_Subscription_messageAdded_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Subscription_messageAdded_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["roomName"]; ok { - arg0, err = e.unmarshalString2string(tmp) + arg0, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -413,12 +380,12 @@ func (e *executableSchema) field_Subscription_messageAdded_args(ctx context.Cont return args, nil } -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = e.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } @@ -427,12 +394,12 @@ func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, raw return args, nil } -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = e.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } @@ -445,7 +412,6 @@ func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs // region **************************** field.gotpl ***************************** -// nolint: vetshadow func (ec *executionContext) _Chatroom_name(ctx context.Context, field graphql.CollectedField, obj *Chatroom) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -469,10 +435,9 @@ func (ec *executionContext) _Chatroom_name(ctx context.Context, field graphql.Co res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Chatroom_messages(ctx context.Context, field graphql.CollectedField, obj *Chatroom) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -496,43 +461,9 @@ func (ec *executionContext) _Chatroom_messages(ctx context.Context, field graphq res := resTmp.([]Message) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._Message(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshalMessage2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Message_id(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -556,10 +487,9 @@ func (ec *executionContext) _Message_id(ctx context.Context, field graphql.Colle res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + return ec.marshalID2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Message_text(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -583,10 +513,9 @@ func (ec *executionContext) _Message_text(ctx context.Context, field graphql.Col res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Message_createdBy(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -610,10 +539,9 @@ func (ec *executionContext) _Message_createdBy(ctx context.Context, field graphq res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Message_createdAt(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -637,10 +565,9 @@ func (ec *executionContext) _Message_createdAt(ctx context.Context, field graphq res := resTmp.(time.Time) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalTime(res) + return ec.marshalTime2timeᚐTime(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Mutation_post(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -671,11 +598,9 @@ func (ec *executionContext) _Mutation_post(ctx context.Context, field graphql.Co res := resTmp.(Message) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._Message(ctx, field.Selections, &res) + return ec.marshalMessage2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_room(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -703,15 +628,9 @@ func (ec *executionContext) _Query_room(ctx context.Context, field graphql.Colle res := resTmp.(*Chatroom) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec._Chatroom(ctx, field.Selections, res) + return ec.marshalChatroom2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐChatroom(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -739,15 +658,9 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -768,12 +681,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Schema(ctx, field.Selections, res) + return ec.marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } func (ec *executionContext) _Subscription_messageAdded(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { @@ -804,16 +712,12 @@ func (ec *executionContext) _Subscription_messageAdded(ctx context.Context, fiel w.Write([]byte{'{'}) graphql.MarshalString(field.Alias).MarshalGQL(w) w.Write([]byte{':'}) - func() graphql.Marshaler { - - return ec._Message(ctx, field.Selections, &res) - }().MarshalGQL(w) + ec.marshalMessage2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx, field.Selections, res).MarshalGQL(w) w.Write([]byte{'}'}) }) } } -// nolint: vetshadow func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -837,10 +741,9 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -861,10 +764,9 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -888,19 +790,9 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 + return ec.marshal__DirectiveLocation2ᚕstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -924,43 +816,9 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -984,10 +842,9 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1008,10 +865,9 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1035,10 +891,9 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1059,14 +914,9 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1090,10 +940,9 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1114,10 +963,9 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1141,43 +989,9 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1201,18 +1015,9 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1236,10 +1041,9 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1260,14 +1064,9 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1291,10 +1090,9 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1315,10 +1113,9 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1342,18 +1139,9 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1374,14 +1162,9 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1405,43 +1188,9 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1465,18 +1214,9 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1497,15 +1237,9 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1526,15 +1260,9 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1558,43 +1286,9 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Directive(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1618,10 +1312,9 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshal__TypeKind2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1642,14 +1335,9 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1670,10 +1358,9 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1701,43 +1388,9 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Field(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1758,43 +1411,9 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1815,43 +1434,9 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1879,43 +1464,9 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1936,43 +1487,9 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1993,12 +1510,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } // endregion **************************** field.gotpl ***************************** @@ -2015,7 +1527,6 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co var chatroomImplementors = []string{"Chatroom"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Chatroom(ctx context.Context, sel ast.SelectionSet, obj *Chatroom) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, chatroomImplementors) @@ -2048,7 +1559,6 @@ func (ec *executionContext) _Chatroom(ctx context.Context, sel ast.SelectionSet, var messageImplementors = []string{"Message"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Message(ctx context.Context, sel ast.SelectionSet, obj *Message) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, messageImplementors) @@ -2091,7 +1601,6 @@ func (ec *executionContext) _Message(ctx context.Context, sel ast.SelectionSet, var mutationImplementors = []string{"Mutation"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, mutationImplementors) @@ -2123,7 +1632,6 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) var queryImplementors = []string{"Query"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, queryImplementors) @@ -2160,7 +1668,6 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr var subscriptionImplementors = []string{"Subscription"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Subscription(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, subscriptionImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ @@ -2181,7 +1688,6 @@ func (ec *executionContext) _Subscription(ctx context.Context, sel ast.Selection var __DirectiveImplementors = []string{"__Directive"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) @@ -2221,7 +1727,6 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS var __EnumValueImplementors = []string{"__EnumValue"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) @@ -2258,7 +1763,6 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS var __FieldImplementors = []string{"__Field"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __FieldImplementors) @@ -2305,7 +1809,6 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, var __InputValueImplementors = []string{"__InputValue"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) @@ -2342,7 +1845,6 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection var __SchemaImplementors = []string{"__Schema"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) @@ -2384,7 +1886,6 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, var __TypeImplementors = []string{"__Type"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __TypeImplementors) @@ -2430,11 +1931,386 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (e *executableSchema) unmarshalBoolean2bool(v interface{}) (bool, error) { +func (ec *executionContext) marshalChatroom2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐChatroom(ctx context.Context, sel ast.SelectionSet, v *Chatroom) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec._Chatroom(ctx, sel, v) +} + +func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.___Schema(ctx, sel, v) +} + +func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.___Type(ctx, sel, v) +} + +func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalString2string(v) + return &res, err +} + +func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.marshalString2string(ctx, sel, *v) +} + +func (ec *executionContext) marshalMessage2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx context.Context, sel ast.SelectionSet, v []Message) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalMessage2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshal__DirectiveLocation2string(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__DirectiveLocation2string(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } -func (e *executableSchema) unmarshalString2string(v interface{}) (string, error) { + +func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + + return graphql.MarshalBoolean(v) +} + +func (ec *executionContext) marshalChatroom2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐChatroom(ctx context.Context, sel ast.SelectionSet, v Chatroom) graphql.Marshaler { + + return ec._Chatroom(ctx, sel, &v) +} + +func (ec *executionContext) marshalMessage2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx context.Context, sel ast.SelectionSet, v Message) graphql.Marshaler { + + return ec._Message(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { + + return ec.___Directive(ctx, sel, &v) +} + +func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { + + return ec.___EnumValue(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { + + return ec.___Field(ctx, sel, &v) +} + +func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { + + return ec.___InputValue(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { + + return ec.___Schema(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + + return ec.___Type(ctx, sel, &v) +} + +func (ec *executionContext) unmarshalID2string(v interface{}) (string, error) { + return graphql.UnmarshalID(v) +} + +func (ec *executionContext) marshalID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalID(v) +} + +func (ec *executionContext) unmarshalString2string(v interface{}) (string, error) { return graphql.UnmarshalString(v) } +func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalTime2timeᚐTime(v interface{}) (time.Time, error) { + return graphql.UnmarshalTime(v) +} + +func (ec *executionContext) marshalTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { + + return graphql.MarshalTime(v) +} + // endregion ***************************** type.gotpl ***************************** diff --git a/example/config/generated.go b/example/config/generated.go index 81687954215..3de72488f4f 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -83,6 +83,8 @@ func (e *executableSchema) Schema() *ast.Schema { } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e} + _ = ec switch typeName + "." + field { case "Mutation.createTodo": @@ -90,7 +92,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Mutation_createTodo_args(context.TODO(), rawArgs) + args, err := ec.field_Mutation_createTodo_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -259,51 +261,16 @@ input NewTodo { `}, ) -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) - - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err - - } - return handleFunc[0](ctx, chainHandler) - } - } - - if n == 1 { - return handleFunc[0] - } - - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) - } -} - // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** -func (e *executableSchema) field_Mutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Mutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 NewTodo if tmp, ok := rawArgs["input"]; ok { - arg0, err = e.unmarshalNewTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐNewTodo(tmp) + arg0, err = ec.unmarshalNewTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐNewTodo(tmp) if err != nil { return nil, err } @@ -312,12 +279,12 @@ func (e *executableSchema) field_Mutation_createTodo_args(ctx context.Context, r return args, nil } -func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = e.unmarshalString2string(tmp) + arg0, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -326,12 +293,12 @@ func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs return args, nil } -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = e.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } @@ -340,12 +307,12 @@ func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, raw return args, nil } -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = e.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } @@ -358,7 +325,6 @@ func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs // region **************************** field.gotpl ***************************** -// nolint: vetshadow func (ec *executionContext) _Mutation_createTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -389,11 +355,9 @@ func (ec *executionContext) _Mutation_createTodo(ctx context.Context, field grap res := resTmp.(Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._Todo(ctx, field.Selections, &res) + return ec.marshalTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐTodo(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -417,43 +381,9 @@ func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.Coll res := resTmp.([]Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._Todo(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐTodo(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -481,15 +411,9 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -510,15 +434,9 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Schema(ctx, field.Selections, res) + return ec.marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -542,10 +460,9 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + return ec.marshalID2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Todo_databaseId(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -569,10 +486,9 @@ func (ec *executionContext) _Todo_databaseId(ctx context.Context, field graphql. res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) + return ec.marshalInt2int(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -596,10 +512,9 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -623,10 +538,9 @@ func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.Collec res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -650,11 +564,9 @@ func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.Collec res := resTmp.(User) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._User(ctx, field.Selections, &res) + return ec.marshalUser2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐUser(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -678,10 +590,9 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + return ec.marshalID2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -705,10 +616,9 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -732,10 +642,9 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -756,10 +665,9 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -783,19 +691,9 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 + return ec.marshal__DirectiveLocation2ᚕstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -819,43 +717,9 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -879,10 +743,9 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -903,10 +766,9 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -930,10 +792,9 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -954,14 +815,9 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -985,10 +841,9 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1009,10 +864,9 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1036,43 +890,9 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1096,18 +916,9 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1131,10 +942,9 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1155,14 +965,9 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1186,10 +991,9 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1210,10 +1014,9 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1237,18 +1040,9 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1269,14 +1063,9 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1300,43 +1089,9 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1360,18 +1115,9 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1392,15 +1138,9 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1421,15 +1161,9 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1453,43 +1187,9 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Directive(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1513,10 +1213,9 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshal__TypeKind2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1537,14 +1236,9 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1565,10 +1259,9 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1596,43 +1289,9 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Field(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1653,43 +1312,9 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1710,43 +1335,9 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1774,43 +1365,9 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1831,43 +1388,9 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1888,19 +1411,14 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** -func (e *executableSchema) unmarshalInputNewTodo(v interface{}) (NewTodo, error) { +func (ec *executionContext) unmarshalInputNewTodo(v interface{}) (NewTodo, error) { var it NewTodo var asMap = v.(map[string]interface{}) @@ -1908,13 +1426,13 @@ func (e *executableSchema) unmarshalInputNewTodo(v interface{}) (NewTodo, error) switch k { case "text": var err error - it.Text, err = graphql.UnmarshalString(v) + it.Text, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "userId": var err error - it.UserID, err = graphql.UnmarshalString(v) + it.UserID, err = ec.unmarshalString2string(v) if err != nil { return it, err } @@ -1934,7 +1452,6 @@ func (e *executableSchema) unmarshalInputNewTodo(v interface{}) (NewTodo, error) var mutationImplementors = []string{"Mutation"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, mutationImplementors) @@ -1966,7 +1483,6 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) var queryImplementors = []string{"Query"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, queryImplementors) @@ -2006,7 +1522,6 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr var todoImplementors = []string{"Todo"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, todoImplementors) @@ -2058,7 +1573,6 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj var userImplementors = []string{"User"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *User) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, userImplementors) @@ -2091,7 +1605,6 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj var __DirectiveImplementors = []string{"__Directive"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) @@ -2131,7 +1644,6 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS var __EnumValueImplementors = []string{"__EnumValue"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) @@ -2168,7 +1680,6 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS var __FieldImplementors = []string{"__Field"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __FieldImplementors) @@ -2215,7 +1726,6 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, var __InputValueImplementors = []string{"__InputValue"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) @@ -2252,7 +1762,6 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection var __SchemaImplementors = []string{"__Schema"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) @@ -2294,7 +1803,6 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, var __TypeImplementors = []string{"__Type"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __TypeImplementors) @@ -2340,14 +1848,381 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (e *executableSchema) unmarshalBoolean2bool(v interface{}) (bool, error) { +func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.___Schema(ctx, sel, v) +} + +func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.___Type(ctx, sel, v) +} + +func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalString2string(v) + return &res, err +} + +func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.marshalString2string(ctx, sel, *v) +} + +func (ec *executionContext) marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐTodo(ctx context.Context, sel ast.SelectionSet, v []Todo) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐTodo(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshal__DirectiveLocation2string(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__DirectiveLocation2string(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } -func (e *executableSchema) unmarshalNewTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐNewTodo(v interface{}) (NewTodo, error) { - return e.unmarshalInputNewTodo(v) + +func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + + return graphql.MarshalBoolean(v) +} + +func (ec *executionContext) unmarshalNewTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐNewTodo(v interface{}) (NewTodo, error) { + return ec.unmarshalInputNewTodo(v) +} + +func (ec *executionContext) marshalTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { + + return ec._Todo(ctx, sel, &v) } -func (e *executableSchema) unmarshalString2string(v interface{}) (string, error) { + +func (ec *executionContext) marshalUser2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler { + + return ec._User(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { + + return ec.___Directive(ctx, sel, &v) +} + +func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { + + return ec.___EnumValue(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { + + return ec.___Field(ctx, sel, &v) +} + +func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { + + return ec.___InputValue(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { + + return ec.___Schema(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + + return ec.___Type(ctx, sel, &v) +} + +func (ec *executionContext) unmarshalInt2int(v interface{}) (int, error) { + return graphql.UnmarshalInt(v) +} + +func (ec *executionContext) marshalInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { + + return graphql.MarshalInt(v) +} + +func (ec *executionContext) unmarshalID2string(v interface{}) (string, error) { + return graphql.UnmarshalID(v) +} + +func (ec *executionContext) marshalID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalID(v) +} + +func (ec *executionContext) unmarshalString2string(v interface{}) (string, error) { return graphql.UnmarshalString(v) } +func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + // endregion ***************************** type.gotpl ***************************** diff --git a/example/dataloader/addressloader_gen.go b/example/dataloader/addressloader_gen.go index 90e1d433fc5..0465446faa7 100644 --- a/example/dataloader/addressloader_gen.go +++ b/example/dataloader/addressloader_gen.go @@ -1,4 +1,4 @@ -// Code generated by github.com/vektah/dataloaden, DO NOT EDIT. +// generated by github.com/vektah/dataloaden ; DO NOT EDIT package dataloader @@ -7,27 +7,6 @@ import ( "time" ) -// AddressLoaderConfig captures the config to create a new AddressLoader -type AddressLoaderConfig struct { - // Fetch is a method that provides the data for the loader - Fetch func(keys []int) ([]*Address, []error) - - // Wait is how long wait before sending a batch - Wait time.Duration - - // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit - MaxBatch int -} - -// NewAddressLoader creates a new AddressLoader given a fetch, wait, and maxBatch -func NewAddressLoader(config AddressLoaderConfig) *AddressLoader { - return &AddressLoader{ - fetch: config.Fetch, - wait: config.Wait, - maxBatch: config.MaxBatch, - } -} - // AddressLoader batches and caches requests type AddressLoader struct { // this method provides the data for the loader diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index 27aae23e17b..b467524125f 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -96,6 +96,8 @@ func (e *executableSchema) Schema() *ast.Schema { } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e} + _ = ec switch typeName + "." + field { case "Address.id": @@ -194,7 +196,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Query_torture1d_args(context.TODO(), rawArgs) + args, err := ec.field_Query_torture1d_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -206,7 +208,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Query_torture2d_args(context.TODO(), rawArgs) + args, err := ec.field_Query_torture2d_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -312,51 +314,16 @@ scalar Time `}, ) -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) - - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err - - } - return handleFunc[0](ctx, chainHandler) - } - } - - if n == 1 { - return handleFunc[0] - } - - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) - } -} - // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** -func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = e.unmarshalString2string(tmp) + arg0, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -365,12 +332,12 @@ func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs return args, nil } -func (e *executableSchema) field_Query_torture1d_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_torture1d_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 []int if tmp, ok := rawArgs["customerIds"]; ok { - arg0, err = e.unmarshalInt2ᚕint(tmp) + arg0, err = ec.unmarshalInt2ᚕint(tmp) if err != nil { return nil, err } @@ -379,12 +346,12 @@ func (e *executableSchema) field_Query_torture1d_args(ctx context.Context, rawAr return args, nil } -func (e *executableSchema) field_Query_torture2d_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_torture2d_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 [][]int if tmp, ok := rawArgs["customerIds"]; ok { - arg0, err = e.unmarshalInt2ᚕᚕint(tmp) + arg0, err = ec.unmarshalInt2ᚕᚕint(tmp) if err != nil { return nil, err } @@ -393,12 +360,12 @@ func (e *executableSchema) field_Query_torture2d_args(ctx context.Context, rawAr return args, nil } -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = e.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } @@ -407,12 +374,12 @@ func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, raw return args, nil } -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = e.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } @@ -425,7 +392,6 @@ func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs // region **************************** field.gotpl ***************************** -// nolint: vetshadow func (ec *executionContext) _Address_id(ctx context.Context, field graphql.CollectedField, obj *Address) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -449,10 +415,9 @@ func (ec *executionContext) _Address_id(ctx context.Context, field graphql.Colle res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) + return ec.marshalInt2int(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Address_street(ctx context.Context, field graphql.CollectedField, obj *Address) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -476,10 +441,9 @@ func (ec *executionContext) _Address_street(ctx context.Context, field graphql.C res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Address_country(ctx context.Context, field graphql.CollectedField, obj *Address) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -503,10 +467,9 @@ func (ec *executionContext) _Address_country(ctx context.Context, field graphql. res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Customer_id(ctx context.Context, field graphql.CollectedField, obj *Customer) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -530,10 +493,9 @@ func (ec *executionContext) _Customer_id(ctx context.Context, field graphql.Coll res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) + return ec.marshalInt2int(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Customer_name(ctx context.Context, field graphql.CollectedField, obj *Customer) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -557,10 +519,9 @@ func (ec *executionContext) _Customer_name(ctx context.Context, field graphql.Co res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Customer_address(ctx context.Context, field graphql.CollectedField, obj *Customer) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -581,15 +542,9 @@ func (ec *executionContext) _Customer_address(ctx context.Context, field graphql res := resTmp.(*Address) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec._Address(ctx, field.Selections, res) + return ec.marshalAddress2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐAddress(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Customer_orders(ctx context.Context, field graphql.CollectedField, obj *Customer) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -610,43 +565,9 @@ func (ec *executionContext) _Customer_orders(ctx context.Context, field graphql. res := resTmp.([]Order) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._Order(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshalOrder2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐOrder(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Item_name(ctx context.Context, field graphql.CollectedField, obj *Item) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -670,10 +591,9 @@ func (ec *executionContext) _Item_name(ctx context.Context, field graphql.Collec res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Order_id(ctx context.Context, field graphql.CollectedField, obj *Order) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -697,10 +617,9 @@ func (ec *executionContext) _Order_id(ctx context.Context, field graphql.Collect res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) + return ec.marshalInt2int(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Order_date(ctx context.Context, field graphql.CollectedField, obj *Order) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -724,10 +643,9 @@ func (ec *executionContext) _Order_date(ctx context.Context, field graphql.Colle res := resTmp.(time.Time) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalTime(res) + return ec.marshalTime2timeᚐTime(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Order_amount(ctx context.Context, field graphql.CollectedField, obj *Order) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -751,10 +669,9 @@ func (ec *executionContext) _Order_amount(ctx context.Context, field graphql.Col res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) + return ec.marshalFloat2float64(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Order_items(ctx context.Context, field graphql.CollectedField, obj *Order) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -775,43 +692,9 @@ func (ec *executionContext) _Order_items(ctx context.Context, field graphql.Coll res := resTmp.([]Item) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._Item(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshalItem2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐItem(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_customers(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -832,43 +715,9 @@ func (ec *executionContext) _Query_customers(ctx context.Context, field graphql. res := resTmp.([]Customer) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._Customer(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshalCustomer2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_torture1d(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -896,43 +745,9 @@ func (ec *executionContext) _Query_torture1d(ctx context.Context, field graphql. res := resTmp.([]Customer) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._Customer(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshalCustomer2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_torture2d(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -960,74 +775,9 @@ func (ec *executionContext) _Query_torture2d(ctx context.Context, field graphql. res := resTmp.([][]Customer) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - arr2 := make(graphql.Array, len(res[idx1])) - - isLen1 := len(res[idx1]) == 1 - if !isLen1 { - wg.Add(len(res[idx1])) - } - - for idx2 := range res[idx1] { - idx2 := idx2 - rctx := &graphql.ResolverContext{ - Index: &idx2, - Result: &res[idx1][idx2], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx2 int) { - if !isLen1 { - defer wg.Done() - } - arr2[idx2] = func() graphql.Marshaler { - - return ec._Customer(ctx, field.Selections, &res[idx1][idx2]) - }() - } - if isLen1 { - f(idx2) - } else { - go f(idx2) - } - - } - - return arr2 - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshalCustomer2ᚕᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1055,15 +805,9 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1084,15 +828,9 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Schema(ctx, field.Selections, res) + return ec.marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1116,10 +854,9 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1140,10 +877,9 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1167,19 +903,9 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 + return ec.marshal__DirectiveLocation2ᚕstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1203,43 +929,9 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1263,10 +955,9 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1287,10 +978,9 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1314,10 +1004,9 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1338,14 +1027,9 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1369,10 +1053,9 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1393,10 +1076,9 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1420,43 +1102,9 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1480,18 +1128,9 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1515,10 +1154,9 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1539,14 +1177,9 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1570,10 +1203,9 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1594,10 +1226,9 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1621,18 +1252,9 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1653,14 +1275,9 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1684,43 +1301,9 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1744,18 +1327,9 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1776,15 +1350,9 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1805,15 +1373,9 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1837,43 +1399,9 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Directive(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1897,10 +1425,9 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshal__TypeKind2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1921,14 +1448,9 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1949,10 +1471,9 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1980,43 +1501,9 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) +} - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Field(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 -} - -// nolint: vetshadow func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2037,43 +1524,9 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2094,43 +1547,9 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2158,43 +1577,9 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2215,43 +1600,9 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2272,12 +1623,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } // endregion **************************** field.gotpl ***************************** @@ -2294,7 +1640,6 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co var addressImplementors = []string{"Address"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, obj *Address) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, addressImplementors) @@ -2332,7 +1677,6 @@ func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, var customerImplementors = []string{"Customer"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Customer(ctx context.Context, sel ast.SelectionSet, obj *Customer) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, customerImplementors) @@ -2377,7 +1721,6 @@ func (ec *executionContext) _Customer(ctx context.Context, sel ast.SelectionSet, var itemImplementors = []string{"Item"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Item(ctx context.Context, sel ast.SelectionSet, obj *Item) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, itemImplementors) @@ -2405,7 +1748,6 @@ func (ec *executionContext) _Item(ctx context.Context, sel ast.SelectionSet, obj var orderImplementors = []string{"Order"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Order(ctx context.Context, sel ast.SelectionSet, obj *Order) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, orderImplementors) @@ -2449,7 +1791,6 @@ func (ec *executionContext) _Order(ctx context.Context, sel ast.SelectionSet, ob var queryImplementors = []string{"Query"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, queryImplementors) @@ -2498,7 +1839,6 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr var __DirectiveImplementors = []string{"__Directive"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) @@ -2538,7 +1878,6 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS var __EnumValueImplementors = []string{"__EnumValue"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) @@ -2575,7 +1914,6 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS var __FieldImplementors = []string{"__Field"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __FieldImplementors) @@ -2622,7 +1960,6 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, var __InputValueImplementors = []string{"__InputValue"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) @@ -2659,7 +1996,6 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection var __SchemaImplementors = []string{"__Schema"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) @@ -2701,7 +2037,6 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, var __TypeImplementors = []string{"__Type"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __TypeImplementors) @@ -2747,7 +2082,83 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (e *executableSchema) unmarshalInt2ᚕᚕint(v interface{}) ([][]int, error) { +func (ec *executionContext) marshalAddress2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐAddress(ctx context.Context, sel ast.SelectionSet, v *Address) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec._Address(ctx, sel, v) +} + +func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.___Schema(ctx, sel, v) +} + +func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.___Type(ctx, sel, v) +} + +func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalString2string(v) + return &res, err +} + +func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.marshalString2string(ctx, sel, *v) +} + +func (ec *executionContext) marshalCustomer2ᚕᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v [][]Customer) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalCustomer2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) unmarshalInt2ᚕᚕint(v interface{}) ([][]int, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -2759,14 +2170,281 @@ func (e *executableSchema) unmarshalInt2ᚕᚕint(v interface{}) ([][]int, error var err error res := make([][]int, len(vSlice)) for i := range vSlice { - res[i], err = e.unmarshalInt2ᚕint(vSlice[i]) + res[i], err = ec.unmarshalInt2ᚕint(vSlice[i]) if err != nil { return nil, err } } return res, nil } -func (e *executableSchema) unmarshalInt2ᚕint(v interface{}) ([]int, error) { + +func (ec *executionContext) marshalInt2ᚕᚕint(ctx context.Context, sel ast.SelectionSet, v [][]int) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalInt2ᚕint(ctx, sel, v[i]) + } + + return ret +} + +func (ec *executionContext) marshalCustomer2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v []Customer) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalCustomer2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshalItem2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐItem(ctx context.Context, sel ast.SelectionSet, v []Item) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalItem2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐItem(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshalOrder2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐOrder(ctx context.Context, sel ast.SelectionSet, v []Order) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalOrder2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐOrder(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) unmarshalInt2ᚕint(v interface{}) ([]int, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -2778,21 +2456,187 @@ func (e *executableSchema) unmarshalInt2ᚕint(v interface{}) ([]int, error) { var err error res := make([]int, len(vSlice)) for i := range vSlice { - res[i], err = e.unmarshalInt2int(vSlice[i]) + res[i], err = ec.unmarshalInt2int(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalInt2ᚕint(ctx context.Context, sel ast.SelectionSet, v []int) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalInt2int(ctx, sel, v[i]) + } + + return ret +} + +func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshal__DirectiveLocation2string(vSlice[i]) if err != nil { return nil, err } } return res, nil } -func (e *executableSchema) unmarshalBoolean2bool(v interface{}) (bool, error) { + +func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__DirectiveLocation2string(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } -func (e *executableSchema) unmarshalInt2int(v interface{}) (int, error) { + +func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + + return graphql.MarshalBoolean(v) +} + +func (ec *executionContext) unmarshalFloat2float64(v interface{}) (float64, error) { + return graphql.UnmarshalFloat(v) +} + +func (ec *executionContext) marshalFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { + + return graphql.MarshalFloat(v) +} + +func (ec *executionContext) marshalAddress2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐAddress(ctx context.Context, sel ast.SelectionSet, v Address) graphql.Marshaler { + + return ec._Address(ctx, sel, &v) +} + +func (ec *executionContext) marshalCustomer2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v Customer) graphql.Marshaler { + + return ec._Customer(ctx, sel, &v) +} + +func (ec *executionContext) marshalItem2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐItem(ctx context.Context, sel ast.SelectionSet, v Item) graphql.Marshaler { + + return ec._Item(ctx, sel, &v) +} + +func (ec *executionContext) marshalOrder2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐOrder(ctx context.Context, sel ast.SelectionSet, v Order) graphql.Marshaler { + + return ec._Order(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { + + return ec.___Directive(ctx, sel, &v) +} + +func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { + + return ec.___EnumValue(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { + + return ec.___Field(ctx, sel, &v) +} + +func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { + + return ec.___InputValue(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { + + return ec.___Schema(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + + return ec.___Type(ctx, sel, &v) +} + +func (ec *executionContext) unmarshalInt2int(v interface{}) (int, error) { return graphql.UnmarshalInt(v) } -func (e *executableSchema) unmarshalString2string(v interface{}) (string, error) { + +func (ec *executionContext) marshalInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { + + return graphql.MarshalInt(v) +} + +func (ec *executionContext) unmarshalString2string(v interface{}) (string, error) { return graphql.UnmarshalString(v) } +func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalTime2timeᚐTime(v interface{}) (time.Time, error) { + return graphql.UnmarshalTime(v) +} + +func (ec *executionContext) marshalTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { + + return graphql.MarshalTime(v) +} + // endregion ***************************** type.gotpl ***************************** diff --git a/example/dataloader/itemsliceloader_gen.go b/example/dataloader/itemsliceloader_gen.go index 5fa10078401..55f21b4cae5 100644 --- a/example/dataloader/itemsliceloader_gen.go +++ b/example/dataloader/itemsliceloader_gen.go @@ -1,4 +1,4 @@ -// Code generated by github.com/vektah/dataloaden, DO NOT EDIT. +// generated by github.com/vektah/dataloaden ; DO NOT EDIT package dataloader @@ -7,27 +7,6 @@ import ( "time" ) -// ItemSliceLoaderConfig captures the config to create a new ItemSliceLoader -type ItemSliceLoaderConfig struct { - // Fetch is a method that provides the data for the loader - Fetch func(keys []int) ([][]Item, []error) - - // Wait is how long wait before sending a batch - Wait time.Duration - - // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit - MaxBatch int -} - -// NewItemSliceLoader creates a new ItemSliceLoader given a fetch, wait, and maxBatch -func NewItemSliceLoader(config ItemSliceLoaderConfig) *ItemSliceLoader { - return &ItemSliceLoader{ - fetch: config.Fetch, - wait: config.Wait, - maxBatch: config.MaxBatch, - } -} - // ItemSliceLoader batches and caches requests type ItemSliceLoader struct { // this method provides the data for the loader diff --git a/example/dataloader/ordersliceloader_gen.go b/example/dataloader/ordersliceloader_gen.go index e76e24d31f0..6b168ec1fb4 100644 --- a/example/dataloader/ordersliceloader_gen.go +++ b/example/dataloader/ordersliceloader_gen.go @@ -1,4 +1,4 @@ -// Code generated by github.com/vektah/dataloaden, DO NOT EDIT. +// generated by github.com/vektah/dataloaden ; DO NOT EDIT package dataloader @@ -7,27 +7,6 @@ import ( "time" ) -// OrderSliceLoaderConfig captures the config to create a new OrderSliceLoader -type OrderSliceLoaderConfig struct { - // Fetch is a method that provides the data for the loader - Fetch func(keys []int) ([][]Order, []error) - - // Wait is how long wait before sending a batch - Wait time.Duration - - // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit - MaxBatch int -} - -// NewOrderSliceLoader creates a new OrderSliceLoader given a fetch, wait, and maxBatch -func NewOrderSliceLoader(config OrderSliceLoaderConfig) *OrderSliceLoader { - return &OrderSliceLoader{ - fetch: config.Fetch, - wait: config.Wait, - maxBatch: config.MaxBatch, - } -} - // OrderSliceLoader batches and caches requests type OrderSliceLoader struct { // this method provides the data for the loader diff --git a/example/scalars/generated.go b/example/scalars/generated.go index a0e54a4770a..bb4f03625d1 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -84,6 +84,8 @@ func (e *executableSchema) Schema() *ast.Schema { } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e} + _ = ec switch typeName + "." + field { case "Address.id": @@ -105,7 +107,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Query_user_args(context.TODO(), rawArgs) + args, err := ec.field_Query_user_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -117,7 +119,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Query_search_args(context.TODO(), rawArgs) + args, err := ec.field_Query_search_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -283,51 +285,16 @@ scalar Banned `}, ) -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) - - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err - - } - return handleFunc[0](ctx, chainHandler) - } - } - - if n == 1 { - return handleFunc[0] - } - - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) - } -} - // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** -func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = e.unmarshalString2string(tmp) + arg0, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -336,12 +303,12 @@ func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs return args, nil } -func (e *executableSchema) field_Query_search_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_search_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 *model.SearchArgs if tmp, ok := rawArgs["input"]; ok { - arg0, err = e.unmarshalSearchArgs2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(tmp) + arg0, err = ec.unmarshalSearchArgs2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(tmp) if err != nil { return nil, err } @@ -350,12 +317,12 @@ func (e *executableSchema) field_Query_search_args(ctx context.Context, rawArgs return args, nil } -func (e *executableSchema) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 external.ObjectID if tmp, ok := rawArgs["id"]; ok { - arg0, err = e.unmarshalID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(tmp) + arg0, err = ec.unmarshalID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(tmp) if err != nil { return nil, err } @@ -364,12 +331,12 @@ func (e *executableSchema) field_Query_user_args(ctx context.Context, rawArgs ma return args, nil } -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = e.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } @@ -378,12 +345,12 @@ func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, raw return args, nil } -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = e.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } @@ -396,7 +363,6 @@ func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs // region **************************** field.gotpl ***************************** -// nolint: vetshadow func (ec *executionContext) _Address_id(ctx context.Context, field graphql.CollectedField, obj *model.Address) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -420,10 +386,9 @@ func (ec *executionContext) _Address_id(ctx context.Context, field graphql.Colle res := resTmp.(external.ObjectID) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return model.MarshalID(res) + return ec.marshalID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Address_location(ctx context.Context, field graphql.CollectedField, obj *model.Address) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -444,14 +409,9 @@ func (ec *executionContext) _Address_location(ctx context.Context, field graphql res := resTmp.(*model.Point) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return *res + return ec.marshalPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -479,15 +439,9 @@ func (ec *executionContext) _Query_user(ctx context.Context, field graphql.Colle res := resTmp.(*model.User) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec._User(ctx, field.Selections, res) + return ec.marshalUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_search(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -518,43 +472,9 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col res := resTmp.([]model.User) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._User(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshalUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -582,15 +502,9 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -611,15 +525,9 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Schema(ctx, field.Selections, res) + return ec.marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -643,10 +551,9 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte res := resTmp.(external.ObjectID) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return model.MarshalID(res) + return ec.marshalID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -670,10 +577,9 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _User_created(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -694,10 +600,9 @@ func (ec *executionContext) _User_created(ctx context.Context, field graphql.Col res := resTmp.(time.Time) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return model.MarshalTimestamp(res) + return ec.marshalTimestamp2timeᚐTime(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _User_isBanned(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -721,10 +626,9 @@ func (ec *executionContext) _User_isBanned(ctx context.Context, field graphql.Co res := resTmp.(model.Banned) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return res + return ec.marshalBanned2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐBanned(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _User_primitiveResolver(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -748,10 +652,9 @@ func (ec *executionContext) _User_primitiveResolver(ctx context.Context, field g res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _User_customResolver(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -775,10 +678,9 @@ func (ec *executionContext) _User_customResolver(ctx context.Context, field grap res := resTmp.(model.Point) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return res + return ec.marshalPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _User_address(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -799,11 +701,9 @@ func (ec *executionContext) _User_address(ctx context.Context, field graphql.Col res := resTmp.(model.Address) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._Address(ctx, field.Selections, &res) + return ec.marshalAddress2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐAddress(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _User_tier(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -824,10 +724,9 @@ func (ec *executionContext) _User_tier(ctx context.Context, field graphql.Collec res := resTmp.(model.Tier) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return res + return ec.marshalTier2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐTier(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -851,10 +750,9 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -875,10 +773,9 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -902,19 +799,9 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 + return ec.marshal__DirectiveLocation2ᚕstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -938,43 +825,9 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -998,10 +851,9 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1022,10 +874,9 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1049,10 +900,9 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1073,14 +923,9 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1104,10 +949,9 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1128,10 +972,9 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1155,43 +998,9 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1215,18 +1024,9 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1250,10 +1050,9 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1274,14 +1073,9 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1305,10 +1099,9 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1329,10 +1122,9 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1356,18 +1148,9 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1388,14 +1171,9 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1419,43 +1197,9 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1479,18 +1223,9 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1511,15 +1246,9 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1540,15 +1269,9 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1572,43 +1295,9 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Directive(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1632,10 +1321,9 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshal__TypeKind2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1656,14 +1344,9 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1684,10 +1367,9 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1715,43 +1397,9 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Field(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1772,43 +1420,9 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1829,43 +1443,9 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1893,43 +1473,9 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1950,43 +1496,9 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) +} - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 -} - -// nolint: vetshadow func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2007,19 +1519,14 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** -func (e *executableSchema) unmarshalInputSearchArgs(v interface{}) (model.SearchArgs, error) { +func (ec *executionContext) unmarshalInputSearchArgs(v interface{}) (model.SearchArgs, error) { var it model.SearchArgs var asMap = v.(map[string]interface{}) @@ -2027,29 +1534,19 @@ func (e *executableSchema) unmarshalInputSearchArgs(v interface{}) (model.Search switch k { case "location": var err error - var ptr1 model.Point - if v != nil { - err = (&ptr1).UnmarshalGQL(v) - it.Location = &ptr1 - } - + it.Location, err = ec.unmarshalPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(v) if err != nil { return it, err } case "createdAfter": var err error - var ptr1 time.Time - if v != nil { - ptr1, err = model.UnmarshalTimestamp(v) - it.CreatedAfter = &ptr1 - } - + it.CreatedAfter, err = ec.unmarshalTimestamp2ᚖtimeᚐTime(v) if err != nil { return it, err } case "isBanned": var err error - err = (&it.IsBanned).UnmarshalGQL(v) + it.IsBanned, err = ec.unmarshalBanned2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐBanned(v) if err != nil { return it, err } @@ -2069,7 +1566,6 @@ func (e *executableSchema) unmarshalInputSearchArgs(v interface{}) (model.Search var addressImplementors = []string{"Address"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, obj *model.Address) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, addressImplementors) @@ -2099,7 +1595,6 @@ func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, var queryImplementors = []string{"Query"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, queryImplementors) @@ -2145,7 +1640,6 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr var userImplementors = []string{"User"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *model.User) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, userImplementors) @@ -2207,7 +1701,6 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj var __DirectiveImplementors = []string{"__Directive"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) @@ -2247,7 +1740,6 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS var __EnumValueImplementors = []string{"__EnumValue"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) @@ -2284,7 +1776,6 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS var __FieldImplementors = []string{"__Field"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __FieldImplementors) @@ -2331,7 +1822,6 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, var __InputValueImplementors = []string{"__InputValue"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) @@ -2368,7 +1858,6 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection var __SchemaImplementors = []string{"__Schema"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) @@ -2410,7 +1899,6 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, var __TypeImplementors = []string{"__Type"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __TypeImplementors) @@ -2456,24 +1944,466 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (e *executableSchema) unmarshalSearchArgs2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v interface{}) (*model.SearchArgs, error) { +func (ec *executionContext) unmarshalPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(v interface{}) (*model.Point, error) { if v == nil { return nil, nil } - res, err := e.unmarshalSearchArgs2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v) + res, err := ec.unmarshalPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(v) return &res, err } -func (e *executableSchema) unmarshalBoolean2bool(v interface{}) (bool, error) { + +func (ec *executionContext) marshalPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, sel ast.SelectionSet, v *model.Point) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return v + +} + +func (ec *executionContext) unmarshalSearchArgs2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v interface{}) (*model.SearchArgs, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalSearchArgs2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v) + return &res, err +} + +func (ec *executionContext) marshalUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec._User(ctx, sel, v) +} + +func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.___Schema(ctx, sel, v) +} + +func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.___Type(ctx, sel, v) +} + +func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalString2string(v) + return &res, err +} + +func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.marshalString2string(ctx, sel, *v) +} + +func (ec *executionContext) unmarshalTimestamp2ᚖtimeᚐTime(v interface{}) (*time.Time, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalTimestamp2timeᚐTime(v) + return &res, err +} + +func (ec *executionContext) marshalTimestamp2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.marshalTimestamp2timeᚐTime(ctx, sel, *v) +} + +func (ec *executionContext) marshalUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v []model.User) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalUser2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshal__DirectiveLocation2string(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__DirectiveLocation2string(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } -func (e *executableSchema) unmarshalID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(v interface{}) (external.ObjectID, error) { + +func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + + return graphql.MarshalBoolean(v) +} + +func (ec *executionContext) unmarshalID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(v interface{}) (external.ObjectID, error) { return model.UnmarshalID(v) } -func (e *executableSchema) unmarshalSearchArgs2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v interface{}) (model.SearchArgs, error) { - return e.unmarshalInputSearchArgs(v) + +func (ec *executionContext) marshalID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(ctx context.Context, sel ast.SelectionSet, v external.ObjectID) graphql.Marshaler { + + return model.MarshalID(v) +} + +func (ec *executionContext) marshalAddress2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐAddress(ctx context.Context, sel ast.SelectionSet, v model.Address) graphql.Marshaler { + + return ec._Address(ctx, sel, &v) +} + +func (ec *executionContext) unmarshalBanned2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐBanned(v interface{}) (model.Banned, error) { + var res model.Banned + return res, res.UnmarshalGQL(v) +} + +func (ec *executionContext) marshalBanned2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐBanned(ctx context.Context, sel ast.SelectionSet, v model.Banned) graphql.Marshaler { + + return v + +} + +func (ec *executionContext) unmarshalPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(v interface{}) (model.Point, error) { + var res model.Point + return res, res.UnmarshalGQL(v) +} + +func (ec *executionContext) marshalPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, sel ast.SelectionSet, v model.Point) graphql.Marshaler { + + return v + +} + +func (ec *executionContext) unmarshalSearchArgs2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v interface{}) (model.SearchArgs, error) { + return ec.unmarshalInputSearchArgs(v) +} + +func (ec *executionContext) unmarshalTier2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐTier(v interface{}) (model.Tier, error) { + var res model.Tier + return res, res.UnmarshalGQL(v) +} + +func (ec *executionContext) marshalTier2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐTier(ctx context.Context, sel ast.SelectionSet, v model.Tier) graphql.Marshaler { + + return v + +} + +func (ec *executionContext) marshalUser2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v model.User) graphql.Marshaler { + + return ec._User(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { + + return ec.___Directive(ctx, sel, &v) +} + +func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { + + return ec.___EnumValue(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { + + return ec.___Field(ctx, sel, &v) +} + +func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { + + return ec.___InputValue(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { + + return ec.___Schema(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + + return ec.___Type(ctx, sel, &v) +} + +func (ec *executionContext) unmarshalString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) } -func (e *executableSchema) unmarshalString2string(v interface{}) (string, error) { + +func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) (string, error) { return graphql.UnmarshalString(v) } +func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalTimestamp2timeᚐTime(v interface{}) (time.Time, error) { + return model.UnmarshalTimestamp(v) +} + +func (ec *executionContext) marshalTimestamp2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { + + return model.MarshalTimestamp(v) +} + // endregion ***************************** type.gotpl ***************************** diff --git a/example/selection/generated.go b/example/selection/generated.go index 0d275b873a3..b4c2aa2b541 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -74,6 +74,8 @@ func (e *executableSchema) Schema() *ast.Schema { } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e} + _ = ec switch typeName + "." + field { case "Like.reaction": @@ -230,51 +232,16 @@ scalar Time `}, ) -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) - - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err - - } - return handleFunc[0](ctx, chainHandler) - } - } - - if n == 1 { - return handleFunc[0] - } - - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) - } -} - // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** -func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = e.unmarshalString2string(tmp) + arg0, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -283,12 +250,12 @@ func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs return args, nil } -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = e.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } @@ -297,12 +264,12 @@ func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, raw return args, nil } -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = e.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } @@ -315,7 +282,6 @@ func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs // region **************************** field.gotpl ***************************** -// nolint: vetshadow func (ec *executionContext) _Like_reaction(ctx context.Context, field graphql.CollectedField, obj *Like) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -339,10 +305,9 @@ func (ec *executionContext) _Like_reaction(ctx context.Context, field graphql.Co res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Like_sent(ctx context.Context, field graphql.CollectedField, obj *Like) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -366,10 +331,9 @@ func (ec *executionContext) _Like_sent(ctx context.Context, field graphql.Collec res := resTmp.(time.Time) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalTime(res) + return ec.marshalTime2timeᚐTime(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Like_selection(ctx context.Context, field graphql.CollectedField, obj *Like) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -390,19 +354,9 @@ func (ec *executionContext) _Like_selection(ctx context.Context, field graphql.C res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 + return ec.marshalString2ᚕstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Like_collected(ctx context.Context, field graphql.CollectedField, obj *Like) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -423,19 +377,9 @@ func (ec *executionContext) _Like_collected(ctx context.Context, field graphql.C res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 + return ec.marshalString2ᚕstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Post_message(ctx context.Context, field graphql.CollectedField, obj *Post) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -459,10 +403,9 @@ func (ec *executionContext) _Post_message(ctx context.Context, field graphql.Col res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Post_sent(ctx context.Context, field graphql.CollectedField, obj *Post) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -486,10 +429,9 @@ func (ec *executionContext) _Post_sent(ctx context.Context, field graphql.Collec res := resTmp.(time.Time) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalTime(res) + return ec.marshalTime2timeᚐTime(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Post_selection(ctx context.Context, field graphql.CollectedField, obj *Post) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -510,19 +452,9 @@ func (ec *executionContext) _Post_selection(ctx context.Context, field graphql.C res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 + return ec.marshalString2ᚕstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Post_collected(ctx context.Context, field graphql.CollectedField, obj *Post) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -543,19 +475,9 @@ func (ec *executionContext) _Post_collected(ctx context.Context, field graphql.C res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 + return ec.marshalString2ᚕstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_events(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -576,43 +498,9 @@ func (ec *executionContext) _Query_events(ctx context.Context, field graphql.Col res := resTmp.([]Event) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._Event(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshalEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋselectionᚐEvent(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -640,15 +528,9 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -669,15 +551,9 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Schema(ctx, field.Selections, res) + return ec.marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -701,10 +577,9 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -725,10 +600,9 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -752,19 +626,9 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 + return ec.marshal__DirectiveLocation2ᚕstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -788,43 +652,9 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -848,10 +678,9 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -872,10 +701,9 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -899,10 +727,9 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -923,14 +750,9 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -954,10 +776,9 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -978,10 +799,9 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1005,43 +825,9 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1065,18 +851,9 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1100,10 +877,9 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1124,14 +900,9 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1155,10 +926,9 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1179,10 +949,9 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1206,18 +975,9 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1238,14 +998,9 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1269,43 +1024,9 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1329,18 +1050,9 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1361,15 +1073,9 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1390,15 +1096,9 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1422,43 +1122,9 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Directive(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1482,10 +1148,9 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshal__TypeKind2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1506,14 +1171,9 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1534,10 +1194,9 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1565,43 +1224,9 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Field(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1622,43 +1247,9 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1679,43 +1270,9 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1743,43 +1300,9 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1800,43 +1323,9 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1857,12 +1346,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } // endregion **************************** field.gotpl ***************************** @@ -1896,7 +1380,6 @@ func (ec *executionContext) _Event(ctx context.Context, sel ast.SelectionSet, ob var likeImplementors = []string{"Like", "Event"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Like(ctx context.Context, sel ast.SelectionSet, obj *Like) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, likeImplementors) @@ -1933,7 +1416,6 @@ func (ec *executionContext) _Like(ctx context.Context, sel ast.SelectionSet, obj var postImplementors = []string{"Post", "Event"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Post(ctx context.Context, sel ast.SelectionSet, obj *Post) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, postImplementors) @@ -1970,7 +1452,6 @@ func (ec *executionContext) _Post(ctx context.Context, sel ast.SelectionSet, obj var queryImplementors = []string{"Query"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, queryImplementors) @@ -2007,7 +1488,6 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr var __DirectiveImplementors = []string{"__Directive"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) @@ -2047,7 +1527,6 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS var __EnumValueImplementors = []string{"__EnumValue"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) @@ -2084,7 +1563,6 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS var __FieldImplementors = []string{"__Field"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __FieldImplementors) @@ -2131,7 +1609,6 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, var __InputValueImplementors = []string{"__InputValue"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) @@ -2168,7 +1645,6 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection var __SchemaImplementors = []string{"__Schema"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) @@ -2210,7 +1686,6 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, var __TypeImplementors = []string{"__Type"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __TypeImplementors) @@ -2256,11 +1731,393 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (e *executableSchema) unmarshalBoolean2bool(v interface{}) (bool, error) { +func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.___Schema(ctx, sel, v) +} + +func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.___Type(ctx, sel, v) +} + +func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalString2string(v) + return &res, err +} + +func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.marshalString2string(ctx, sel, *v) +} + +func (ec *executionContext) marshalEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋselectionᚐEvent(ctx context.Context, sel ast.SelectionSet, v []Event) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalEvent2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋselectionᚐEvent(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) unmarshalString2ᚕstring(v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshalString2string(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalString2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalString2string(ctx, sel, v[i]) + } + + return ret +} + +func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshal__DirectiveLocation2string(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__DirectiveLocation2string(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } -func (e *executableSchema) unmarshalString2string(v interface{}) (string, error) { + +func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + + return graphql.MarshalBoolean(v) +} + +func (ec *executionContext) marshalEvent2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋselectionᚐEvent(ctx context.Context, sel ast.SelectionSet, v Event) graphql.Marshaler { + + return ec._Event(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { + + return ec.___Directive(ctx, sel, &v) +} + +func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { + + return ec.___EnumValue(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { + + return ec.___Field(ctx, sel, &v) +} + +func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { + + return ec.___InputValue(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { + + return ec.___Schema(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + + return ec.___Type(ctx, sel, &v) +} + +func (ec *executionContext) unmarshalString2string(v interface{}) (string, error) { return graphql.UnmarshalString(v) } +func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalTime2timeᚐTime(v interface{}) (time.Time, error) { + return graphql.UnmarshalTime(v) +} + +func (ec *executionContext) marshalTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { + + return graphql.MarshalTime(v) +} + // endregion ***************************** type.gotpl ***************************** diff --git a/example/starwars/generated.go b/example/starwars/generated.go index ebaccfb121d..17df8f7229e 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -152,6 +152,8 @@ func (e *executableSchema) Schema() *ast.Schema { } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e} + _ = ec switch typeName + "." + field { case "Droid.id": @@ -180,7 +182,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Droid_friendsConnection_args(context.TODO(), rawArgs) + args, err := ec.field_Droid_friendsConnection_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -262,7 +264,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Human_height_args(context.TODO(), rawArgs) + args, err := ec.field_Human_height_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -288,7 +290,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Human_friendsConnection_args(context.TODO(), rawArgs) + args, err := ec.field_Human_friendsConnection_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -314,7 +316,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Mutation_createReview_args(context.TODO(), rawArgs) + args, err := ec.field_Mutation_createReview_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -347,7 +349,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Query_hero_args(context.TODO(), rawArgs) + args, err := ec.field_Query_hero_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -359,7 +361,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Query_reviews_args(context.TODO(), rawArgs) + args, err := ec.field_Query_reviews_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -371,7 +373,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Query_search_args(context.TODO(), rawArgs) + args, err := ec.field_Query_search_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -383,7 +385,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Query_character_args(context.TODO(), rawArgs) + args, err := ec.field_Query_character_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -395,7 +397,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Query_droid_args(context.TODO(), rawArgs) + args, err := ec.field_Query_droid_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -407,7 +409,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Query_human_args(context.TODO(), rawArgs) + args, err := ec.field_Query_human_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -419,7 +421,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Query_starship_args(context.TODO(), rawArgs) + args, err := ec.field_Query_starship_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -466,7 +468,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Starship_length_args(context.TODO(), rawArgs) + args, err := ec.field_Starship_length_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -691,51 +693,16 @@ scalar Time `}, ) -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) - - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err - - } - return handleFunc[0](ctx, chainHandler) - } - } - - if n == 1 { - return handleFunc[0] - } - - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) - } -} - // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** -func (e *executableSchema) field_Droid_friendsConnection_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Droid_friendsConnection_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["first"]; ok { - arg0, err = e.unmarshalInt2ᚖint(tmp) + arg0, err = ec.unmarshalInt2ᚖint(tmp) if err != nil { return nil, err } @@ -743,7 +710,7 @@ func (e *executableSchema) field_Droid_friendsConnection_args(ctx context.Contex args["first"] = arg0 var arg1 *string if tmp, ok := rawArgs["after"]; ok { - arg1, err = e.unmarshalID2ᚖstring(tmp) + arg1, err = ec.unmarshalID2ᚖstring(tmp) if err != nil { return nil, err } @@ -752,12 +719,12 @@ func (e *executableSchema) field_Droid_friendsConnection_args(ctx context.Contex return args, nil } -func (e *executableSchema) field_Human_friendsConnection_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Human_friendsConnection_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["first"]; ok { - arg0, err = e.unmarshalInt2ᚖint(tmp) + arg0, err = ec.unmarshalInt2ᚖint(tmp) if err != nil { return nil, err } @@ -765,7 +732,7 @@ func (e *executableSchema) field_Human_friendsConnection_args(ctx context.Contex args["first"] = arg0 var arg1 *string if tmp, ok := rawArgs["after"]; ok { - arg1, err = e.unmarshalID2ᚖstring(tmp) + arg1, err = ec.unmarshalID2ᚖstring(tmp) if err != nil { return nil, err } @@ -774,12 +741,12 @@ func (e *executableSchema) field_Human_friendsConnection_args(ctx context.Contex return args, nil } -func (e *executableSchema) field_Human_height_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Human_height_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 LengthUnit if tmp, ok := rawArgs["unit"]; ok { - arg0, err = e.unmarshalLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(tmp) + arg0, err = ec.unmarshalLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(tmp) if err != nil { return nil, err } @@ -788,12 +755,12 @@ func (e *executableSchema) field_Human_height_args(ctx context.Context, rawArgs return args, nil } -func (e *executableSchema) field_Mutation_createReview_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Mutation_createReview_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 Episode if tmp, ok := rawArgs["episode"]; ok { - arg0, err = e.unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(tmp) + arg0, err = ec.unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(tmp) if err != nil { return nil, err } @@ -801,7 +768,7 @@ func (e *executableSchema) field_Mutation_createReview_args(ctx context.Context, args["episode"] = arg0 var arg1 Review if tmp, ok := rawArgs["review"]; ok { - arg1, err = e.unmarshalReviewInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(tmp) + arg1, err = ec.unmarshalReviewInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(tmp) if err != nil { return nil, err } @@ -810,12 +777,12 @@ func (e *executableSchema) field_Mutation_createReview_args(ctx context.Context, return args, nil } -func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = e.unmarshalString2string(tmp) + arg0, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -824,12 +791,12 @@ func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs return args, nil } -func (e *executableSchema) field_Query_character_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_character_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["id"]; ok { - arg0, err = e.unmarshalID2string(tmp) + arg0, err = ec.unmarshalID2string(tmp) if err != nil { return nil, err } @@ -838,12 +805,12 @@ func (e *executableSchema) field_Query_character_args(ctx context.Context, rawAr return args, nil } -func (e *executableSchema) field_Query_droid_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_droid_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["id"]; ok { - arg0, err = e.unmarshalID2string(tmp) + arg0, err = ec.unmarshalID2string(tmp) if err != nil { return nil, err } @@ -852,12 +819,12 @@ func (e *executableSchema) field_Query_droid_args(ctx context.Context, rawArgs m return args, nil } -func (e *executableSchema) field_Query_hero_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_hero_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 *Episode if tmp, ok := rawArgs["episode"]; ok { - arg0, err = e.unmarshalEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(tmp) + arg0, err = ec.unmarshalEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(tmp) if err != nil { return nil, err } @@ -866,12 +833,12 @@ func (e *executableSchema) field_Query_hero_args(ctx context.Context, rawArgs ma return args, nil } -func (e *executableSchema) field_Query_human_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_human_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["id"]; ok { - arg0, err = e.unmarshalID2string(tmp) + arg0, err = ec.unmarshalID2string(tmp) if err != nil { return nil, err } @@ -880,12 +847,12 @@ func (e *executableSchema) field_Query_human_args(ctx context.Context, rawArgs m return args, nil } -func (e *executableSchema) field_Query_reviews_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_reviews_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 Episode if tmp, ok := rawArgs["episode"]; ok { - arg0, err = e.unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(tmp) + arg0, err = ec.unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(tmp) if err != nil { return nil, err } @@ -893,7 +860,7 @@ func (e *executableSchema) field_Query_reviews_args(ctx context.Context, rawArgs args["episode"] = arg0 var arg1 *time.Time if tmp, ok := rawArgs["since"]; ok { - arg1, err = e.unmarshalTime2ᚖtimeᚐTime(tmp) + arg1, err = ec.unmarshalTime2ᚖtimeᚐTime(tmp) if err != nil { return nil, err } @@ -902,12 +869,12 @@ func (e *executableSchema) field_Query_reviews_args(ctx context.Context, rawArgs return args, nil } -func (e *executableSchema) field_Query_search_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_search_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["text"]; ok { - arg0, err = e.unmarshalString2string(tmp) + arg0, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -916,12 +883,12 @@ func (e *executableSchema) field_Query_search_args(ctx context.Context, rawArgs return args, nil } -func (e *executableSchema) field_Query_starship_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_starship_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["id"]; ok { - arg0, err = e.unmarshalID2string(tmp) + arg0, err = ec.unmarshalID2string(tmp) if err != nil { return nil, err } @@ -930,12 +897,12 @@ func (e *executableSchema) field_Query_starship_args(ctx context.Context, rawArg return args, nil } -func (e *executableSchema) field_Starship_length_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Starship_length_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 *LengthUnit if tmp, ok := rawArgs["unit"]; ok { - arg0, err = e.unmarshalLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(tmp) + arg0, err = ec.unmarshalLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(tmp) if err != nil { return nil, err } @@ -944,12 +911,12 @@ func (e *executableSchema) field_Starship_length_args(ctx context.Context, rawAr return args, nil } -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = e.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } @@ -958,12 +925,12 @@ func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, raw return args, nil } -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = e.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } @@ -976,7 +943,6 @@ func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs // region **************************** field.gotpl ***************************** -// nolint: vetshadow func (ec *executionContext) _Droid_id(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1000,10 +966,9 @@ func (ec *executionContext) _Droid_id(ctx context.Context, field graphql.Collect res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + return ec.marshalID2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Droid_name(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1027,10 +992,9 @@ func (ec *executionContext) _Droid_name(ctx context.Context, field graphql.Colle res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Droid_friends(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1051,43 +1015,9 @@ func (ec *executionContext) _Droid_friends(ctx context.Context, field graphql.Co res := resTmp.([]Character) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._Character(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshalCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1118,11 +1048,9 @@ func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field res := resTmp.(FriendsConnection) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._FriendsConnection(ctx, field.Selections, &res) + return ec.marshalFriendsConnection2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsConnection(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1146,19 +1074,9 @@ func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql. res := resTmp.([]Episode) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return res[idx1] - }() - } - - return arr1 + return ec.marshalEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Droid_primaryFunction(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1179,10 +1097,9 @@ func (ec *executionContext) _Droid_primaryFunction(ctx context.Context, field gr res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _FriendsConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1206,10 +1123,9 @@ func (ec *executionContext) _FriendsConnection_totalCount(ctx context.Context, f res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) + return ec.marshalInt2int(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _FriendsConnection_edges(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1230,43 +1146,9 @@ func (ec *executionContext) _FriendsConnection_edges(ctx context.Context, field res := resTmp.([]FriendsEdge) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._FriendsEdge(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshalFriendsEdge2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsEdge(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _FriendsConnection_friends(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1287,43 +1169,9 @@ func (ec *executionContext) _FriendsConnection_friends(ctx context.Context, fiel res := resTmp.([]Character) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._Character(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshalCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _FriendsConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1347,11 +1195,9 @@ func (ec *executionContext) _FriendsConnection_pageInfo(ctx context.Context, fie res := resTmp.(PageInfo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._PageInfo(ctx, field.Selections, &res) + return ec.marshalPageInfo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐPageInfo(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _FriendsEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *FriendsEdge) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1375,10 +1221,9 @@ func (ec *executionContext) _FriendsEdge_cursor(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + return ec.marshalID2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _FriendsEdge_node(ctx context.Context, field graphql.CollectedField, obj *FriendsEdge) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1399,11 +1244,9 @@ func (ec *executionContext) _FriendsEdge_node(ctx context.Context, field graphql res := resTmp.(Character) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._Character(ctx, field.Selections, &res) + return ec.marshalCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Human_id(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1427,10 +1270,9 @@ func (ec *executionContext) _Human_id(ctx context.Context, field graphql.Collect res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + return ec.marshalID2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Human_name(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1454,10 +1296,9 @@ func (ec *executionContext) _Human_name(ctx context.Context, field graphql.Colle res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Human_height(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1488,10 +1329,9 @@ func (ec *executionContext) _Human_height(ctx context.Context, field graphql.Col res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) + return ec.marshalFloat2float64(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Human_mass(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1512,10 +1352,9 @@ func (ec *executionContext) _Human_mass(ctx context.Context, field graphql.Colle res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) + return ec.marshalFloat2float64(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1536,43 +1375,9 @@ func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.Co res := resTmp.([]Character) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._Character(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshalCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1603,11 +1408,9 @@ func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field res := resTmp.(FriendsConnection) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._FriendsConnection(ctx, field.Selections, &res) + return ec.marshalFriendsConnection2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsConnection(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Human_appearsIn(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1631,19 +1434,9 @@ func (ec *executionContext) _Human_appearsIn(ctx context.Context, field graphql. res := resTmp.([]Episode) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return res[idx1] - }() - } - - return arr1 + return ec.marshalEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Human_starships(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1664,43 +1457,9 @@ func (ec *executionContext) _Human_starships(ctx context.Context, field graphql. res := resTmp.([]Starship) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._Starship(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshalStarship2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Mutation_createReview(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1728,15 +1487,9 @@ func (ec *executionContext) _Mutation_createReview(ctx context.Context, field gr res := resTmp.(*Review) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec._Review(ctx, field.Selections, res) + return ec.marshalReview2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *PageInfo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1760,10 +1513,9 @@ func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field gra res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + return ec.marshalID2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *PageInfo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1787,10 +1539,9 @@ func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + return ec.marshalID2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *PageInfo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1814,10 +1565,9 @@ func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field gra res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_hero(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1845,11 +1595,9 @@ func (ec *executionContext) _Query_hero(ctx context.Context, field graphql.Colle res := resTmp.(Character) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._Character(ctx, field.Selections, &res) + return ec.marshalCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1880,43 +1628,9 @@ func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.Co res := resTmp.([]Review) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._Review(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshalReview2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_search(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1947,43 +1661,9 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col res := resTmp.([]SearchResult) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._SearchResult(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshalSearchResult2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐSearchResult(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_character(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2011,11 +1691,9 @@ func (ec *executionContext) _Query_character(ctx context.Context, field graphql. res := resTmp.(Character) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._Character(ctx, field.Selections, &res) + return ec.marshalCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_droid(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2043,15 +1721,9 @@ func (ec *executionContext) _Query_droid(ctx context.Context, field graphql.Coll res := resTmp.(*Droid) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec._Droid(ctx, field.Selections, res) + return ec.marshalDroid2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐDroid(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_human(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2079,15 +1751,9 @@ func (ec *executionContext) _Query_human(ctx context.Context, field graphql.Coll res := resTmp.(*Human) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec._Human(ctx, field.Selections, res) + return ec.marshalHuman2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐHuman(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_starship(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2115,15 +1781,9 @@ func (ec *executionContext) _Query_starship(ctx context.Context, field graphql.C res := resTmp.(*Starship) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec._Starship(ctx, field.Selections, res) + return ec.marshalStarship2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2151,15 +1811,9 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2180,15 +1834,9 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Schema(ctx, field.Selections, res) + return ec.marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Review_stars(ctx context.Context, field graphql.CollectedField, obj *Review) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2212,10 +1860,9 @@ func (ec *executionContext) _Review_stars(ctx context.Context, field graphql.Col res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) + return ec.marshalInt2int(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Review_commentary(ctx context.Context, field graphql.CollectedField, obj *Review) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2236,14 +1883,9 @@ func (ec *executionContext) _Review_commentary(ctx context.Context, field graphq res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Review_time(ctx context.Context, field graphql.CollectedField, obj *Review) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2264,10 +1906,9 @@ func (ec *executionContext) _Review_time(ctx context.Context, field graphql.Coll res := resTmp.(time.Time) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalTime(res) + return ec.marshalTime2timeᚐTime(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Starship_id(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2291,10 +1932,9 @@ func (ec *executionContext) _Starship_id(ctx context.Context, field graphql.Coll res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + return ec.marshalID2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Starship_name(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2318,10 +1958,9 @@ func (ec *executionContext) _Starship_name(ctx context.Context, field graphql.Co res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Starship_length(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2352,10 +1991,9 @@ func (ec *executionContext) _Starship_length(ctx context.Context, field graphql. res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalFloat(res) + return ec.marshalFloat2float64(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Starship_history(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2379,28 +2017,9 @@ func (ec *executionContext) _Starship_history(ctx context.Context, field graphql res := resTmp.([][]int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - - arr2 := make(graphql.Array, len(res[idx1])) - - for idx2 := range res[idx1] { - arr2[idx2] = func() graphql.Marshaler { - return graphql.MarshalInt(res[idx1][idx2]) - }() - } - - return arr2 - }() - } - - return arr1 + return ec.marshalInt2ᚕᚕint(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2424,10 +2043,9 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2448,10 +2066,9 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2475,19 +2092,9 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 + return ec.marshal__DirectiveLocation2ᚕstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2511,43 +2118,9 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2571,10 +2144,9 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2595,10 +2167,9 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2622,10 +2193,9 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2646,14 +2216,9 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2677,10 +2242,9 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2701,10 +2265,9 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2728,43 +2291,9 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2788,18 +2317,9 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2823,10 +2343,9 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2847,14 +2366,9 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) +} - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) -} - -// nolint: vetshadow func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2878,10 +2392,9 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2902,10 +2415,9 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2929,18 +2441,9 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2961,14 +2464,9 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2992,43 +2490,9 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3052,18 +2516,9 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3084,15 +2539,9 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3113,15 +2562,9 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3145,43 +2588,9 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Directive(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3205,10 +2614,9 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshal__TypeKind2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3229,14 +2637,9 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3257,10 +2660,9 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3288,43 +2690,9 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Field(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3345,43 +2713,9 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3402,43 +2736,9 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3466,43 +2766,9 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3523,43 +2789,9 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3580,19 +2812,14 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** -func (e *executableSchema) unmarshalInputReviewInput(v interface{}) (Review, error) { +func (ec *executionContext) unmarshalInputReviewInput(v interface{}) (Review, error) { var it Review var asMap = v.(map[string]interface{}) @@ -3600,24 +2827,19 @@ func (e *executableSchema) unmarshalInputReviewInput(v interface{}) (Review, err switch k { case "stars": var err error - it.Stars, err = graphql.UnmarshalInt(v) + it.Stars, err = ec.unmarshalInt2int(v) if err != nil { return it, err } case "commentary": var err error - var ptr1 string - if v != nil { - ptr1, err = graphql.UnmarshalString(v) - it.Commentary = &ptr1 - } - + it.Commentary, err = ec.unmarshalString2ᚖstring(v) if err != nil { return it, err } case "time": var err error - it.Time, err = graphql.UnmarshalTime(v) + it.Time, err = ec.unmarshalTime2timeᚐTime(v) if err != nil { return it, err } @@ -3675,7 +2897,6 @@ func (ec *executionContext) _SearchResult(ctx context.Context, sel ast.Selection var droidImplementors = []string{"Droid", "Character"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Droid(ctx context.Context, sel ast.SelectionSet, obj *Droid) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, droidImplementors) @@ -3730,7 +2951,6 @@ func (ec *executionContext) _Droid(ctx context.Context, sel ast.SelectionSet, ob var friendsConnectionImplementors = []string{"FriendsConnection"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _FriendsConnection(ctx context.Context, sel ast.SelectionSet, obj *FriendsConnection) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, friendsConnectionImplementors) @@ -3775,7 +2995,6 @@ func (ec *executionContext) _FriendsConnection(ctx context.Context, sel ast.Sele var friendsEdgeImplementors = []string{"FriendsEdge"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _FriendsEdge(ctx context.Context, sel ast.SelectionSet, obj *FriendsEdge) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, friendsEdgeImplementors) @@ -3805,7 +3024,6 @@ func (ec *executionContext) _FriendsEdge(ctx context.Context, sel ast.SelectionS var humanImplementors = []string{"Human", "Character"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Human(ctx context.Context, sel ast.SelectionSet, obj *Human) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, humanImplementors) @@ -3871,7 +3089,6 @@ func (ec *executionContext) _Human(ctx context.Context, sel ast.SelectionSet, ob var mutationImplementors = []string{"Mutation"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, mutationImplementors) @@ -3900,7 +3117,6 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) var pageInfoImplementors = []string{"PageInfo"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *PageInfo) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, pageInfoImplementors) @@ -3938,7 +3154,6 @@ func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, var queryImplementors = []string{"Query"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, queryImplementors) @@ -4017,7 +3232,6 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr var reviewImplementors = []string{"Review"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Review(ctx context.Context, sel ast.SelectionSet, obj *Review) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, reviewImplementors) @@ -4049,7 +3263,6 @@ func (ec *executionContext) _Review(ctx context.Context, sel ast.SelectionSet, o var starshipImplementors = []string{"Starship"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Starship(ctx context.Context, sel ast.SelectionSet, obj *Starship) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, starshipImplementors) @@ -4096,7 +3309,6 @@ func (ec *executionContext) _Starship(ctx context.Context, sel ast.SelectionSet, var __DirectiveImplementors = []string{"__Directive"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) @@ -4136,7 +3348,6 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS var __EnumValueImplementors = []string{"__EnumValue"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) @@ -4173,7 +3384,6 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS var __FieldImplementors = []string{"__Field"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __FieldImplementors) @@ -4220,7 +3430,6 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, var __InputValueImplementors = []string{"__InputValue"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) @@ -4257,7 +3466,6 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection var __SchemaImplementors = []string{"__Schema"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) @@ -4299,7 +3507,6 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, var __TypeImplementors = []string{"__Type"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __TypeImplementors) @@ -4345,66 +3552,819 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (e *executableSchema) unmarshalEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v interface{}) (*Episode, error) { +func (ec *executionContext) marshalDroid2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐDroid(ctx context.Context, sel ast.SelectionSet, v *Droid) graphql.Marshaler { + if v == nil { - return nil, nil + return graphql.Null } - res, err := e.unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v) - return &res, err + + return ec._Droid(ctx, sel, v) } -func (e *executableSchema) unmarshalLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(v interface{}) (*LengthUnit, error) { + +func (ec *executionContext) unmarshalEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v interface{}) (*Episode, error) { if v == nil { return nil, nil } - res, err := e.unmarshalLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(v) + res, err := ec.unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v) return &res, err } -func (e *executableSchema) unmarshalInt2ᚖint(v interface{}) (*int, error) { + +func (ec *executionContext) marshalEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v *Episode) graphql.Marshaler { + if v == nil { - return nil, nil + return graphql.Null } - res, err := e.unmarshalInt2int(v) - return &res, err + + return v + +} + +func (ec *executionContext) marshalHuman2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐHuman(ctx context.Context, sel ast.SelectionSet, v *Human) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec._Human(ctx, sel, v) } -func (e *executableSchema) unmarshalID2ᚖstring(v interface{}) (*string, error) { + +func (ec *executionContext) unmarshalLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(v interface{}) (*LengthUnit, error) { if v == nil { return nil, nil } - res, err := e.unmarshalID2string(v) + res, err := ec.unmarshalLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(v) return &res, err } -func (e *executableSchema) unmarshalTime2ᚖtimeᚐTime(v interface{}) (*time.Time, error) { + +func (ec *executionContext) marshalLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(ctx context.Context, sel ast.SelectionSet, v *LengthUnit) graphql.Marshaler { + if v == nil { - return nil, nil + return graphql.Null } - res, err := e.unmarshalTime2timeᚐTime(v) - return &res, err + + return v + } -func (e *executableSchema) unmarshalBoolean2bool(v interface{}) (bool, error) { - return graphql.UnmarshalBoolean(v) + +func (ec *executionContext) marshalReview2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx context.Context, sel ast.SelectionSet, v *Review) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec._Review(ctx, sel, v) } -func (e *executableSchema) unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v interface{}) (Episode, error) { - var res Episode - return res, res.UnmarshalGQL(v) + +func (ec *executionContext) marshalStarship2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx context.Context, sel ast.SelectionSet, v *Starship) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec._Starship(ctx, sel, v) } -func (e *executableSchema) unmarshalLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(v interface{}) (LengthUnit, error) { - var res LengthUnit - return res, res.UnmarshalGQL(v) + +func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.___Schema(ctx, sel, v) } -func (e *executableSchema) unmarshalReviewInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(v interface{}) (Review, error) { - return e.unmarshalInputReviewInput(v) + +func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.___Type(ctx, sel, v) } -func (e *executableSchema) unmarshalInt2int(v interface{}) (int, error) { - return graphql.UnmarshalInt(v) + +func (ec *executionContext) unmarshalInt2ᚖint(v interface{}) (*int, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInt2int(v) + return &res, err } -func (e *executableSchema) unmarshalID2string(v interface{}) (string, error) { - return graphql.UnmarshalID(v) + +func (ec *executionContext) marshalInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.marshalInt2int(ctx, sel, *v) } -func (e *executableSchema) unmarshalString2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) + +func (ec *executionContext) unmarshalID2ᚖstring(v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalID2string(v) + return &res, err } -func (e *executableSchema) unmarshalTime2timeᚐTime(v interface{}) (time.Time, error) { - return graphql.UnmarshalTime(v) + +func (ec *executionContext) marshalID2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.marshalID2string(ctx, sel, *v) +} + +func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalString2string(v) + return &res, err +} + +func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.marshalString2string(ctx, sel, *v) +} + +func (ec *executionContext) unmarshalTime2ᚖtimeᚐTime(v interface{}) (*time.Time, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalTime2timeᚐTime(v) + return &res, err +} + +func (ec *executionContext) marshalTime2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.marshalTime2timeᚐTime(ctx, sel, *v) +} + +func (ec *executionContext) unmarshalInt2ᚕᚕint(v interface{}) ([][]int, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([][]int, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshalInt2ᚕint(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalInt2ᚕᚕint(ctx context.Context, sel ast.SelectionSet, v [][]int) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalInt2ᚕint(ctx, sel, v[i]) + } + + return ret +} + +func (ec *executionContext) marshalCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v []Character) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) unmarshalEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v interface{}) ([]Episode, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]Episode, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v []Episode) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshalFriendsEdge2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsEdge(ctx context.Context, sel ast.SelectionSet, v []FriendsEdge) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalFriendsEdge2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshalReview2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx context.Context, sel ast.SelectionSet, v []Review) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalReview2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshalSearchResult2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐSearchResult(ctx context.Context, sel ast.SelectionSet, v []SearchResult) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalSearchResult2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐSearchResult(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshalStarship2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx context.Context, sel ast.SelectionSet, v []Starship) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalStarship2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) unmarshalInt2ᚕint(v interface{}) ([]int, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]int, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshalInt2int(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalInt2ᚕint(ctx context.Context, sel ast.SelectionSet, v []int) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalInt2int(ctx, sel, v[i]) + } + + return ret +} + +func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshal__DirectiveLocation2string(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__DirectiveLocation2string(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) +} + +func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + + return graphql.MarshalBoolean(v) +} + +func (ec *executionContext) unmarshalFloat2float64(v interface{}) (float64, error) { + return graphql.UnmarshalFloat(v) +} + +func (ec *executionContext) marshalFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { + + return graphql.MarshalFloat(v) +} + +func (ec *executionContext) marshalCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v Character) graphql.Marshaler { + + return ec._Character(ctx, sel, &v) +} + +func (ec *executionContext) marshalDroid2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐDroid(ctx context.Context, sel ast.SelectionSet, v Droid) graphql.Marshaler { + + return ec._Droid(ctx, sel, &v) +} + +func (ec *executionContext) unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v interface{}) (Episode, error) { + var res Episode + return res, res.UnmarshalGQL(v) +} + +func (ec *executionContext) marshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v Episode) graphql.Marshaler { + + return v + +} + +func (ec *executionContext) marshalFriendsConnection2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsConnection(ctx context.Context, sel ast.SelectionSet, v FriendsConnection) graphql.Marshaler { + + return ec._FriendsConnection(ctx, sel, &v) +} + +func (ec *executionContext) marshalFriendsEdge2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsEdge(ctx context.Context, sel ast.SelectionSet, v FriendsEdge) graphql.Marshaler { + + return ec._FriendsEdge(ctx, sel, &v) +} + +func (ec *executionContext) marshalHuman2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐHuman(ctx context.Context, sel ast.SelectionSet, v Human) graphql.Marshaler { + + return ec._Human(ctx, sel, &v) +} + +func (ec *executionContext) unmarshalLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(v interface{}) (LengthUnit, error) { + var res LengthUnit + return res, res.UnmarshalGQL(v) +} + +func (ec *executionContext) marshalLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(ctx context.Context, sel ast.SelectionSet, v LengthUnit) graphql.Marshaler { + + return v + +} + +func (ec *executionContext) marshalPageInfo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐPageInfo(ctx context.Context, sel ast.SelectionSet, v PageInfo) graphql.Marshaler { + + return ec._PageInfo(ctx, sel, &v) +} + +func (ec *executionContext) marshalReview2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx context.Context, sel ast.SelectionSet, v Review) graphql.Marshaler { + + return ec._Review(ctx, sel, &v) +} + +func (ec *executionContext) unmarshalReviewInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(v interface{}) (Review, error) { + return ec.unmarshalInputReviewInput(v) +} + +func (ec *executionContext) marshalSearchResult2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐSearchResult(ctx context.Context, sel ast.SelectionSet, v SearchResult) graphql.Marshaler { + + return ec._SearchResult(ctx, sel, &v) +} + +func (ec *executionContext) marshalStarship2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx context.Context, sel ast.SelectionSet, v Starship) graphql.Marshaler { + + return ec._Starship(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { + + return ec.___Directive(ctx, sel, &v) +} + +func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { + + return ec.___EnumValue(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { + + return ec.___Field(ctx, sel, &v) +} + +func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { + + return ec.___InputValue(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { + + return ec.___Schema(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + + return ec.___Type(ctx, sel, &v) +} + +func (ec *executionContext) unmarshalInt2int(v interface{}) (int, error) { + return graphql.UnmarshalInt(v) +} + +func (ec *executionContext) marshalInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { + + return graphql.MarshalInt(v) +} + +func (ec *executionContext) unmarshalID2string(v interface{}) (string, error) { + return graphql.UnmarshalID(v) +} + +func (ec *executionContext) marshalID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalID(v) +} + +func (ec *executionContext) unmarshalString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalTime2timeᚐTime(v interface{}) (time.Time, error) { + return graphql.UnmarshalTime(v) +} + +func (ec *executionContext) marshalTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { + + return graphql.MarshalTime(v) } // endregion ***************************** type.gotpl ***************************** diff --git a/example/todo/generated.go b/example/todo/generated.go index b6935928e40..3f127bcfa85 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -79,6 +79,8 @@ func (e *executableSchema) Schema() *ast.Schema { } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e} + _ = ec switch typeName + "." + field { case "MyMutation.createTodo": @@ -86,7 +88,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_MyMutation_createTodo_args(context.TODO(), rawArgs) + args, err := ec.field_MyMutation_createTodo_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -98,7 +100,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_MyMutation_updateTodo_args(context.TODO(), rawArgs) + args, err := ec.field_MyMutation_updateTodo_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -110,7 +112,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_MyQuery_todo_args(context.TODO(), rawArgs) + args, err := ec.field_MyQuery_todo_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -289,51 +291,16 @@ enum Role { `}, ) -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) - - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err - - } - return handleFunc[0](ctx, chainHandler) - } - } - - if n == 1 { - return handleFunc[0] - } - - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) - } -} - // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** -func (e *executableSchema) dir_hasRole_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) dir_hasRole_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 Role if tmp, ok := rawArgs["role"]; ok { - arg0, err = e.unmarshalRole2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐRole(tmp) + arg0, err = ec.unmarshalRole2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐRole(tmp) if err != nil { return nil, err } @@ -342,12 +309,12 @@ func (e *executableSchema) dir_hasRole_args(ctx context.Context, rawArgs map[str return args, nil } -func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_MyMutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 TodoInput if tmp, ok := rawArgs["todo"]; ok { - arg0, err = e.unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodoInput(tmp) + arg0, err = ec.unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodoInput(tmp) if err != nil { return nil, err } @@ -356,12 +323,12 @@ func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, return args, nil } -func (e *executableSchema) field_MyMutation_updateTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_MyMutation_updateTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 int if tmp, ok := rawArgs["id"]; ok { - arg0, err = e.unmarshalInt2int(tmp) + arg0, err = ec.unmarshalInt2int(tmp) if err != nil { return nil, err } @@ -369,7 +336,7 @@ func (e *executableSchema) field_MyMutation_updateTodo_args(ctx context.Context, args["id"] = arg0 var arg1 map[string]interface{} if tmp, ok := rawArgs["changes"]; ok { - arg1, err = e.unmarshalMap2map(tmp) + arg1, err = ec.unmarshalMap2map(tmp) if err != nil { return nil, err } @@ -378,12 +345,12 @@ func (e *executableSchema) field_MyMutation_updateTodo_args(ctx context.Context, return args, nil } -func (e *executableSchema) field_MyQuery___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_MyQuery___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = e.unmarshalString2string(tmp) + arg0, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -392,12 +359,12 @@ func (e *executableSchema) field_MyQuery___type_args(ctx context.Context, rawArg return args, nil } -func (e *executableSchema) field_MyQuery_todo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_MyQuery_todo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 int if tmp, ok := rawArgs["id"]; ok { - arg0, err = e.unmarshalInt2int(tmp) + arg0, err = ec.unmarshalInt2int(tmp) if err != nil { return nil, err } @@ -406,12 +373,12 @@ func (e *executableSchema) field_MyQuery_todo_args(ctx context.Context, rawArgs return args, nil } -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = e.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } @@ -420,12 +387,12 @@ func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, raw return args, nil } -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = e.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } @@ -438,7 +405,6 @@ func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs // region **************************** field.gotpl ***************************** -// nolint: vetshadow func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -469,11 +435,9 @@ func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field gr res := resTmp.(Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._Todo(ctx, field.Selections, &res) + return ec.marshalTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _MyMutation_updateTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -501,15 +465,9 @@ func (ec *executionContext) _MyMutation_updateTodo(ctx context.Context, field gr res := resTmp.(*Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec._Todo(ctx, field.Selections, res) + return ec.marshalTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -537,15 +495,9 @@ func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.Col res := resTmp.(*Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec._Todo(ctx, field.Selections, res) + return ec.marshalTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _MyQuery_lastTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -566,15 +518,9 @@ func (ec *executionContext) _MyQuery_lastTodo(ctx context.Context, field graphql res := resTmp.(*Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec._Todo(ctx, field.Selections, res) + return ec.marshalTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -598,43 +544,9 @@ func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.Co res := resTmp.([]Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._Todo(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -662,15 +574,9 @@ func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.C res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -691,15 +597,9 @@ func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Schema(ctx, field.Selections, res) + return ec.marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -723,10 +623,9 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalInt(res) + return ec.marshalInt2int(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -750,10 +649,9 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -777,10 +675,9 @@ func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.Collec res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -804,10 +701,9 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -828,10 +724,9 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -855,19 +750,9 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 + return ec.marshal__DirectiveLocation2ᚕstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -891,43 +776,9 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -951,10 +802,9 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -975,10 +825,9 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1002,10 +851,9 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1026,14 +874,9 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1057,10 +900,9 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1081,10 +923,9 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1108,43 +949,9 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1168,18 +975,9 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1203,10 +1001,9 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1227,14 +1024,9 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1258,10 +1050,9 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1282,10 +1073,9 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1309,18 +1099,9 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1341,14 +1122,9 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1372,43 +1148,9 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1432,18 +1174,9 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1464,15 +1197,9 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1493,15 +1220,9 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1525,43 +1246,9 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Directive(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1585,10 +1272,9 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshal__TypeKind2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1609,14 +1295,9 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1637,10 +1318,9 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1668,43 +1348,9 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Field(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1725,43 +1371,9 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1782,43 +1394,9 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1846,50 +1424,16 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) +} - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1903,43 +1447,9 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1960,19 +1470,14 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** -func (e *executableSchema) unmarshalInputTodoInput(v interface{}) (TodoInput, error) { +func (ec *executionContext) unmarshalInputTodoInput(v interface{}) (TodoInput, error) { var it TodoInput var asMap = v.(map[string]interface{}) @@ -1980,18 +1485,13 @@ func (e *executableSchema) unmarshalInputTodoInput(v interface{}) (TodoInput, er switch k { case "text": var err error - it.Text, err = graphql.UnmarshalString(v) + it.Text, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "done": var err error - var ptr1 bool - if v != nil { - ptr1, err = graphql.UnmarshalBoolean(v) - it.Done = &ptr1 - } - + it.Done, err = ec.unmarshalBoolean2ᚖbool(v) if err != nil { return it, err } @@ -2011,7 +1511,6 @@ func (e *executableSchema) unmarshalInputTodoInput(v interface{}) (TodoInput, er var myMutationImplementors = []string{"MyMutation"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, myMutationImplementors) @@ -2045,7 +1544,6 @@ func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSe var myQueryImplementors = []string{"MyQuery"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, myQueryImplementors) @@ -2097,7 +1595,6 @@ func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) var todoImplementors = []string{"Todo"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, todoImplementors) @@ -2135,7 +1632,6 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj var __DirectiveImplementors = []string{"__Directive"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) @@ -2175,7 +1671,6 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS var __EnumValueImplementors = []string{"__EnumValue"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) @@ -2212,7 +1707,6 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS var __FieldImplementors = []string{"__Field"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __FieldImplementors) @@ -2259,7 +1753,6 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, var __InputValueImplementors = []string{"__InputValue"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) @@ -2296,7 +1789,6 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection var __SchemaImplementors = []string{"__Schema"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) @@ -2338,7 +1830,6 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, var __TypeImplementors = []string{"__Type"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __TypeImplementors) @@ -2384,24 +1875,413 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (e *executableSchema) unmarshalBoolean2bool(v interface{}) (bool, error) { +func (ec *executionContext) unmarshalBoolean2ᚖbool(v interface{}) (*bool, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalBoolean2bool(v) + return &res, err +} + +func (ec *executionContext) marshalBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.marshalBoolean2bool(ctx, sel, *v) +} + +func (ec *executionContext) marshalTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec._Todo(ctx, sel, v) +} + +func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.___Schema(ctx, sel, v) +} + +func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.___Type(ctx, sel, v) +} + +func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalString2string(v) + return &res, err +} + +func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.marshalString2string(ctx, sel, *v) +} + +func (ec *executionContext) marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v []Todo) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshal__DirectiveLocation2string(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__DirectiveLocation2string(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } -func (e *executableSchema) unmarshalRole2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐRole(v interface{}) (Role, error) { + +func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + + return graphql.MarshalBoolean(v) +} + +func (ec *executionContext) unmarshalRole2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐRole(v interface{}) (Role, error) { var res Role return res, res.UnmarshalGQL(v) } -func (e *executableSchema) unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodoInput(v interface{}) (TodoInput, error) { - return e.unmarshalInputTodoInput(v) + +func (ec *executionContext) marshalRole2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐRole(ctx context.Context, sel ast.SelectionSet, v Role) graphql.Marshaler { + + return v + +} + +func (ec *executionContext) unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodoInput(v interface{}) (TodoInput, error) { + return ec.unmarshalInputTodoInput(v) +} + +func (ec *executionContext) marshalTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { + + return ec._Todo(ctx, sel, &v) } -func (e *executableSchema) unmarshalInt2int(v interface{}) (int, error) { + +func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { + + return ec.___Directive(ctx, sel, &v) +} + +func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { + + return ec.___EnumValue(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { + + return ec.___Field(ctx, sel, &v) +} + +func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { + + return ec.___InputValue(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { + + return ec.___Schema(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + + return ec.___Type(ctx, sel, &v) +} + +func (ec *executionContext) unmarshalInt2int(v interface{}) (int, error) { return graphql.UnmarshalInt(v) } -func (e *executableSchema) unmarshalMap2map(v interface{}) (map[string]interface{}, error) { + +func (ec *executionContext) marshalInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { + + return graphql.MarshalInt(v) +} + +func (ec *executionContext) unmarshalMap2map(v interface{}) (map[string]interface{}, error) { return graphql.UnmarshalMap(v) } -func (e *executableSchema) unmarshalString2string(v interface{}) (string, error) { + +func (ec *executionContext) marshalMap2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler { + + return graphql.MarshalMap(v) +} + +func (ec *executionContext) unmarshalString2string(v interface{}) (string, error) { return graphql.UnmarshalString(v) } +func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + // endregion ***************************** type.gotpl ***************************** diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index aec26931601..a682889cc4a 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -89,6 +89,8 @@ func (e *executableSchema) Schema() *ast.Schema { } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e} + _ = ec switch typeName + "." + field { case "MyMutation.createTodo": @@ -96,7 +98,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_MyMutation_createTodo_args(context.TODO(), rawArgs) + args, err := ec.field_MyMutation_createTodo_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -115,7 +117,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_MyQuery_todo_args(context.TODO(), rawArgs) + args, err := ec.field_MyQuery_todo_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -358,51 +360,16 @@ extend union Data @unionLogging `}, ) -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) - - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err - - } - return handleFunc[0](ctx, chainHandler) - } - } - - if n == 1 { - return handleFunc[0] - } - - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) - } -} - // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** -func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_MyMutation_createTodo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 TodoInput if tmp, ok := rawArgs["todo"]; ok { - arg0, err = e.unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodoInput(tmp) + arg0, err = ec.unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodoInput(tmp) if err != nil { return nil, err } @@ -411,12 +378,12 @@ func (e *executableSchema) field_MyMutation_createTodo_args(ctx context.Context, return args, nil } -func (e *executableSchema) field_MyQuery___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_MyQuery___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = e.unmarshalString2string(tmp) + arg0, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -425,12 +392,12 @@ func (e *executableSchema) field_MyQuery___type_args(ctx context.Context, rawArg return args, nil } -func (e *executableSchema) field_MyQuery_todo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_MyQuery_todo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["id"]; ok { - arg0, err = e.unmarshalID2string(tmp) + arg0, err = ec.unmarshalID2string(tmp) if err != nil { return nil, err } @@ -439,12 +406,12 @@ func (e *executableSchema) field_MyQuery_todo_args(ctx context.Context, rawArgs return args, nil } -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = e.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } @@ -453,12 +420,12 @@ func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, raw return args, nil } -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = e.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } @@ -471,7 +438,6 @@ func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs // region **************************** field.gotpl ***************************** -// nolint: vetshadow func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -502,11 +468,9 @@ func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field gr res := resTmp.(Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._Todo(ctx, field.Selections, &res) + return ec.marshalTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -530,43 +494,9 @@ func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.Co res := resTmp.([]Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec._Todo(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -594,15 +524,9 @@ func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.Col res := resTmp.(*Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec._Todo(ctx, field.Selections, res) + return ec.marshalTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -630,15 +554,9 @@ func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.C res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -659,15 +577,9 @@ func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Schema(ctx, field.Selections, res) + return ec.marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -691,10 +603,9 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalID(res) + return ec.marshalID2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -718,10 +629,9 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Todo_state(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -745,10 +655,9 @@ func (ec *executionContext) _Todo_state(ctx context.Context, field graphql.Colle res := resTmp.(State) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return res + return ec.marshalState2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐState(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Todo_verified(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -772,10 +681,9 @@ func (ec *executionContext) _Todo_verified(ctx context.Context, field graphql.Co res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -799,10 +707,9 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -823,10 +730,9 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -850,19 +756,9 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 + return ec.marshal__DirectiveLocation2ᚕstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -886,43 +782,9 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -946,10 +808,9 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -970,10 +831,9 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -997,10 +857,9 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1021,14 +880,9 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1052,10 +906,9 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1076,10 +929,9 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1103,43 +955,9 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1163,18 +981,9 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1198,10 +1007,9 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1222,14 +1030,9 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1253,10 +1056,9 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1277,10 +1079,9 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1304,18 +1105,9 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1336,14 +1128,9 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1367,43 +1154,9 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1427,18 +1180,9 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1459,15 +1203,9 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1488,15 +1226,9 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1520,43 +1252,9 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Directive(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1580,10 +1278,9 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshal__TypeKind2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1604,14 +1301,9 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1632,10 +1324,9 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1663,43 +1354,9 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Field(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1720,43 +1377,9 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1777,43 +1400,9 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1841,43 +1430,9 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1898,43 +1453,9 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1955,19 +1476,14 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** -func (e *executableSchema) unmarshalInputTodoInput(v interface{}) (TodoInput, error) { +func (ec *executionContext) unmarshalInputTodoInput(v interface{}) (TodoInput, error) { var it TodoInput var asMap = v.(map[string]interface{}) @@ -1975,7 +1491,7 @@ func (e *executableSchema) unmarshalInputTodoInput(v interface{}) (TodoInput, er switch k { case "text": var err error - it.Text, err = graphql.UnmarshalString(v) + it.Text, err = ec.unmarshalString2string(v) if err != nil { return it, err } @@ -2021,7 +1537,6 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj var myMutationImplementors = []string{"MyMutation"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, myMutationImplementors) @@ -2053,7 +1568,6 @@ func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSe var myQueryImplementors = []string{"MyQuery"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, myQueryImplementors) @@ -2099,7 +1613,6 @@ func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) var todoImplementors = []string{"Todo", "Node"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, todoImplementors) @@ -2142,7 +1655,6 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj var __DirectiveImplementors = []string{"__Directive"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) @@ -2182,7 +1694,6 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS var __EnumValueImplementors = []string{"__EnumValue"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) @@ -2219,7 +1730,6 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS var __FieldImplementors = []string{"__Field"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __FieldImplementors) @@ -2266,7 +1776,6 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, var __InputValueImplementors = []string{"__InputValue"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) @@ -2303,7 +1812,6 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection var __SchemaImplementors = []string{"__Schema"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) @@ -2345,7 +1853,6 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, var __TypeImplementors = []string{"__Type"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __TypeImplementors) @@ -2391,17 +1898,387 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (e *executableSchema) unmarshalBoolean2bool(v interface{}) (bool, error) { +func (ec *executionContext) marshalTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec._Todo(ctx, sel, v) +} + +func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.___Schema(ctx, sel, v) +} + +func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.___Type(ctx, sel, v) +} + +func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalString2string(v) + return &res, err +} + +func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + + if v == nil { + return graphql.Null + } + + return ec.marshalString2string(ctx, sel, *v) +} + +func (ec *executionContext) marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v []Todo) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshal__DirectiveLocation2string(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__DirectiveLocation2string(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } -func (e *executableSchema) unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodoInput(v interface{}) (TodoInput, error) { - return e.unmarshalInputTodoInput(v) + +func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + + return graphql.MarshalBoolean(v) +} + +func (ec *executionContext) unmarshalState2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐState(v interface{}) (State, error) { + var res State + return res, res.UnmarshalGQL(v) } -func (e *executableSchema) unmarshalID2string(v interface{}) (string, error) { + +func (ec *executionContext) marshalState2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐState(ctx context.Context, sel ast.SelectionSet, v State) graphql.Marshaler { + + return v + +} + +func (ec *executionContext) unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodoInput(v interface{}) (TodoInput, error) { + return ec.unmarshalInputTodoInput(v) +} + +func (ec *executionContext) marshalTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { + + return ec._Todo(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { + + return ec.___Directive(ctx, sel, &v) +} + +func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { + + return ec.___EnumValue(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { + + return ec.___Field(ctx, sel, &v) +} + +func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { + + return ec.___InputValue(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { + + return ec.___Schema(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + + return ec.___Type(ctx, sel, &v) +} + +func (ec *executionContext) unmarshalID2string(v interface{}) (string, error) { return graphql.UnmarshalID(v) } -func (e *executableSchema) unmarshalString2string(v interface{}) (string, error) { + +func (ec *executionContext) marshalID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalID(v) +} + +func (ec *executionContext) unmarshalString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) (string, error) { return graphql.UnmarshalString(v) } +func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + + return graphql.MarshalString(v) +} + // endregion ***************************** type.gotpl ***************************** diff --git a/integration/generated.go b/integration/generated.go index ce09e2eeff1..3940c1de2c5 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -94,6 +94,8 @@ func (e *executableSchema) Schema() *ast.Schema { } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e} + _ = ec switch typeName + "." + field { case "Element.child": @@ -129,7 +131,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Query_date_args(context.TODO(), rawArgs) + args, err := ec.field_Query_date_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -155,7 +157,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - args, err := e.field_Query_error_args(context.TODO(), rawArgs) + args, err := ec.field_Query_error_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -318,51 +320,16 @@ enum ErrorType { `}, ) -// ChainFieldMiddleware add chain by FieldMiddleware -// nolint: deadcode -func chainFieldMiddleware(handleFunc ...graphql.FieldMiddleware) graphql.FieldMiddleware { - n := len(handleFunc) - - if n > 1 { - lastI := n - 1 - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - var ( - chainHandler graphql.Resolver - curI int - ) - chainHandler = func(currentCtx context.Context) (interface{}, error) { - if curI == lastI { - return next(currentCtx) - } - curI++ - res, err := handleFunc[curI](currentCtx, chainHandler) - curI-- - return res, err - - } - return handleFunc[0](ctx, chainHandler) - } - } - - if n == 1 { - return handleFunc[0] - } - - return func(ctx context.Context, next graphql.Resolver) (interface{}, error) { - return next(ctx) - } -} - // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** -func (e *executableSchema) dir_magic_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) dir_magic_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["kind"]; ok { - arg0, err = e.unmarshalInt2ᚖint(tmp) + arg0, err = ec.unmarshalInt2ᚖint(tmp) if err != nil { return nil, err } @@ -371,12 +338,12 @@ func (e *executableSchema) dir_magic_args(ctx context.Context, rawArgs map[strin return args, nil } -func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = e.unmarshalString2string(tmp) + arg0, err = ec.unmarshalString2string(tmp) if err != nil { return nil, err } @@ -385,12 +352,12 @@ func (e *executableSchema) field_Query___type_args(ctx context.Context, rawArgs return args, nil } -func (e *executableSchema) field_Query_date_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_date_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 models.DateFilter if tmp, ok := rawArgs["filter"]; ok { - arg0, err = e.unmarshalDateFilter2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilter(tmp) + arg0, err = ec.unmarshalDateFilter2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilter(tmp) if err != nil { return nil, err } @@ -399,12 +366,12 @@ func (e *executableSchema) field_Query_date_args(ctx context.Context, rawArgs ma return args, nil } -func (e *executableSchema) field_Query_error_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_error_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 *models.ErrorType if tmp, ok := rawArgs["type"]; ok { - arg0, err = e.unmarshalErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(tmp) + arg0, err = ec.unmarshalErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(tmp) if err != nil { return nil, err } @@ -413,12 +380,12 @@ func (e *executableSchema) field_Query_error_args(ctx context.Context, rawArgs m return args, nil } -func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = e.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } @@ -427,12 +394,12 @@ func (e *executableSchema) field___Type_enumValues_args(ctx context.Context, raw return args, nil } -func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = e.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalBoolean2bool(tmp) if err != nil { return nil, err } @@ -445,7 +412,6 @@ func (e *executableSchema) field___Type_fields_args(ctx context.Context, rawArgs // region **************************** field.gotpl ***************************** -// nolint: vetshadow func (ec *executionContext) _Element_child(ctx context.Context, field graphql.CollectedField, obj *models.Element) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -469,11 +435,9 @@ func (ec *executionContext) _Element_child(ctx context.Context, field graphql.Co res := resTmp.(models.Element) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - return ec._Element(ctx, field.Selections, &res) + return ec.marshalElement2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Element_error(ctx context.Context, field graphql.CollectedField, obj *models.Element) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -497,10 +461,9 @@ func (ec *executionContext) _Element_error(ctx context.Context, field graphql.Co res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Element_mismatched(ctx context.Context, field graphql.CollectedField, obj *models.Element) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -521,19 +484,9 @@ func (ec *executionContext) _Element_mismatched(ctx context.Context, field graph res := resTmp.([]bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalBoolean(res[idx1]) - }() - } - - return arr1 + return ec.marshalBoolean2ᚕbool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_path(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -554,47 +507,9 @@ func (ec *executionContext) _Query_path(ctx context.Context, field graphql.Colle res := resTmp.([]*models.Element) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - if res[idx1] == nil { - return graphql.Null - } - - return ec._Element(ctx, field.Selections, res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshalElement2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_date(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -625,10 +540,9 @@ func (ec *executionContext) _Query_date(ctx context.Context, field graphql.Colle res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_viewer(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -649,15 +563,9 @@ func (ec *executionContext) _Query_viewer(ctx context.Context, field graphql.Col res := resTmp.(*models.Viewer) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec._Viewer(ctx, field.Selections, res) + return ec.marshalViewer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐViewer(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_jsonEncoding(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -681,10 +589,9 @@ func (ec *executionContext) _Query_jsonEncoding(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query_error(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -715,10 +622,9 @@ func (ec *executionContext) _Query_error(ctx context.Context, field graphql.Coll res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -746,15 +652,9 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -775,15 +675,9 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Schema(ctx, field.Selections, res) + return ec.marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *remote_api.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -807,10 +701,9 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _User_likes(ctx context.Context, field graphql.CollectedField, obj *remote_api.User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -834,19 +727,9 @@ func (ec *executionContext) _User_likes(ctx context.Context, field graphql.Colle res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 + return ec.marshalString2ᚕstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) _Viewer_user(ctx context.Context, field graphql.CollectedField, obj *models.Viewer) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -867,15 +750,9 @@ func (ec *executionContext) _Viewer_user(ctx context.Context, field graphql.Coll res := resTmp.(*remote_api.User) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec._User(ctx, field.Selections, res) + return ec.marshalUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋremote_apiᚐUser(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -899,10 +776,9 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -923,10 +799,9 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -950,19 +825,9 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return graphql.MarshalString(res[idx1]) - }() - } - - return arr1 + return ec.marshal__DirectiveLocation2ᚕstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -986,43 +851,9 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1046,10 +877,9 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1070,10 +900,9 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1097,10 +926,9 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1121,14 +949,9 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1152,10 +975,9 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1176,10 +998,9 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1203,43 +1024,9 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1263,18 +1050,9 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1298,10 +1076,9 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalBoolean(res) + return ec.marshalBoolean2bool(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1322,14 +1099,9 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1353,10 +1125,9 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1377,10 +1148,9 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1404,18 +1174,9 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1436,14 +1197,9 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1467,43 +1223,9 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1527,18 +1249,9 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1559,15 +1272,9 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1588,15 +1295,9 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1620,43 +1321,9 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Directive(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1680,10 +1347,9 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshal__TypeKind2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1704,14 +1370,9 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - return graphql.MarshalString(*res) + return ec.marshalString2ᚖstring(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1732,10 +1393,9 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return graphql.MarshalString(res) + return ec.marshalString2string(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1763,43 +1423,9 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Field(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1820,43 +1446,9 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1877,43 +1469,9 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___Type(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -1941,50 +1499,16 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) +} - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___EnumValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 -} - -// nolint: vetshadow -func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "__Type", + Field: field, + Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1998,43 +1522,9 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - arr1 := make(graphql.Array, len(res)) - var wg sync.WaitGroup - - isLen1 := len(res) == 1 - if !isLen1 { - wg.Add(len(res)) - } - - for idx1 := range res { - idx1 := idx1 - rctx := &graphql.ResolverContext{ - Index: &idx1, - Result: &res[idx1], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(idx1 int) { - if !isLen1 { - defer wg.Done() - } - arr1[idx1] = func() graphql.Marshaler { - - return ec.___InputValue(ctx, field.Selections, &res[idx1]) - }() - } - if isLen1 { - f(idx1) - } else { - go f(idx1) - } - - } - wg.Wait() - return arr1 + return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } -// nolint: vetshadow func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2055,19 +1545,14 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - - if res == nil { - return graphql.Null - } - - return ec.___Type(ctx, field.Selections, res) + return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** -func (e *executableSchema) unmarshalInputDateFilter(v interface{}) (models.DateFilter, error) { +func (ec *executionContext) unmarshalInputDateFilter(v interface{}) (models.DateFilter, error) { var it models.DateFilter var asMap = v.(map[string]interface{}) @@ -2082,29 +1567,19 @@ func (e *executableSchema) unmarshalInputDateFilter(v interface{}) (models.DateF switch k { case "value": var err error - it.Value, err = graphql.UnmarshalString(v) + it.Value, err = ec.unmarshalString2string(v) if err != nil { return it, err } case "timezone": var err error - var ptr1 string - if v != nil { - ptr1, err = graphql.UnmarshalString(v) - it.Timezone = &ptr1 - } - + it.Timezone, err = ec.unmarshalString2ᚖstring(v) if err != nil { return it, err } case "op": var err error - var ptr1 models.DateFilterOp - if v != nil { - err = (&ptr1).UnmarshalGQL(v) - it.Op = &ptr1 - } - + it.Op, err = ec.unmarshalDATE_FILTER_OP2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(v) if err != nil { return it, err } @@ -2124,7 +1599,6 @@ func (e *executableSchema) unmarshalInputDateFilter(v interface{}) (models.DateF var elementImplementors = []string{"Element"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Element(ctx context.Context, sel ast.SelectionSet, obj *models.Element) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, elementImplementors) @@ -2171,7 +1645,6 @@ func (ec *executionContext) _Element(ctx context.Context, sel ast.SelectionSet, var queryImplementors = []string{"Query"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, queryImplementors) @@ -2241,7 +1714,6 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr var userImplementors = []string{"User"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *remote_api.User) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, userImplementors) @@ -2278,7 +1750,6 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj var viewerImplementors = []string{"Viewer"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _Viewer(ctx context.Context, sel ast.SelectionSet, obj *models.Viewer) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, viewerImplementors) @@ -2303,7 +1774,6 @@ func (ec *executionContext) _Viewer(ctx context.Context, sel ast.SelectionSet, o var __DirectiveImplementors = []string{"__Directive"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __DirectiveImplementors) @@ -2343,7 +1813,6 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS var __EnumValueImplementors = []string{"__EnumValue"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __EnumValueImplementors) @@ -2380,7 +1849,6 @@ func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionS var __FieldImplementors = []string{"__Field"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __FieldImplementors) @@ -2427,7 +1895,6 @@ func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, var __InputValueImplementors = []string{"__InputValue"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __InputValueImplementors) @@ -2464,7 +1931,6 @@ func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.Selection var __SchemaImplementors = []string{"__Schema"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __SchemaImplementors) @@ -2506,7 +1972,6 @@ func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, var __TypeImplementors = []string{"__Type"} -// nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, __TypeImplementors) @@ -2552,35 +2017,492 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (e *executableSchema) unmarshalErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(v interface{}) (*models.ErrorType, error) { +func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Schema(ctx, sel, v) +} + +func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Type(ctx, sel, v) +} + +func (ec *executionContext) unmarshalDATE_FILTER_OP2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(v interface{}) (*models.DateFilterOp, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalDATE_FILTER_OP2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(v) + return &res, err +} + +func (ec *executionContext) marshalDATE_FILTER_OP2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(ctx context.Context, sel ast.SelectionSet, v *models.DateFilterOp) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) marshalElement2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx context.Context, sel ast.SelectionSet, v *models.Element) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Element(ctx, sel, v) +} + +func (ec *executionContext) unmarshalErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(v interface{}) (*models.ErrorType, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalErrorType2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(v) + return &res, err +} + +func (ec *executionContext) marshalErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(ctx context.Context, sel ast.SelectionSet, v *models.ErrorType) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) marshalViewer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐViewer(ctx context.Context, sel ast.SelectionSet, v *models.Viewer) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Viewer(ctx, sel, v) +} + +func (ec *executionContext) marshalUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋremote_apiᚐUser(ctx context.Context, sel ast.SelectionSet, v *remote_api.User) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._User(ctx, sel, v) +} + +func (ec *executionContext) unmarshalInt2ᚖint(v interface{}) (*int, error) { if v == nil { return nil, nil } - res, err := e.unmarshalErrorType2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(v) + res, err := ec.unmarshalInt2int(v) return &res, err } -func (e *executableSchema) unmarshalInt2ᚖint(v interface{}) (*int, error) { + +func (ec *executionContext) marshalInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalInt2int(ctx, sel, *v) +} + +func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := e.unmarshalInt2int(v) + res, err := ec.unmarshalString2string(v) return &res, err } -func (e *executableSchema) unmarshalBoolean2bool(v interface{}) (bool, error) { + +func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalString2string(ctx, sel, *v) +} + +func (ec *executionContext) marshalElement2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx context.Context, sel ast.SelectionSet, v []*models.Element) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalElement2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) unmarshalBoolean2ᚕbool(v interface{}) ([]bool, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]bool, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshalBoolean2bool(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalBoolean2ᚕbool(ctx context.Context, sel ast.SelectionSet, v []bool) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalBoolean2bool(ctx, sel, v[i]) + } + + return ret +} + +func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) unmarshalString2ᚕstring(v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshalString2string(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalString2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalString2string(ctx, sel, v[i]) + } + + return ret +} + +func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshal__DirectiveLocation2string(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshal__DirectiveLocation2string(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } -func (e *executableSchema) unmarshalDateFilter2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilter(v interface{}) (models.DateFilter, error) { - return e.unmarshalInputDateFilter(v) + +func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + return graphql.MarshalBoolean(v) +} + +func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { + return ec.___Directive(ctx, sel, &v) } -func (e *executableSchema) unmarshalErrorType2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(v interface{}) (models.ErrorType, error) { + +func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { + return ec.___EnumValue(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { + return ec.___Field(ctx, sel, &v) +} + +func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { + return ec.___InputValue(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { + return ec.___Schema(ctx, sel, &v) +} + +func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + return ec.___Type(ctx, sel, &v) +} + +func (ec *executionContext) unmarshalDateFilter2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilter(v interface{}) (models.DateFilter, error) { + return ec.unmarshalInputDateFilter(v) +} + +func (ec *executionContext) unmarshalDATE_FILTER_OP2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(v interface{}) (models.DateFilterOp, error) { + var res models.DateFilterOp + return res, res.UnmarshalGQL(v) +} + +func (ec *executionContext) marshalDATE_FILTER_OP2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(ctx context.Context, sel ast.SelectionSet, v models.DateFilterOp) graphql.Marshaler { + return v +} + +func (ec *executionContext) marshalElement2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx context.Context, sel ast.SelectionSet, v models.Element) graphql.Marshaler { + return ec._Element(ctx, sel, &v) +} + +func (ec *executionContext) unmarshalErrorType2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(v interface{}) (models.ErrorType, error) { var res models.ErrorType return res, res.UnmarshalGQL(v) } -func (e *executableSchema) unmarshalInt2int(v interface{}) (int, error) { + +func (ec *executionContext) marshalErrorType2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(ctx context.Context, sel ast.SelectionSet, v models.ErrorType) graphql.Marshaler { + return v +} + +func (ec *executionContext) marshalViewer2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐViewer(ctx context.Context, sel ast.SelectionSet, v models.Viewer) graphql.Marshaler { + return ec._Viewer(ctx, sel, &v) +} + +func (ec *executionContext) marshalUser2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋremote_apiᚐUser(ctx context.Context, sel ast.SelectionSet, v remote_api.User) graphql.Marshaler { + return ec._User(ctx, sel, &v) +} + +func (ec *executionContext) unmarshalInt2int(v interface{}) (int, error) { return graphql.UnmarshalInt(v) } -func (e *executableSchema) unmarshalString2string(v interface{}) (string, error) { + +func (ec *executionContext) marshalInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { + return graphql.MarshalInt(v) +} + +func (ec *executionContext) unmarshalString2string(v interface{}) (string, error) { return graphql.UnmarshalString(v) } +func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + // endregion ***************************** type.gotpl ***************************** diff --git a/plugin/modelgen/models.go b/plugin/modelgen/models.go index 62a53ad1915..841684f9739 100644 --- a/plugin/modelgen/models.go +++ b/plugin/modelgen/models.go @@ -166,7 +166,7 @@ func (m *Plugin) MutateConfig(cfg *config.Config) error { sort.Slice(b.Interfaces, func(i, j int) bool { return b.Interfaces[i].Name < b.Interfaces[j].Name }) for _, it := range b.Enums { - cfg.Models.Add(it.Name, cfg.Model.ImportPath()+"."+it.Name) + cfg.Models.Add(it.Raw, cfg.Model.ImportPath()+"."+it.Name) } for _, it := range b.Models { cfg.Models.Add(it.Name, cfg.Model.ImportPath()+"."+it.Name) From b3f139c9374854d87d61a0628031136d1f215653 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Wed, 6 Feb 2019 14:09:14 +1100 Subject: [PATCH 066/147] Cleanup field/method bind code --- codegen/args.go | 2 +- codegen/config/binder.go | 22 ++ codegen/data.go | 51 ++-- codegen/errors_test.go | 2 +- codegen/field.go | 274 ++++++++++++--------- codegen/field_test.go | 2 +- codegen/object.go | 38 +-- codegen/testserver/generated.go | 54 ---- codegen/type.gotpl | 5 - example/chat/generated.go | 29 --- example/config/generated.go | 67 ++--- example/dataloader/generated.go | 37 --- example/scalars/generated.go | 40 --- example/selection/generated.go | 26 -- example/starwars/generated.go | 67 ----- example/todo/generated.go | 32 --- example/type-system-extension/generated.go | 29 --- integration/generated.go | 9 +- 18 files changed, 218 insertions(+), 568 deletions(-) diff --git a/codegen/args.go b/codegen/args.go index 8ae1e097b35..ea3bacbff19 100644 --- a/codegen/args.go +++ b/codegen/args.go @@ -83,7 +83,7 @@ nextArg: } // no matching arg found, abort - return fmt.Errorf("arg %s not found on method", param.Name()) + return fmt.Errorf("%s is not in schema", param.Name()) } field.Args = newArgs diff --git a/codegen/config/binder.go b/codegen/config/binder.go index 29f23cfa8a4..372fde0b74d 100644 --- a/codegen/config/binder.go +++ b/codegen/config/binder.go @@ -2,6 +2,7 @@ package config import ( "fmt" + "go/token" "go/types" "regexp" "strings" @@ -33,6 +34,27 @@ func (c *Config) NewBinder(s *ast.Schema) (*Binder, error) { }, nil } +func (b *Binder) TypePosition(typ types.Type) token.Position { + named, isNamed := typ.(*types.Named) + if !isNamed { + return token.Position{ + Filename: "unknown", + } + } + + return b.ObjectPosition(named.Obj()) +} + +func (b *Binder) ObjectPosition(typ types.Object) token.Position { + if typ == nil { + return token.Position{ + Filename: "unknown", + } + } + pkg := b.getPkg(typ.Pkg().Path()) + return pkg.Fset.Position(typ.Pos()) +} + func (b *Binder) FindType(pkgName string, typeName string) (types.Type, error) { obj, err := b.FindObject(pkgName, typeName) if err != nil { diff --git a/codegen/data.go b/codegen/data.go index e390f588bf2..df1188b75a4 100644 --- a/codegen/data.go +++ b/codegen/data.go @@ -132,50 +132,29 @@ func (b *builder) injectIntrospectionRoots(s *Data) error { return fmt.Errorf("root query type must be defined") } - typeType, err := b.Binder.TypeReference(ast.NamedType("__Type", nil)) - if err != nil { - return errors.Wrap(err, "unable to find root Type introspection type") - } - stringRef, err := b.Binder.TypeReference(ast.NonNullNamedType("String", nil)) - if err != nil { - return errors.Wrap(err, "unable to find root string type reference") - } - - obj.Fields = append(obj.Fields, &Field{ - TypeReference: typeType, - FieldDefinition: &ast.FieldDefinition{ - Name: "__type", - }, - GoFieldType: GoFieldMethod, - GoReceiverName: "ec", - GoFieldName: "introspectType", - Args: []*FieldArgument{ + __type, err := b.buildField(obj, &ast.FieldDefinition{ + Name: "__type", + Type: ast.NamedType("__Type", nil), + Arguments: []*ast.ArgumentDefinition{ { - ArgumentDefinition: &ast.ArgumentDefinition{ - Name: "name", - }, - TypeReference: stringRef, - Object: &Object{}, + Name: "name", + Type: ast.NonNullNamedType("String", nil), }, }, - Object: obj, }) - - schemaType, err := b.Binder.TypeReference(ast.NamedType("__Schema", nil)) if err != nil { - return errors.Wrap(err, "unable to find root Schema introspection type") + return err } - obj.Fields = append(obj.Fields, &Field{ - TypeReference: schemaType, - FieldDefinition: &ast.FieldDefinition{ - Name: "__schema", - }, - GoFieldType: GoFieldMethod, - GoReceiverName: "ec", - GoFieldName: "introspectSchema", - Object: obj, + __schema, err := b.buildField(obj, &ast.FieldDefinition{ + Name: "__schema", + Type: ast.NamedType("__Schema", nil), }) + if err != nil { + return err + } + + obj.Fields = append(obj.Fields, __type, __schema) return nil } diff --git a/codegen/errors_test.go b/codegen/errors_test.go index 2cd16b593bd..53c213aed5a 100644 --- a/codegen/errors_test.go +++ b/codegen/errors_test.go @@ -10,7 +10,7 @@ import ( func TestTypeUnionAsInput(t *testing.T) { err := generate("inputunion", `testdata/unioninput.graphqls`) - require.EqualError(t, err, "unable to build object definition: Query.addBookmark: cannot use Bookmarkable! as argument b because UNION is not a valid input type") + require.EqualError(t, err, "unable to build object definition: cannot use Bookmarkable! as argument b because UNION is not a valid input type") } func TestTypeInInput(t *testing.T) { diff --git a/codegen/field.go b/codegen/field.go index 057aa7265ac..c10666e28f1 100644 --- a/codegen/field.go +++ b/codegen/field.go @@ -3,6 +3,7 @@ package codegen import ( "fmt" "go/types" + "log" "reflect" "strconv" "strings" @@ -51,6 +52,16 @@ func (b *builder) buildField(obj *Object, field *ast.FieldDefinition) (*Field, e GoReceiverName: "obj", } + if obj.Kind == ast.InputObject && !f.TypeReference.Definition.IsInputType() { + return nil, errors.Errorf( + "%s.%s: cannot use %s because %s is not a valid input type", + obj.Name, + field.Name, + f.TypeReference.Definition.Name, + f.TypeReference.Definition.Kind, + ) + } + if field.DefaultValue != nil { var err error f.Default, err = field.DefaultValue.Value(nil) @@ -59,18 +70,6 @@ func (b *builder) buildField(obj *Object, field *ast.FieldDefinition) (*Field, e } } - typeEntry, entryExists := b.Config.Models[obj.Definition.Name] - if entryExists { - if typeField, ok := typeEntry.Fields[field.Name]; ok { - if typeField.Resolver { - f.IsResolver = true - } - if typeField.FieldName != "" { - f.GoFieldName = templates.ToGo(typeField.FieldName) - } - } - } - for _, arg := range field.Arguments { newArg, err := b.buildArg(obj, arg) if err != nil { @@ -78,92 +77,147 @@ func (b *builder) buildField(obj *Object, field *ast.FieldDefinition) (*Field, e } f.Args = append(f.Args, newArg) } + + if err = b.bindField(obj, &f); err != nil { + log.Printf(err.Error()) + } + return &f, nil } -func (b *builder) bindMethod(t types.Type, field *Field) error { - namedType, err := findGoNamedType(t) +func (b *builder) bindField(obj *Object, f *Field) error { + switch { + case f.Name == "__schema": + f.GoFieldType = GoFieldMethod + f.GoReceiverName = "ec" + f.GoFieldName = "introspectSchema" + return nil + case f.Name == "__type": + f.GoFieldType = GoFieldMethod + f.GoReceiverName = "ec" + f.GoFieldName = "introspectType" + return nil + case obj.Root: + f.IsResolver = true + return nil + case b.Config.Models[obj.Name].Fields[f.Name].Resolver: + f.IsResolver = true + return nil + case obj.Type == config.MapType: + return nil + case b.Config.Models[obj.Name].Fields[f.Name].FieldName != "": + f.Name = b.Config.Models[obj.Name].Fields[f.Name].FieldName + } + + target, err := b.findBindTarget(obj.Type.(*types.Named), f.Name) if err != nil { return err } - method := b.findMethod(namedType, field.GoFieldName) - if method == nil { - return fmt.Errorf("no method named %s", field.GoFieldName) - } - sig := method.Type().(*types.Signature) + pos := b.Binder.ObjectPosition(target) + + switch target := target.(type) { + case nil: + f.IsResolver = true + + objPos := b.Binder.TypePosition(obj.Type) + return fmt.Errorf( + "%s:%d adding resolver method for %s.%s, nothing matched", + objPos.Filename, + objPos.Line, + obj.Name, + f.Name, + ) + case *types.Func: + sig := target.Type().(*types.Signature) + if sig.Results().Len() == 1 { + f.NoErr = true + } else if sig.Results().Len() != 2 { + return fmt.Errorf("method has wrong number of args") + } + params := sig.Params() + // If the first argument is the context, remove it from the comparison and set + // the MethodHasContext flag so that the context will be passed to this model's method + if params.Len() > 0 && params.At(0).Type().String() == "context.Context" { + f.MethodHasContext = true + vars := make([]*types.Var, params.Len()-1) + for i := 1; i < params.Len(); i++ { + vars[i-1] = params.At(i) + } + params = types.NewTuple(vars...) + } - if sig.Results().Len() == 1 { - field.NoErr = true - } else if sig.Results().Len() != 2 { - return fmt.Errorf("method has wrong number of args") - } - params := sig.Params() - // If the first argument is the context, remove it from the comparison and set - // the MethodHasContext flag so that the context will be passed to this model's method - if params.Len() > 0 && params.At(0).Type().String() == "context.Context" { - field.MethodHasContext = true - vars := make([]*types.Var, params.Len()-1) - for i := 1; i < params.Len(); i++ { - vars[i-1] = params.At(i) + if err = b.bindArgs(f, params); err != nil { + return errors.Wrapf(err, "%s:%d", pos.Filename, pos.Line) } - params = types.NewTuple(vars...) - } - if err := b.bindArgs(field, params); err != nil { - return err - } + result := sig.Results().At(0) + if err = code.CompatibleTypes(f.TypeReference.GO, result.Type()); err != nil { + return errors.Wrapf(err, "%s:%d %s is not compatible with %s", pos.Filename, pos.Line, f.TypeReference.GO.String(), result.Type().String()) + } - result := sig.Results().At(0) - if err = code.CompatibleTypes(field.TypeReference.GO, result.Type()); err != nil { - return errors.Wrapf(err, "%s is not compatible with %s", field.TypeReference.GO.String(), result.String()) - } + // success, args and return type match. Bind to method + f.GoFieldType = GoFieldMethod + f.GoReceiverName = "obj" + f.GoFieldName = target.Name() + f.TypeReference.GO = result.Type() - // success, args and return type match. Bind to method - field.GoFieldType = GoFieldMethod - field.GoReceiverName = "obj" - field.GoFieldName = method.Name() - field.TypeReference.GO = result.Type() - return nil -} + return nil -func (b *builder) bindVar(t types.Type, field *Field) error { - underlying, ok := t.Underlying().(*types.Struct) - if !ok { - return fmt.Errorf("not a struct") - } + case *types.Var: + if err = code.CompatibleTypes(f.TypeReference.GO, target.Type()); err != nil { + return errors.Wrapf(err, "%s:%d %s is not compatible with %s", pos.Filename, pos.Line, f.TypeReference.GO.String(), target.Type().String()) + } - structField, err := b.findField(underlying, field.GoFieldName) - if err != nil { - return err - } + // success, bind to var + f.GoFieldType = GoFieldVariable + f.GoReceiverName = "obj" + f.GoFieldName = target.Name() + f.TypeReference.GO = target.Type() - if err = code.CompatibleTypes(field.TypeReference.GO, structField.Type()); err != nil { - return errors.Wrapf(err, "%s is not compatible with %s", field.TypeReference.GO.String(), field.TypeReference.GO.String()) + return nil + default: + panic(fmt.Errorf("unknown bind target %T for %s", target, f.Name)) } - - // success, bind to var - field.GoFieldType = GoFieldVariable - field.GoReceiverName = "obj" - field.GoFieldName = structField.Name() - field.TypeReference.GO = structField.Type() - return nil } // findField attempts to match the name to a struct field with the following // priorites: -// 1. If struct tag is passed then struct tag has highest priority -// 2. Actual Field name -// 3. Field in an embedded struct -func (b *builder) findField(typ *types.Struct, name string) (*types.Var, error) { +// 1. Any method with a matching name +// 2. Any Fields with a struct tag (see config.StructTag) +// 3. Any fields with a matching name +// 4. Same logic again for embedded fields +func (b *builder) findBindTarget(named *types.Named, name string) (types.Object, error) { + for i := 0; i < named.NumMethods(); i++ { + method := named.Method(i) + if !method.Exported() { + continue + } + + if !strings.EqualFold(method.Name(), name) { + continue + } + + return method, nil + } + + strukt, ok := named.Underlying().(*types.Struct) + if !ok { + return nil, fmt.Errorf("not a struct") + } + return b.findBindStructTarget(strukt, name) +} + +func (b *builder) findBindStructTarget(strukt *types.Struct, name string) (types.Object, error) { + // struct tags have the highest priority if b.Config.StructTag != "" { var foundField *types.Var - for i := 0; i < typ.NumFields(); i++ { - field := typ.Field(i) + for i := 0; i < strukt.NumFields(); i++ { + field := strukt.Field(i) if !field.Exported() { continue } - tags := reflect.StructTag(typ.Tag(i)) + tags := reflect.StructTag(strukt.Tag(i)) if val, ok := tags.Lookup(b.Config.StructTag); ok && equalFieldName(val, name) { if foundField != nil { return nil, errors.Errorf("tag %s is ambigious; multiple fields have the same tag value of %s", b.Config.StructTag, val) @@ -177,8 +231,9 @@ func (b *builder) findField(typ *types.Struct, name string) (*types.Var, error) } } - for i := 0; i < typ.NumFields(); i++ { - field := typ.Field(i) + // Then matching field names + for i := 0; i < strukt.NumFields(); i++ { + field := strukt.Field(i) if !field.Exported() { continue } @@ -187,64 +242,45 @@ func (b *builder) findField(typ *types.Struct, name string) (*types.Var, error) } } - for i := 0; i < typ.NumFields(); i++ { - field := typ.Field(i) + // Then look in embedded structs + for i := 0; i < strukt.NumFields(); i++ { + field := strukt.Field(i) if !field.Exported() { continue } - if field.Anonymous() { - fieldType := field.Type() - - if ptr, ok := fieldType.(*types.Pointer); ok { - fieldType = ptr.Elem() - } - - // Type.Underlying() returns itself for all types except types.Named, where it returns a struct type. - // It should be safe to always call. - if named, ok := fieldType.Underlying().(*types.Struct); ok { - f, err := b.findField(named, name) - if err != nil && !strings.HasPrefix(err.Error(), "no field named") { - return nil, err - } - if f != nil { - return f, nil - } - } - } - } - - return nil, fmt.Errorf("no field named %s", name) -} - -func (b *builder) findMethod(typ *types.Named, name string) *types.Func { - for i := 0; i < typ.NumMethods(); i++ { - method := typ.Method(i) - if !method.Exported() { + if !field.Anonymous() { continue } - if strings.EqualFold(method.Name(), name) { - return method + fieldType := field.Type() + if ptr, ok := fieldType.(*types.Pointer); ok { + fieldType = ptr.Elem() } - } - if s, ok := typ.Underlying().(*types.Struct); ok { - for i := 0; i < s.NumFields(); i++ { - field := s.Field(i) - if !field.Anonymous() { - continue + switch fieldType := fieldType.(type) { + case *types.Named: + f, err := b.findBindTarget(fieldType, name) + if err != nil { + return nil, err } - - if named, ok := field.Type().(*types.Named); ok { - if f := b.findMethod(named, name); f != nil { - return f - } + if f != nil { + return f, nil + } + case *types.Struct: + f, err := b.findBindStructTarget(fieldType, name) + if err != nil { + return nil, err + } + if f != nil { + return f, nil } + default: + panic(fmt.Errorf("unknown embedded field type %T", field.Type())) } } - return nil + return nil, nil } func (f *Field) HasDirectives() bool { diff --git a/codegen/field_test.go b/codegen/field_test.go index cdd9a21f3fd..6702a606974 100644 --- a/codegen/field_test.go +++ b/codegen/field_test.go @@ -65,7 +65,7 @@ type Embed struct { for _, tt := range tests { b := builder{Config: &config.Config{StructTag: tt.Tag}} - field, err := b.findField(tt.Struct, tt.Field) + field, err := b.findBindStructTarget(tt.Struct, tt.Field) if tt.ShouldError { require.Nil(t, field, tt.Name) require.Error(t, err, tt.Name) diff --git a/codegen/object.go b/codegen/object.go index 20e5533a375..243b35371a4 100644 --- a/codegen/object.go +++ b/codegen/object.go @@ -2,7 +2,6 @@ package codegen import ( "go/types" - "log" "strconv" "strings" "unicode" @@ -72,45 +71,10 @@ func (b *builder) buildObject(typ *ast.Definition) (*Object, error) { var f *Field f, err = b.buildField(obj, field) if err != nil { - return nil, errors.Wrap(err, typ.Name+"."+field.Name) - } - - if typ.Kind == ast.InputObject && !f.TypeReference.Definition.IsInputType() { - return nil, errors.Errorf( - "%s.%s: cannot use %s because %s is not a valid input type", - typ.Name, - field.Name, - f.TypeReference.Definition.Name, - f.TypeReference.Definition.Kind, - ) + return nil, err } obj.Fields = append(obj.Fields, f) - - if obj.Root { - f.IsResolver = true - } else if !f.IsResolver { - // first try binding to a method - methodErr := b.bindMethod(obj.Type, f) - if methodErr == nil { - continue - } - - // otherwise try binding to a var - varErr := b.bindVar(obj.Type, f) - - // if both failed, add a resolver - if varErr != nil { - f.IsResolver = true - - log.Printf("\nadding resolver method for %s.%s to %s\n %s\n %s", - obj.Name, - field.Name, - obj.Type.String(), - methodErr.Error(), - varErr.Error()) - } - } } return obj, nil diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 10749ed35e7..3efb3719ca6 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -4312,29 +4312,23 @@ func (ec *executionContext) unmarshalBoolean2ᚖbool(v interface{}) (*bool, erro } func (ec *executionContext) marshalBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalBoolean2bool(ctx, sel, *v) } func (ec *executionContext) marshalCircle2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCircle(ctx context.Context, sel ast.SelectionSet, v *Circle) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._Circle(ctx, sel, v) } func (ec *executionContext) marshalError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx context.Context, sel ast.SelectionSet, v *Error) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._Error(ctx, sel, v) } @@ -4363,11 +4357,9 @@ func (ec *executionContext) unmarshalKeywords2ᚖgithubᚗcomᚋ99designsᚋgqlg } func (ec *executionContext) marshalModelMethods2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐModelMethods(ctx context.Context, sel ast.SelectionSet, v *ModelMethods) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._ModelMethods(ctx, sel, v) } @@ -4380,11 +4372,9 @@ func (ec *executionContext) unmarshalOuterInput2ᚖgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshalOuterObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v *OuterObject) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._OuterObject(ctx, sel, v) } @@ -4397,38 +4387,30 @@ func (ec *executionContext) unmarshalRecursiveInputSlice2ᚖgithubᚗcomᚋ99des } func (ec *executionContext) marshalIt2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋintrospectionᚐIt(ctx context.Context, sel ast.SelectionSet, v *introspection1.It) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._It(ctx, sel, v) } func (ec *executionContext) marshalInvalidIdentifier2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx context.Context, sel ast.SelectionSet, v *invalid_packagename.InvalidIdentifier) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._InvalidIdentifier(ctx, sel, v) } func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Schema(ctx, sel, v) } func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Type(ctx, sel, v) } @@ -4441,11 +4423,9 @@ func (ec *executionContext) unmarshalInt2ᚖint(v interface{}) (*int, error) { } func (ec *executionContext) marshalInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalInt2int(ctx, sel, *v) } @@ -4458,11 +4438,9 @@ func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, e } func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalString2string(ctx, sel, *v) } @@ -4487,7 +4465,6 @@ func (ec *executionContext) unmarshalOuterInput2ᚕᚖgithubᚗcomᚋ99designs } func (ec *executionContext) marshalOuterObject2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v []*OuterObject) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4539,7 +4516,6 @@ func (ec *executionContext) unmarshalOuterInput2ᚕᚕᚖgithubᚗcomᚋ99design } func (ec *executionContext) marshalOuterObject2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v [][]*OuterObject) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4591,7 +4567,6 @@ func (ec *executionContext) unmarshalRecursiveInputSlice2ᚕgithubᚗcomᚋ99des } func (ec *executionContext) marshalShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx context.Context, sel ast.SelectionSet, v []Shape) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4623,7 +4598,6 @@ func (ec *executionContext) marshalShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ } func (ec *executionContext) marshalUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx context.Context, sel ast.SelectionSet, v []User) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4655,7 +4629,6 @@ func (ec *executionContext) marshalUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋc } func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4687,7 +4660,6 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4719,7 +4691,6 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4751,7 +4722,6 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4783,7 +4753,6 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4835,7 +4804,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{} } func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4871,7 +4839,6 @@ func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { } func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) } @@ -4880,17 +4847,14 @@ func (ec *executionContext) unmarshalFloat2float64(v interface{}) (float64, erro } func (ec *executionContext) marshalFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { - return graphql.MarshalFloat(v) } func (ec *executionContext) marshalCircle2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCircle(ctx context.Context, sel ast.SelectionSet, v Circle) graphql.Marshaler { - return ec._Circle(ctx, sel, &v) } func (ec *executionContext) marshalError2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx context.Context, sel ast.SelectionSet, v Error) graphql.Marshaler { - return ec._Error(ctx, sel, &v) } @@ -4903,7 +4867,6 @@ func (ec *executionContext) unmarshalInnerInput2githubᚗcomᚋ99designsᚋgqlge } func (ec *executionContext) marshalInnerObject2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerObject(ctx context.Context, sel ast.SelectionSet, v InnerObject) graphql.Marshaler { - return ec._InnerObject(ctx, sel, &v) } @@ -4916,7 +4879,6 @@ func (ec *executionContext) unmarshalKeywords2githubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalModelMethods2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐModelMethods(ctx context.Context, sel ast.SelectionSet, v ModelMethods) graphql.Marshaler { - return ec._ModelMethods(ctx, sel, &v) } @@ -4925,7 +4887,6 @@ func (ec *executionContext) unmarshalOuterInput2githubᚗcomᚋ99designsᚋgqlge } func (ec *executionContext) marshalOuterObject2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v OuterObject) graphql.Marshaler { - return ec._OuterObject(ctx, sel, &v) } @@ -4934,52 +4895,42 @@ func (ec *executionContext) unmarshalRecursiveInputSlice2githubᚗcomᚋ99design } func (ec *executionContext) marshalShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx context.Context, sel ast.SelectionSet, v Shape) graphql.Marshaler { - return ec._Shape(ctx, sel, &v) } func (ec *executionContext) marshalUser2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler { - return ec._User(ctx, sel, &v) } func (ec *executionContext) marshalIt2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋintrospectionᚐIt(ctx context.Context, sel ast.SelectionSet, v introspection1.It) graphql.Marshaler { - return ec._It(ctx, sel, &v) } func (ec *executionContext) marshalInvalidIdentifier2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx context.Context, sel ast.SelectionSet, v invalid_packagename.InvalidIdentifier) graphql.Marshaler { - return ec._InvalidIdentifier(ctx, sel, &v) } func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) } func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) } func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) } func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) } func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) } func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) } @@ -4988,7 +4939,6 @@ func (ec *executionContext) unmarshalInt2int(v interface{}) (int, error) { } func (ec *executionContext) marshalInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - return graphql.MarshalInt(v) } @@ -5001,7 +4951,6 @@ func (ec *executionContext) unmarshalID2string(v interface{}) (string, error) { } func (ec *executionContext) marshalID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalID(v) } @@ -5010,7 +4959,6 @@ func (ec *executionContext) unmarshalString2string(v interface{}) (string, error } func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -5019,7 +4967,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) ( } func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -5028,7 +4975,6 @@ func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, e } func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } diff --git a/codegen/type.gotpl b/codegen/type.gotpl index c96bf844f6a..37aab4b1a95 100644 --- a/codegen/type.gotpl +++ b/codegen/type.gotpl @@ -40,11 +40,6 @@ func (ec *executionContext) marshal{{ $type.Definition.Name }}2{{ $type.GO | ts }}(ctx context.Context, sel ast.SelectionSet, v {{ $type.GO | ref }}) graphql.Marshaler { {{- if $type.IsPtr }} if v == nil { - {{- if $type.GQL.NonNull }} - if !ec.HasError(graphql.GetResolverContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - {{- end }} return graphql.Null } {{- end }} diff --git a/example/chat/generated.go b/example/chat/generated.go index e2dbf7c4a7c..27672e9c291 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -1932,29 +1932,23 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshalChatroom2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐChatroom(ctx context.Context, sel ast.SelectionSet, v *Chatroom) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._Chatroom(ctx, sel, v) } func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Schema(ctx, sel, v) } func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Type(ctx, sel, v) } @@ -1967,16 +1961,13 @@ func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, e } func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalString2string(ctx, sel, *v) } func (ec *executionContext) marshalMessage2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx context.Context, sel ast.SelectionSet, v []Message) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2008,7 +1999,6 @@ func (ec *executionContext) marshalMessage2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2040,7 +2030,6 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2072,7 +2061,6 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2104,7 +2092,6 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2136,7 +2123,6 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2188,7 +2174,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{} } func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2224,47 +2209,38 @@ func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { } func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) } func (ec *executionContext) marshalChatroom2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐChatroom(ctx context.Context, sel ast.SelectionSet, v Chatroom) graphql.Marshaler { - return ec._Chatroom(ctx, sel, &v) } func (ec *executionContext) marshalMessage2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx context.Context, sel ast.SelectionSet, v Message) graphql.Marshaler { - return ec._Message(ctx, sel, &v) } func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) } func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) } func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) } func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) } func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) } func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) } @@ -2273,7 +2249,6 @@ func (ec *executionContext) unmarshalID2string(v interface{}) (string, error) { } func (ec *executionContext) marshalID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalID(v) } @@ -2282,7 +2257,6 @@ func (ec *executionContext) unmarshalString2string(v interface{}) (string, error } func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2291,7 +2265,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) ( } func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2300,7 +2273,6 @@ func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, e } func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2309,7 +2281,6 @@ func (ec *executionContext) unmarshalTime2timeᚐTime(v interface{}) (time.Time, } func (ec *executionContext) marshalTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - return graphql.MarshalTime(v) } diff --git a/example/config/generated.go b/example/config/generated.go index 3de72488f4f..2538c61bcf1 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -49,16 +49,16 @@ type ComplexityRoot struct { } Todo struct { - Id func(childComplexity int) int - DatabaseId func(childComplexity int) int - Text func(childComplexity int) int - Done func(childComplexity int) int - User func(childComplexity int) int + Id func(childComplexity int) int + DatabaseId func(childComplexity int) int + Description func(childComplexity int) int + Done func(childComplexity int) int + User func(childComplexity int) int } User struct { - Id func(childComplexity int) int - Name func(childComplexity int) int + Id func(childComplexity int) int + FullName func(childComplexity int) int } } @@ -120,12 +120,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Todo.DatabaseId(childComplexity), true - case "Todo.text": - if e.complexity.Todo.Text == nil { + case "Todo.Description": + if e.complexity.Todo.Description == nil { break } - return e.complexity.Todo.Text(childComplexity), true + return e.complexity.Todo.Description(childComplexity), true case "Todo.done": if e.complexity.Todo.Done == nil { @@ -148,12 +148,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.User.Id(childComplexity), true - case "User.name": - if e.complexity.User.Name == nil { + case "User.FullName": + if e.complexity.User.FullName == nil { break } - return e.complexity.User.Name(childComplexity), true + return e.complexity.User.FullName(childComplexity), true } return 0, false @@ -489,7 +489,7 @@ func (ec *executionContext) _Todo_databaseId(ctx context.Context, field graphql. return ec.marshalInt2int(ctx, field.Selections, res) } -func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { +func (ec *executionContext) _Todo_Description(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -593,7 +593,7 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte return ec.marshalID2string(ctx, field.Selections, res) } -func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { +func (ec *executionContext) _User_FullName(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1430,7 +1430,7 @@ func (ec *executionContext) unmarshalInputNewTodo(v interface{}) (NewTodo, error if err != nil { return it, err } - case "userId": + case "UserID": var err error it.UserID, err = ec.unmarshalString2string(v) if err != nil { @@ -1545,8 +1545,8 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj if out.Values[i] == graphql.Null { invalid = true } - case "text": - out.Values[i] = ec._Todo_text(ctx, field, obj) + case "Description": + out.Values[i] = ec._Todo_Description(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } @@ -1587,8 +1587,8 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj if out.Values[i] == graphql.Null { invalid = true } - case "name": - out.Values[i] = ec._User_name(ctx, field, obj) + case "FullName": + out.Values[i] = ec._User_FullName(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } @@ -1849,20 +1849,16 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Schema(ctx, sel, v) } func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Type(ctx, sel, v) } @@ -1875,16 +1871,13 @@ func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, e } func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalString2string(ctx, sel, *v) } func (ec *executionContext) marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐTodo(ctx context.Context, sel ast.SelectionSet, v []Todo) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1916,7 +1909,6 @@ func (ec *executionContext) marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋe } func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1948,7 +1940,6 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1980,7 +1971,6 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2012,7 +2002,6 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2044,7 +2033,6 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2096,7 +2084,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{} } func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2132,7 +2119,6 @@ func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { } func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) } @@ -2141,42 +2127,34 @@ func (ec *executionContext) unmarshalNewTodo2githubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { - return ec._Todo(ctx, sel, &v) } func (ec *executionContext) marshalUser2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler { - return ec._User(ctx, sel, &v) } func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) } func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) } func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) } func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) } func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) } func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) } @@ -2185,7 +2163,6 @@ func (ec *executionContext) unmarshalInt2int(v interface{}) (int, error) { } func (ec *executionContext) marshalInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - return graphql.MarshalInt(v) } @@ -2194,7 +2171,6 @@ func (ec *executionContext) unmarshalID2string(v interface{}) (string, error) { } func (ec *executionContext) marshalID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalID(v) } @@ -2203,7 +2179,6 @@ func (ec *executionContext) unmarshalString2string(v interface{}) (string, error } func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2212,7 +2187,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) ( } func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2221,7 +2195,6 @@ func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, e } func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index b467524125f..1cfbd291c75 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -2083,29 +2083,23 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshalAddress2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐAddress(ctx context.Context, sel ast.SelectionSet, v *Address) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._Address(ctx, sel, v) } func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Schema(ctx, sel, v) } func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Type(ctx, sel, v) } @@ -2118,16 +2112,13 @@ func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, e } func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalString2string(ctx, sel, *v) } func (ec *executionContext) marshalCustomer2ᚕᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v [][]Customer) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2179,7 +2170,6 @@ func (ec *executionContext) unmarshalInt2ᚕᚕint(v interface{}) ([][]int, erro } func (ec *executionContext) marshalInt2ᚕᚕint(ctx context.Context, sel ast.SelectionSet, v [][]int) graphql.Marshaler { - ret := make(graphql.Array, len(v)) for i := range v { ret[i] = ec.marshalInt2ᚕint(ctx, sel, v[i]) @@ -2189,7 +2179,6 @@ func (ec *executionContext) marshalInt2ᚕᚕint(ctx context.Context, sel ast.Se } func (ec *executionContext) marshalCustomer2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v []Customer) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2221,7 +2210,6 @@ func (ec *executionContext) marshalCustomer2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalItem2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐItem(ctx context.Context, sel ast.SelectionSet, v []Item) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2253,7 +2241,6 @@ func (ec *executionContext) marshalItem2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋe } func (ec *executionContext) marshalOrder2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐOrder(ctx context.Context, sel ast.SelectionSet, v []Order) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2285,7 +2272,6 @@ func (ec *executionContext) marshalOrder2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ } func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2317,7 +2303,6 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2349,7 +2334,6 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2381,7 +2365,6 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2413,7 +2396,6 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2465,7 +2447,6 @@ func (ec *executionContext) unmarshalInt2ᚕint(v interface{}) ([]int, error) { } func (ec *executionContext) marshalInt2ᚕint(ctx context.Context, sel ast.SelectionSet, v []int) graphql.Marshaler { - ret := make(graphql.Array, len(v)) for i := range v { ret[i] = ec.marshalInt2int(ctx, sel, v[i]) @@ -2495,7 +2476,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{} } func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2531,7 +2511,6 @@ func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { } func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) } @@ -2540,57 +2519,46 @@ func (ec *executionContext) unmarshalFloat2float64(v interface{}) (float64, erro } func (ec *executionContext) marshalFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { - return graphql.MarshalFloat(v) } func (ec *executionContext) marshalAddress2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐAddress(ctx context.Context, sel ast.SelectionSet, v Address) graphql.Marshaler { - return ec._Address(ctx, sel, &v) } func (ec *executionContext) marshalCustomer2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v Customer) graphql.Marshaler { - return ec._Customer(ctx, sel, &v) } func (ec *executionContext) marshalItem2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐItem(ctx context.Context, sel ast.SelectionSet, v Item) graphql.Marshaler { - return ec._Item(ctx, sel, &v) } func (ec *executionContext) marshalOrder2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐOrder(ctx context.Context, sel ast.SelectionSet, v Order) graphql.Marshaler { - return ec._Order(ctx, sel, &v) } func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) } func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) } func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) } func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) } func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) } func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) } @@ -2599,7 +2567,6 @@ func (ec *executionContext) unmarshalInt2int(v interface{}) (int, error) { } func (ec *executionContext) marshalInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - return graphql.MarshalInt(v) } @@ -2608,7 +2575,6 @@ func (ec *executionContext) unmarshalString2string(v interface{}) (string, error } func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2617,7 +2583,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) ( } func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2626,7 +2591,6 @@ func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, e } func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2635,7 +2599,6 @@ func (ec *executionContext) unmarshalTime2timeᚐTime(v interface{}) (time.Time, } func (ec *executionContext) marshalTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - return graphql.MarshalTime(v) } diff --git a/example/scalars/generated.go b/example/scalars/generated.go index bb4f03625d1..4ab97d8e144 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -1953,13 +1953,10 @@ func (ec *executionContext) unmarshalPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, sel ast.SelectionSet, v *model.Point) graphql.Marshaler { - if v == nil { return graphql.Null } - return v - } func (ec *executionContext) unmarshalSearchArgs2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v interface{}) (*model.SearchArgs, error) { @@ -1971,29 +1968,23 @@ func (ec *executionContext) unmarshalSearchArgs2ᚖgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshalUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._User(ctx, sel, v) } func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Schema(ctx, sel, v) } func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Type(ctx, sel, v) } @@ -2006,11 +1997,9 @@ func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, e } func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalString2string(ctx, sel, *v) } @@ -2023,16 +2012,13 @@ func (ec *executionContext) unmarshalTimestamp2ᚖtimeᚐTime(v interface{}) (*t } func (ec *executionContext) marshalTimestamp2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalTimestamp2timeᚐTime(ctx, sel, *v) } func (ec *executionContext) marshalUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v []model.User) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2064,7 +2050,6 @@ func (ec *executionContext) marshalUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋe } func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2096,7 +2081,6 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2128,7 +2112,6 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2160,7 +2143,6 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2192,7 +2174,6 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2244,7 +2225,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{} } func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2280,7 +2260,6 @@ func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { } func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) } @@ -2289,12 +2268,10 @@ func (ec *executionContext) unmarshalID2githubᚗcomᚋ99designsᚋgqlgenᚋexam } func (ec *executionContext) marshalID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(ctx context.Context, sel ast.SelectionSet, v external.ObjectID) graphql.Marshaler { - return model.MarshalID(v) } func (ec *executionContext) marshalAddress2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐAddress(ctx context.Context, sel ast.SelectionSet, v model.Address) graphql.Marshaler { - return ec._Address(ctx, sel, &v) } @@ -2304,9 +2281,7 @@ func (ec *executionContext) unmarshalBanned2githubᚗcomᚋ99designsᚋgqlgenᚋ } func (ec *executionContext) marshalBanned2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐBanned(ctx context.Context, sel ast.SelectionSet, v model.Banned) graphql.Marshaler { - return v - } func (ec *executionContext) unmarshalPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(v interface{}) (model.Point, error) { @@ -2315,9 +2290,7 @@ func (ec *executionContext) unmarshalPoint2githubᚗcomᚋ99designsᚋgqlgenᚋe } func (ec *executionContext) marshalPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, sel ast.SelectionSet, v model.Point) graphql.Marshaler { - return v - } func (ec *executionContext) unmarshalSearchArgs2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v interface{}) (model.SearchArgs, error) { @@ -2330,43 +2303,34 @@ func (ec *executionContext) unmarshalTier2githubᚗcomᚋ99designsᚋgqlgenᚋex } func (ec *executionContext) marshalTier2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐTier(ctx context.Context, sel ast.SelectionSet, v model.Tier) graphql.Marshaler { - return v - } func (ec *executionContext) marshalUser2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v model.User) graphql.Marshaler { - return ec._User(ctx, sel, &v) } func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) } func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) } func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) } func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) } func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) } func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) } @@ -2375,7 +2339,6 @@ func (ec *executionContext) unmarshalString2string(v interface{}) (string, error } func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2384,7 +2347,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) ( } func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2393,7 +2355,6 @@ func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, e } func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2402,7 +2363,6 @@ func (ec *executionContext) unmarshalTimestamp2timeᚐTime(v interface{}) (time. } func (ec *executionContext) marshalTimestamp2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - return model.MarshalTimestamp(v) } diff --git a/example/selection/generated.go b/example/selection/generated.go index b4c2aa2b541..4c076024652 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -1732,20 +1732,16 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Schema(ctx, sel, v) } func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Type(ctx, sel, v) } @@ -1758,16 +1754,13 @@ func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, e } func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalString2string(ctx, sel, *v) } func (ec *executionContext) marshalEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋselectionᚐEvent(ctx context.Context, sel ast.SelectionSet, v []Event) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1799,7 +1792,6 @@ func (ec *executionContext) marshalEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ } func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1831,7 +1823,6 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1863,7 +1854,6 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1895,7 +1885,6 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1927,7 +1916,6 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1979,7 +1967,6 @@ func (ec *executionContext) unmarshalString2ᚕstring(v interface{}) ([]string, } func (ec *executionContext) marshalString2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) for i := range v { ret[i] = ec.marshalString2string(ctx, sel, v[i]) @@ -2009,7 +1996,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{} } func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2045,42 +2031,34 @@ func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { } func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) } func (ec *executionContext) marshalEvent2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋselectionᚐEvent(ctx context.Context, sel ast.SelectionSet, v Event) graphql.Marshaler { - return ec._Event(ctx, sel, &v) } func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) } func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) } func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) } func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) } func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) } func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) } @@ -2089,7 +2067,6 @@ func (ec *executionContext) unmarshalString2string(v interface{}) (string, error } func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2098,7 +2075,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) ( } func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2107,7 +2083,6 @@ func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, e } func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2116,7 +2091,6 @@ func (ec *executionContext) unmarshalTime2timeᚐTime(v interface{}) (time.Time, } func (ec *executionContext) marshalTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - return graphql.MarshalTime(v) } diff --git a/example/starwars/generated.go b/example/starwars/generated.go index 17df8f7229e..ffbad29c928 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -3553,11 +3553,9 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshalDroid2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐDroid(ctx context.Context, sel ast.SelectionSet, v *Droid) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._Droid(ctx, sel, v) } @@ -3570,21 +3568,16 @@ func (ec *executionContext) unmarshalEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlge } func (ec *executionContext) marshalEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v *Episode) graphql.Marshaler { - if v == nil { return graphql.Null } - return v - } func (ec *executionContext) marshalHuman2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐHuman(ctx context.Context, sel ast.SelectionSet, v *Human) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._Human(ctx, sel, v) } @@ -3597,48 +3590,37 @@ func (ec *executionContext) unmarshalLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshalLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(ctx context.Context, sel ast.SelectionSet, v *LengthUnit) graphql.Marshaler { - if v == nil { return graphql.Null } - return v - } func (ec *executionContext) marshalReview2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx context.Context, sel ast.SelectionSet, v *Review) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._Review(ctx, sel, v) } func (ec *executionContext) marshalStarship2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx context.Context, sel ast.SelectionSet, v *Starship) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._Starship(ctx, sel, v) } func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Schema(ctx, sel, v) } func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Type(ctx, sel, v) } @@ -3651,11 +3633,9 @@ func (ec *executionContext) unmarshalInt2ᚖint(v interface{}) (*int, error) { } func (ec *executionContext) marshalInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalInt2int(ctx, sel, *v) } @@ -3668,11 +3648,9 @@ func (ec *executionContext) unmarshalID2ᚖstring(v interface{}) (*string, error } func (ec *executionContext) marshalID2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalID2string(ctx, sel, *v) } @@ -3685,11 +3663,9 @@ func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, e } func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalString2string(ctx, sel, *v) } @@ -3702,11 +3678,9 @@ func (ec *executionContext) unmarshalTime2ᚖtimeᚐTime(v interface{}) (*time.T } func (ec *executionContext) marshalTime2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalTime2timeᚐTime(ctx, sel, *v) } @@ -3731,7 +3705,6 @@ func (ec *executionContext) unmarshalInt2ᚕᚕint(v interface{}) ([][]int, erro } func (ec *executionContext) marshalInt2ᚕᚕint(ctx context.Context, sel ast.SelectionSet, v [][]int) graphql.Marshaler { - ret := make(graphql.Array, len(v)) for i := range v { ret[i] = ec.marshalInt2ᚕint(ctx, sel, v[i]) @@ -3741,7 +3714,6 @@ func (ec *executionContext) marshalInt2ᚕᚕint(ctx context.Context, sel ast.Se } func (ec *executionContext) marshalCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v []Character) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -3793,7 +3765,6 @@ func (ec *executionContext) unmarshalEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlge } func (ec *executionContext) marshalEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v []Episode) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -3825,7 +3796,6 @@ func (ec *executionContext) marshalEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalFriendsEdge2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsEdge(ctx context.Context, sel ast.SelectionSet, v []FriendsEdge) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -3857,7 +3827,6 @@ func (ec *executionContext) marshalFriendsEdge2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshalReview2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx context.Context, sel ast.SelectionSet, v []Review) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -3889,7 +3858,6 @@ func (ec *executionContext) marshalReview2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalSearchResult2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐSearchResult(ctx context.Context, sel ast.SelectionSet, v []SearchResult) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -3921,7 +3889,6 @@ func (ec *executionContext) marshalSearchResult2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshalStarship2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx context.Context, sel ast.SelectionSet, v []Starship) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -3953,7 +3920,6 @@ func (ec *executionContext) marshalStarship2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -3985,7 +3951,6 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4017,7 +3982,6 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4049,7 +4013,6 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4081,7 +4044,6 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4133,7 +4095,6 @@ func (ec *executionContext) unmarshalInt2ᚕint(v interface{}) ([]int, error) { } func (ec *executionContext) marshalInt2ᚕint(ctx context.Context, sel ast.SelectionSet, v []int) graphql.Marshaler { - ret := make(graphql.Array, len(v)) for i := range v { ret[i] = ec.marshalInt2int(ctx, sel, v[i]) @@ -4163,7 +4124,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{} } func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4199,7 +4159,6 @@ func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { } func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) } @@ -4208,17 +4167,14 @@ func (ec *executionContext) unmarshalFloat2float64(v interface{}) (float64, erro } func (ec *executionContext) marshalFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { - return graphql.MarshalFloat(v) } func (ec *executionContext) marshalCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v Character) graphql.Marshaler { - return ec._Character(ctx, sel, &v) } func (ec *executionContext) marshalDroid2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐDroid(ctx context.Context, sel ast.SelectionSet, v Droid) graphql.Marshaler { - return ec._Droid(ctx, sel, &v) } @@ -4228,23 +4184,18 @@ func (ec *executionContext) unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v Episode) graphql.Marshaler { - return v - } func (ec *executionContext) marshalFriendsConnection2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsConnection(ctx context.Context, sel ast.SelectionSet, v FriendsConnection) graphql.Marshaler { - return ec._FriendsConnection(ctx, sel, &v) } func (ec *executionContext) marshalFriendsEdge2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsEdge(ctx context.Context, sel ast.SelectionSet, v FriendsEdge) graphql.Marshaler { - return ec._FriendsEdge(ctx, sel, &v) } func (ec *executionContext) marshalHuman2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐHuman(ctx context.Context, sel ast.SelectionSet, v Human) graphql.Marshaler { - return ec._Human(ctx, sel, &v) } @@ -4254,18 +4205,14 @@ func (ec *executionContext) unmarshalLengthUnit2githubᚗcomᚋ99designsᚋgqlge } func (ec *executionContext) marshalLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(ctx context.Context, sel ast.SelectionSet, v LengthUnit) graphql.Marshaler { - return v - } func (ec *executionContext) marshalPageInfo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐPageInfo(ctx context.Context, sel ast.SelectionSet, v PageInfo) graphql.Marshaler { - return ec._PageInfo(ctx, sel, &v) } func (ec *executionContext) marshalReview2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx context.Context, sel ast.SelectionSet, v Review) graphql.Marshaler { - return ec._Review(ctx, sel, &v) } @@ -4274,42 +4221,34 @@ func (ec *executionContext) unmarshalReviewInput2githubᚗcomᚋ99designsᚋgqlg } func (ec *executionContext) marshalSearchResult2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐSearchResult(ctx context.Context, sel ast.SelectionSet, v SearchResult) graphql.Marshaler { - return ec._SearchResult(ctx, sel, &v) } func (ec *executionContext) marshalStarship2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx context.Context, sel ast.SelectionSet, v Starship) graphql.Marshaler { - return ec._Starship(ctx, sel, &v) } func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) } func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) } func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) } func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) } func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) } func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) } @@ -4318,7 +4257,6 @@ func (ec *executionContext) unmarshalInt2int(v interface{}) (int, error) { } func (ec *executionContext) marshalInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - return graphql.MarshalInt(v) } @@ -4327,7 +4265,6 @@ func (ec *executionContext) unmarshalID2string(v interface{}) (string, error) { } func (ec *executionContext) marshalID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalID(v) } @@ -4336,7 +4273,6 @@ func (ec *executionContext) unmarshalString2string(v interface{}) (string, error } func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -4345,7 +4281,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) ( } func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -4354,7 +4289,6 @@ func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, e } func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -4363,7 +4297,6 @@ func (ec *executionContext) unmarshalTime2timeᚐTime(v interface{}) (time.Time, } func (ec *executionContext) marshalTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - return graphql.MarshalTime(v) } diff --git a/example/todo/generated.go b/example/todo/generated.go index 3f127bcfa85..020f2d06589 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -1884,38 +1884,30 @@ func (ec *executionContext) unmarshalBoolean2ᚖbool(v interface{}) (*bool, erro } func (ec *executionContext) marshalBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalBoolean2bool(ctx, sel, *v) } func (ec *executionContext) marshalTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._Todo(ctx, sel, v) } func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Schema(ctx, sel, v) } func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Type(ctx, sel, v) } @@ -1928,16 +1920,13 @@ func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, e } func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalString2string(ctx, sel, *v) } func (ec *executionContext) marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v []Todo) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1969,7 +1958,6 @@ func (ec *executionContext) marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋe } func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2001,7 +1989,6 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2033,7 +2020,6 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2065,7 +2051,6 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2097,7 +2082,6 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2149,7 +2133,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{} } func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2185,7 +2168,6 @@ func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { } func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) } @@ -2195,9 +2177,7 @@ func (ec *executionContext) unmarshalRole2githubᚗcomᚋ99designsᚋgqlgenᚋex } func (ec *executionContext) marshalRole2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐRole(ctx context.Context, sel ast.SelectionSet, v Role) graphql.Marshaler { - return v - } func (ec *executionContext) unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodoInput(v interface{}) (TodoInput, error) { @@ -2205,37 +2185,30 @@ func (ec *executionContext) unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { - return ec._Todo(ctx, sel, &v) } func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) } func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) } func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) } func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) } func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) } func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) } @@ -2244,7 +2217,6 @@ func (ec *executionContext) unmarshalInt2int(v interface{}) (int, error) { } func (ec *executionContext) marshalInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - return graphql.MarshalInt(v) } @@ -2253,7 +2225,6 @@ func (ec *executionContext) unmarshalMap2map(v interface{}) (map[string]interfac } func (ec *executionContext) marshalMap2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler { - return graphql.MarshalMap(v) } @@ -2262,7 +2233,6 @@ func (ec *executionContext) unmarshalString2string(v interface{}) (string, error } func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2271,7 +2241,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) ( } func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2280,7 +2249,6 @@ func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, e } func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index a682889cc4a..b9cf6c165ba 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -1899,29 +1899,23 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshalTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._Todo(ctx, sel, v) } func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Schema(ctx, sel, v) } func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Type(ctx, sel, v) } @@ -1934,16 +1928,13 @@ func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, e } func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalString2string(ctx, sel, *v) } func (ec *executionContext) marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v []Todo) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1975,7 +1966,6 @@ func (ec *executionContext) marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋe } func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2007,7 +1997,6 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2039,7 +2028,6 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2071,7 +2059,6 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2103,7 +2090,6 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2155,7 +2141,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{} } func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2191,7 +2176,6 @@ func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { } func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) } @@ -2201,9 +2185,7 @@ func (ec *executionContext) unmarshalState2githubᚗcomᚋ99designsᚋgqlgenᚋe } func (ec *executionContext) marshalState2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐState(ctx context.Context, sel ast.SelectionSet, v State) graphql.Marshaler { - return v - } func (ec *executionContext) unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodoInput(v interface{}) (TodoInput, error) { @@ -2211,37 +2193,30 @@ func (ec *executionContext) unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { - return ec._Todo(ctx, sel, &v) } func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) } func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) } func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) } func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) } func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) } func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) } @@ -2250,7 +2225,6 @@ func (ec *executionContext) unmarshalID2string(v interface{}) (string, error) { } func (ec *executionContext) marshalID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalID(v) } @@ -2259,7 +2233,6 @@ func (ec *executionContext) unmarshalString2string(v interface{}) (string, error } func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2268,7 +2241,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) ( } func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2277,7 +2249,6 @@ func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, e } func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } diff --git a/integration/generated.go b/integration/generated.go index 3940c1de2c5..42d7c2ef604 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -70,7 +70,6 @@ type ComplexityRoot struct { type ElementResolver interface { Child(ctx context.Context, obj *models.Element) (models.Element, error) Error(ctx context.Context, obj *models.Element) (bool, error) - Mismatched(ctx context.Context, obj *models.Element) ([]bool, error) } type QueryResolver interface { Path(ctx context.Context) ([]*models.Element, error) @@ -476,7 +475,7 @@ func (ec *executionContext) _Element_mismatched(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Element().Mismatched(rctx, obj) + return obj.Mismatched, nil }) if resTmp == nil { return graphql.Null @@ -1627,11 +1626,7 @@ func (ec *executionContext) _Element(ctx context.Context, sel ast.SelectionSet, return res }) case "mismatched": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Element_mismatched(ctx, field, obj) - return res - }) + out.Values[i] = ec._Element_mismatched(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } From 8047b82ad25c4f71741a53360f814a576a06c4b3 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Wed, 6 Feb 2019 14:47:39 +1100 Subject: [PATCH 067/147] Fix nullability checks in new marshalling --- codegen/args.gotpl | 4 +- codegen/config/binder.go | 52 +- codegen/field.gotpl | 4 +- codegen/input.gotpl | 2 +- codegen/testserver/generated.go | 1102 +++++++++++--------- codegen/type.go | 26 +- codegen/type.gotpl | 29 +- example/chat/generated.go | 440 ++++---- example/config/generated.go | 434 +++++--- example/dataloader/generated.go | 568 +++++----- example/scalars/generated.go | 584 ++++++----- example/selection/generated.go | 442 ++++---- example/starwars/generated.go | 1009 ++++++++++-------- example/todo/generated.go | 486 +++++---- example/type-system-extension/generated.go | 438 +++++--- integration/generated.go | 644 +++++++----- 16 files changed, 3665 insertions(+), 2599 deletions(-) diff --git a/codegen/args.gotpl b/codegen/args.gotpl index 030b415510f..df615a71fbd 100644 --- a/codegen/args.gotpl +++ b/codegen/args.gotpl @@ -6,7 +6,7 @@ func (ec *executionContext) {{ $name }}(ctx context.Context, rawArgs map[string] var arg{{$i}} {{ $arg.TypeReference.GO | ref}} if tmp, ok := rawArgs[{{$arg.Name|quote}}]; ok { {{- if $arg.Directives }} - getArg0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshal{{$arg.TypeReference.GQL.Name}}2{{ $arg.TypeReference.GO | ts }}(tmp) } + getArg0 := func(ctx context.Context) (interface{}, error) { return ec.{{ $arg.TypeReference.UnmarshalFunc }}(tmp) } {{- range $i, $directive := $arg.Directives }} getArg{{add $i 1}} := func(ctx context.Context) (res interface{}, err error) { @@ -30,7 +30,7 @@ func (ec *executionContext) {{ $name }}(ctx context.Context, rawArgs map[string] return nil, fmt.Errorf(`unexpected type %T from directive, should be {{ $arg.TypeReference.GO }}`, tmp) } {{- else }} - arg{{$i}}, err = ec.unmarshal{{$arg.TypeReference.GQL.Name}}2{{ $arg.TypeReference.GO | ts }}(tmp) + arg{{$i}}, err = ec.{{ $arg.TypeReference.UnmarshalFunc }}(tmp) if err != nil { return nil, err } diff --git a/codegen/config/binder.go b/codegen/config/binder.go index 372fde0b74d..5830941f4a2 100644 --- a/codegen/config/binder.go +++ b/codegen/config/binder.go @@ -7,6 +7,8 @@ import ( "regexp" "strings" + "github.com/99designs/gqlgen/codegen/templates" + "github.com/99designs/gqlgen/internal/code" "github.com/pkg/errors" "github.com/vektah/gqlparser/ast" @@ -152,6 +154,29 @@ type TypeReference struct { Unmarshaler *types.Func // When using external marshalling functions this will point to the Unmarshal function } +func (ref TypeReference) Elem() *TypeReference { + if p, isPtr := ref.GO.(*types.Pointer); isPtr { + return &TypeReference{ + GO: p.Elem(), + GQL: ref.GQL, + Definition: ref.Definition, + Unmarshaler: ref.Unmarshaler, + Marshaler: ref.Marshaler, + } + } + + if s, isSlice := ref.GO.(*types.Slice); isSlice { + return &TypeReference{ + GO: s.Elem(), + GQL: ref.GQL.Elem, + Definition: ref.Definition, + Unmarshaler: ref.Unmarshaler, + Marshaler: ref.Marshaler, + } + } + return nil +} + func (t TypeReference) IsPtr() bool { _, isPtr := t.GO.(*types.Pointer) return isPtr @@ -190,18 +215,37 @@ func (t TypeReference) SelfMarshalling() bool { return false } -func (t TypeReference) NeedsUnmarshaler() bool { +func (t TypeReference) UniquenessKey() string { + var nullability = "O" + if t.GQL.NonNull { + nullability = "N" + } + + return nullability + t.Definition.Name + "2" + templates.TypeIdentifier(t.GO) +} + +func (t TypeReference) MarshalFunc() string { if t.Definition == nil { panic(errors.New("Definition missing for " + t.GQL.Name())) } - return t.Definition.IsInputType() + + if t.Definition.Kind == ast.InputObject { + return "" + } + + return "marshal" + t.UniquenessKey() } -func (t TypeReference) NeedsMarshaler() bool { +func (t TypeReference) UnmarshalFunc() string { if t.Definition == nil { panic(errors.New("Definition missing for " + t.GQL.Name())) } - return t.Definition.Kind != ast.InputObject + + if !t.Definition.IsInputType() { + return "" + } + + return "unmarshal" + t.UniquenessKey() } func (b *Binder) PushRef(ret *TypeReference) { diff --git a/codegen/field.gotpl b/codegen/field.gotpl index 41617ed5574..f07a6f03674 100644 --- a/codegen/field.gotpl +++ b/codegen/field.gotpl @@ -31,7 +31,7 @@ w.Write([]byte{'{'}) graphql.MarshalString(field.Alias).MarshalGQL(w) w.Write([]byte{':'}) - ec.marshal{{ $field.TypeReference.Definition.Name }}2{{ $field.TypeReference.GO | ts }}(ctx, field.Selections, res).MarshalGQL(w) + ec.{{ $field.TypeReference.MarshalFunc }}(ctx, field.Selections, res).MarshalGQL(w) w.Write([]byte{'}'}) }) } @@ -81,7 +81,7 @@ res := resTmp.({{$field.TypeReference.GO | ref}}) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal{{ $field.TypeReference.Definition.Name }}2{{ $field.TypeReference.GO | ts }}(ctx, field.Selections, res) + return ec.{{ $field.TypeReference.MarshalFunc }}(ctx, field.Selections, res) } {{ end }} diff --git a/codegen/input.gotpl b/codegen/input.gotpl index 2c5efeb0039..2897d7f3ebf 100644 --- a/codegen/input.gotpl +++ b/codegen/input.gotpl @@ -16,7 +16,7 @@ {{- range $field := .Fields }} case {{$field.Name|quote}}: var err error - it.{{$field.GoFieldName}}, err = ec.unmarshal{{$field.TypeReference.GQL.Name}}2{{ $field.TypeReference.GO | ts }}(v) + it.{{$field.GoFieldName}}, err = ec.{{ $field.TypeReference.UnmarshalFunc }}(v) if err != nil { return it, err } diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 3efb3719ca6..d556e070d47 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -831,7 +831,7 @@ func (ec *executionContext) dir_length_args(ctx context.Context, rawArgs map[str args := map[string]interface{}{} var arg0 int if tmp, ok := rawArgs["min"]; ok { - arg0, err = ec.unmarshalInt2int(tmp) + arg0, err = ec.unmarshalNInt2int(tmp) if err != nil { return nil, err } @@ -839,7 +839,7 @@ func (ec *executionContext) dir_length_args(ctx context.Context, rawArgs map[str args["min"] = arg0 var arg1 *int if tmp, ok := rawArgs["max"]; ok { - arg1, err = ec.unmarshalInt2ᚖint(tmp) + arg1, err = ec.unmarshalOInt2ᚖint(tmp) if err != nil { return nil, err } @@ -847,7 +847,7 @@ func (ec *executionContext) dir_length_args(ctx context.Context, rawArgs map[str args["max"] = arg1 var arg2 string if tmp, ok := rawArgs["message"]; ok { - arg2, err = ec.unmarshalString2string(tmp) + arg2, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -861,7 +861,7 @@ func (ec *executionContext) dir_range_args(ctx context.Context, rawArgs map[stri args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["min"]; ok { - arg0, err = ec.unmarshalInt2ᚖint(tmp) + arg0, err = ec.unmarshalOInt2ᚖint(tmp) if err != nil { return nil, err } @@ -869,7 +869,7 @@ func (ec *executionContext) dir_range_args(ctx context.Context, rawArgs map[stri args["min"] = arg0 var arg1 *int if tmp, ok := rawArgs["max"]; ok { - arg1, err = ec.unmarshalInt2ᚖint(tmp) + arg1, err = ec.unmarshalOInt2ᚖint(tmp) if err != nil { return nil, err } @@ -877,7 +877,7 @@ func (ec *executionContext) dir_range_args(ctx context.Context, rawArgs map[stri args["max"] = arg1 var arg2 *string if tmp, ok := rawArgs["message"]; ok { - arg2, err = ec.unmarshalString2ᚖstring(tmp) + arg2, err = ec.unmarshalOString2ᚖstring(tmp) if err != nil { return nil, err } @@ -891,7 +891,7 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = ec.unmarshalString2string(tmp) + arg0, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -905,7 +905,7 @@ func (ec *executionContext) field_Query_directiveArg_args(ctx context.Context, r args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["arg"]; ok { - getArg0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalString2string(tmp) } + getArg0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalNString2string(tmp) } getArg1 := func(ctx context.Context) (res interface{}, err error) { max := 255 n := getArg0 @@ -931,7 +931,7 @@ func (ec *executionContext) field_Query_directiveInputNullable_args(ctx context. args := map[string]interface{}{} var arg0 *InputDirectives if tmp, ok := rawArgs["arg"]; ok { - arg0, err = ec.unmarshalInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(tmp) + arg0, err = ec.unmarshalOInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(tmp) if err != nil { return nil, err } @@ -945,7 +945,7 @@ func (ec *executionContext) field_Query_directiveInput_args(ctx context.Context, args := map[string]interface{}{} var arg0 InputDirectives if tmp, ok := rawArgs["arg"]; ok { - arg0, err = ec.unmarshalInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(tmp) + arg0, err = ec.unmarshalNInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(tmp) if err != nil { return nil, err } @@ -959,7 +959,7 @@ func (ec *executionContext) field_Query_directiveNullableArg_args(ctx context.Co args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["arg"]; ok { - getArg0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalInt2ᚖint(tmp) } + getArg0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOInt2ᚖint(tmp) } getArg1 := func(ctx context.Context) (res interface{}, err error) { min := 0 n := getArg0 @@ -979,7 +979,7 @@ func (ec *executionContext) field_Query_directiveNullableArg_args(ctx context.Co args["arg"] = arg0 var arg1 *int if tmp, ok := rawArgs["arg2"]; ok { - getArg0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalInt2ᚖint(tmp) } + getArg0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOInt2ᚖint(tmp) } getArg1 := func(ctx context.Context) (res interface{}, err error) { min := 0 n := getArg0 @@ -1005,7 +1005,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["break"]; ok { - arg0, err = ec.unmarshalString2string(tmp) + arg0, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -1013,7 +1013,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["break"] = arg0 var arg1 string if tmp, ok := rawArgs["default"]; ok { - arg1, err = ec.unmarshalString2string(tmp) + arg1, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -1021,7 +1021,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["default"] = arg1 var arg2 string if tmp, ok := rawArgs["func"]; ok { - arg2, err = ec.unmarshalString2string(tmp) + arg2, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -1029,7 +1029,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["func"] = arg2 var arg3 string if tmp, ok := rawArgs["interface"]; ok { - arg3, err = ec.unmarshalString2string(tmp) + arg3, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -1037,7 +1037,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["interface"] = arg3 var arg4 string if tmp, ok := rawArgs["select"]; ok { - arg4, err = ec.unmarshalString2string(tmp) + arg4, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -1045,7 +1045,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["select"] = arg4 var arg5 string if tmp, ok := rawArgs["case"]; ok { - arg5, err = ec.unmarshalString2string(tmp) + arg5, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -1053,7 +1053,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["case"] = arg5 var arg6 string if tmp, ok := rawArgs["defer"]; ok { - arg6, err = ec.unmarshalString2string(tmp) + arg6, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -1061,7 +1061,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["defer"] = arg6 var arg7 string if tmp, ok := rawArgs["go"]; ok { - arg7, err = ec.unmarshalString2string(tmp) + arg7, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -1069,7 +1069,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["go"] = arg7 var arg8 string if tmp, ok := rawArgs["map"]; ok { - arg8, err = ec.unmarshalString2string(tmp) + arg8, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -1077,7 +1077,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["map"] = arg8 var arg9 string if tmp, ok := rawArgs["struct"]; ok { - arg9, err = ec.unmarshalString2string(tmp) + arg9, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -1085,7 +1085,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["struct"] = arg9 var arg10 string if tmp, ok := rawArgs["chan"]; ok { - arg10, err = ec.unmarshalString2string(tmp) + arg10, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -1093,7 +1093,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["chan"] = arg10 var arg11 string if tmp, ok := rawArgs["else"]; ok { - arg11, err = ec.unmarshalString2string(tmp) + arg11, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -1101,7 +1101,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["else"] = arg11 var arg12 string if tmp, ok := rawArgs["goto"]; ok { - arg12, err = ec.unmarshalString2string(tmp) + arg12, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -1109,7 +1109,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["goto"] = arg12 var arg13 string if tmp, ok := rawArgs["package"]; ok { - arg13, err = ec.unmarshalString2string(tmp) + arg13, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -1117,7 +1117,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["package"] = arg13 var arg14 string if tmp, ok := rawArgs["switch"]; ok { - arg14, err = ec.unmarshalString2string(tmp) + arg14, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -1125,7 +1125,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["switch"] = arg14 var arg15 string if tmp, ok := rawArgs["const"]; ok { - arg15, err = ec.unmarshalString2string(tmp) + arg15, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -1133,7 +1133,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["const"] = arg15 var arg16 string if tmp, ok := rawArgs["fallthrough"]; ok { - arg16, err = ec.unmarshalString2string(tmp) + arg16, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -1141,7 +1141,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["fallthrough"] = arg16 var arg17 string if tmp, ok := rawArgs["if"]; ok { - arg17, err = ec.unmarshalString2string(tmp) + arg17, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -1149,7 +1149,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["if"] = arg17 var arg18 string if tmp, ok := rawArgs["range"]; ok { - arg18, err = ec.unmarshalString2string(tmp) + arg18, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -1157,7 +1157,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["range"] = arg18 var arg19 string if tmp, ok := rawArgs["type"]; ok { - arg19, err = ec.unmarshalString2string(tmp) + arg19, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -1165,7 +1165,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["type"] = arg19 var arg20 string if tmp, ok := rawArgs["continue"]; ok { - arg20, err = ec.unmarshalString2string(tmp) + arg20, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -1173,7 +1173,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["continue"] = arg20 var arg21 string if tmp, ok := rawArgs["for"]; ok { - arg21, err = ec.unmarshalString2string(tmp) + arg21, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -1181,7 +1181,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["for"] = arg21 var arg22 string if tmp, ok := rawArgs["import"]; ok { - arg22, err = ec.unmarshalString2string(tmp) + arg22, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -1189,7 +1189,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["import"] = arg22 var arg23 string if tmp, ok := rawArgs["return"]; ok { - arg23, err = ec.unmarshalString2string(tmp) + arg23, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -1197,7 +1197,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["return"] = arg23 var arg24 string if tmp, ok := rawArgs["var"]; ok { - arg24, err = ec.unmarshalString2string(tmp) + arg24, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -1211,7 +1211,7 @@ func (ec *executionContext) field_Query_keywords_args(ctx context.Context, rawAr args := map[string]interface{}{} var arg0 *Keywords if tmp, ok := rawArgs["input"]; ok { - arg0, err = ec.unmarshalKeywords2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(tmp) + arg0, err = ec.unmarshalOKeywords2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(tmp) if err != nil { return nil, err } @@ -1225,7 +1225,7 @@ func (ec *executionContext) field_Query_mapInput_args(ctx context.Context, rawAr args := map[string]interface{}{} var arg0 map[string]interface{} if tmp, ok := rawArgs["input"]; ok { - arg0, err = ec.unmarshalChanges2map(tmp) + arg0, err = ec.unmarshalOChanges2map(tmp) if err != nil { return nil, err } @@ -1239,7 +1239,7 @@ func (ec *executionContext) field_Query_nestedInputs_args(ctx context.Context, r args := map[string]interface{}{} var arg0 [][]*OuterInput if tmp, ok := rawArgs["input"]; ok { - arg0, err = ec.unmarshalOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(tmp) + arg0, err = ec.unmarshalOOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(tmp) if err != nil { return nil, err } @@ -1253,7 +1253,7 @@ func (ec *executionContext) field_Query_nullableArg_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["arg"]; ok { - arg0, err = ec.unmarshalInt2ᚖint(tmp) + arg0, err = ec.unmarshalOInt2ᚖint(tmp) if err != nil { return nil, err } @@ -1267,7 +1267,7 @@ func (ec *executionContext) field_Query_recursive_args(ctx context.Context, rawA args := map[string]interface{}{} var arg0 *RecursiveInputSlice if tmp, ok := rawArgs["input"]; ok { - arg0, err = ec.unmarshalRecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(tmp) + arg0, err = ec.unmarshalORecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(tmp) if err != nil { return nil, err } @@ -1281,7 +1281,7 @@ func (ec *executionContext) field_Query_user_args(ctx context.Context, rawArgs m args := map[string]interface{}{} var arg0 int if tmp, ok := rawArgs["id"]; ok { - arg0, err = ec.unmarshalInt2int(tmp) + arg0, err = ec.unmarshalNInt2int(tmp) if err != nil { return nil, err } @@ -1295,7 +1295,7 @@ func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(tmp) if err != nil { return nil, err } @@ -1309,7 +1309,7 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(tmp) if err != nil { return nil, err } @@ -1342,7 +1342,7 @@ func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.Co res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalFloat2float64(ctx, field.Selections, res) + return ec.marshalOFloat2float64(ctx, field.Selections, res) } func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.CollectedField, obj *Circle) graphql.Marshaler { @@ -1365,7 +1365,7 @@ func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.Coll res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalFloat2float64(ctx, field.Selections, res) + return ec.marshalOFloat2float64(ctx, field.Selections, res) } func (ec *executionContext) _EmbeddedPointer_ID(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) graphql.Marshaler { @@ -1388,7 +1388,7 @@ func (ec *executionContext) _EmbeddedPointer_ID(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) _EmbeddedPointer_Title(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) graphql.Marshaler { @@ -1411,7 +1411,7 @@ func (ec *executionContext) _EmbeddedPointer_Title(ctx context.Context, field gr res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) _Error_id(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { @@ -1437,7 +1437,7 @@ func (ec *executionContext) _Error_id(ctx context.Context, field graphql.Collect res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalID2string(ctx, field.Selections, res) + return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _Error_errorOnNonRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { @@ -1460,7 +1460,7 @@ func (ec *executionContext) _Error_errorOnNonRequiredField(ctx context.Context, res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { @@ -1486,7 +1486,7 @@ func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, fie res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Error_nilOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { @@ -1512,7 +1512,7 @@ func (ec *executionContext) _Error_nilOnRequiredField(ctx context.Context, field res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field graphql.CollectedField, obj *ForcedResolver) graphql.Marshaler { @@ -1535,7 +1535,7 @@ func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field gra res := resTmp.(*Circle) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalCircle2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCircle(ctx, field.Selections, res) + return ec.marshalOCircle2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCircle(ctx, field.Selections, res) } func (ec *executionContext) _InnerObject_id(ctx context.Context, field graphql.CollectedField, obj *InnerObject) graphql.Marshaler { @@ -1561,7 +1561,7 @@ func (ec *executionContext) _InnerObject_id(ctx context.Context, field graphql.C res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalInt2int(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _InvalidIdentifier_id(ctx context.Context, field graphql.CollectedField, obj *invalid_packagename.InvalidIdentifier) graphql.Marshaler { @@ -1587,7 +1587,7 @@ func (ec *executionContext) _InvalidIdentifier_id(ctx context.Context, field gra res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalInt2int(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedField, obj *introspection1.It) graphql.Marshaler { @@ -1613,7 +1613,7 @@ func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedF res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalID2string(ctx, field.Selections, res) + return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _ModelMethods_resolverField(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) graphql.Marshaler { @@ -1639,7 +1639,7 @@ func (ec *executionContext) _ModelMethods_resolverField(ctx context.Context, fie res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) _ModelMethods_noContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) graphql.Marshaler { @@ -1665,7 +1665,7 @@ func (ec *executionContext) _ModelMethods_noContext(ctx context.Context, field g res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) _ModelMethods_withContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) graphql.Marshaler { @@ -1691,7 +1691,7 @@ func (ec *executionContext) _ModelMethods_withContext(ctx context.Context, field res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphql.CollectedField, obj *OuterObject) graphql.Marshaler { @@ -1717,7 +1717,7 @@ func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphq res := resTmp.(InnerObject) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalInnerObject2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerObject(ctx, field.Selections, res) + return ec.marshalNInnerObject2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerObject(ctx, field.Selections, res) } func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1740,7 +1740,7 @@ func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field res := resTmp.(*invalid_packagename.InvalidIdentifier) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalInvalidIdentifier2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx, field.Selections, res) + return ec.marshalOInvalidIdentifier2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx, field.Selections, res) } func (ec *executionContext) _Query_collision(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1763,7 +1763,7 @@ func (ec *executionContext) _Query_collision(ctx context.Context, field graphql. res := resTmp.(*introspection1.It) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalIt2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋintrospectionᚐIt(ctx, field.Selections, res) + return ec.marshalOIt2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋintrospectionᚐIt(ctx, field.Selections, res) } func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1793,7 +1793,7 @@ func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.C res := resTmp.(*bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2ᚖbool(ctx, field.Selections, res) + return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) } func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1823,7 +1823,7 @@ func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql. res := resTmp.(*bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2ᚖbool(ctx, field.Selections, res) + return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) } func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1853,7 +1853,7 @@ func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graph res := resTmp.(*bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2ᚖbool(ctx, field.Selections, res) + return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) } func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1876,7 +1876,7 @@ func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field grap res := resTmp.([][]*OuterObject) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOuterObject2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx, field.Selections, res) + return ec.marshalOOuterObject2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx, field.Selections, res) } func (ec *executionContext) _Query_keywords(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1909,7 +1909,7 @@ func (ec *executionContext) _Query_keywords(ctx context.Context, field graphql.C res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1932,7 +1932,7 @@ func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.Col res := resTmp.([]Shape) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx, field.Selections, res) + return ec.marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx, field.Selections, res) } func (ec *executionContext) _Query_errorBubble(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1955,7 +1955,7 @@ func (ec *executionContext) _Query_errorBubble(ctx context.Context, field graphq res := resTmp.(*Error) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx, field.Selections, res) + return ec.marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx, field.Selections, res) } func (ec *executionContext) _Query_modelMethods(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1978,7 +1978,7 @@ func (ec *executionContext) _Query_modelMethods(ctx context.Context, field graph res := resTmp.(*ModelMethods) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalModelMethods2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐModelMethods(ctx, field.Selections, res) + return ec.marshalOModelMethods2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐModelMethods(ctx, field.Selections, res) } func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -2004,7 +2004,7 @@ func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.Coll res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -2037,7 +2037,7 @@ func (ec *executionContext) _Query_user(ctx context.Context, field graphql.Colle res := resTmp.(User) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalUser2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx, field.Selections, res) + return ec.marshalNUser2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx, field.Selections, res) } func (ec *executionContext) _Query_nullableArg(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -2067,7 +2067,7 @@ func (ec *executionContext) _Query_nullableArg(ctx context.Context, field graphq res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) _Query_directiveArg(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -2097,7 +2097,7 @@ func (ec *executionContext) _Query_directiveArg(ctx context.Context, field graph res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) _Query_directiveNullableArg(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -2127,7 +2127,7 @@ func (ec *executionContext) _Query_directiveNullableArg(ctx context.Context, fie res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) _Query_directiveInputNullable(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -2157,7 +2157,7 @@ func (ec *executionContext) _Query_directiveInputNullable(ctx context.Context, f res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) _Query_directiveInput(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -2187,7 +2187,7 @@ func (ec *executionContext) _Query_directiveInput(ctx context.Context, field gra res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) _Query_keywordArgs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -2220,7 +2220,7 @@ func (ec *executionContext) _Query_keywordArgs(ctx context.Context, field graphq res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -2250,7 +2250,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -2273,7 +2273,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) + return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { @@ -2296,7 +2296,7 @@ func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalFloat2float64(ctx, field.Selections, res) + return ec.marshalOFloat2float64(ctx, field.Selections, res) } func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { @@ -2319,7 +2319,7 @@ func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql. res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalFloat2float64(ctx, field.Selections, res) + return ec.marshalOFloat2float64(ctx, field.Selections, res) } func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { @@ -2342,7 +2342,7 @@ func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.C res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalFloat2float64(ctx, field.Selections, res) + return ec.marshalOFloat2float64(ctx, field.Selections, res) } func (ec *executionContext) _Subscription_updated(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { @@ -2367,7 +2367,7 @@ func (ec *executionContext) _Subscription_updated(ctx context.Context, field gra w.Write([]byte{'{'}) graphql.MarshalString(field.Alias).MarshalGQL(w) w.Write([]byte{':'}) - ec.marshalString2string(ctx, field.Selections, res).MarshalGQL(w) + ec.marshalNString2string(ctx, field.Selections, res).MarshalGQL(w) w.Write([]byte{'}'}) }) } @@ -2395,7 +2395,7 @@ func (ec *executionContext) _Subscription_initPayload(ctx context.Context, field w.Write([]byte{'{'}) graphql.MarshalString(field.Alias).MarshalGQL(w) w.Write([]byte{':'}) - ec.marshalString2string(ctx, field.Selections, res).MarshalGQL(w) + ec.marshalNString2string(ctx, field.Selections, res).MarshalGQL(w) w.Write([]byte{'}'}) }) } @@ -2424,7 +2424,7 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalInt2int(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _User_friends(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { @@ -2450,7 +2450,7 @@ func (ec *executionContext) _User_friends(ctx context.Context, field graphql.Col res := resTmp.([]User) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx, field.Selections, res) + return ec.marshalNUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -2476,7 +2476,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -2499,7 +2499,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -2525,7 +2525,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__DirectiveLocation2ᚕstring(ctx, field.Selections, res) + return ec.marshalN__DirectiveLocation2ᚕstring(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -2551,7 +2551,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -2577,7 +2577,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -2600,7 +2600,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -2626,7 +2626,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -2649,7 +2649,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -2675,7 +2675,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -2698,7 +2698,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -2724,7 +2724,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -2750,7 +2750,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -2776,7 +2776,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -2799,7 +2799,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -2825,7 +2825,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -2848,7 +2848,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -2874,7 +2874,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -2897,7 +2897,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -2923,7 +2923,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -2949,7 +2949,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -2972,7 +2972,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -2995,7 +2995,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -3021,7 +3021,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) + return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -3047,7 +3047,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__TypeKind2string(ctx, field.Selections, res) + return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -3070,7 +3070,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -3093,7 +3093,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -3123,7 +3123,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) + return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -3146,7 +3146,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -3169,7 +3169,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -3199,7 +3199,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -3222,7 +3222,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -3245,7 +3245,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } // endregion **************************** field.gotpl ***************************** @@ -3260,7 +3260,7 @@ func (ec *executionContext) unmarshalInputInnerDirectives(v interface{}) (InnerD switch k { case "message": var err error - it.Message, err = ec.unmarshalString2string(v) + it.Message, err = ec.unmarshalNString2string(v) if err != nil { return it, err } @@ -3278,7 +3278,7 @@ func (ec *executionContext) unmarshalInputInnerInput(v interface{}) (InnerInput, switch k { case "id": var err error - it.ID, err = ec.unmarshalInt2int(v) + it.ID, err = ec.unmarshalNInt2int(v) if err != nil { return it, err } @@ -3296,19 +3296,19 @@ func (ec *executionContext) unmarshalInputInputDirectives(v interface{}) (InputD switch k { case "text": var err error - it.Text, err = ec.unmarshalString2string(v) + it.Text, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "inner": var err error - it.Inner, err = ec.unmarshalInnerDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(v) + it.Inner, err = ec.unmarshalNInnerDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(v) if err != nil { return it, err } case "innerNullable": var err error - it.InnerNullable, err = ec.unmarshalInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(v) + it.InnerNullable, err = ec.unmarshalOInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(v) if err != nil { return it, err } @@ -3326,151 +3326,151 @@ func (ec *executionContext) unmarshalInputKeywords(v interface{}) (Keywords, err switch k { case "break": var err error - it.Break, err = ec.unmarshalString2string(v) + it.Break, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "default": var err error - it.Default, err = ec.unmarshalString2string(v) + it.Default, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "func": var err error - it.Func, err = ec.unmarshalString2string(v) + it.Func, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "interface": var err error - it.Interface, err = ec.unmarshalString2string(v) + it.Interface, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "select": var err error - it.Select, err = ec.unmarshalString2string(v) + it.Select, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "case": var err error - it.Case, err = ec.unmarshalString2string(v) + it.Case, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "defer": var err error - it.Defer, err = ec.unmarshalString2string(v) + it.Defer, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "go": var err error - it.Go, err = ec.unmarshalString2string(v) + it.Go, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "map": var err error - it.Map, err = ec.unmarshalString2string(v) + it.Map, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "struct": var err error - it.Struct, err = ec.unmarshalString2string(v) + it.Struct, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "chan": var err error - it.Chan, err = ec.unmarshalString2string(v) + it.Chan, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "else": var err error - it.Else, err = ec.unmarshalString2string(v) + it.Else, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "goto": var err error - it.Goto, err = ec.unmarshalString2string(v) + it.Goto, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "package": var err error - it.Package, err = ec.unmarshalString2string(v) + it.Package, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "switch": var err error - it.Switch, err = ec.unmarshalString2string(v) + it.Switch, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "const": var err error - it.Const, err = ec.unmarshalString2string(v) + it.Const, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "fallthrough": var err error - it.Fallthrough, err = ec.unmarshalString2string(v) + it.Fallthrough, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "if": var err error - it.If, err = ec.unmarshalString2string(v) + it.If, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "range": var err error - it.Range, err = ec.unmarshalString2string(v) + it.Range, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "type": var err error - it.Type, err = ec.unmarshalString2string(v) + it.Type, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "continue": var err error - it.Continue, err = ec.unmarshalString2string(v) + it.Continue, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "for": var err error - it.For, err = ec.unmarshalString2string(v) + it.For, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "import": var err error - it.Import, err = ec.unmarshalString2string(v) + it.Import, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "return": var err error - it.Return, err = ec.unmarshalString2string(v) + it.Return, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "var": var err error - it.Var, err = ec.unmarshalString2string(v) + it.Var, err = ec.unmarshalNString2string(v) if err != nil { return it, err } @@ -3488,7 +3488,7 @@ func (ec *executionContext) unmarshalInputOuterInput(v interface{}) (OuterInput, switch k { case "inner": var err error - it.Inner, err = ec.unmarshalInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerInput(v) + it.Inner, err = ec.unmarshalNInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerInput(v) if err != nil { return it, err } @@ -3506,7 +3506,7 @@ func (ec *executionContext) unmarshalInputRecursiveInputSlice(v interface{}) (Re switch k { case "self": var err error - it.Self, err = ec.unmarshalRecursiveInputSlice2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v) + it.Self, err = ec.unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v) if err != nil { return it, err } @@ -4303,148 +4303,155 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (ec *executionContext) unmarshalBoolean2ᚖbool(v interface{}) (*bool, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalBoolean2bool(v) - return &res, err +func (ec *executionContext) unmarshalNBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) } -func (ec *executionContext) marshalBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.marshalBoolean2bool(ctx, sel, *v) +func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + return graphql.MarshalBoolean(v) } -func (ec *executionContext) marshalCircle2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCircle(ctx context.Context, sel ast.SelectionSet, v *Circle) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._Circle(ctx, sel, v) +func (ec *executionContext) unmarshalNID2string(v interface{}) (string, error) { + return graphql.UnmarshalID(v) } -func (ec *executionContext) marshalError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx context.Context, sel ast.SelectionSet, v *Error) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._Error(ctx, sel, v) +func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalID(v) } -func (ec *executionContext) unmarshalInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(v interface{}) (*InnerDirectives, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInnerDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(v) - return &res, err +func (ec *executionContext) unmarshalNInnerDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(v interface{}) (InnerDirectives, error) { + return ec.unmarshalInputInnerDirectives(v) } -func (ec *executionContext) unmarshalInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v interface{}) (*InputDirectives, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v) - return &res, err +func (ec *executionContext) unmarshalNInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerInput(v interface{}) (InnerInput, error) { + return ec.unmarshalInputInnerInput(v) } -func (ec *executionContext) unmarshalKeywords2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(v interface{}) (*Keywords, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalKeywords2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(v) - return &res, err +func (ec *executionContext) marshalNInnerObject2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerObject(ctx context.Context, sel ast.SelectionSet, v InnerObject) graphql.Marshaler { + return ec._InnerObject(ctx, sel, &v) } -func (ec *executionContext) marshalModelMethods2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐModelMethods(ctx context.Context, sel ast.SelectionSet, v *ModelMethods) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._ModelMethods(ctx, sel, v) +func (ec *executionContext) unmarshalNInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v interface{}) (InputDirectives, error) { + return ec.unmarshalInputInputDirectives(v) } -func (ec *executionContext) unmarshalOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) (*OuterInput, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalOuterInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v) - return &res, err +func (ec *executionContext) unmarshalNInt2int(v interface{}) (int, error) { + return graphql.UnmarshalInt(v) } -func (ec *executionContext) marshalOuterObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v *OuterObject) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._OuterObject(ctx, sel, v) +func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { + return graphql.MarshalInt(v) } -func (ec *executionContext) unmarshalRecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v interface{}) (*RecursiveInputSlice, error) { +func (ec *executionContext) unmarshalNRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { + return ec.unmarshalInputRecursiveInputSlice(v) +} + +func (ec *executionContext) unmarshalNString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalNString2ᚖstring(v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v) + res, err := ec.unmarshalNString2string(v) return &res, err } -func (ec *executionContext) marshalIt2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋintrospectionᚐIt(ctx context.Context, sel ast.SelectionSet, v *introspection1.It) graphql.Marshaler { +func (ec *executionContext) marshalNString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - return ec._It(ctx, sel, v) + return ec.marshalNString2string(ctx, sel, *v) } -func (ec *executionContext) marshalInvalidIdentifier2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx context.Context, sel ast.SelectionSet, v *invalid_packagename.InvalidIdentifier) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._InvalidIdentifier(ctx, sel, v) +func (ec *executionContext) marshalNUser2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler { + return ec._User(ctx, sel, &v) } -func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { - return graphql.Null +func (ec *executionContext) marshalNUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx context.Context, sel ast.SelectionSet, v []User) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) } - return ec.___Schema(ctx, sel, v) -} + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNUser2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } -func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { - return graphql.Null } - return ec.___Type(ctx, sel, v) + wg.Wait() + return ret } -func (ec *executionContext) unmarshalInt2ᚖint(v interface{}) (*int, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInt2int(v) - return &res, err +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { + return ec.___Directive(ctx, sel, &v) } -func (ec *executionContext) marshalInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { - if v == nil { - return graphql.Null +func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) } - return ec.marshalInt2int(ctx, sel, *v) -} + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } -func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, error) { - if v == nil { - return nil, nil } - res, err := ec.unmarshalString2string(v) - return &res, err + wg.Wait() + return ret } -func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.marshalString2string(ctx, sel, *v) +func (ec *executionContext) unmarshalN__DirectiveLocation2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) } -func (ec *executionContext) unmarshalOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) ([]*OuterInput, error) { +func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -4454,9 +4461,9 @@ func (ec *executionContext) unmarshalOuterInput2ᚕᚖgithubᚗcomᚋ99designs } } var err error - res := make([]*OuterInput, len(vSlice)) + res := make([]string, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(vSlice[i]) + res[i], err = ec.unmarshalN__DirectiveLocation2string(vSlice[i]) if err != nil { return nil, err } @@ -4464,7 +4471,7 @@ func (ec *executionContext) unmarshalOuterInput2ᚕᚖgithubᚗcomᚋ99designs return res, nil } -func (ec *executionContext) marshalOuterObject2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v []*OuterObject) graphql.Marshaler { +func (ec *executionContext) marshalN__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4482,7 +4489,7 @@ func (ec *executionContext) marshalOuterObject2ᚕᚖgithubᚗcomᚋ99designsᚋ if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalOuterObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx, sel, v[i]) + ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) } if isLen1 { f(i) @@ -4491,11 +4498,260 @@ func (ec *executionContext) marshalOuterObject2ᚕᚖgithubᚗcomᚋ99designsᚋ } } - wg.Wait() - return ret + wg.Wait() + return ret +} + +func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { + return ec.___EnumValue(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { + return ec.___Field(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { + return ec.___InputValue(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + return ec.___Type(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec.___Type(ctx, sel, v) +} + +func (ec *executionContext) unmarshalN__TypeKind2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalOBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) +} + +func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + return graphql.MarshalBoolean(v) +} + +func (ec *executionContext) unmarshalOBoolean2ᚖbool(v interface{}) (*bool, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOBoolean2bool(v) + return &res, err +} + +func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOBoolean2bool(ctx, sel, *v) +} + +func (ec *executionContext) unmarshalOChanges2map(v interface{}) (map[string]interface{}, error) { + return v.(map[string]interface{}), nil +} + +func (ec *executionContext) marshalOCircle2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCircle(ctx context.Context, sel ast.SelectionSet, v Circle) graphql.Marshaler { + return ec._Circle(ctx, sel, &v) +} + +func (ec *executionContext) marshalOCircle2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCircle(ctx context.Context, sel ast.SelectionSet, v *Circle) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Circle(ctx, sel, v) +} + +func (ec *executionContext) marshalOError2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx context.Context, sel ast.SelectionSet, v Error) graphql.Marshaler { + return ec._Error(ctx, sel, &v) +} + +func (ec *executionContext) marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx context.Context, sel ast.SelectionSet, v *Error) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Error(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOFloat2float64(v interface{}) (float64, error) { + return graphql.UnmarshalFloat(v) +} + +func (ec *executionContext) marshalOFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { + return graphql.MarshalFloat(v) +} + +func (ec *executionContext) unmarshalOInnerDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(v interface{}) (InnerDirectives, error) { + return ec.unmarshalInputInnerDirectives(v) +} + +func (ec *executionContext) unmarshalOInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(v interface{}) (*InnerDirectives, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOInnerDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(v) + return &res, err +} + +func (ec *executionContext) unmarshalOInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v interface{}) (InputDirectives, error) { + return ec.unmarshalInputInputDirectives(v) +} + +func (ec *executionContext) unmarshalOInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v interface{}) (*InputDirectives, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v) + return &res, err +} + +func (ec *executionContext) unmarshalOInt2int(v interface{}) (int, error) { + return graphql.UnmarshalInt(v) +} + +func (ec *executionContext) marshalOInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { + return graphql.MarshalInt(v) +} + +func (ec *executionContext) unmarshalOInt2ᚖint(v interface{}) (*int, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOInt2int(v) + return &res, err +} + +func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOInt2int(ctx, sel, *v) +} + +func (ec *executionContext) marshalOInvalidIdentifier2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx context.Context, sel ast.SelectionSet, v invalid_packagename.InvalidIdentifier) graphql.Marshaler { + return ec._InvalidIdentifier(ctx, sel, &v) +} + +func (ec *executionContext) marshalOInvalidIdentifier2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx context.Context, sel ast.SelectionSet, v *invalid_packagename.InvalidIdentifier) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._InvalidIdentifier(ctx, sel, v) +} + +func (ec *executionContext) marshalOIt2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋintrospectionᚐIt(ctx context.Context, sel ast.SelectionSet, v introspection1.It) graphql.Marshaler { + return ec._It(ctx, sel, &v) +} + +func (ec *executionContext) marshalOIt2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋintrospectionᚐIt(ctx context.Context, sel ast.SelectionSet, v *introspection1.It) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._It(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOKeywords2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(v interface{}) (Keywords, error) { + return ec.unmarshalInputKeywords(v) +} + +func (ec *executionContext) unmarshalOKeywords2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(v interface{}) (*Keywords, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOKeywords2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(v) + return &res, err +} + +func (ec *executionContext) marshalOModelMethods2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐModelMethods(ctx context.Context, sel ast.SelectionSet, v ModelMethods) graphql.Marshaler { + return ec._ModelMethods(ctx, sel, &v) +} + +func (ec *executionContext) marshalOModelMethods2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐModelMethods(ctx context.Context, sel ast.SelectionSet, v *ModelMethods) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._ModelMethods(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOOuterInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) (OuterInput, error) { + return ec.unmarshalInputOuterInput(v) } -func (ec *executionContext) unmarshalOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) ([][]*OuterInput, error) { +func (ec *executionContext) unmarshalOOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) ([][]*OuterInput, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -4507,7 +4763,7 @@ func (ec *executionContext) unmarshalOuterInput2ᚕᚕᚖgithubᚗcomᚋ99design var err error res := make([][]*OuterInput, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(vSlice[i]) + res[i], err = ec.unmarshalOOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(vSlice[i]) if err != nil { return nil, err } @@ -4515,38 +4771,7 @@ func (ec *executionContext) unmarshalOuterInput2ᚕᚕᚖgithubᚗcomᚋ99design return res, nil } -func (ec *executionContext) marshalOuterObject2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v [][]*OuterObject) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - rctx := &graphql.ResolverContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(i int) { - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalOuterObject2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - return ret -} - -func (ec *executionContext) unmarshalRecursiveInputSlice2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v interface{}) ([]RecursiveInputSlice, error) { +func (ec *executionContext) unmarshalOOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) ([]*OuterInput, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -4556,9 +4781,9 @@ func (ec *executionContext) unmarshalRecursiveInputSlice2ᚕgithubᚗcomᚋ99des } } var err error - res := make([]RecursiveInputSlice, len(vSlice)) + res := make([]*OuterInput, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(vSlice[i]) + res[i], err = ec.unmarshalOOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(vSlice[i]) if err != nil { return nil, err } @@ -4566,7 +4791,19 @@ func (ec *executionContext) unmarshalRecursiveInputSlice2ᚕgithubᚗcomᚋ99des return res, nil } -func (ec *executionContext) marshalShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx context.Context, sel ast.SelectionSet, v []Shape) graphql.Marshaler { +func (ec *executionContext) unmarshalOOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) (*OuterInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOOuterInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v) + return &res, err +} + +func (ec *executionContext) marshalOOuterObject2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v OuterObject) graphql.Marshaler { + return ec._OuterObject(ctx, sel, &v) +} + +func (ec *executionContext) marshalOOuterObject2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v [][]*OuterObject) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4584,7 +4821,7 @@ func (ec *executionContext) marshalShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx, sel, v[i]) + ret[i] = ec.marshalOOuterObject2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx, sel, v[i]) } if isLen1 { f(i) @@ -4597,7 +4834,7 @@ func (ec *executionContext) marshalShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ return ret } -func (ec *executionContext) marshalUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx context.Context, sel ast.SelectionSet, v []User) graphql.Marshaler { +func (ec *executionContext) marshalOOuterObject2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v []*OuterObject) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4615,7 +4852,7 @@ func (ec *executionContext) marshalUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋc if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalUser2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx, sel, v[i]) + ret[i] = ec.marshalOOuterObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx, sel, v[i]) } if isLen1 { f(i) @@ -4628,38 +4865,50 @@ func (ec *executionContext) marshalUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋc return ret } -func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) +func (ec *executionContext) marshalOOuterObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v *OuterObject) graphql.Marshaler { + if v == nil { + return graphql.Null } - for i := range v { - i := i - rctx := &graphql.ResolverContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(i int) { - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) - } - if isLen1 { - f(i) + return ec._OuterObject(ctx, sel, v) +} + +func (ec *executionContext) unmarshalORecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { + return ec.unmarshalInputRecursiveInputSlice(v) +} + +func (ec *executionContext) unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v interface{}) ([]RecursiveInputSlice, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 } else { - go f(i) + vSlice = []interface{}{v} + } + } + var err error + res := make([]RecursiveInputSlice, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshalNRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(vSlice[i]) + if err != nil { + return nil, err } + } + return res, nil +} +func (ec *executionContext) unmarshalORecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v interface{}) (*RecursiveInputSlice, error) { + if v == nil { + return nil, nil } - wg.Wait() - return ret + res, err := ec.unmarshalORecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v) + return &res, err +} + +func (ec *executionContext) marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx context.Context, sel ast.SelectionSet, v Shape) graphql.Marshaler { + return ec._Shape(ctx, sel, &v) } -func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx context.Context, sel ast.SelectionSet, v []Shape) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4677,7 +4926,7 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) + ret[i] = ec.marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx, sel, v[i]) } if isLen1 { f(i) @@ -4690,7 +4939,30 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql return ret } -func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { +func (ec *executionContext) unmarshalOString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalOString2ᚖstring(v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOString2string(v) + return &res, err +} + +func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOString2string(ctx, sel, *v) +} + +func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4708,7 +4980,7 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -4721,7 +4993,7 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4739,7 +5011,7 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) } if isLen1 { f(i) @@ -4752,7 +5024,7 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq return ret } -func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { +func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4770,7 +5042,7 @@ func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -4783,27 +5055,22 @@ func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { - var vSlice []interface{} - if v != nil { - if tmp1, ok := v.([]interface{}); ok { - vSlice = tmp1 - } else { - vSlice = []interface{}{v} - } - } - var err error - res := make([]string, len(vSlice)) - for i := range vSlice { - res[i], err = ec.unmarshal__DirectiveLocation2string(vSlice[i]) - if err != nil { - return nil, err - } +func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { + return ec.___Schema(ctx, sel, &v) +} + +func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { + if v == nil { + return graphql.Null } - return res, nil + return ec.___Schema(ctx, sel, v) +} + +func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + return ec.___Type(ctx, sel, &v) } -func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { +func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4821,7 +5088,7 @@ func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Con if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__DirectiveLocation2string(ctx, sel, v[i]) + ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) } if isLen1 { f(i) @@ -4834,148 +5101,11 @@ func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Con return ret } -func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { - return graphql.UnmarshalBoolean(v) -} - -func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) -} - -func (ec *executionContext) unmarshalFloat2float64(v interface{}) (float64, error) { - return graphql.UnmarshalFloat(v) -} - -func (ec *executionContext) marshalFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { - return graphql.MarshalFloat(v) -} - -func (ec *executionContext) marshalCircle2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCircle(ctx context.Context, sel ast.SelectionSet, v Circle) graphql.Marshaler { - return ec._Circle(ctx, sel, &v) -} - -func (ec *executionContext) marshalError2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx context.Context, sel ast.SelectionSet, v Error) graphql.Marshaler { - return ec._Error(ctx, sel, &v) -} - -func (ec *executionContext) unmarshalInnerDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(v interface{}) (InnerDirectives, error) { - return ec.unmarshalInputInnerDirectives(v) -} - -func (ec *executionContext) unmarshalInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerInput(v interface{}) (InnerInput, error) { - return ec.unmarshalInputInnerInput(v) -} - -func (ec *executionContext) marshalInnerObject2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerObject(ctx context.Context, sel ast.SelectionSet, v InnerObject) graphql.Marshaler { - return ec._InnerObject(ctx, sel, &v) -} - -func (ec *executionContext) unmarshalInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v interface{}) (InputDirectives, error) { - return ec.unmarshalInputInputDirectives(v) -} - -func (ec *executionContext) unmarshalKeywords2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(v interface{}) (Keywords, error) { - return ec.unmarshalInputKeywords(v) -} - -func (ec *executionContext) marshalModelMethods2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐModelMethods(ctx context.Context, sel ast.SelectionSet, v ModelMethods) graphql.Marshaler { - return ec._ModelMethods(ctx, sel, &v) -} - -func (ec *executionContext) unmarshalOuterInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) (OuterInput, error) { - return ec.unmarshalInputOuterInput(v) -} - -func (ec *executionContext) marshalOuterObject2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v OuterObject) graphql.Marshaler { - return ec._OuterObject(ctx, sel, &v) -} - -func (ec *executionContext) unmarshalRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { - return ec.unmarshalInputRecursiveInputSlice(v) -} - -func (ec *executionContext) marshalShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx context.Context, sel ast.SelectionSet, v Shape) graphql.Marshaler { - return ec._Shape(ctx, sel, &v) -} - -func (ec *executionContext) marshalUser2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler { - return ec._User(ctx, sel, &v) -} - -func (ec *executionContext) marshalIt2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋintrospectionᚐIt(ctx context.Context, sel ast.SelectionSet, v introspection1.It) graphql.Marshaler { - return ec._It(ctx, sel, &v) -} - -func (ec *executionContext) marshalInvalidIdentifier2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx context.Context, sel ast.SelectionSet, v invalid_packagename.InvalidIdentifier) graphql.Marshaler { - return ec._InvalidIdentifier(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) -} - -func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) -} - -func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - -func (ec *executionContext) unmarshalInt2int(v interface{}) (int, error) { - return graphql.UnmarshalInt(v) -} - -func (ec *executionContext) marshalInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - return graphql.MarshalInt(v) -} - -func (ec *executionContext) unmarshalChanges2map(v interface{}) (map[string]interface{}, error) { - return v.(map[string]interface{}), nil -} - -func (ec *executionContext) unmarshalID2string(v interface{}) (string, error) { - return graphql.UnmarshalID(v) -} - -func (ec *executionContext) marshalID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalID(v) -} - -func (ec *executionContext) unmarshalString2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) -} - -func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) -} - -func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) -} - -func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) -} - -func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) -} - -func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) +func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Type(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** diff --git a/codegen/type.go b/codegen/type.go index a650405b537..e0083732368 100644 --- a/codegen/type.go +++ b/codegen/type.go @@ -1,8 +1,6 @@ package codegen import ( - "go/types" - "github.com/99designs/gqlgen/codegen/config" ) @@ -10,28 +8,10 @@ func (b *builder) buildTypes() (map[string]*config.TypeReference, error) { ret := map[string]*config.TypeReference{} for _, ref := range b.Binder.References { - for { - ret[ref.GO.String()+ref.GQL.Name()] = ref + for ref != nil { + ret[ref.UniquenessKey()] = ref - if p, isPtr := ref.GO.(*types.Pointer); isPtr { - ref = &config.TypeReference{ - GO: p.Elem(), - GQL: ref.GQL, - Definition: ref.Definition, - Unmarshaler: ref.Unmarshaler, - Marshaler: ref.Marshaler, - } - } else if s, isSlice := ref.GO.(*types.Slice); isSlice { - ref = &config.TypeReference{ - GO: s.Elem(), - GQL: ref.GQL, - Definition: ref.Definition, - Unmarshaler: ref.Unmarshaler, - Marshaler: ref.Marshaler, - } - } else { - break - } + ref = ref.Elem() } } return ret, nil diff --git a/codegen/type.gotpl b/codegen/type.gotpl index 37aab4b1a95..6e852f96d16 100644 --- a/codegen/type.gotpl +++ b/codegen/type.gotpl @@ -1,9 +1,9 @@ {{- range $type := .ReferencedTypes }} - {{ if $type.NeedsUnmarshaler }} - func (ec *executionContext) unmarshal{{ $type.Definition.Name }}2{{ $type.GO | ts }}(v interface{}) ({{ $type.GO | ref }}, error) { + {{ with $type.UnmarshalFunc }} + func (ec *executionContext) {{ . }}(v interface{}) ({{ $type.GO | ref }}, error) { {{- if $type.IsPtr }} if v == nil { return nil, nil } - res, err := ec.unmarshal{{ $type.Definition.Name }}2{{ $type.GO.Elem | ts }}(v) + res, err := ec.{{ $type.Elem.UnmarshalFunc }}(v) return &res, err {{- else if $type.IsSlice }} var vSlice []interface{} @@ -17,7 +17,7 @@ var err error res := make([]{{$type.GO.Elem | ref}}, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshal{{ $type.Definition.Name }}2{{ $type.GO.Elem | ts }}(vSlice[i]) + res[i], err = ec.{{ $type.Elem.UnmarshalFunc }}(vSlice[i]) if err != nil { return nil, err } @@ -36,10 +36,15 @@ } {{- end }} - {{ if $type.NeedsMarshaler }} - func (ec *executionContext) marshal{{ $type.Definition.Name }}2{{ $type.GO | ts }}(ctx context.Context, sel ast.SelectionSet, v {{ $type.GO | ref }}) graphql.Marshaler { + {{ with $type.MarshalFunc }} + func (ec *executionContext) {{ . }}(ctx context.Context, sel ast.SelectionSet, v {{ $type.GO | ref }}) graphql.Marshaler { {{- if $type.IsPtr }} if v == nil { + {{- if $type.GQL.NonNull }} + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + {{- end }} return graphql.Null } {{- end }} @@ -48,7 +53,7 @@ return v {{- else if $type.IsSlice }} ret := make(graphql.Array, len(v)) - {{- if not .IsScalar }} + {{- if not $type.IsScalar }} var wg sync.WaitGroup isLen1 := len(v) == 1 if !isLen1 { @@ -56,7 +61,7 @@ } {{- end }} for i := range v { - {{- if not .IsScalar }} + {{- if not $type.IsScalar }} i := i rctx := &graphql.ResolverContext{ Index: &i, @@ -67,7 +72,7 @@ if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal{{ $type.Definition.Name }}2{{ $type.GO.Elem | ts }}(ctx, sel, v[i]) + ret[i] = ec.{{ $type.Elem.MarshalFunc }}(ctx, sel, v[i]) } if isLen1 { f(i) @@ -75,16 +80,16 @@ go f(i) } {{ else }} - ret[i] = ec.marshal{{ $type.Definition.Name }}2{{ $type.GO.Elem | ts }}(ctx, sel, v[i]) + ret[i] = ec.{{ $type.Elem.MarshalFunc }}(ctx, sel, v[i]) {{- end}} } - {{ if not .IsScalar }} wg.Wait() {{ end }} + {{ if not $type.IsScalar }} wg.Wait() {{ end }} return ret {{- else }} {{- if $type.Marshaler }} {{- if $type.IsPtr }} - return ec.marshal{{ $type.Definition.Name }}2{{ $type.GO.Elem | ts }}(ctx, sel, *v) + return ec.{{ $type.Elem.MarshalFunc }}(ctx, sel, *v) {{- else }} return {{ $type.Marshaler | call }}(v) {{- end }} diff --git a/example/chat/generated.go b/example/chat/generated.go index 27672e9c291..91491bf0250 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -313,7 +313,7 @@ func (ec *executionContext) field_Mutation_post_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["text"]; ok { - arg0, err = ec.unmarshalString2string(tmp) + arg0, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -321,7 +321,7 @@ func (ec *executionContext) field_Mutation_post_args(ctx context.Context, rawArg args["text"] = arg0 var arg1 string if tmp, ok := rawArgs["username"]; ok { - arg1, err = ec.unmarshalString2string(tmp) + arg1, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -329,7 +329,7 @@ func (ec *executionContext) field_Mutation_post_args(ctx context.Context, rawArg args["username"] = arg1 var arg2 string if tmp, ok := rawArgs["roomName"]; ok { - arg2, err = ec.unmarshalString2string(tmp) + arg2, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -343,7 +343,7 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = ec.unmarshalString2string(tmp) + arg0, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -357,7 +357,7 @@ func (ec *executionContext) field_Query_room_args(ctx context.Context, rawArgs m args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = ec.unmarshalString2string(tmp) + arg0, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -371,7 +371,7 @@ func (ec *executionContext) field_Subscription_messageAdded_args(ctx context.Con args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["roomName"]; ok { - arg0, err = ec.unmarshalString2string(tmp) + arg0, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -385,7 +385,7 @@ func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(tmp) if err != nil { return nil, err } @@ -399,7 +399,7 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(tmp) if err != nil { return nil, err } @@ -435,7 +435,7 @@ func (ec *executionContext) _Chatroom_name(ctx context.Context, field graphql.Co res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Chatroom_messages(ctx context.Context, field graphql.CollectedField, obj *Chatroom) graphql.Marshaler { @@ -461,7 +461,7 @@ func (ec *executionContext) _Chatroom_messages(ctx context.Context, field graphq res := resTmp.([]Message) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalMessage2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx, field.Selections, res) + return ec.marshalNMessage2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx, field.Selections, res) } func (ec *executionContext) _Message_id(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { @@ -487,7 +487,7 @@ func (ec *executionContext) _Message_id(ctx context.Context, field graphql.Colle res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalID2string(ctx, field.Selections, res) + return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _Message_text(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { @@ -513,7 +513,7 @@ func (ec *executionContext) _Message_text(ctx context.Context, field graphql.Col res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Message_createdBy(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { @@ -539,7 +539,7 @@ func (ec *executionContext) _Message_createdBy(ctx context.Context, field graphq res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Message_createdAt(ctx context.Context, field graphql.CollectedField, obj *Message) graphql.Marshaler { @@ -565,7 +565,7 @@ func (ec *executionContext) _Message_createdAt(ctx context.Context, field graphq res := resTmp.(time.Time) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } func (ec *executionContext) _Mutation_post(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -598,7 +598,7 @@ func (ec *executionContext) _Mutation_post(ctx context.Context, field graphql.Co res := resTmp.(Message) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalMessage2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx, field.Selections, res) + return ec.marshalNMessage2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx, field.Selections, res) } func (ec *executionContext) _Query_room(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -628,7 +628,7 @@ func (ec *executionContext) _Query_room(ctx context.Context, field graphql.Colle res := resTmp.(*Chatroom) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalChatroom2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐChatroom(ctx, field.Selections, res) + return ec.marshalOChatroom2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐChatroom(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -658,7 +658,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -681,7 +681,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) + return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } func (ec *executionContext) _Subscription_messageAdded(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { @@ -712,7 +712,7 @@ func (ec *executionContext) _Subscription_messageAdded(ctx context.Context, fiel w.Write([]byte{'{'}) graphql.MarshalString(field.Alias).MarshalGQL(w) w.Write([]byte{':'}) - ec.marshalMessage2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx, field.Selections, res).MarshalGQL(w) + ec.marshalNMessage2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx, field.Selections, res).MarshalGQL(w) w.Write([]byte{'}'}) }) } @@ -741,7 +741,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -764,7 +764,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -790,7 +790,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__DirectiveLocation2ᚕstring(ctx, field.Selections, res) + return ec.marshalN__DirectiveLocation2ᚕstring(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -816,7 +816,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -842,7 +842,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -865,7 +865,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -891,7 +891,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -914,7 +914,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -940,7 +940,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -963,7 +963,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -989,7 +989,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -1015,7 +1015,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -1041,7 +1041,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -1064,7 +1064,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1090,7 +1090,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1113,7 +1113,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1139,7 +1139,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1162,7 +1162,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1188,7 +1188,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1214,7 +1214,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1237,7 +1237,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1260,7 +1260,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1286,7 +1286,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) + return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1312,7 +1312,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__TypeKind2string(ctx, field.Selections, res) + return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1335,7 +1335,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1358,7 +1358,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1388,7 +1388,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) + return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1411,7 +1411,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1434,7 +1434,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1464,7 +1464,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1487,7 +1487,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1510,7 +1510,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } // endregion **************************** field.gotpl ***************************** @@ -1931,43 +1931,27 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (ec *executionContext) marshalChatroom2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐChatroom(ctx context.Context, sel ast.SelectionSet, v *Chatroom) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._Chatroom(ctx, sel, v) +func (ec *executionContext) unmarshalNBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) } -func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Schema(ctx, sel, v) +func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + return graphql.MarshalBoolean(v) } -func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Type(ctx, sel, v) +func (ec *executionContext) unmarshalNID2string(v interface{}) (string, error) { + return graphql.UnmarshalID(v) } -func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalString2string(v) - return &res, err +func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalID(v) } -func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.marshalString2string(ctx, sel, *v) +func (ec *executionContext) marshalNMessage2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx context.Context, sel ast.SelectionSet, v Message) graphql.Marshaler { + return ec._Message(ctx, sel, &v) } -func (ec *executionContext) marshalMessage2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx context.Context, sel ast.SelectionSet, v []Message) graphql.Marshaler { +func (ec *executionContext) marshalNMessage2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx context.Context, sel ast.SelectionSet, v []Message) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1985,7 +1969,7 @@ func (ec *executionContext) marshalMessage2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalMessage2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx, sel, v[i]) + ret[i] = ec.marshalNMessage2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx, sel, v[i]) } if isLen1 { f(i) @@ -1998,7 +1982,27 @@ func (ec *executionContext) marshalMessage2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { +func (ec *executionContext) unmarshalNString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalNTime2timeᚐTime(v interface{}) (time.Time, error) { + return graphql.UnmarshalTime(v) +} + +func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { + return graphql.MarshalTime(v) +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { + return ec.___Directive(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2016,7 +2020,7 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) + ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2029,7 +2033,35 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql return ret } -func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) unmarshalN__DirectiveLocation2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshalN__DirectiveLocation2string(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalN__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2047,7 +2079,7 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) + ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2060,7 +2092,19 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql return ret } -func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { +func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { + return ec.___EnumValue(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { + return ec.___Field(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { + return ec.___InputValue(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2078,7 +2122,7 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2091,7 +2135,11 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + return ec.___Type(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2109,7 +2157,7 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2122,7 +2170,67 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq return ret } -func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { +func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec.___Type(ctx, sel, v) +} + +func (ec *executionContext) unmarshalN__TypeKind2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalOBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) +} + +func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + return graphql.MarshalBoolean(v) +} + +func (ec *executionContext) marshalOChatroom2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐChatroom(ctx context.Context, sel ast.SelectionSet, v Chatroom) graphql.Marshaler { + return ec._Chatroom(ctx, sel, &v) +} + +func (ec *executionContext) marshalOChatroom2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐChatroom(ctx context.Context, sel ast.SelectionSet, v *Chatroom) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Chatroom(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalOString2ᚖstring(v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOString2string(v) + return &res, err +} + +func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOString2string(ctx, sel, *v) +} + +func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2140,7 +2248,7 @@ func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2153,27 +2261,38 @@ func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { - var vSlice []interface{} - if v != nil { - if tmp1, ok := v.([]interface{}); ok { - vSlice = tmp1 - } else { - vSlice = []interface{}{v} - } +func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) } - var err error - res := make([]string, len(vSlice)) - for i := range vSlice { - res[i], err = ec.unmarshal__DirectiveLocation2string(vSlice[i]) - if err != nil { - return nil, err + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) } + } - return res, nil + wg.Wait() + return ret } -func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { +func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2191,7 +2310,7 @@ func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Con if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__DirectiveLocation2string(ctx, sel, v[i]) + ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2204,84 +2323,57 @@ func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Con return ret } -func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { - return graphql.UnmarshalBoolean(v) -} - -func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) -} - -func (ec *executionContext) marshalChatroom2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐChatroom(ctx context.Context, sel ast.SelectionSet, v Chatroom) graphql.Marshaler { - return ec._Chatroom(ctx, sel, &v) -} - -func (ec *executionContext) marshalMessage2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx context.Context, sel ast.SelectionSet, v Message) graphql.Marshaler { - return ec._Message(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) -} - -func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) -} - -func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { +func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { return ec.___Schema(ctx, sel, &v) } -func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - -func (ec *executionContext) unmarshalID2string(v interface{}) (string, error) { - return graphql.UnmarshalID(v) -} - -func (ec *executionContext) marshalID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalID(v) -} - -func (ec *executionContext) unmarshalString2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) -} - -func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) -} - -func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) -} - -func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) +func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Schema(ctx, sel, v) } -func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) +func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + return ec.___Type(ctx, sel, &v) } -func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) -} +func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } -func (ec *executionContext) unmarshalTime2timeᚐTime(v interface{}) (time.Time, error) { - return graphql.UnmarshalTime(v) + } + wg.Wait() + return ret } -func (ec *executionContext) marshalTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - return graphql.MarshalTime(v) +func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Type(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** diff --git a/example/config/generated.go b/example/config/generated.go index 2538c61bcf1..1348176e7f1 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -270,7 +270,7 @@ func (ec *executionContext) field_Mutation_createTodo_args(ctx context.Context, args := map[string]interface{}{} var arg0 NewTodo if tmp, ok := rawArgs["input"]; ok { - arg0, err = ec.unmarshalNewTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐNewTodo(tmp) + arg0, err = ec.unmarshalNNewTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐNewTodo(tmp) if err != nil { return nil, err } @@ -284,7 +284,7 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = ec.unmarshalString2string(tmp) + arg0, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -298,7 +298,7 @@ func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(tmp) if err != nil { return nil, err } @@ -312,7 +312,7 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(tmp) if err != nil { return nil, err } @@ -355,7 +355,7 @@ func (ec *executionContext) _Mutation_createTodo(ctx context.Context, field grap res := resTmp.(Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐTodo(ctx, field.Selections, res) + return ec.marshalNTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐTodo(ctx, field.Selections, res) } func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -381,7 +381,7 @@ func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.Coll res := resTmp.([]Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐTodo(ctx, field.Selections, res) + return ec.marshalNTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐTodo(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -411,7 +411,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -434,7 +434,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) + return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { @@ -460,7 +460,7 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalID2string(ctx, field.Selections, res) + return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _Todo_databaseId(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { @@ -486,7 +486,7 @@ func (ec *executionContext) _Todo_databaseId(ctx context.Context, field graphql. res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalInt2int(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _Todo_Description(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { @@ -512,7 +512,7 @@ func (ec *executionContext) _Todo_Description(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { @@ -538,7 +538,7 @@ func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.Collec res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { @@ -564,7 +564,7 @@ func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.Collec res := resTmp.(User) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalUser2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐUser(ctx, field.Selections, res) + return ec.marshalNUser2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐUser(ctx, field.Selections, res) } func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { @@ -590,7 +590,7 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalID2string(ctx, field.Selections, res) + return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _User_FullName(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { @@ -616,7 +616,7 @@ func (ec *executionContext) _User_FullName(ctx context.Context, field graphql.Co res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -642,7 +642,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -665,7 +665,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -691,7 +691,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__DirectiveLocation2ᚕstring(ctx, field.Selections, res) + return ec.marshalN__DirectiveLocation2ᚕstring(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -717,7 +717,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -743,7 +743,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -766,7 +766,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -792,7 +792,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -815,7 +815,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -841,7 +841,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -864,7 +864,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -890,7 +890,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -916,7 +916,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -942,7 +942,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -965,7 +965,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -991,7 +991,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1014,7 +1014,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1040,7 +1040,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1063,7 +1063,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1089,7 +1089,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1115,7 +1115,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1138,7 +1138,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1161,7 +1161,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1187,7 +1187,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) + return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1213,7 +1213,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__TypeKind2string(ctx, field.Selections, res) + return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1236,7 +1236,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1259,7 +1259,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1289,7 +1289,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) + return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1312,7 +1312,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1335,7 +1335,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1365,7 +1365,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1388,7 +1388,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1411,7 +1411,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } // endregion **************************** field.gotpl ***************************** @@ -1426,13 +1426,13 @@ func (ec *executionContext) unmarshalInputNewTodo(v interface{}) (NewTodo, error switch k { case "text": var err error - it.Text, err = ec.unmarshalString2string(v) + it.Text, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "UserID": var err error - it.UserID, err = ec.unmarshalString2string(v) + it.UserID, err = ec.unmarshalNString2string(v) if err != nil { return it, err } @@ -1848,36 +1848,47 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Schema(ctx, sel, v) +func (ec *executionContext) unmarshalNBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) } -func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Type(ctx, sel, v) +func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + return graphql.MarshalBoolean(v) } -func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalString2string(v) - return &res, err +func (ec *executionContext) unmarshalNID2string(v interface{}) (string, error) { + return graphql.UnmarshalID(v) } -func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.marshalString2string(ctx, sel, *v) +func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalID(v) +} + +func (ec *executionContext) unmarshalNInt2int(v interface{}) (int, error) { + return graphql.UnmarshalInt(v) +} + +func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { + return graphql.MarshalInt(v) +} + +func (ec *executionContext) unmarshalNNewTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐNewTodo(v interface{}) (NewTodo, error) { + return ec.unmarshalInputNewTodo(v) +} + +func (ec *executionContext) unmarshalNString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) } -func (ec *executionContext) marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐTodo(ctx context.Context, sel ast.SelectionSet, v []Todo) graphql.Marshaler { +func (ec *executionContext) marshalNTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { + return ec._Todo(ctx, sel, &v) +} + +func (ec *executionContext) marshalNTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐTodo(ctx context.Context, sel ast.SelectionSet, v []Todo) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1895,7 +1906,7 @@ func (ec *executionContext) marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋe if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐTodo(ctx, sel, v[i]) + ret[i] = ec.marshalNTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐTodo(ctx, sel, v[i]) } if isLen1 { f(i) @@ -1908,7 +1919,15 @@ func (ec *executionContext) marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋe return ret } -func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { +func (ec *executionContext) marshalNUser2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler { + return ec._User(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { + return ec.___Directive(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1926,7 +1945,7 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) + ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) } if isLen1 { f(i) @@ -1939,7 +1958,35 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql return ret } -func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) unmarshalN__DirectiveLocation2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshalN__DirectiveLocation2string(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalN__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1957,7 +2004,7 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) + ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) } if isLen1 { f(i) @@ -1970,7 +2017,19 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql return ret } -func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { +func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { + return ec.___EnumValue(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { + return ec.___Field(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { + return ec.___InputValue(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1988,7 +2047,7 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2001,7 +2060,11 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + return ec.___Type(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2019,7 +2082,7 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2032,7 +2095,56 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq return ret } -func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { +func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec.___Type(ctx, sel, v) +} + +func (ec *executionContext) unmarshalN__TypeKind2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalOBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) +} + +func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + return graphql.MarshalBoolean(v) +} + +func (ec *executionContext) unmarshalOString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalOString2ᚖstring(v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOString2string(v) + return &res, err +} + +func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOString2string(ctx, sel, *v) +} + +func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2050,7 +2162,7 @@ func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2063,27 +2175,38 @@ func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { - var vSlice []interface{} - if v != nil { - if tmp1, ok := v.([]interface{}); ok { - vSlice = tmp1 - } else { - vSlice = []interface{}{v} - } +func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) } - var err error - res := make([]string, len(vSlice)) - for i := range vSlice { - res[i], err = ec.unmarshal__DirectiveLocation2string(vSlice[i]) - if err != nil { - return nil, err + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + } - return res, nil + wg.Wait() + return ret } -func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { +func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2101,7 +2224,7 @@ func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Con if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__DirectiveLocation2string(ctx, sel, v[i]) + ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2114,88 +2237,57 @@ func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Con return ret } -func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { - return graphql.UnmarshalBoolean(v) -} - -func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) -} - -func (ec *executionContext) unmarshalNewTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐNewTodo(v interface{}) (NewTodo, error) { - return ec.unmarshalInputNewTodo(v) -} - -func (ec *executionContext) marshalTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { - return ec._Todo(ctx, sel, &v) -} - -func (ec *executionContext) marshalUser2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler { - return ec._User(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) -} - -func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) -} - -func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { +func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { return ec.___Schema(ctx, sel, &v) } -func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - -func (ec *executionContext) unmarshalInt2int(v interface{}) (int, error) { - return graphql.UnmarshalInt(v) -} - -func (ec *executionContext) marshalInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - return graphql.MarshalInt(v) -} - -func (ec *executionContext) unmarshalID2string(v interface{}) (string, error) { - return graphql.UnmarshalID(v) -} - -func (ec *executionContext) marshalID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalID(v) -} - -func (ec *executionContext) unmarshalString2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) -} - -func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) +func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Schema(ctx, sel, v) } -func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) +func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + return ec.___Type(ctx, sel, &v) } -func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) -} +func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } -func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) + } + wg.Wait() + return ret } -func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) +func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Type(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index 1cfbd291c75..78761ab4fcf 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -323,7 +323,7 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = ec.unmarshalString2string(tmp) + arg0, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -337,7 +337,7 @@ func (ec *executionContext) field_Query_torture1d_args(ctx context.Context, rawA args := map[string]interface{}{} var arg0 []int if tmp, ok := rawArgs["customerIds"]; ok { - arg0, err = ec.unmarshalInt2ᚕint(tmp) + arg0, err = ec.unmarshalOInt2ᚕint(tmp) if err != nil { return nil, err } @@ -351,7 +351,7 @@ func (ec *executionContext) field_Query_torture2d_args(ctx context.Context, rawA args := map[string]interface{}{} var arg0 [][]int if tmp, ok := rawArgs["customerIds"]; ok { - arg0, err = ec.unmarshalInt2ᚕᚕint(tmp) + arg0, err = ec.unmarshalOInt2ᚕᚕint(tmp) if err != nil { return nil, err } @@ -365,7 +365,7 @@ func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(tmp) if err != nil { return nil, err } @@ -379,7 +379,7 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(tmp) if err != nil { return nil, err } @@ -415,7 +415,7 @@ func (ec *executionContext) _Address_id(ctx context.Context, field graphql.Colle res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalInt2int(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _Address_street(ctx context.Context, field graphql.CollectedField, obj *Address) graphql.Marshaler { @@ -441,7 +441,7 @@ func (ec *executionContext) _Address_street(ctx context.Context, field graphql.C res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Address_country(ctx context.Context, field graphql.CollectedField, obj *Address) graphql.Marshaler { @@ -467,7 +467,7 @@ func (ec *executionContext) _Address_country(ctx context.Context, field graphql. res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Customer_id(ctx context.Context, field graphql.CollectedField, obj *Customer) graphql.Marshaler { @@ -493,7 +493,7 @@ func (ec *executionContext) _Customer_id(ctx context.Context, field graphql.Coll res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalInt2int(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _Customer_name(ctx context.Context, field graphql.CollectedField, obj *Customer) graphql.Marshaler { @@ -519,7 +519,7 @@ func (ec *executionContext) _Customer_name(ctx context.Context, field graphql.Co res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Customer_address(ctx context.Context, field graphql.CollectedField, obj *Customer) graphql.Marshaler { @@ -542,7 +542,7 @@ func (ec *executionContext) _Customer_address(ctx context.Context, field graphql res := resTmp.(*Address) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalAddress2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐAddress(ctx, field.Selections, res) + return ec.marshalOAddress2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐAddress(ctx, field.Selections, res) } func (ec *executionContext) _Customer_orders(ctx context.Context, field graphql.CollectedField, obj *Customer) graphql.Marshaler { @@ -565,7 +565,7 @@ func (ec *executionContext) _Customer_orders(ctx context.Context, field graphql. res := resTmp.([]Order) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOrder2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐOrder(ctx, field.Selections, res) + return ec.marshalOOrder2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐOrder(ctx, field.Selections, res) } func (ec *executionContext) _Item_name(ctx context.Context, field graphql.CollectedField, obj *Item) graphql.Marshaler { @@ -591,7 +591,7 @@ func (ec *executionContext) _Item_name(ctx context.Context, field graphql.Collec res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Order_id(ctx context.Context, field graphql.CollectedField, obj *Order) graphql.Marshaler { @@ -617,7 +617,7 @@ func (ec *executionContext) _Order_id(ctx context.Context, field graphql.Collect res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalInt2int(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _Order_date(ctx context.Context, field graphql.CollectedField, obj *Order) graphql.Marshaler { @@ -643,7 +643,7 @@ func (ec *executionContext) _Order_date(ctx context.Context, field graphql.Colle res := resTmp.(time.Time) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } func (ec *executionContext) _Order_amount(ctx context.Context, field graphql.CollectedField, obj *Order) graphql.Marshaler { @@ -669,7 +669,7 @@ func (ec *executionContext) _Order_amount(ctx context.Context, field graphql.Col res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalFloat2float64(ctx, field.Selections, res) + return ec.marshalNFloat2float64(ctx, field.Selections, res) } func (ec *executionContext) _Order_items(ctx context.Context, field graphql.CollectedField, obj *Order) graphql.Marshaler { @@ -692,7 +692,7 @@ func (ec *executionContext) _Order_items(ctx context.Context, field graphql.Coll res := resTmp.([]Item) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalItem2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐItem(ctx, field.Selections, res) + return ec.marshalOItem2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐItem(ctx, field.Selections, res) } func (ec *executionContext) _Query_customers(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -715,7 +715,7 @@ func (ec *executionContext) _Query_customers(ctx context.Context, field graphql. res := resTmp.([]Customer) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalCustomer2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx, field.Selections, res) + return ec.marshalOCustomer2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx, field.Selections, res) } func (ec *executionContext) _Query_torture1d(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -745,7 +745,7 @@ func (ec *executionContext) _Query_torture1d(ctx context.Context, field graphql. res := resTmp.([]Customer) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalCustomer2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx, field.Selections, res) + return ec.marshalOCustomer2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx, field.Selections, res) } func (ec *executionContext) _Query_torture2d(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -775,7 +775,7 @@ func (ec *executionContext) _Query_torture2d(ctx context.Context, field graphql. res := resTmp.([][]Customer) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalCustomer2ᚕᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx, field.Selections, res) + return ec.marshalOCustomer2ᚕᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -805,7 +805,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -828,7 +828,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) + return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -854,7 +854,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -877,7 +877,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -903,7 +903,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__DirectiveLocation2ᚕstring(ctx, field.Selections, res) + return ec.marshalN__DirectiveLocation2ᚕstring(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -929,7 +929,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -955,7 +955,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -978,7 +978,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -1004,7 +1004,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -1027,7 +1027,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -1053,7 +1053,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -1076,7 +1076,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -1102,7 +1102,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -1128,7 +1128,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -1154,7 +1154,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -1177,7 +1177,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1203,7 +1203,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1226,7 +1226,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1252,7 +1252,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1275,7 +1275,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1301,7 +1301,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1327,7 +1327,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1350,7 +1350,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1373,7 +1373,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1399,7 +1399,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) + return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1425,7 +1425,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__TypeKind2string(ctx, field.Selections, res) + return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1448,7 +1448,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1471,7 +1471,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1501,7 +1501,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) + return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1524,7 +1524,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1547,7 +1547,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1577,7 +1577,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1600,7 +1600,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1623,7 +1623,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } // endregion **************************** field.gotpl ***************************** @@ -2082,43 +2082,63 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (ec *executionContext) marshalAddress2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐAddress(ctx context.Context, sel ast.SelectionSet, v *Address) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._Address(ctx, sel, v) +func (ec *executionContext) unmarshalNBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) } -func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Schema(ctx, sel, v) +func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + return graphql.MarshalBoolean(v) } -func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Type(ctx, sel, v) +func (ec *executionContext) marshalNCustomer2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v Customer) graphql.Marshaler { + return ec._Customer(ctx, sel, &v) } -func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalString2string(v) - return &res, err +func (ec *executionContext) unmarshalNFloat2float64(v interface{}) (float64, error) { + return graphql.UnmarshalFloat(v) } -func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.marshalString2string(ctx, sel, *v) +func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { + return graphql.MarshalFloat(v) +} + +func (ec *executionContext) unmarshalNInt2int(v interface{}) (int, error) { + return graphql.UnmarshalInt(v) +} + +func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { + return graphql.MarshalInt(v) +} + +func (ec *executionContext) marshalNItem2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐItem(ctx context.Context, sel ast.SelectionSet, v Item) graphql.Marshaler { + return ec._Item(ctx, sel, &v) +} + +func (ec *executionContext) marshalNOrder2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐOrder(ctx context.Context, sel ast.SelectionSet, v Order) graphql.Marshaler { + return ec._Order(ctx, sel, &v) +} + +func (ec *executionContext) unmarshalNString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalNTime2timeᚐTime(v interface{}) (time.Time, error) { + return graphql.UnmarshalTime(v) } -func (ec *executionContext) marshalCustomer2ᚕᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v [][]Customer) graphql.Marshaler { +func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { + return graphql.MarshalTime(v) +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { + return ec.___Directive(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2136,7 +2156,7 @@ func (ec *executionContext) marshalCustomer2ᚕᚕgithubᚗcomᚋ99designsᚋgql if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalCustomer2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx, sel, v[i]) + ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2149,7 +2169,15 @@ func (ec *executionContext) marshalCustomer2ᚕᚕgithubᚗcomᚋ99designsᚋgql return ret } -func (ec *executionContext) unmarshalInt2ᚕᚕint(v interface{}) ([][]int, error) { +func (ec *executionContext) unmarshalN__DirectiveLocation2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -2159,9 +2187,9 @@ func (ec *executionContext) unmarshalInt2ᚕᚕint(v interface{}) ([][]int, erro } } var err error - res := make([][]int, len(vSlice)) + res := make([]string, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalInt2ᚕint(vSlice[i]) + res[i], err = ec.unmarshalN__DirectiveLocation2string(vSlice[i]) if err != nil { return nil, err } @@ -2169,16 +2197,7 @@ func (ec *executionContext) unmarshalInt2ᚕᚕint(v interface{}) ([][]int, erro return res, nil } -func (ec *executionContext) marshalInt2ᚕᚕint(ctx context.Context, sel ast.SelectionSet, v [][]int) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - for i := range v { - ret[i] = ec.marshalInt2ᚕint(ctx, sel, v[i]) - } - - return ret -} - -func (ec *executionContext) marshalCustomer2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v []Customer) graphql.Marshaler { +func (ec *executionContext) marshalN__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2196,7 +2215,7 @@ func (ec *executionContext) marshalCustomer2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalCustomer2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx, sel, v[i]) + ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2209,7 +2228,19 @@ func (ec *executionContext) marshalCustomer2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) marshalItem2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐItem(ctx context.Context, sel ast.SelectionSet, v []Item) graphql.Marshaler { +func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { + return ec.___EnumValue(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { + return ec.___Field(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { + return ec.___InputValue(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2227,7 +2258,7 @@ func (ec *executionContext) marshalItem2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋe if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalItem2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐItem(ctx, sel, v[i]) + ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2240,7 +2271,11 @@ func (ec *executionContext) marshalItem2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋe return ret } -func (ec *executionContext) marshalOrder2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐOrder(ctx context.Context, sel ast.SelectionSet, v []Order) graphql.Marshaler { +func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + return ec.___Type(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2258,7 +2293,7 @@ func (ec *executionContext) marshalOrder2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalOrder2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐOrder(ctx, sel, v[i]) + ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2271,7 +2306,44 @@ func (ec *executionContext) marshalOrder2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ return ret } -func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { +func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec.___Type(ctx, sel, v) +} + +func (ec *executionContext) unmarshalN__TypeKind2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) marshalOAddress2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐAddress(ctx context.Context, sel ast.SelectionSet, v Address) graphql.Marshaler { + return ec._Address(ctx, sel, &v) +} + +func (ec *executionContext) marshalOAddress2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐAddress(ctx context.Context, sel ast.SelectionSet, v *Address) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Address(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) +} + +func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + return graphql.MarshalBoolean(v) +} + +func (ec *executionContext) marshalOCustomer2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v []Customer) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2289,7 +2361,7 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) + ret[i] = ec.marshalNCustomer2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2302,7 +2374,7 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql return ret } -func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) marshalOCustomer2ᚕᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v [][]Customer) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2320,7 +2392,7 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) + ret[i] = ec.marshalOCustomer2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2333,7 +2405,65 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql return ret } -func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { +func (ec *executionContext) unmarshalOInt2ᚕint(v interface{}) ([]int, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]int, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshalNInt2int(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalOInt2ᚕint(ctx context.Context, sel ast.SelectionSet, v []int) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNInt2int(ctx, sel, v[i]) + } + + return ret +} + +func (ec *executionContext) unmarshalOInt2ᚕᚕint(v interface{}) ([][]int, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([][]int, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshalOInt2ᚕint(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalOInt2ᚕᚕint(ctx context.Context, sel ast.SelectionSet, v [][]int) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalOInt2ᚕint(ctx, sel, v[i]) + } + + return ret +} + +func (ec *executionContext) marshalOItem2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐItem(ctx context.Context, sel ast.SelectionSet, v []Item) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2351,7 +2481,7 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + ret[i] = ec.marshalNItem2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐItem(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2364,7 +2494,7 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) marshalOOrder2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐOrder(ctx context.Context, sel ast.SelectionSet, v []Order) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2382,7 +2512,7 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + ret[i] = ec.marshalNOrder2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐOrder(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2395,7 +2525,30 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq return ret } -func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { +func (ec *executionContext) unmarshalOString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalOString2ᚖstring(v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOString2string(v) + return &res, err +} + +func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOString2string(ctx, sel, *v) +} + +func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2413,7 +2566,7 @@ func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2426,56 +2579,38 @@ func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) unmarshalInt2ᚕint(v interface{}) ([]int, error) { - var vSlice []interface{} - if v != nil { - if tmp1, ok := v.([]interface{}); ok { - vSlice = tmp1 - } else { - vSlice = []interface{}{v} - } - } - var err error - res := make([]int, len(vSlice)) - for i := range vSlice { - res[i], err = ec.unmarshalInt2int(vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalInt2ᚕint(ctx context.Context, sel ast.SelectionSet, v []int) graphql.Marshaler { +func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { ret := make(graphql.Array, len(v)) - for i := range v { - ret[i] = ec.marshalInt2int(ctx, sel, v[i]) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) } - - return ret -} - -func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { - var vSlice []interface{} - if v != nil { - if tmp1, ok := v.([]interface{}); ok { - vSlice = tmp1 - } else { - vSlice = []interface{}{v} + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], } - } - var err error - res := make([]string, len(vSlice)) - for i := range vSlice { - res[i], err = ec.unmarshal__DirectiveLocation2string(vSlice[i]) - if err != nil { - return nil, err + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) } + if isLen1 { + f(i) + } else { + go f(i) + } + } - return res, nil + wg.Wait() + return ret } -func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { +func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2493,7 +2628,7 @@ func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Con if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__DirectiveLocation2string(ctx, sel, v[i]) + ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2506,100 +2641,57 @@ func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Con return ret } -func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { - return graphql.UnmarshalBoolean(v) -} - -func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) -} - -func (ec *executionContext) unmarshalFloat2float64(v interface{}) (float64, error) { - return graphql.UnmarshalFloat(v) -} - -func (ec *executionContext) marshalFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { - return graphql.MarshalFloat(v) -} - -func (ec *executionContext) marshalAddress2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐAddress(ctx context.Context, sel ast.SelectionSet, v Address) graphql.Marshaler { - return ec._Address(ctx, sel, &v) -} - -func (ec *executionContext) marshalCustomer2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v Customer) graphql.Marshaler { - return ec._Customer(ctx, sel, &v) -} - -func (ec *executionContext) marshalItem2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐItem(ctx context.Context, sel ast.SelectionSet, v Item) graphql.Marshaler { - return ec._Item(ctx, sel, &v) -} - -func (ec *executionContext) marshalOrder2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐOrder(ctx context.Context, sel ast.SelectionSet, v Order) graphql.Marshaler { - return ec._Order(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) -} - -func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) -} - -func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { +func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { return ec.___Schema(ctx, sel, &v) } -func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - -func (ec *executionContext) unmarshalInt2int(v interface{}) (int, error) { - return graphql.UnmarshalInt(v) -} - -func (ec *executionContext) marshalInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - return graphql.MarshalInt(v) -} - -func (ec *executionContext) unmarshalString2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) -} - -func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) -} - -func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) -} - -func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) +func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Schema(ctx, sel, v) } -func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) +func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + return ec.___Type(ctx, sel, &v) } -func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) -} +func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } -func (ec *executionContext) unmarshalTime2timeᚐTime(v interface{}) (time.Time, error) { - return graphql.UnmarshalTime(v) + } + wg.Wait() + return ret } -func (ec *executionContext) marshalTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - return graphql.MarshalTime(v) +func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Type(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** diff --git a/example/scalars/generated.go b/example/scalars/generated.go index 4ab97d8e144..d5858509666 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -294,7 +294,7 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = ec.unmarshalString2string(tmp) + arg0, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -308,7 +308,7 @@ func (ec *executionContext) field_Query_search_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 *model.SearchArgs if tmp, ok := rawArgs["input"]; ok { - arg0, err = ec.unmarshalSearchArgs2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(tmp) + arg0, err = ec.unmarshalOSearchArgs2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(tmp) if err != nil { return nil, err } @@ -322,7 +322,7 @@ func (ec *executionContext) field_Query_user_args(ctx context.Context, rawArgs m args := map[string]interface{}{} var arg0 external.ObjectID if tmp, ok := rawArgs["id"]; ok { - arg0, err = ec.unmarshalID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(tmp) + arg0, err = ec.unmarshalNID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(tmp) if err != nil { return nil, err } @@ -336,7 +336,7 @@ func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(tmp) if err != nil { return nil, err } @@ -350,7 +350,7 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(tmp) if err != nil { return nil, err } @@ -386,7 +386,7 @@ func (ec *executionContext) _Address_id(ctx context.Context, field graphql.Colle res := resTmp.(external.ObjectID) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(ctx, field.Selections, res) + return ec.marshalNID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(ctx, field.Selections, res) } func (ec *executionContext) _Address_location(ctx context.Context, field graphql.CollectedField, obj *model.Address) graphql.Marshaler { @@ -409,7 +409,7 @@ func (ec *executionContext) _Address_location(ctx context.Context, field graphql res := resTmp.(*model.Point) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx, field.Selections, res) + return ec.marshalOPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx, field.Selections, res) } func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -439,7 +439,7 @@ func (ec *executionContext) _Query_user(ctx context.Context, field graphql.Colle res := resTmp.(*model.User) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx, field.Selections, res) + return ec.marshalOUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx, field.Selections, res) } func (ec *executionContext) _Query_search(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -472,7 +472,7 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col res := resTmp.([]model.User) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx, field.Selections, res) + return ec.marshalNUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -502,7 +502,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -525,7 +525,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) + return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { @@ -551,7 +551,7 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte res := resTmp.(external.ObjectID) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(ctx, field.Selections, res) + return ec.marshalNID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(ctx, field.Selections, res) } func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { @@ -577,7 +577,7 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _User_created(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { @@ -600,7 +600,7 @@ func (ec *executionContext) _User_created(ctx context.Context, field graphql.Col res := resTmp.(time.Time) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalTimestamp2timeᚐTime(ctx, field.Selections, res) + return ec.marshalOTimestamp2timeᚐTime(ctx, field.Selections, res) } func (ec *executionContext) _User_isBanned(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { @@ -626,7 +626,7 @@ func (ec *executionContext) _User_isBanned(ctx context.Context, field graphql.Co res := resTmp.(model.Banned) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBanned2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐBanned(ctx, field.Selections, res) + return ec.marshalNBanned2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐBanned(ctx, field.Selections, res) } func (ec *executionContext) _User_primitiveResolver(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { @@ -652,7 +652,7 @@ func (ec *executionContext) _User_primitiveResolver(ctx context.Context, field g res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _User_customResolver(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { @@ -678,7 +678,7 @@ func (ec *executionContext) _User_customResolver(ctx context.Context, field grap res := resTmp.(model.Point) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx, field.Selections, res) + return ec.marshalNPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx, field.Selections, res) } func (ec *executionContext) _User_address(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { @@ -701,7 +701,7 @@ func (ec *executionContext) _User_address(ctx context.Context, field graphql.Col res := resTmp.(model.Address) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalAddress2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐAddress(ctx, field.Selections, res) + return ec.marshalOAddress2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐAddress(ctx, field.Selections, res) } func (ec *executionContext) _User_tier(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { @@ -724,7 +724,7 @@ func (ec *executionContext) _User_tier(ctx context.Context, field graphql.Collec res := resTmp.(model.Tier) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalTier2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐTier(ctx, field.Selections, res) + return ec.marshalOTier2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐTier(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -750,7 +750,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -773,7 +773,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -799,7 +799,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__DirectiveLocation2ᚕstring(ctx, field.Selections, res) + return ec.marshalN__DirectiveLocation2ᚕstring(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -825,7 +825,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -851,7 +851,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -874,7 +874,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -900,7 +900,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -923,7 +923,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -949,7 +949,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -972,7 +972,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -998,7 +998,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -1024,7 +1024,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -1050,7 +1050,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -1073,7 +1073,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1099,7 +1099,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1122,7 +1122,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1148,7 +1148,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1171,7 +1171,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1197,7 +1197,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1223,7 +1223,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1246,7 +1246,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1269,7 +1269,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1295,7 +1295,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) + return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1321,7 +1321,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__TypeKind2string(ctx, field.Selections, res) + return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1344,7 +1344,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1367,7 +1367,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1397,7 +1397,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) + return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1420,7 +1420,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1443,7 +1443,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1473,7 +1473,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1496,7 +1496,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1519,7 +1519,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } // endregion **************************** field.gotpl ***************************** @@ -1534,19 +1534,19 @@ func (ec *executionContext) unmarshalInputSearchArgs(v interface{}) (model.Searc switch k { case "location": var err error - it.Location, err = ec.unmarshalPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(v) + it.Location, err = ec.unmarshalOPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(v) if err != nil { return it, err } case "createdAfter": var err error - it.CreatedAfter, err = ec.unmarshalTimestamp2ᚖtimeᚐTime(v) + it.CreatedAfter, err = ec.unmarshalOTimestamp2ᚖtimeᚐTime(v) if err != nil { return it, err } case "isBanned": var err error - it.IsBanned, err = ec.unmarshalBanned2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐBanned(v) + it.IsBanned, err = ec.unmarshalOBanned2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐBanned(v) if err != nil { return it, err } @@ -1944,81 +1944,53 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (ec *executionContext) unmarshalPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(v interface{}) (*model.Point, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(v) - return &res, err +func (ec *executionContext) unmarshalNBanned2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐBanned(v interface{}) (model.Banned, error) { + var res model.Banned + return res, res.UnmarshalGQL(v) } -func (ec *executionContext) marshalPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, sel ast.SelectionSet, v *model.Point) graphql.Marshaler { - if v == nil { - return graphql.Null - } +func (ec *executionContext) marshalNBanned2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐBanned(ctx context.Context, sel ast.SelectionSet, v model.Banned) graphql.Marshaler { return v } -func (ec *executionContext) unmarshalSearchArgs2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v interface{}) (*model.SearchArgs, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalSearchArgs2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v) - return &res, err +func (ec *executionContext) unmarshalNBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) } -func (ec *executionContext) marshalUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._User(ctx, sel, v) +func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + return graphql.MarshalBoolean(v) } -func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Schema(ctx, sel, v) +func (ec *executionContext) unmarshalNID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(v interface{}) (external.ObjectID, error) { + return model.UnmarshalID(v) } -func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Type(ctx, sel, v) +func (ec *executionContext) marshalNID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(ctx context.Context, sel ast.SelectionSet, v external.ObjectID) graphql.Marshaler { + return model.MarshalID(v) } -func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalString2string(v) - return &res, err +func (ec *executionContext) unmarshalNPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(v interface{}) (model.Point, error) { + var res model.Point + return res, res.UnmarshalGQL(v) } -func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.marshalString2string(ctx, sel, *v) +func (ec *executionContext) marshalNPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, sel ast.SelectionSet, v model.Point) graphql.Marshaler { + return v } -func (ec *executionContext) unmarshalTimestamp2ᚖtimeᚐTime(v interface{}) (*time.Time, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalTimestamp2timeᚐTime(v) - return &res, err +func (ec *executionContext) unmarshalNString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) } -func (ec *executionContext) marshalTimestamp2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.marshalTimestamp2timeᚐTime(ctx, sel, *v) +func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) } -func (ec *executionContext) marshalUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v []model.User) graphql.Marshaler { +func (ec *executionContext) marshalNUser2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v model.User) graphql.Marshaler { + return ec._User(ctx, sel, &v) +} + +func (ec *executionContext) marshalNUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v []model.User) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2036,7 +2008,7 @@ func (ec *executionContext) marshalUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋe if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalUser2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx, sel, v[i]) + ret[i] = ec.marshalNUser2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2049,7 +2021,11 @@ func (ec *executionContext) marshalUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋe return ret } -func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { + return ec.___Directive(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2067,7 +2043,7 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) + ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2080,7 +2056,35 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql return ret } -func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) unmarshalN__DirectiveLocation2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshalN__DirectiveLocation2string(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalN__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2098,7 +2102,7 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) + ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2111,7 +2115,19 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql return ret } -func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { +func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { + return ec.___EnumValue(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { + return ec.___Field(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { + return ec.___InputValue(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2129,7 +2145,7 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2142,7 +2158,11 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + return ec.___Type(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2160,7 +2180,7 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2173,7 +2193,148 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq return ret } -func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { +func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec.___Type(ctx, sel, v) +} + +func (ec *executionContext) unmarshalN__TypeKind2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) marshalOAddress2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐAddress(ctx context.Context, sel ast.SelectionSet, v model.Address) graphql.Marshaler { + return ec._Address(ctx, sel, &v) +} + +func (ec *executionContext) unmarshalOBanned2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐBanned(v interface{}) (model.Banned, error) { + var res model.Banned + return res, res.UnmarshalGQL(v) +} + +func (ec *executionContext) marshalOBanned2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐBanned(ctx context.Context, sel ast.SelectionSet, v model.Banned) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalOBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) +} + +func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + return graphql.MarshalBoolean(v) +} + +func (ec *executionContext) unmarshalOPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(v interface{}) (model.Point, error) { + var res model.Point + return res, res.UnmarshalGQL(v) +} + +func (ec *executionContext) marshalOPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, sel ast.SelectionSet, v model.Point) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalOPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(v interface{}) (*model.Point, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(v) + return &res, err +} + +func (ec *executionContext) marshalOPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, sel ast.SelectionSet, v *model.Point) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) unmarshalOSearchArgs2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v interface{}) (model.SearchArgs, error) { + return ec.unmarshalInputSearchArgs(v) +} + +func (ec *executionContext) unmarshalOSearchArgs2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v interface{}) (*model.SearchArgs, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOSearchArgs2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v) + return &res, err +} + +func (ec *executionContext) unmarshalOString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalOString2ᚖstring(v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOString2string(v) + return &res, err +} + +func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOString2string(ctx, sel, *v) +} + +func (ec *executionContext) unmarshalOTier2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐTier(v interface{}) (model.Tier, error) { + var res model.Tier + return res, res.UnmarshalGQL(v) +} + +func (ec *executionContext) marshalOTier2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐTier(ctx context.Context, sel ast.SelectionSet, v model.Tier) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalOTimestamp2timeᚐTime(v interface{}) (time.Time, error) { + return model.UnmarshalTimestamp(v) +} + +func (ec *executionContext) marshalOTimestamp2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { + return model.MarshalTimestamp(v) +} + +func (ec *executionContext) unmarshalOTimestamp2ᚖtimeᚐTime(v interface{}) (*time.Time, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOTimestamp2timeᚐTime(v) + return &res, err +} + +func (ec *executionContext) marshalOTimestamp2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOTimestamp2timeᚐTime(ctx, sel, *v) +} + +func (ec *executionContext) marshalOUser2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v model.User) graphql.Marshaler { + return ec._User(ctx, sel, &v) +} + +func (ec *executionContext) marshalOUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._User(ctx, sel, v) +} + +func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2191,7 +2352,7 @@ func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2204,27 +2365,38 @@ func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { - var vSlice []interface{} - if v != nil { - if tmp1, ok := v.([]interface{}); ok { - vSlice = tmp1 - } else { - vSlice = []interface{}{v} - } +func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) } - var err error - res := make([]string, len(vSlice)) - for i := range vSlice { - res[i], err = ec.unmarshal__DirectiveLocation2string(vSlice[i]) - if err != nil { - return nil, err + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) } + } - return res, nil + wg.Wait() + return ret } -func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { +func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2242,7 +2414,7 @@ func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Con if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__DirectiveLocation2string(ctx, sel, v[i]) + ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2255,115 +2427,57 @@ func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Con return ret } -func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { - return graphql.UnmarshalBoolean(v) -} - -func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) -} - -func (ec *executionContext) unmarshalID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(v interface{}) (external.ObjectID, error) { - return model.UnmarshalID(v) -} - -func (ec *executionContext) marshalID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(ctx context.Context, sel ast.SelectionSet, v external.ObjectID) graphql.Marshaler { - return model.MarshalID(v) -} - -func (ec *executionContext) marshalAddress2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐAddress(ctx context.Context, sel ast.SelectionSet, v model.Address) graphql.Marshaler { - return ec._Address(ctx, sel, &v) -} - -func (ec *executionContext) unmarshalBanned2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐBanned(v interface{}) (model.Banned, error) { - var res model.Banned - return res, res.UnmarshalGQL(v) -} - -func (ec *executionContext) marshalBanned2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐBanned(ctx context.Context, sel ast.SelectionSet, v model.Banned) graphql.Marshaler { - return v -} - -func (ec *executionContext) unmarshalPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(v interface{}) (model.Point, error) { - var res model.Point - return res, res.UnmarshalGQL(v) -} - -func (ec *executionContext) marshalPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, sel ast.SelectionSet, v model.Point) graphql.Marshaler { - return v -} - -func (ec *executionContext) unmarshalSearchArgs2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v interface{}) (model.SearchArgs, error) { - return ec.unmarshalInputSearchArgs(v) -} - -func (ec *executionContext) unmarshalTier2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐTier(v interface{}) (model.Tier, error) { - var res model.Tier - return res, res.UnmarshalGQL(v) -} - -func (ec *executionContext) marshalTier2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐTier(ctx context.Context, sel ast.SelectionSet, v model.Tier) graphql.Marshaler { - return v -} - -func (ec *executionContext) marshalUser2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v model.User) graphql.Marshaler { - return ec._User(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) -} - -func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) -} - -func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { +func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { return ec.___Schema(ctx, sel, &v) } -func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - -func (ec *executionContext) unmarshalString2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) -} - -func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) -} - -func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) -} - -func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) +func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Schema(ctx, sel, v) } -func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) +func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + return ec.___Type(ctx, sel, &v) } -func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) -} +func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } -func (ec *executionContext) unmarshalTimestamp2timeᚐTime(v interface{}) (time.Time, error) { - return model.UnmarshalTimestamp(v) + } + wg.Wait() + return ret } -func (ec *executionContext) marshalTimestamp2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - return model.MarshalTimestamp(v) +func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Type(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** diff --git a/example/selection/generated.go b/example/selection/generated.go index 4c076024652..cd674795ed1 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -241,7 +241,7 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = ec.unmarshalString2string(tmp) + arg0, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -255,7 +255,7 @@ func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(tmp) if err != nil { return nil, err } @@ -269,7 +269,7 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(tmp) if err != nil { return nil, err } @@ -305,7 +305,7 @@ func (ec *executionContext) _Like_reaction(ctx context.Context, field graphql.Co res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Like_sent(ctx context.Context, field graphql.CollectedField, obj *Like) graphql.Marshaler { @@ -331,7 +331,7 @@ func (ec *executionContext) _Like_sent(ctx context.Context, field graphql.Collec res := resTmp.(time.Time) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } func (ec *executionContext) _Like_selection(ctx context.Context, field graphql.CollectedField, obj *Like) graphql.Marshaler { @@ -354,7 +354,7 @@ func (ec *executionContext) _Like_selection(ctx context.Context, field graphql.C res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚕstring(ctx, field.Selections, res) + return ec.marshalOString2ᚕstring(ctx, field.Selections, res) } func (ec *executionContext) _Like_collected(ctx context.Context, field graphql.CollectedField, obj *Like) graphql.Marshaler { @@ -377,7 +377,7 @@ func (ec *executionContext) _Like_collected(ctx context.Context, field graphql.C res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚕstring(ctx, field.Selections, res) + return ec.marshalOString2ᚕstring(ctx, field.Selections, res) } func (ec *executionContext) _Post_message(ctx context.Context, field graphql.CollectedField, obj *Post) graphql.Marshaler { @@ -403,7 +403,7 @@ func (ec *executionContext) _Post_message(ctx context.Context, field graphql.Col res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Post_sent(ctx context.Context, field graphql.CollectedField, obj *Post) graphql.Marshaler { @@ -429,7 +429,7 @@ func (ec *executionContext) _Post_sent(ctx context.Context, field graphql.Collec res := resTmp.(time.Time) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } func (ec *executionContext) _Post_selection(ctx context.Context, field graphql.CollectedField, obj *Post) graphql.Marshaler { @@ -452,7 +452,7 @@ func (ec *executionContext) _Post_selection(ctx context.Context, field graphql.C res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚕstring(ctx, field.Selections, res) + return ec.marshalOString2ᚕstring(ctx, field.Selections, res) } func (ec *executionContext) _Post_collected(ctx context.Context, field graphql.CollectedField, obj *Post) graphql.Marshaler { @@ -475,7 +475,7 @@ func (ec *executionContext) _Post_collected(ctx context.Context, field graphql.C res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚕstring(ctx, field.Selections, res) + return ec.marshalOString2ᚕstring(ctx, field.Selections, res) } func (ec *executionContext) _Query_events(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -498,7 +498,7 @@ func (ec *executionContext) _Query_events(ctx context.Context, field graphql.Col res := resTmp.([]Event) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋselectionᚐEvent(ctx, field.Selections, res) + return ec.marshalOEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋselectionᚐEvent(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -528,7 +528,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -551,7 +551,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) + return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -577,7 +577,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -600,7 +600,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -626,7 +626,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__DirectiveLocation2ᚕstring(ctx, field.Selections, res) + return ec.marshalN__DirectiveLocation2ᚕstring(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -652,7 +652,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -678,7 +678,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -701,7 +701,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -727,7 +727,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -750,7 +750,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -776,7 +776,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -799,7 +799,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -825,7 +825,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -851,7 +851,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -877,7 +877,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -900,7 +900,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -926,7 +926,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -949,7 +949,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -975,7 +975,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -998,7 +998,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1024,7 +1024,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1050,7 +1050,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1073,7 +1073,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1096,7 +1096,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1122,7 +1122,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) + return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1148,7 +1148,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__TypeKind2string(ctx, field.Selections, res) + return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1171,7 +1171,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1194,7 +1194,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1224,7 +1224,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) + return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1247,7 +1247,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1270,7 +1270,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1300,7 +1300,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1323,7 +1323,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1346,7 +1346,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } // endregion **************************** field.gotpl ***************************** @@ -1731,36 +1731,39 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Schema(ctx, sel, v) +func (ec *executionContext) unmarshalNBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) } -func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Type(ctx, sel, v) +func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + return graphql.MarshalBoolean(v) } -func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalString2string(v) - return &res, err +func (ec *executionContext) marshalNEvent2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋselectionᚐEvent(ctx context.Context, sel ast.SelectionSet, v Event) graphql.Marshaler { + return ec._Event(ctx, sel, &v) } -func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.marshalString2string(ctx, sel, *v) +func (ec *executionContext) unmarshalNString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalNTime2timeᚐTime(v interface{}) (time.Time, error) { + return graphql.UnmarshalTime(v) +} + +func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { + return graphql.MarshalTime(v) } -func (ec *executionContext) marshalEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋselectionᚐEvent(ctx context.Context, sel ast.SelectionSet, v []Event) graphql.Marshaler { +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { + return ec.___Directive(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1778,7 +1781,7 @@ func (ec *executionContext) marshalEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalEvent2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋselectionᚐEvent(ctx, sel, v[i]) + ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) } if isLen1 { f(i) @@ -1791,38 +1794,35 @@ func (ec *executionContext) marshalEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ return ret } -func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - rctx := &graphql.ResolverContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(i int) { - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) - } - if isLen1 { - f(i) +func (ec *executionContext) unmarshalN__DirectiveLocation2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 } else { - go f(i) + vSlice = []interface{}{v} } - } - wg.Wait() - return ret + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshalN__DirectiveLocation2string(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil } -func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) marshalN__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1840,7 +1840,7 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) + ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) } if isLen1 { f(i) @@ -1853,7 +1853,19 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql return ret } -func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { +func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { + return ec.___EnumValue(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { + return ec.___Field(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { + return ec.___InputValue(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1871,7 +1883,7 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -1884,7 +1896,11 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + return ec.___Type(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1902,7 +1918,7 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) } if isLen1 { f(i) @@ -1915,7 +1931,33 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq return ret } -func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { +func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec.___Type(ctx, sel, v) +} + +func (ec *executionContext) unmarshalN__TypeKind2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalOBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) +} + +func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + return graphql.MarshalBoolean(v) +} + +func (ec *executionContext) marshalOEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋselectionᚐEvent(ctx context.Context, sel ast.SelectionSet, v []Event) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1933,7 +1975,7 @@ func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + ret[i] = ec.marshalNEvent2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋselectionᚐEvent(ctx, sel, v[i]) } if isLen1 { f(i) @@ -1946,7 +1988,15 @@ func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) unmarshalString2ᚕstring(v interface{}) ([]string, error) { +func (ec *executionContext) unmarshalOString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalOString2ᚕstring(v interface{}) ([]string, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -1958,7 +2008,7 @@ func (ec *executionContext) unmarshalString2ᚕstring(v interface{}) ([]string, var err error res := make([]string, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalString2string(vSlice[i]) + res[i], err = ec.unmarshalNString2string(vSlice[i]) if err != nil { return nil, err } @@ -1966,36 +2016,31 @@ func (ec *executionContext) unmarshalString2ᚕstring(v interface{}) ([]string, return res, nil } -func (ec *executionContext) marshalString2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { +func (ec *executionContext) marshalOString2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { ret := make(graphql.Array, len(v)) for i := range v { - ret[i] = ec.marshalString2string(ctx, sel, v[i]) + ret[i] = ec.marshalNString2string(ctx, sel, v[i]) } return ret } -func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { - var vSlice []interface{} - if v != nil { - if tmp1, ok := v.([]interface{}); ok { - vSlice = tmp1 - } else { - vSlice = []interface{}{v} - } +func (ec *executionContext) unmarshalOString2ᚖstring(v interface{}) (*string, error) { + if v == nil { + return nil, nil } - var err error - res := make([]string, len(vSlice)) - for i := range vSlice { - res[i], err = ec.unmarshal__DirectiveLocation2string(vSlice[i]) - if err != nil { - return nil, err - } + res, err := ec.unmarshalOString2string(v) + return &res, err +} + +func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + if v == nil { + return graphql.Null } - return res, nil + return ec.marshalOString2string(ctx, sel, *v) } -func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { +func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2013,7 +2058,7 @@ func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Con if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__DirectiveLocation2string(ctx, sel, v[i]) + ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2026,72 +2071,119 @@ func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Con return ret } -func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { - return graphql.UnmarshalBoolean(v) -} - -func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) -} - -func (ec *executionContext) marshalEvent2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋselectionᚐEvent(ctx context.Context, sel ast.SelectionSet, v Event) graphql.Marshaler { - return ec._Event(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) -} +func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } -func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) + } + wg.Wait() + return ret } -func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) -} +func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } -func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) + } + wg.Wait() + return ret } -func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { +func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { return ec.___Schema(ctx, sel, &v) } -func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - -func (ec *executionContext) unmarshalString2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) -} - -func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) -} - -func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) -} - -func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) +func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Schema(ctx, sel, v) } -func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) +func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + return ec.___Type(ctx, sel, &v) } -func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) -} +func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } -func (ec *executionContext) unmarshalTime2timeᚐTime(v interface{}) (time.Time, error) { - return graphql.UnmarshalTime(v) + } + wg.Wait() + return ret } -func (ec *executionContext) marshalTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - return graphql.MarshalTime(v) +func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Type(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** diff --git a/example/starwars/generated.go b/example/starwars/generated.go index ffbad29c928..88165adc243 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -702,7 +702,7 @@ func (ec *executionContext) field_Droid_friendsConnection_args(ctx context.Conte args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["first"]; ok { - arg0, err = ec.unmarshalInt2ᚖint(tmp) + arg0, err = ec.unmarshalOInt2ᚖint(tmp) if err != nil { return nil, err } @@ -710,7 +710,7 @@ func (ec *executionContext) field_Droid_friendsConnection_args(ctx context.Conte args["first"] = arg0 var arg1 *string if tmp, ok := rawArgs["after"]; ok { - arg1, err = ec.unmarshalID2ᚖstring(tmp) + arg1, err = ec.unmarshalOID2ᚖstring(tmp) if err != nil { return nil, err } @@ -724,7 +724,7 @@ func (ec *executionContext) field_Human_friendsConnection_args(ctx context.Conte args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["first"]; ok { - arg0, err = ec.unmarshalInt2ᚖint(tmp) + arg0, err = ec.unmarshalOInt2ᚖint(tmp) if err != nil { return nil, err } @@ -732,7 +732,7 @@ func (ec *executionContext) field_Human_friendsConnection_args(ctx context.Conte args["first"] = arg0 var arg1 *string if tmp, ok := rawArgs["after"]; ok { - arg1, err = ec.unmarshalID2ᚖstring(tmp) + arg1, err = ec.unmarshalOID2ᚖstring(tmp) if err != nil { return nil, err } @@ -746,7 +746,7 @@ func (ec *executionContext) field_Human_height_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 LengthUnit if tmp, ok := rawArgs["unit"]; ok { - arg0, err = ec.unmarshalLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(tmp) + arg0, err = ec.unmarshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(tmp) if err != nil { return nil, err } @@ -760,7 +760,7 @@ func (ec *executionContext) field_Mutation_createReview_args(ctx context.Context args := map[string]interface{}{} var arg0 Episode if tmp, ok := rawArgs["episode"]; ok { - arg0, err = ec.unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(tmp) + arg0, err = ec.unmarshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(tmp) if err != nil { return nil, err } @@ -768,7 +768,7 @@ func (ec *executionContext) field_Mutation_createReview_args(ctx context.Context args["episode"] = arg0 var arg1 Review if tmp, ok := rawArgs["review"]; ok { - arg1, err = ec.unmarshalReviewInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(tmp) + arg1, err = ec.unmarshalNReviewInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(tmp) if err != nil { return nil, err } @@ -782,7 +782,7 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = ec.unmarshalString2string(tmp) + arg0, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -796,7 +796,7 @@ func (ec *executionContext) field_Query_character_args(ctx context.Context, rawA args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["id"]; ok { - arg0, err = ec.unmarshalID2string(tmp) + arg0, err = ec.unmarshalNID2string(tmp) if err != nil { return nil, err } @@ -810,7 +810,7 @@ func (ec *executionContext) field_Query_droid_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["id"]; ok { - arg0, err = ec.unmarshalID2string(tmp) + arg0, err = ec.unmarshalNID2string(tmp) if err != nil { return nil, err } @@ -824,7 +824,7 @@ func (ec *executionContext) field_Query_hero_args(ctx context.Context, rawArgs m args := map[string]interface{}{} var arg0 *Episode if tmp, ok := rawArgs["episode"]; ok { - arg0, err = ec.unmarshalEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(tmp) + arg0, err = ec.unmarshalOEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(tmp) if err != nil { return nil, err } @@ -838,7 +838,7 @@ func (ec *executionContext) field_Query_human_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["id"]; ok { - arg0, err = ec.unmarshalID2string(tmp) + arg0, err = ec.unmarshalNID2string(tmp) if err != nil { return nil, err } @@ -852,7 +852,7 @@ func (ec *executionContext) field_Query_reviews_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 Episode if tmp, ok := rawArgs["episode"]; ok { - arg0, err = ec.unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(tmp) + arg0, err = ec.unmarshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(tmp) if err != nil { return nil, err } @@ -860,7 +860,7 @@ func (ec *executionContext) field_Query_reviews_args(ctx context.Context, rawArg args["episode"] = arg0 var arg1 *time.Time if tmp, ok := rawArgs["since"]; ok { - arg1, err = ec.unmarshalTime2ᚖtimeᚐTime(tmp) + arg1, err = ec.unmarshalOTime2ᚖtimeᚐTime(tmp) if err != nil { return nil, err } @@ -874,7 +874,7 @@ func (ec *executionContext) field_Query_search_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["text"]; ok { - arg0, err = ec.unmarshalString2string(tmp) + arg0, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -888,7 +888,7 @@ func (ec *executionContext) field_Query_starship_args(ctx context.Context, rawAr args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["id"]; ok { - arg0, err = ec.unmarshalID2string(tmp) + arg0, err = ec.unmarshalNID2string(tmp) if err != nil { return nil, err } @@ -902,7 +902,7 @@ func (ec *executionContext) field_Starship_length_args(ctx context.Context, rawA args := map[string]interface{}{} var arg0 *LengthUnit if tmp, ok := rawArgs["unit"]; ok { - arg0, err = ec.unmarshalLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(tmp) + arg0, err = ec.unmarshalOLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(tmp) if err != nil { return nil, err } @@ -916,7 +916,7 @@ func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(tmp) if err != nil { return nil, err } @@ -930,7 +930,7 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(tmp) if err != nil { return nil, err } @@ -966,7 +966,7 @@ func (ec *executionContext) _Droid_id(ctx context.Context, field graphql.Collect res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalID2string(ctx, field.Selections, res) + return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _Droid_name(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { @@ -992,7 +992,7 @@ func (ec *executionContext) _Droid_name(ctx context.Context, field graphql.Colle res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Droid_friends(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { @@ -1015,7 +1015,7 @@ func (ec *executionContext) _Droid_friends(ctx context.Context, field graphql.Co res := resTmp.([]Character) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, field.Selections, res) + return ec.marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, field.Selections, res) } func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { @@ -1048,7 +1048,7 @@ func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field res := resTmp.(FriendsConnection) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalFriendsConnection2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsConnection(ctx, field.Selections, res) + return ec.marshalNFriendsConnection2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsConnection(ctx, field.Selections, res) } func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { @@ -1074,7 +1074,7 @@ func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql. res := resTmp.([]Episode) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx, field.Selections, res) + return ec.marshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx, field.Selections, res) } func (ec *executionContext) _Droid_primaryFunction(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { @@ -1097,7 +1097,7 @@ func (ec *executionContext) _Droid_primaryFunction(ctx context.Context, field gr res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) _FriendsConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { @@ -1123,7 +1123,7 @@ func (ec *executionContext) _FriendsConnection_totalCount(ctx context.Context, f res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalInt2int(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _FriendsConnection_edges(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { @@ -1146,7 +1146,7 @@ func (ec *executionContext) _FriendsConnection_edges(ctx context.Context, field res := resTmp.([]FriendsEdge) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalFriendsEdge2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsEdge(ctx, field.Selections, res) + return ec.marshalOFriendsEdge2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsEdge(ctx, field.Selections, res) } func (ec *executionContext) _FriendsConnection_friends(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { @@ -1169,7 +1169,7 @@ func (ec *executionContext) _FriendsConnection_friends(ctx context.Context, fiel res := resTmp.([]Character) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, field.Selections, res) + return ec.marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, field.Selections, res) } func (ec *executionContext) _FriendsConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { @@ -1195,7 +1195,7 @@ func (ec *executionContext) _FriendsConnection_pageInfo(ctx context.Context, fie res := resTmp.(PageInfo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalPageInfo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐPageInfo(ctx, field.Selections, res) + return ec.marshalNPageInfo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐPageInfo(ctx, field.Selections, res) } func (ec *executionContext) _FriendsEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *FriendsEdge) graphql.Marshaler { @@ -1221,7 +1221,7 @@ func (ec *executionContext) _FriendsEdge_cursor(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalID2string(ctx, field.Selections, res) + return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _FriendsEdge_node(ctx context.Context, field graphql.CollectedField, obj *FriendsEdge) graphql.Marshaler { @@ -1244,7 +1244,7 @@ func (ec *executionContext) _FriendsEdge_node(ctx context.Context, field graphql res := resTmp.(Character) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, field.Selections, res) + return ec.marshalOCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, field.Selections, res) } func (ec *executionContext) _Human_id(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { @@ -1270,7 +1270,7 @@ func (ec *executionContext) _Human_id(ctx context.Context, field graphql.Collect res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalID2string(ctx, field.Selections, res) + return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _Human_name(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { @@ -1296,7 +1296,7 @@ func (ec *executionContext) _Human_name(ctx context.Context, field graphql.Colle res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Human_height(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { @@ -1329,7 +1329,7 @@ func (ec *executionContext) _Human_height(ctx context.Context, field graphql.Col res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalFloat2float64(ctx, field.Selections, res) + return ec.marshalNFloat2float64(ctx, field.Selections, res) } func (ec *executionContext) _Human_mass(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { @@ -1352,7 +1352,7 @@ func (ec *executionContext) _Human_mass(ctx context.Context, field graphql.Colle res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalFloat2float64(ctx, field.Selections, res) + return ec.marshalOFloat2float64(ctx, field.Selections, res) } func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { @@ -1375,7 +1375,7 @@ func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.Co res := resTmp.([]Character) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, field.Selections, res) + return ec.marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, field.Selections, res) } func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { @@ -1408,7 +1408,7 @@ func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field res := resTmp.(FriendsConnection) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalFriendsConnection2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsConnection(ctx, field.Selections, res) + return ec.marshalNFriendsConnection2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsConnection(ctx, field.Selections, res) } func (ec *executionContext) _Human_appearsIn(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { @@ -1434,7 +1434,7 @@ func (ec *executionContext) _Human_appearsIn(ctx context.Context, field graphql. res := resTmp.([]Episode) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx, field.Selections, res) + return ec.marshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx, field.Selections, res) } func (ec *executionContext) _Human_starships(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { @@ -1457,7 +1457,7 @@ func (ec *executionContext) _Human_starships(ctx context.Context, field graphql. res := resTmp.([]Starship) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalStarship2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx, field.Selections, res) + return ec.marshalOStarship2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx, field.Selections, res) } func (ec *executionContext) _Mutation_createReview(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1487,7 +1487,7 @@ func (ec *executionContext) _Mutation_createReview(ctx context.Context, field gr res := resTmp.(*Review) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalReview2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx, field.Selections, res) + return ec.marshalOReview2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx, field.Selections, res) } func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *PageInfo) graphql.Marshaler { @@ -1513,7 +1513,7 @@ func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field gra res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalID2string(ctx, field.Selections, res) + return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *PageInfo) graphql.Marshaler { @@ -1539,7 +1539,7 @@ func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalID2string(ctx, field.Selections, res) + return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *PageInfo) graphql.Marshaler { @@ -1565,7 +1565,7 @@ func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field gra res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) _Query_hero(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1595,7 +1595,7 @@ func (ec *executionContext) _Query_hero(ctx context.Context, field graphql.Colle res := resTmp.(Character) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, field.Selections, res) + return ec.marshalOCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, field.Selections, res) } func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1628,7 +1628,7 @@ func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.Co res := resTmp.([]Review) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalReview2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx, field.Selections, res) + return ec.marshalNReview2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx, field.Selections, res) } func (ec *executionContext) _Query_search(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1661,7 +1661,7 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col res := resTmp.([]SearchResult) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalSearchResult2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐSearchResult(ctx, field.Selections, res) + return ec.marshalNSearchResult2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐSearchResult(ctx, field.Selections, res) } func (ec *executionContext) _Query_character(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1691,7 +1691,7 @@ func (ec *executionContext) _Query_character(ctx context.Context, field graphql. res := resTmp.(Character) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, field.Selections, res) + return ec.marshalOCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, field.Selections, res) } func (ec *executionContext) _Query_droid(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1721,7 +1721,7 @@ func (ec *executionContext) _Query_droid(ctx context.Context, field graphql.Coll res := resTmp.(*Droid) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalDroid2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐDroid(ctx, field.Selections, res) + return ec.marshalODroid2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐDroid(ctx, field.Selections, res) } func (ec *executionContext) _Query_human(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1751,7 +1751,7 @@ func (ec *executionContext) _Query_human(ctx context.Context, field graphql.Coll res := resTmp.(*Human) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalHuman2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐHuman(ctx, field.Selections, res) + return ec.marshalOHuman2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐHuman(ctx, field.Selections, res) } func (ec *executionContext) _Query_starship(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1781,7 +1781,7 @@ func (ec *executionContext) _Query_starship(ctx context.Context, field graphql.C res := resTmp.(*Starship) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalStarship2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx, field.Selections, res) + return ec.marshalOStarship2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1811,7 +1811,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1834,7 +1834,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) + return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } func (ec *executionContext) _Review_stars(ctx context.Context, field graphql.CollectedField, obj *Review) graphql.Marshaler { @@ -1860,7 +1860,7 @@ func (ec *executionContext) _Review_stars(ctx context.Context, field graphql.Col res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalInt2int(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _Review_commentary(ctx context.Context, field graphql.CollectedField, obj *Review) graphql.Marshaler { @@ -1883,7 +1883,7 @@ func (ec *executionContext) _Review_commentary(ctx context.Context, field graphq res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) _Review_time(ctx context.Context, field graphql.CollectedField, obj *Review) graphql.Marshaler { @@ -1906,7 +1906,7 @@ func (ec *executionContext) _Review_time(ctx context.Context, field graphql.Coll res := resTmp.(time.Time) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalOTime2timeᚐTime(ctx, field.Selections, res) } func (ec *executionContext) _Starship_id(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { @@ -1932,7 +1932,7 @@ func (ec *executionContext) _Starship_id(ctx context.Context, field graphql.Coll res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalID2string(ctx, field.Selections, res) + return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _Starship_name(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { @@ -1958,7 +1958,7 @@ func (ec *executionContext) _Starship_name(ctx context.Context, field graphql.Co res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Starship_length(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { @@ -1991,7 +1991,7 @@ func (ec *executionContext) _Starship_length(ctx context.Context, field graphql. res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalFloat2float64(ctx, field.Selections, res) + return ec.marshalNFloat2float64(ctx, field.Selections, res) } func (ec *executionContext) _Starship_history(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { @@ -2017,7 +2017,7 @@ func (ec *executionContext) _Starship_history(ctx context.Context, field graphql res := resTmp.([][]int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalInt2ᚕᚕint(ctx, field.Selections, res) + return ec.marshalNInt2ᚕᚕint(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -2043,7 +2043,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -2066,7 +2066,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -2092,7 +2092,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__DirectiveLocation2ᚕstring(ctx, field.Selections, res) + return ec.marshalN__DirectiveLocation2ᚕstring(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -2118,7 +2118,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -2144,7 +2144,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -2167,7 +2167,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -2193,7 +2193,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -2216,7 +2216,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -2242,7 +2242,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -2265,7 +2265,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -2291,7 +2291,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -2317,7 +2317,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -2343,7 +2343,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -2366,7 +2366,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -2392,7 +2392,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -2415,7 +2415,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -2441,7 +2441,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -2464,7 +2464,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -2490,7 +2490,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -2516,7 +2516,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -2539,7 +2539,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -2562,7 +2562,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -2588,7 +2588,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) + return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -2614,7 +2614,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__TypeKind2string(ctx, field.Selections, res) + return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -2637,7 +2637,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -2660,7 +2660,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -2690,7 +2690,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) + return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -2713,7 +2713,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -2736,7 +2736,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -2766,7 +2766,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -2789,7 +2789,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -2812,7 +2812,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } // endregion **************************** field.gotpl ***************************** @@ -2827,19 +2827,19 @@ func (ec *executionContext) unmarshalInputReviewInput(v interface{}) (Review, er switch k { case "stars": var err error - it.Stars, err = ec.unmarshalInt2int(v) + it.Stars, err = ec.unmarshalNInt2int(v) if err != nil { return it, err } case "commentary": var err error - it.Commentary, err = ec.unmarshalString2ᚖstring(v) + it.Commentary, err = ec.unmarshalOString2ᚖstring(v) if err != nil { return it, err } case "time": var err error - it.Time, err = ec.unmarshalTime2timeᚐTime(v) + it.Time, err = ec.unmarshalOTime2timeᚐTime(v) if err != nil { return it, err } @@ -3552,139 +3552,111 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (ec *executionContext) marshalDroid2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐDroid(ctx context.Context, sel ast.SelectionSet, v *Droid) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._Droid(ctx, sel, v) -} - -func (ec *executionContext) unmarshalEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v interface{}) (*Episode, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v) - return &res, err +func (ec *executionContext) unmarshalNBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) } -func (ec *executionContext) marshalEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v *Episode) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return v +func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + return graphql.MarshalBoolean(v) } -func (ec *executionContext) marshalHuman2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐHuman(ctx context.Context, sel ast.SelectionSet, v *Human) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._Human(ctx, sel, v) +func (ec *executionContext) marshalNCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v Character) graphql.Marshaler { + return ec._Character(ctx, sel, &v) } -func (ec *executionContext) unmarshalLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(v interface{}) (*LengthUnit, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(v) - return &res, err +func (ec *executionContext) unmarshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v interface{}) (Episode, error) { + var res Episode + return res, res.UnmarshalGQL(v) } -func (ec *executionContext) marshalLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(ctx context.Context, sel ast.SelectionSet, v *LengthUnit) graphql.Marshaler { - if v == nil { - return graphql.Null - } +func (ec *executionContext) marshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v Episode) graphql.Marshaler { return v } -func (ec *executionContext) marshalReview2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx context.Context, sel ast.SelectionSet, v *Review) graphql.Marshaler { - if v == nil { - return graphql.Null +func (ec *executionContext) unmarshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v interface{}) ([]Episode, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } } - return ec._Review(ctx, sel, v) -} - -func (ec *executionContext) marshalStarship2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx context.Context, sel ast.SelectionSet, v *Starship) graphql.Marshaler { - if v == nil { - return graphql.Null + var err error + res := make([]Episode, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(vSlice[i]) + if err != nil { + return nil, err + } } - return ec._Starship(ctx, sel, v) + return res, nil } -func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { - return graphql.Null +func (ec *executionContext) marshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v []Episode) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) } - return ec.___Schema(ctx, sel, v) -} + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } -func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { - return graphql.Null } - return ec.___Type(ctx, sel, v) + wg.Wait() + return ret } -func (ec *executionContext) unmarshalInt2ᚖint(v interface{}) (*int, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInt2int(v) - return &res, err +func (ec *executionContext) unmarshalNFloat2float64(v interface{}) (float64, error) { + return graphql.UnmarshalFloat(v) } -func (ec *executionContext) marshalInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.marshalInt2int(ctx, sel, *v) +func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { + return graphql.MarshalFloat(v) } -func (ec *executionContext) unmarshalID2ᚖstring(v interface{}) (*string, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalID2string(v) - return &res, err +func (ec *executionContext) marshalNFriendsConnection2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsConnection(ctx context.Context, sel ast.SelectionSet, v FriendsConnection) graphql.Marshaler { + return ec._FriendsConnection(ctx, sel, &v) } -func (ec *executionContext) marshalID2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.marshalID2string(ctx, sel, *v) +func (ec *executionContext) marshalNFriendsEdge2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsEdge(ctx context.Context, sel ast.SelectionSet, v FriendsEdge) graphql.Marshaler { + return ec._FriendsEdge(ctx, sel, &v) } -func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalString2string(v) - return &res, err +func (ec *executionContext) unmarshalNID2string(v interface{}) (string, error) { + return graphql.UnmarshalID(v) } -func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.marshalString2string(ctx, sel, *v) +func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalID(v) } -func (ec *executionContext) unmarshalTime2ᚖtimeᚐTime(v interface{}) (*time.Time, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalTime2timeᚐTime(v) - return &res, err +func (ec *executionContext) unmarshalNInt2int(v interface{}) (int, error) { + return graphql.UnmarshalInt(v) } -func (ec *executionContext) marshalTime2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.marshalTime2timeᚐTime(ctx, sel, *v) +func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { + return graphql.MarshalInt(v) } -func (ec *executionContext) unmarshalInt2ᚕᚕint(v interface{}) ([][]int, error) { +func (ec *executionContext) unmarshalNInt2ᚕint(v interface{}) ([]int, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -3694,9 +3666,9 @@ func (ec *executionContext) unmarshalInt2ᚕᚕint(v interface{}) ([][]int, erro } } var err error - res := make([][]int, len(vSlice)) + res := make([]int, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalInt2ᚕint(vSlice[i]) + res[i], err = ec.unmarshalNInt2int(vSlice[i]) if err != nil { return nil, err } @@ -3704,47 +3676,16 @@ func (ec *executionContext) unmarshalInt2ᚕᚕint(v interface{}) ([][]int, erro return res, nil } -func (ec *executionContext) marshalInt2ᚕᚕint(ctx context.Context, sel ast.SelectionSet, v [][]int) graphql.Marshaler { +func (ec *executionContext) marshalNInt2ᚕint(ctx context.Context, sel ast.SelectionSet, v []int) graphql.Marshaler { ret := make(graphql.Array, len(v)) for i := range v { - ret[i] = ec.marshalInt2ᚕint(ctx, sel, v[i]) - } - - return ret -} - -func (ec *executionContext) marshalCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v []Character) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) + ret[i] = ec.marshalNInt2int(ctx, sel, v[i]) } - for i := range v { - i := i - rctx := &graphql.ResolverContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(i int) { - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - } - wg.Wait() return ret } -func (ec *executionContext) unmarshalEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v interface{}) ([]Episode, error) { +func (ec *executionContext) unmarshalNInt2ᚕᚕint(v interface{}) ([][]int, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -3754,9 +3695,9 @@ func (ec *executionContext) unmarshalEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlge } } var err error - res := make([]Episode, len(vSlice)) + res := make([][]int, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(vSlice[i]) + res[i], err = ec.unmarshalNInt2ᚕint(vSlice[i]) if err != nil { return nil, err } @@ -3764,7 +3705,24 @@ func (ec *executionContext) unmarshalEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlge return res, nil } -func (ec *executionContext) marshalEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v []Episode) graphql.Marshaler { +func (ec *executionContext) marshalNInt2ᚕᚕint(ctx context.Context, sel ast.SelectionSet, v [][]int) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNInt2ᚕint(ctx, sel, v[i]) + } + + return ret +} + +func (ec *executionContext) marshalNPageInfo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐPageInfo(ctx context.Context, sel ast.SelectionSet, v PageInfo) graphql.Marshaler { + return ec._PageInfo(ctx, sel, &v) +} + +func (ec *executionContext) marshalNReview2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx context.Context, sel ast.SelectionSet, v Review) graphql.Marshaler { + return ec._Review(ctx, sel, &v) +} + +func (ec *executionContext) marshalNReview2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx context.Context, sel ast.SelectionSet, v []Review) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -3782,7 +3740,7 @@ func (ec *executionContext) marshalEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx, sel, v[i]) + ret[i] = ec.marshalNReview2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx, sel, v[i]) } if isLen1 { f(i) @@ -3795,7 +3753,15 @@ func (ec *executionContext) marshalEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) marshalFriendsEdge2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsEdge(ctx context.Context, sel ast.SelectionSet, v []FriendsEdge) graphql.Marshaler { +func (ec *executionContext) unmarshalNReviewInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(v interface{}) (Review, error) { + return ec.unmarshalInputReviewInput(v) +} + +func (ec *executionContext) marshalNSearchResult2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐSearchResult(ctx context.Context, sel ast.SelectionSet, v SearchResult) graphql.Marshaler { + return ec._SearchResult(ctx, sel, &v) +} + +func (ec *executionContext) marshalNSearchResult2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐSearchResult(ctx context.Context, sel ast.SelectionSet, v []SearchResult) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -3813,7 +3779,7 @@ func (ec *executionContext) marshalFriendsEdge2ᚕgithubᚗcomᚋ99designsᚋgql if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalFriendsEdge2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsEdge(ctx, sel, v[i]) + ret[i] = ec.marshalNSearchResult2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐSearchResult(ctx, sel, v[i]) } if isLen1 { f(i) @@ -3826,7 +3792,23 @@ func (ec *executionContext) marshalFriendsEdge2ᚕgithubᚗcomᚋ99designsᚋgql return ret } -func (ec *executionContext) marshalReview2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx context.Context, sel ast.SelectionSet, v []Review) graphql.Marshaler { +func (ec *executionContext) marshalNStarship2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx context.Context, sel ast.SelectionSet, v Starship) graphql.Marshaler { + return ec._Starship(ctx, sel, &v) +} + +func (ec *executionContext) unmarshalNString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { + return ec.___Directive(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -3844,7 +3826,7 @@ func (ec *executionContext) marshalReview2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalReview2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx, sel, v[i]) + ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) } if isLen1 { f(i) @@ -3857,7 +3839,35 @@ func (ec *executionContext) marshalReview2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) marshalSearchResult2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐSearchResult(ctx context.Context, sel ast.SelectionSet, v []SearchResult) graphql.Marshaler { +func (ec *executionContext) unmarshalN__DirectiveLocation2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshalN__DirectiveLocation2string(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalN__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -3875,7 +3885,7 @@ func (ec *executionContext) marshalSearchResult2ᚕgithubᚗcomᚋ99designsᚋgq if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalSearchResult2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐSearchResult(ctx, sel, v[i]) + ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) } if isLen1 { f(i) @@ -3888,7 +3898,19 @@ func (ec *executionContext) marshalSearchResult2ᚕgithubᚗcomᚋ99designsᚋgq return ret } -func (ec *executionContext) marshalStarship2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx context.Context, sel ast.SelectionSet, v []Starship) graphql.Marshaler { +func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { + return ec.___EnumValue(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { + return ec.___Field(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { + return ec.___InputValue(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -3906,7 +3928,7 @@ func (ec *executionContext) marshalStarship2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalStarship2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx, sel, v[i]) + ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -3919,7 +3941,11 @@ func (ec *executionContext) marshalStarship2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { +func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + return ec.___Type(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -3937,7 +3963,7 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) + ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) } if isLen1 { f(i) @@ -3950,7 +3976,37 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql return ret } -func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec.___Type(ctx, sel, v) +} + +func (ec *executionContext) unmarshalN__TypeKind2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalOBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) +} + +func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + return graphql.MarshalBoolean(v) +} + +func (ec *executionContext) marshalOCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v Character) graphql.Marshaler { + return ec._Character(ctx, sel, &v) +} + +func (ec *executionContext) marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v []Character) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -3968,7 +4024,7 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) + ret[i] = ec.marshalNCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, sel, v[i]) } if isLen1 { f(i) @@ -3981,17 +4037,60 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql return ret } -func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) +func (ec *executionContext) marshalODroid2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐDroid(ctx context.Context, sel ast.SelectionSet, v Droid) graphql.Marshaler { + return ec._Droid(ctx, sel, &v) +} + +func (ec *executionContext) marshalODroid2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐDroid(ctx context.Context, sel ast.SelectionSet, v *Droid) graphql.Marshaler { + if v == nil { + return graphql.Null } - for i := range v { - i := i - rctx := &graphql.ResolverContext{ - Index: &i, + return ec._Droid(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v interface{}) (Episode, error) { + var res Episode + return res, res.UnmarshalGQL(v) +} + +func (ec *executionContext) marshalOEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v Episode) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalOEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v interface{}) (*Episode, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v) + return &res, err +} + +func (ec *executionContext) marshalOEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v *Episode) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) unmarshalOFloat2float64(v interface{}) (float64, error) { + return graphql.UnmarshalFloat(v) +} + +func (ec *executionContext) marshalOFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { + return graphql.MarshalFloat(v) +} + +func (ec *executionContext) marshalOFriendsEdge2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsEdge(ctx context.Context, sel ast.SelectionSet, v []FriendsEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, Result: &v[i], } ctx := graphql.WithResolverContext(ctx, rctx) @@ -3999,7 +4098,7 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + ret[i] = ec.marshalNFriendsEdge2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsEdge(ctx, sel, v[i]) } if isLen1 { f(i) @@ -4012,7 +4111,103 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) marshalOHuman2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐHuman(ctx context.Context, sel ast.SelectionSet, v Human) graphql.Marshaler { + return ec._Human(ctx, sel, &v) +} + +func (ec *executionContext) marshalOHuman2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐHuman(ctx context.Context, sel ast.SelectionSet, v *Human) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Human(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOID2string(v interface{}) (string, error) { + return graphql.UnmarshalID(v) +} + +func (ec *executionContext) marshalOID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalID(v) +} + +func (ec *executionContext) unmarshalOID2ᚖstring(v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOID2string(v) + return &res, err +} + +func (ec *executionContext) marshalOID2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOID2string(ctx, sel, *v) +} + +func (ec *executionContext) unmarshalOInt2int(v interface{}) (int, error) { + return graphql.UnmarshalInt(v) +} + +func (ec *executionContext) marshalOInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { + return graphql.MarshalInt(v) +} + +func (ec *executionContext) unmarshalOInt2ᚖint(v interface{}) (*int, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOInt2int(v) + return &res, err +} + +func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOInt2int(ctx, sel, *v) +} + +func (ec *executionContext) unmarshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(v interface{}) (LengthUnit, error) { + var res LengthUnit + return res, res.UnmarshalGQL(v) +} + +func (ec *executionContext) marshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(ctx context.Context, sel ast.SelectionSet, v LengthUnit) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalOLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(v interface{}) (*LengthUnit, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(v) + return &res, err +} + +func (ec *executionContext) marshalOLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(ctx context.Context, sel ast.SelectionSet, v *LengthUnit) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) marshalOReview2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx context.Context, sel ast.SelectionSet, v Review) graphql.Marshaler { + return ec._Review(ctx, sel, &v) +} + +func (ec *executionContext) marshalOReview2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx context.Context, sel ast.SelectionSet, v *Review) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Review(ctx, sel, v) +} + +func (ec *executionContext) marshalOStarship2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx context.Context, sel ast.SelectionSet, v Starship) graphql.Marshaler { + return ec._Starship(ctx, sel, &v) +} + +func (ec *executionContext) marshalOStarship2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx context.Context, sel ast.SelectionSet, v []Starship) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4030,7 +4225,7 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + ret[i] = ec.marshalNStarship2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx, sel, v[i]) } if isLen1 { f(i) @@ -4043,7 +4238,60 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq return ret } -func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { +func (ec *executionContext) marshalOStarship2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx context.Context, sel ast.SelectionSet, v *Starship) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Starship(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalOString2ᚖstring(v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOString2string(v) + return &res, err +} + +func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOString2string(ctx, sel, *v) +} + +func (ec *executionContext) unmarshalOTime2timeᚐTime(v interface{}) (time.Time, error) { + return graphql.UnmarshalTime(v) +} + +func (ec *executionContext) marshalOTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { + return graphql.MarshalTime(v) +} + +func (ec *executionContext) unmarshalOTime2ᚖtimeᚐTime(v interface{}) (*time.Time, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOTime2timeᚐTime(v) + return &res, err +} + +func (ec *executionContext) marshalOTime2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOTime2timeᚐTime(ctx, sel, *v) +} + +func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4061,7 +4309,7 @@ func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -4074,56 +4322,38 @@ func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) unmarshalInt2ᚕint(v interface{}) ([]int, error) { - var vSlice []interface{} - if v != nil { - if tmp1, ok := v.([]interface{}); ok { - vSlice = tmp1 - } else { - vSlice = []interface{}{v} - } - } - var err error - res := make([]int, len(vSlice)) - for i := range vSlice { - res[i], err = ec.unmarshalInt2int(vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) marshalInt2ᚕint(ctx context.Context, sel ast.SelectionSet, v []int) graphql.Marshaler { +func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { ret := make(graphql.Array, len(v)) - for i := range v { - ret[i] = ec.marshalInt2int(ctx, sel, v[i]) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) } - - return ret -} - -func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { - var vSlice []interface{} - if v != nil { - if tmp1, ok := v.([]interface{}); ok { - vSlice = tmp1 - } else { - vSlice = []interface{}{v} + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], } - } - var err error - res := make([]string, len(vSlice)) - for i := range vSlice { - res[i], err = ec.unmarshal__DirectiveLocation2string(vSlice[i]) - if err != nil { - return nil, err + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) } + if isLen1 { + f(i) + } else { + go f(i) + } + } - return res, nil + wg.Wait() + return ret } -func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { +func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4141,7 +4371,7 @@ func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Con if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__DirectiveLocation2string(ctx, sel, v[i]) + ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -4154,150 +4384,57 @@ func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Con return ret } -func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { - return graphql.UnmarshalBoolean(v) -} - -func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) -} - -func (ec *executionContext) unmarshalFloat2float64(v interface{}) (float64, error) { - return graphql.UnmarshalFloat(v) -} - -func (ec *executionContext) marshalFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { - return graphql.MarshalFloat(v) -} - -func (ec *executionContext) marshalCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v Character) graphql.Marshaler { - return ec._Character(ctx, sel, &v) -} - -func (ec *executionContext) marshalDroid2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐDroid(ctx context.Context, sel ast.SelectionSet, v Droid) graphql.Marshaler { - return ec._Droid(ctx, sel, &v) -} - -func (ec *executionContext) unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v interface{}) (Episode, error) { - var res Episode - return res, res.UnmarshalGQL(v) -} - -func (ec *executionContext) marshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v Episode) graphql.Marshaler { - return v -} - -func (ec *executionContext) marshalFriendsConnection2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsConnection(ctx context.Context, sel ast.SelectionSet, v FriendsConnection) graphql.Marshaler { - return ec._FriendsConnection(ctx, sel, &v) -} - -func (ec *executionContext) marshalFriendsEdge2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsEdge(ctx context.Context, sel ast.SelectionSet, v FriendsEdge) graphql.Marshaler { - return ec._FriendsEdge(ctx, sel, &v) -} - -func (ec *executionContext) marshalHuman2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐHuman(ctx context.Context, sel ast.SelectionSet, v Human) graphql.Marshaler { - return ec._Human(ctx, sel, &v) -} - -func (ec *executionContext) unmarshalLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(v interface{}) (LengthUnit, error) { - var res LengthUnit - return res, res.UnmarshalGQL(v) -} - -func (ec *executionContext) marshalLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(ctx context.Context, sel ast.SelectionSet, v LengthUnit) graphql.Marshaler { - return v -} - -func (ec *executionContext) marshalPageInfo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐPageInfo(ctx context.Context, sel ast.SelectionSet, v PageInfo) graphql.Marshaler { - return ec._PageInfo(ctx, sel, &v) -} - -func (ec *executionContext) marshalReview2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx context.Context, sel ast.SelectionSet, v Review) graphql.Marshaler { - return ec._Review(ctx, sel, &v) -} - -func (ec *executionContext) unmarshalReviewInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(v interface{}) (Review, error) { - return ec.unmarshalInputReviewInput(v) -} - -func (ec *executionContext) marshalSearchResult2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐSearchResult(ctx context.Context, sel ast.SelectionSet, v SearchResult) graphql.Marshaler { - return ec._SearchResult(ctx, sel, &v) -} - -func (ec *executionContext) marshalStarship2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx context.Context, sel ast.SelectionSet, v Starship) graphql.Marshaler { - return ec._Starship(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) -} - -func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) -} - -func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { +func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { return ec.___Schema(ctx, sel, &v) } -func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - -func (ec *executionContext) unmarshalInt2int(v interface{}) (int, error) { - return graphql.UnmarshalInt(v) -} - -func (ec *executionContext) marshalInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - return graphql.MarshalInt(v) -} - -func (ec *executionContext) unmarshalID2string(v interface{}) (string, error) { - return graphql.UnmarshalID(v) -} - -func (ec *executionContext) marshalID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalID(v) -} - -func (ec *executionContext) unmarshalString2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) -} - -func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) -} - -func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) -} - -func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) +func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Schema(ctx, sel, v) } -func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) +func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + return ec.___Type(ctx, sel, &v) } -func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) -} +func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } -func (ec *executionContext) unmarshalTime2timeᚐTime(v interface{}) (time.Time, error) { - return graphql.UnmarshalTime(v) + } + wg.Wait() + return ret } -func (ec *executionContext) marshalTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - return graphql.MarshalTime(v) +func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Type(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** diff --git a/example/todo/generated.go b/example/todo/generated.go index 020f2d06589..8112480fc7e 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -300,7 +300,7 @@ func (ec *executionContext) dir_hasRole_args(ctx context.Context, rawArgs map[st args := map[string]interface{}{} var arg0 Role if tmp, ok := rawArgs["role"]; ok { - arg0, err = ec.unmarshalRole2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐRole(tmp) + arg0, err = ec.unmarshalNRole2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐRole(tmp) if err != nil { return nil, err } @@ -314,7 +314,7 @@ func (ec *executionContext) field_MyMutation_createTodo_args(ctx context.Context args := map[string]interface{}{} var arg0 TodoInput if tmp, ok := rawArgs["todo"]; ok { - arg0, err = ec.unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodoInput(tmp) + arg0, err = ec.unmarshalNTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodoInput(tmp) if err != nil { return nil, err } @@ -328,7 +328,7 @@ func (ec *executionContext) field_MyMutation_updateTodo_args(ctx context.Context args := map[string]interface{}{} var arg0 int if tmp, ok := rawArgs["id"]; ok { - arg0, err = ec.unmarshalInt2int(tmp) + arg0, err = ec.unmarshalNInt2int(tmp) if err != nil { return nil, err } @@ -336,7 +336,7 @@ func (ec *executionContext) field_MyMutation_updateTodo_args(ctx context.Context args["id"] = arg0 var arg1 map[string]interface{} if tmp, ok := rawArgs["changes"]; ok { - arg1, err = ec.unmarshalMap2map(tmp) + arg1, err = ec.unmarshalNMap2map(tmp) if err != nil { return nil, err } @@ -350,7 +350,7 @@ func (ec *executionContext) field_MyQuery___type_args(ctx context.Context, rawAr args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = ec.unmarshalString2string(tmp) + arg0, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -364,7 +364,7 @@ func (ec *executionContext) field_MyQuery_todo_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 int if tmp, ok := rawArgs["id"]; ok { - arg0, err = ec.unmarshalInt2int(tmp) + arg0, err = ec.unmarshalNInt2int(tmp) if err != nil { return nil, err } @@ -378,7 +378,7 @@ func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(tmp) if err != nil { return nil, err } @@ -392,7 +392,7 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(tmp) if err != nil { return nil, err } @@ -435,7 +435,7 @@ func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field gr res := resTmp.(Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx, field.Selections, res) + return ec.marshalNTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx, field.Selections, res) } func (ec *executionContext) _MyMutation_updateTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -465,7 +465,7 @@ func (ec *executionContext) _MyMutation_updateTodo(ctx context.Context, field gr res := resTmp.(*Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx, field.Selections, res) + return ec.marshalOTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx, field.Selections, res) } func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -495,7 +495,7 @@ func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.Col res := resTmp.(*Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx, field.Selections, res) + return ec.marshalOTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx, field.Selections, res) } func (ec *executionContext) _MyQuery_lastTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -518,7 +518,7 @@ func (ec *executionContext) _MyQuery_lastTodo(ctx context.Context, field graphql res := resTmp.(*Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx, field.Selections, res) + return ec.marshalOTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx, field.Selections, res) } func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -544,7 +544,7 @@ func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.Co res := resTmp.([]Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx, field.Selections, res) + return ec.marshalNTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx, field.Selections, res) } func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -574,7 +574,7 @@ func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.C res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -597,7 +597,7 @@ func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) + return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { @@ -623,7 +623,7 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalInt2int(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { @@ -649,7 +649,7 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { @@ -675,7 +675,7 @@ func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.Collec res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -701,7 +701,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -724,7 +724,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -750,7 +750,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__DirectiveLocation2ᚕstring(ctx, field.Selections, res) + return ec.marshalN__DirectiveLocation2ᚕstring(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -776,7 +776,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -802,7 +802,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -825,7 +825,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -851,7 +851,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -874,7 +874,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -900,7 +900,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -923,7 +923,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -949,7 +949,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -975,7 +975,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -1001,7 +1001,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -1024,7 +1024,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1050,7 +1050,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1073,7 +1073,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1099,7 +1099,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1122,7 +1122,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1148,7 +1148,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1174,7 +1174,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1197,7 +1197,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1220,7 +1220,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1246,7 +1246,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) + return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1272,7 +1272,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__TypeKind2string(ctx, field.Selections, res) + return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1295,7 +1295,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1318,7 +1318,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1348,7 +1348,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) + return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1371,7 +1371,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1394,7 +1394,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1424,7 +1424,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1447,7 +1447,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1470,7 +1470,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } // endregion **************************** field.gotpl ***************************** @@ -1485,13 +1485,13 @@ func (ec *executionContext) unmarshalInputTodoInput(v interface{}) (TodoInput, e switch k { case "text": var err error - it.Text, err = ec.unmarshalString2string(v) + it.Text, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "done": var err error - it.Done, err = ec.unmarshalBoolean2ᚖbool(v) + it.Done, err = ec.unmarshalOBoolean2ᚖbool(v) if err != nil { return it, err } @@ -1875,58 +1875,52 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (ec *executionContext) unmarshalBoolean2ᚖbool(v interface{}) (*bool, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalBoolean2bool(v) - return &res, err +func (ec *executionContext) unmarshalNBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) } -func (ec *executionContext) marshalBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.marshalBoolean2bool(ctx, sel, *v) +func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + return graphql.MarshalBoolean(v) } -func (ec *executionContext) marshalTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._Todo(ctx, sel, v) +func (ec *executionContext) unmarshalNInt2int(v interface{}) (int, error) { + return graphql.UnmarshalInt(v) } -func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Schema(ctx, sel, v) +func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { + return graphql.MarshalInt(v) } -func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Type(ctx, sel, v) +func (ec *executionContext) unmarshalNMap2map(v interface{}) (map[string]interface{}, error) { + return graphql.UnmarshalMap(v) } -func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalString2string(v) - return &res, err +func (ec *executionContext) marshalNMap2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler { + return graphql.MarshalMap(v) } -func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.marshalString2string(ctx, sel, *v) +func (ec *executionContext) unmarshalNRole2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐRole(v interface{}) (Role, error) { + var res Role + return res, res.UnmarshalGQL(v) } -func (ec *executionContext) marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v []Todo) graphql.Marshaler { +func (ec *executionContext) marshalNRole2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐRole(ctx context.Context, sel ast.SelectionSet, v Role) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalNString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) marshalNTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { + return ec._Todo(ctx, sel, &v) +} + +func (ec *executionContext) marshalNTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v []Todo) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1944,7 +1938,7 @@ func (ec *executionContext) marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋe if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx, sel, v[i]) + ret[i] = ec.marshalNTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx, sel, v[i]) } if isLen1 { f(i) @@ -1957,7 +1951,15 @@ func (ec *executionContext) marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋe return ret } -func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { +func (ec *executionContext) unmarshalNTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodoInput(v interface{}) (TodoInput, error) { + return ec.unmarshalInputTodoInput(v) +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { + return ec.___Directive(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1975,7 +1977,7 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) + ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) } if isLen1 { f(i) @@ -1988,7 +1990,35 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql return ret } -func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) unmarshalN__DirectiveLocation2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshalN__DirectiveLocation2string(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalN__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2006,7 +2036,7 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) + ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2019,7 +2049,19 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql return ret } -func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { +func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { + return ec.___EnumValue(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { + return ec.___Field(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { + return ec.___InputValue(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2037,7 +2079,7 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2050,7 +2092,11 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + return ec.___Type(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2068,7 +2114,7 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2081,7 +2127,82 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq return ret } -func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { +func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec.___Type(ctx, sel, v) +} + +func (ec *executionContext) unmarshalN__TypeKind2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalOBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) +} + +func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + return graphql.MarshalBoolean(v) +} + +func (ec *executionContext) unmarshalOBoolean2ᚖbool(v interface{}) (*bool, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOBoolean2bool(v) + return &res, err +} + +func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOBoolean2bool(ctx, sel, *v) +} + +func (ec *executionContext) unmarshalOString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalOString2ᚖstring(v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOString2string(v) + return &res, err +} + +func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOString2string(ctx, sel, *v) +} + +func (ec *executionContext) marshalOTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { + return ec._Todo(ctx, sel, &v) +} + +func (ec *executionContext) marshalOTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Todo(ctx, sel, v) +} + +func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2099,7 +2220,7 @@ func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2112,27 +2233,38 @@ func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { - var vSlice []interface{} - if v != nil { - if tmp1, ok := v.([]interface{}); ok { - vSlice = tmp1 - } else { - vSlice = []interface{}{v} - } +func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) } - var err error - res := make([]string, len(vSlice)) - for i := range vSlice { - res[i], err = ec.unmarshal__DirectiveLocation2string(vSlice[i]) - if err != nil { - return nil, err + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) } + if isLen1 { + f(i) + } else { + go f(i) + } + } - return res, nil + wg.Wait() + return ret } -func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { +func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2150,7 +2282,7 @@ func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Con if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__DirectiveLocation2string(ctx, sel, v[i]) + ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2163,93 +2295,57 @@ func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Con return ret } -func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { - return graphql.UnmarshalBoolean(v) -} - -func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) -} - -func (ec *executionContext) unmarshalRole2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐRole(v interface{}) (Role, error) { - var res Role - return res, res.UnmarshalGQL(v) -} - -func (ec *executionContext) marshalRole2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐRole(ctx context.Context, sel ast.SelectionSet, v Role) graphql.Marshaler { - return v -} - -func (ec *executionContext) unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodoInput(v interface{}) (TodoInput, error) { - return ec.unmarshalInputTodoInput(v) -} - -func (ec *executionContext) marshalTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { - return ec._Todo(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) -} - -func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) -} - -func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { +func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { return ec.___Schema(ctx, sel, &v) } -func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - -func (ec *executionContext) unmarshalInt2int(v interface{}) (int, error) { - return graphql.UnmarshalInt(v) -} - -func (ec *executionContext) marshalInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - return graphql.MarshalInt(v) -} - -func (ec *executionContext) unmarshalMap2map(v interface{}) (map[string]interface{}, error) { - return graphql.UnmarshalMap(v) -} - -func (ec *executionContext) marshalMap2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler { - return graphql.MarshalMap(v) -} - -func (ec *executionContext) unmarshalString2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) -} - -func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) +func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Schema(ctx, sel, v) } -func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) +func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + return ec.___Type(ctx, sel, &v) } -func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) -} +func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } -func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) + } + wg.Wait() + return ret } -func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) +func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Type(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index b9cf6c165ba..92fdcd2bf3c 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -369,7 +369,7 @@ func (ec *executionContext) field_MyMutation_createTodo_args(ctx context.Context args := map[string]interface{}{} var arg0 TodoInput if tmp, ok := rawArgs["todo"]; ok { - arg0, err = ec.unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodoInput(tmp) + arg0, err = ec.unmarshalNTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodoInput(tmp) if err != nil { return nil, err } @@ -383,7 +383,7 @@ func (ec *executionContext) field_MyQuery___type_args(ctx context.Context, rawAr args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = ec.unmarshalString2string(tmp) + arg0, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -397,7 +397,7 @@ func (ec *executionContext) field_MyQuery_todo_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["id"]; ok { - arg0, err = ec.unmarshalID2string(tmp) + arg0, err = ec.unmarshalNID2string(tmp) if err != nil { return nil, err } @@ -411,7 +411,7 @@ func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(tmp) if err != nil { return nil, err } @@ -425,7 +425,7 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(tmp) if err != nil { return nil, err } @@ -468,7 +468,7 @@ func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field gr res := resTmp.(Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx, field.Selections, res) + return ec.marshalNTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx, field.Selections, res) } func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -494,7 +494,7 @@ func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.Co res := resTmp.([]Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx, field.Selections, res) + return ec.marshalNTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx, field.Selections, res) } func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -524,7 +524,7 @@ func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.Col res := resTmp.(*Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx, field.Selections, res) + return ec.marshalOTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx, field.Selections, res) } func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -554,7 +554,7 @@ func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.C res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -577,7 +577,7 @@ func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) + return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { @@ -603,7 +603,7 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalID2string(ctx, field.Selections, res) + return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { @@ -629,7 +629,7 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Todo_state(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { @@ -655,7 +655,7 @@ func (ec *executionContext) _Todo_state(ctx context.Context, field graphql.Colle res := resTmp.(State) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalState2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐState(ctx, field.Selections, res) + return ec.marshalNState2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐState(ctx, field.Selections, res) } func (ec *executionContext) _Todo_verified(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { @@ -681,7 +681,7 @@ func (ec *executionContext) _Todo_verified(ctx context.Context, field graphql.Co res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -707,7 +707,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -730,7 +730,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -756,7 +756,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__DirectiveLocation2ᚕstring(ctx, field.Selections, res) + return ec.marshalN__DirectiveLocation2ᚕstring(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -782,7 +782,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -808,7 +808,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -831,7 +831,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -857,7 +857,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -880,7 +880,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -906,7 +906,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -929,7 +929,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -955,7 +955,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -981,7 +981,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -1007,7 +1007,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -1030,7 +1030,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1056,7 +1056,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1079,7 +1079,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1105,7 +1105,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1128,7 +1128,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1154,7 +1154,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1180,7 +1180,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1203,7 +1203,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1226,7 +1226,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1252,7 +1252,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) + return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1278,7 +1278,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__TypeKind2string(ctx, field.Selections, res) + return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1301,7 +1301,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1324,7 +1324,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1354,7 +1354,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) + return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1377,7 +1377,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1400,7 +1400,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1430,7 +1430,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1453,7 +1453,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1476,7 +1476,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } // endregion **************************** field.gotpl ***************************** @@ -1491,7 +1491,7 @@ func (ec *executionContext) unmarshalInputTodoInput(v interface{}) (TodoInput, e switch k { case "text": var err error - it.Text, err = ec.unmarshalString2string(v) + it.Text, err = ec.unmarshalNString2string(v) if err != nil { return it, err } @@ -1898,43 +1898,44 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (ec *executionContext) marshalTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._Todo(ctx, sel, v) +func (ec *executionContext) unmarshalNBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) } -func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Schema(ctx, sel, v) +func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + return graphql.MarshalBoolean(v) } -func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Type(ctx, sel, v) +func (ec *executionContext) unmarshalNID2string(v interface{}) (string, error) { + return graphql.UnmarshalID(v) } -func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalString2string(v) - return &res, err +func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalID(v) } -func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.marshalString2string(ctx, sel, *v) +func (ec *executionContext) unmarshalNState2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐState(v interface{}) (State, error) { + var res State + return res, res.UnmarshalGQL(v) +} + +func (ec *executionContext) marshalNState2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐState(ctx context.Context, sel ast.SelectionSet, v State) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalNString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) } -func (ec *executionContext) marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v []Todo) graphql.Marshaler { +func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) marshalNTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { + return ec._Todo(ctx, sel, &v) +} + +func (ec *executionContext) marshalNTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v []Todo) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1952,7 +1953,7 @@ func (ec *executionContext) marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋe if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx, sel, v[i]) + ret[i] = ec.marshalNTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx, sel, v[i]) } if isLen1 { f(i) @@ -1965,7 +1966,15 @@ func (ec *executionContext) marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋe return ret } -func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { +func (ec *executionContext) unmarshalNTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodoInput(v interface{}) (TodoInput, error) { + return ec.unmarshalInputTodoInput(v) +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { + return ec.___Directive(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1983,7 +1992,7 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) + ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) } if isLen1 { f(i) @@ -1996,7 +2005,35 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql return ret } -func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { +func (ec *executionContext) unmarshalN__DirectiveLocation2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshalN__DirectiveLocation2string(vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalN__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2014,7 +2051,7 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) + ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2027,7 +2064,19 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql return ret } -func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { +func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { + return ec.___EnumValue(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { + return ec.___Field(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { + return ec.___InputValue(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2045,7 +2094,7 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2058,7 +2107,11 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + return ec.___Type(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2076,7 +2129,7 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2089,7 +2142,67 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq return ret } -func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { +func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec.___Type(ctx, sel, v) +} + +func (ec *executionContext) unmarshalN__TypeKind2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalOBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) +} + +func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + return graphql.MarshalBoolean(v) +} + +func (ec *executionContext) unmarshalOString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalOString2ᚖstring(v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOString2string(v) + return &res, err +} + +func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOString2string(ctx, sel, *v) +} + +func (ec *executionContext) marshalOTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { + return ec._Todo(ctx, sel, &v) +} + +func (ec *executionContext) marshalOTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Todo(ctx, sel, v) +} + +func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2107,7 +2220,7 @@ func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2120,27 +2233,38 @@ func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { - var vSlice []interface{} - if v != nil { - if tmp1, ok := v.([]interface{}); ok { - vSlice = tmp1 - } else { - vSlice = []interface{}{v} - } +func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) } - var err error - res := make([]string, len(vSlice)) - for i := range vSlice { - res[i], err = ec.unmarshal__DirectiveLocation2string(vSlice[i]) - if err != nil { - return nil, err + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) } + } - return res, nil + wg.Wait() + return ret } -func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { +func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2158,7 +2282,7 @@ func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Con if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__DirectiveLocation2string(ctx, sel, v[i]) + ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2171,85 +2295,57 @@ func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Con return ret } -func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { - return graphql.UnmarshalBoolean(v) -} - -func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) -} - -func (ec *executionContext) unmarshalState2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐState(v interface{}) (State, error) { - var res State - return res, res.UnmarshalGQL(v) -} - -func (ec *executionContext) marshalState2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐState(ctx context.Context, sel ast.SelectionSet, v State) graphql.Marshaler { - return v -} - -func (ec *executionContext) unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodoInput(v interface{}) (TodoInput, error) { - return ec.unmarshalInputTodoInput(v) -} - -func (ec *executionContext) marshalTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { - return ec._Todo(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) -} - -func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) -} - -func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) -} - -func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { +func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { return ec.___Schema(ctx, sel, &v) } -func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - -func (ec *executionContext) unmarshalID2string(v interface{}) (string, error) { - return graphql.UnmarshalID(v) -} - -func (ec *executionContext) marshalID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalID(v) -} - -func (ec *executionContext) unmarshalString2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) -} - -func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) +func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Schema(ctx, sel, v) } -func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) +func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + return ec.___Type(ctx, sel, &v) } -func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) -} +func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } -func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) + } + wg.Wait() + return ret } -func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) +func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Type(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** diff --git a/integration/generated.go b/integration/generated.go index 42d7c2ef604..8d1f0b03a54 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -328,7 +328,7 @@ func (ec *executionContext) dir_magic_args(ctx context.Context, rawArgs map[stri args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["kind"]; ok { - arg0, err = ec.unmarshalInt2ᚖint(tmp) + arg0, err = ec.unmarshalOInt2ᚖint(tmp) if err != nil { return nil, err } @@ -342,7 +342,7 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = ec.unmarshalString2string(tmp) + arg0, err = ec.unmarshalNString2string(tmp) if err != nil { return nil, err } @@ -356,7 +356,7 @@ func (ec *executionContext) field_Query_date_args(ctx context.Context, rawArgs m args := map[string]interface{}{} var arg0 models.DateFilter if tmp, ok := rawArgs["filter"]; ok { - arg0, err = ec.unmarshalDateFilter2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilter(tmp) + arg0, err = ec.unmarshalNDateFilter2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilter(tmp) if err != nil { return nil, err } @@ -370,7 +370,7 @@ func (ec *executionContext) field_Query_error_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 *models.ErrorType if tmp, ok := rawArgs["type"]; ok { - arg0, err = ec.unmarshalErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(tmp) + arg0, err = ec.unmarshalOErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(tmp) if err != nil { return nil, err } @@ -384,7 +384,7 @@ func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(tmp) if err != nil { return nil, err } @@ -398,7 +398,7 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(tmp) if err != nil { return nil, err } @@ -434,7 +434,7 @@ func (ec *executionContext) _Element_child(ctx context.Context, field graphql.Co res := resTmp.(models.Element) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalElement2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx, field.Selections, res) + return ec.marshalNElement2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx, field.Selections, res) } func (ec *executionContext) _Element_error(ctx context.Context, field graphql.CollectedField, obj *models.Element) graphql.Marshaler { @@ -460,7 +460,7 @@ func (ec *executionContext) _Element_error(ctx context.Context, field graphql.Co res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) _Element_mismatched(ctx context.Context, field graphql.CollectedField, obj *models.Element) graphql.Marshaler { @@ -483,7 +483,7 @@ func (ec *executionContext) _Element_mismatched(ctx context.Context, field graph res := resTmp.([]bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2ᚕbool(ctx, field.Selections, res) + return ec.marshalOBoolean2ᚕbool(ctx, field.Selections, res) } func (ec *executionContext) _Query_path(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -506,7 +506,7 @@ func (ec *executionContext) _Query_path(ctx context.Context, field graphql.Colle res := resTmp.([]*models.Element) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalElement2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx, field.Selections, res) + return ec.marshalOElement2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx, field.Selections, res) } func (ec *executionContext) _Query_date(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -539,7 +539,7 @@ func (ec *executionContext) _Query_date(ctx context.Context, field graphql.Colle res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) _Query_viewer(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -562,7 +562,7 @@ func (ec *executionContext) _Query_viewer(ctx context.Context, field graphql.Col res := resTmp.(*models.Viewer) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalViewer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐViewer(ctx, field.Selections, res) + return ec.marshalOViewer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐViewer(ctx, field.Selections, res) } func (ec *executionContext) _Query_jsonEncoding(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -588,7 +588,7 @@ func (ec *executionContext) _Query_jsonEncoding(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Query_error(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -621,7 +621,7 @@ func (ec *executionContext) _Query_error(ctx context.Context, field graphql.Coll res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -651,7 +651,7 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -674,7 +674,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) + return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *remote_api.User) graphql.Marshaler { @@ -700,7 +700,7 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _User_likes(ctx context.Context, field graphql.CollectedField, obj *remote_api.User) graphql.Marshaler { @@ -726,7 +726,7 @@ func (ec *executionContext) _User_likes(ctx context.Context, field graphql.Colle res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚕstring(ctx, field.Selections, res) + return ec.marshalNString2ᚕstring(ctx, field.Selections, res) } func (ec *executionContext) _Viewer_user(ctx context.Context, field graphql.CollectedField, obj *models.Viewer) graphql.Marshaler { @@ -749,7 +749,7 @@ func (ec *executionContext) _Viewer_user(ctx context.Context, field graphql.Coll res := resTmp.(*remote_api.User) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋremote_apiᚐUser(ctx, field.Selections, res) + return ec.marshalOUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋremote_apiᚐUser(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -775,7 +775,7 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -798,7 +798,7 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -824,7 +824,7 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__DirectiveLocation2ᚕstring(ctx, field.Selections, res) + return ec.marshalN__DirectiveLocation2ᚕstring(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { @@ -850,7 +850,7 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -876,7 +876,7 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -899,7 +899,7 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -925,7 +925,7 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) graphql.Marshaler { @@ -948,7 +948,7 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -974,7 +974,7 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -997,7 +997,7 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -1023,7 +1023,7 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -1049,7 +1049,7 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -1075,7 +1075,7 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalBoolean2bool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) graphql.Marshaler { @@ -1098,7 +1098,7 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1124,7 +1124,7 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1147,7 +1147,7 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1173,7 +1173,7 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) graphql.Marshaler { @@ -1196,7 +1196,7 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1222,7 +1222,7 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1248,7 +1248,7 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1271,7 +1271,7 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1294,7 +1294,7 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) graphql.Marshaler { @@ -1320,7 +1320,7 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) + return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1346,7 +1346,7 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__TypeKind2string(ctx, field.Selections, res) + return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1369,7 +1369,7 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1392,7 +1392,7 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1422,7 +1422,7 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) + return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1445,7 +1445,7 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1468,7 +1468,7 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1498,7 +1498,7 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1521,7 +1521,7 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) graphql.Marshaler { @@ -1544,7 +1544,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } // endregion **************************** field.gotpl ***************************** @@ -1566,19 +1566,19 @@ func (ec *executionContext) unmarshalInputDateFilter(v interface{}) (models.Date switch k { case "value": var err error - it.Value, err = ec.unmarshalString2string(v) + it.Value, err = ec.unmarshalNString2string(v) if err != nil { return it, err } case "timezone": var err error - it.Timezone, err = ec.unmarshalString2ᚖstring(v) + it.Timezone, err = ec.unmarshalOString2ᚖstring(v) if err != nil { return it, err } case "op": var err error - it.Op, err = ec.unmarshalDATE_FILTER_OP2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(v) + it.Op, err = ec.unmarshalODATE_FILTER_OP2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(v) if err != nil { return it, err } @@ -2012,102 +2012,64 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Schema(ctx, sel, v) -} - -func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.___Type(ctx, sel, v) -} - -func (ec *executionContext) unmarshalDATE_FILTER_OP2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(v interface{}) (*models.DateFilterOp, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalDATE_FILTER_OP2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(v) - return &res, err +func (ec *executionContext) unmarshalNBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) } -func (ec *executionContext) marshalDATE_FILTER_OP2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(ctx context.Context, sel ast.SelectionSet, v *models.DateFilterOp) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return v +func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + return graphql.MarshalBoolean(v) } -func (ec *executionContext) marshalElement2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx context.Context, sel ast.SelectionSet, v *models.Element) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._Element(ctx, sel, v) +func (ec *executionContext) unmarshalNDateFilter2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilter(v interface{}) (models.DateFilter, error) { + return ec.unmarshalInputDateFilter(v) } -func (ec *executionContext) unmarshalErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(v interface{}) (*models.ErrorType, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalErrorType2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(v) - return &res, err +func (ec *executionContext) marshalNElement2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx context.Context, sel ast.SelectionSet, v models.Element) graphql.Marshaler { + return ec._Element(ctx, sel, &v) } -func (ec *executionContext) marshalErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(ctx context.Context, sel ast.SelectionSet, v *models.ErrorType) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return v +func (ec *executionContext) unmarshalNString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) } -func (ec *executionContext) marshalViewer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐViewer(ctx context.Context, sel ast.SelectionSet, v *models.Viewer) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._Viewer(ctx, sel, v) +func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) } -func (ec *executionContext) marshalUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋremote_apiᚐUser(ctx context.Context, sel ast.SelectionSet, v *remote_api.User) graphql.Marshaler { - if v == nil { - return graphql.Null +func (ec *executionContext) unmarshalNString2ᚕstring(v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } } - return ec._User(ctx, sel, v) -} - -func (ec *executionContext) unmarshalInt2ᚖint(v interface{}) (*int, error) { - if v == nil { - return nil, nil + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshalNString2string(vSlice[i]) + if err != nil { + return nil, err + } } - res, err := ec.unmarshalInt2int(v) - return &res, err + return res, nil } -func (ec *executionContext) marshalInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { - if v == nil { - return graphql.Null +func (ec *executionContext) marshalNString2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNString2string(ctx, sel, v[i]) } - return ec.marshalInt2int(ctx, sel, *v) -} -func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalString2string(v) - return &res, err + return ret } -func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec.marshalString2string(ctx, sel, *v) +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { + return ec.___Directive(ctx, sel, &v) } -func (ec *executionContext) marshalElement2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx context.Context, sel ast.SelectionSet, v []*models.Element) graphql.Marshaler { +func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2125,7 +2087,7 @@ func (ec *executionContext) marshalElement2ᚕᚖgithubᚗcomᚋ99designsᚋgqlg if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalElement2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx, sel, v[i]) + ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2138,7 +2100,15 @@ func (ec *executionContext) marshalElement2ᚕᚖgithubᚗcomᚋ99designsᚋgqlg return ret } -func (ec *executionContext) unmarshalBoolean2ᚕbool(v interface{}) ([]bool, error) { +func (ec *executionContext) unmarshalN__DirectiveLocation2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -2148,9 +2118,9 @@ func (ec *executionContext) unmarshalBoolean2ᚕbool(v interface{}) ([]bool, err } } var err error - res := make([]bool, len(vSlice)) + res := make([]string, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalBoolean2bool(vSlice[i]) + res[i], err = ec.unmarshalN__DirectiveLocation2string(vSlice[i]) if err != nil { return nil, err } @@ -2158,16 +2128,7 @@ func (ec *executionContext) unmarshalBoolean2ᚕbool(v interface{}) ([]bool, err return res, nil } -func (ec *executionContext) marshalBoolean2ᚕbool(ctx context.Context, sel ast.SelectionSet, v []bool) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - for i := range v { - ret[i] = ec.marshalBoolean2bool(ctx, sel, v[i]) - } - - return ret -} - -func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { +func (ec *executionContext) marshalN__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2185,7 +2146,7 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) + ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2198,38 +2159,19 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql return ret } -func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - rctx := &graphql.ResolverContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(i int) { - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } +func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { + return ec.___EnumValue(ctx, sel, &v) +} - } - wg.Wait() - return ret +func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { + return ec.___Field(ctx, sel, &v) } -func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { +func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { + return ec.___InputValue(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2247,7 +2189,7 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2260,7 +2202,11 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { +func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + return ec.___Type(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2278,7 +2224,7 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2291,38 +2237,33 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq return ret } -func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - rctx := &graphql.ResolverContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithResolverContext(ctx, rctx) - f := func(i int) { - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) +func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") } - + return graphql.Null } - wg.Wait() - return ret + return ec.___Type(ctx, sel, v) +} + +func (ec *executionContext) unmarshalN__TypeKind2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalOBoolean2bool(v interface{}) (bool, error) { + return graphql.UnmarshalBoolean(v) +} + +func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + return graphql.MarshalBoolean(v) } -func (ec *executionContext) unmarshalString2ᚕstring(v interface{}) ([]string, error) { +func (ec *executionContext) unmarshalOBoolean2ᚕbool(v interface{}) ([]bool, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -2332,9 +2273,9 @@ func (ec *executionContext) unmarshalString2ᚕstring(v interface{}) ([]string, } } var err error - res := make([]string, len(vSlice)) + res := make([]bool, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalString2string(vSlice[i]) + res[i], err = ec.unmarshalNBoolean2bool(vSlice[i]) if err != nil { return nil, err } @@ -2342,36 +2283,44 @@ func (ec *executionContext) unmarshalString2ᚕstring(v interface{}) ([]string, return res, nil } -func (ec *executionContext) marshalString2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { +func (ec *executionContext) marshalOBoolean2ᚕbool(ctx context.Context, sel ast.SelectionSet, v []bool) graphql.Marshaler { ret := make(graphql.Array, len(v)) for i := range v { - ret[i] = ec.marshalString2string(ctx, sel, v[i]) + ret[i] = ec.marshalNBoolean2bool(ctx, sel, v[i]) } return ret } -func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { - var vSlice []interface{} - if v != nil { - if tmp1, ok := v.([]interface{}); ok { - vSlice = tmp1 - } else { - vSlice = []interface{}{v} - } +func (ec *executionContext) unmarshalODATE_FILTER_OP2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(v interface{}) (models.DateFilterOp, error) { + var res models.DateFilterOp + return res, res.UnmarshalGQL(v) +} + +func (ec *executionContext) marshalODATE_FILTER_OP2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(ctx context.Context, sel ast.SelectionSet, v models.DateFilterOp) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalODATE_FILTER_OP2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(v interface{}) (*models.DateFilterOp, error) { + if v == nil { + return nil, nil } - var err error - res := make([]string, len(vSlice)) - for i := range vSlice { - res[i], err = ec.unmarshal__DirectiveLocation2string(vSlice[i]) - if err != nil { - return nil, err - } + res, err := ec.unmarshalODATE_FILTER_OP2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(v) + return &res, err +} + +func (ec *executionContext) marshalODATE_FILTER_OP2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(ctx context.Context, sel ast.SelectionSet, v *models.DateFilterOp) graphql.Marshaler { + if v == nil { + return graphql.Null } - return res, nil + return v } -func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { +func (ec *executionContext) marshalOElement2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx context.Context, sel ast.SelectionSet, v models.Element) graphql.Marshaler { + return ec._Element(ctx, sel, &v) +} + +func (ec *executionContext) marshalOElement2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx context.Context, sel ast.SelectionSet, v []*models.Element) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2389,7 +2338,7 @@ func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Con if !isLen1 { defer wg.Done() } - ret[i] = ec.marshal__DirectiveLocation2string(ctx, sel, v[i]) + ret[i] = ec.marshalOElement2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx, sel, v[i]) } if isLen1 { f(i) @@ -2402,102 +2351,249 @@ func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Con return ret } -func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { - return graphql.UnmarshalBoolean(v) +func (ec *executionContext) marshalOElement2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx context.Context, sel ast.SelectionSet, v *models.Element) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Element(ctx, sel, v) } -func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) +func (ec *executionContext) unmarshalOErrorType2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(v interface{}) (models.ErrorType, error) { + var res models.ErrorType + return res, res.UnmarshalGQL(v) } -func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) +func (ec *executionContext) marshalOErrorType2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(ctx context.Context, sel ast.SelectionSet, v models.ErrorType) graphql.Marshaler { + return v } -func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) +func (ec *executionContext) unmarshalOErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(v interface{}) (*models.ErrorType, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOErrorType2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(v) + return &res, err } -func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) +func (ec *executionContext) marshalOErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(ctx context.Context, sel ast.SelectionSet, v *models.ErrorType) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v } -func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) +func (ec *executionContext) unmarshalOInt2int(v interface{}) (int, error) { + return graphql.UnmarshalInt(v) } -func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) +func (ec *executionContext) marshalOInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { + return graphql.MarshalInt(v) } -func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) +func (ec *executionContext) unmarshalOInt2ᚖint(v interface{}) (*int, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOInt2int(v) + return &res, err } -func (ec *executionContext) unmarshalDateFilter2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilter(v interface{}) (models.DateFilter, error) { - return ec.unmarshalInputDateFilter(v) +func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOInt2int(ctx, sel, *v) } -func (ec *executionContext) unmarshalDATE_FILTER_OP2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(v interface{}) (models.DateFilterOp, error) { - var res models.DateFilterOp - return res, res.UnmarshalGQL(v) +func (ec *executionContext) unmarshalOString2string(v interface{}) (string, error) { + return graphql.UnmarshalString(v) } -func (ec *executionContext) marshalDATE_FILTER_OP2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(ctx context.Context, sel ast.SelectionSet, v models.DateFilterOp) graphql.Marshaler { - return v +func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) } -func (ec *executionContext) marshalElement2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx context.Context, sel ast.SelectionSet, v models.Element) graphql.Marshaler { - return ec._Element(ctx, sel, &v) +func (ec *executionContext) unmarshalOString2ᚖstring(v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOString2string(v) + return &res, err } -func (ec *executionContext) unmarshalErrorType2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(v interface{}) (models.ErrorType, error) { - var res models.ErrorType - return res, res.UnmarshalGQL(v) +func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOString2string(ctx, sel, *v) } -func (ec *executionContext) marshalErrorType2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(ctx context.Context, sel ast.SelectionSet, v models.ErrorType) graphql.Marshaler { - return v +func (ec *executionContext) marshalOUser2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋremote_apiᚐUser(ctx context.Context, sel ast.SelectionSet, v remote_api.User) graphql.Marshaler { + return ec._User(ctx, sel, &v) } -func (ec *executionContext) marshalViewer2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐViewer(ctx context.Context, sel ast.SelectionSet, v models.Viewer) graphql.Marshaler { +func (ec *executionContext) marshalOUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋremote_apiᚐUser(ctx context.Context, sel ast.SelectionSet, v *remote_api.User) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._User(ctx, sel, v) +} + +func (ec *executionContext) marshalOViewer2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐViewer(ctx context.Context, sel ast.SelectionSet, v models.Viewer) graphql.Marshaler { return ec._Viewer(ctx, sel, &v) } -func (ec *executionContext) marshalUser2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋremote_apiᚐUser(ctx context.Context, sel ast.SelectionSet, v remote_api.User) graphql.Marshaler { - return ec._User(ctx, sel, &v) +func (ec *executionContext) marshalOViewer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐViewer(ctx context.Context, sel ast.SelectionSet, v *models.Viewer) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Viewer(ctx, sel, v) } -func (ec *executionContext) unmarshalInt2int(v interface{}) (int, error) { - return graphql.UnmarshalInt(v) +func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret } -func (ec *executionContext) marshalInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - return graphql.MarshalInt(v) +func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret } -func (ec *executionContext) unmarshalString2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) +func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret } -func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) +func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { + return ec.___Schema(ctx, sel, &v) } -func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) +func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Schema(ctx, sel, v) } -func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) +func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + return ec.___Type(ctx, sel, &v) } -func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, error) { - return graphql.UnmarshalString(v) +func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + rctx := &graphql.ResolverContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithResolverContext(ctx, rctx) + f := func(i int) { + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret } -func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) +func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Type(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** From 50f7d9c846f48a0824946aa4f3ca0b7d9fc572cd Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Wed, 6 Feb 2019 15:42:58 +1100 Subject: [PATCH 068/147] Add input field directives back in --- codegen/args.gotpl | 4 +- codegen/config/binder.go | 52 ++-- codegen/input.gotpl | 36 ++- codegen/testserver/generated.go | 329 +++++++++++---------- codegen/testserver/generated_test.go | 84 +++--- codegen/testserver/schema.graphql | 4 +- codegen/type.gotpl | 10 +- example/chat/generated.go | 40 +-- example/config/generated.go | 42 +-- example/dataloader/generated.go | 44 +-- example/scalars/generated.go | 68 ++--- example/selection/generated.go | 32 +- example/starwars/generated.go | 122 ++++---- example/todo/generated.go | 56 ++-- example/type-system-extension/generated.go | 42 +-- integration/generated.go | 70 ++--- 16 files changed, 537 insertions(+), 498 deletions(-) diff --git a/codegen/args.gotpl b/codegen/args.gotpl index df615a71fbd..cab7327fe85 100644 --- a/codegen/args.gotpl +++ b/codegen/args.gotpl @@ -6,7 +6,7 @@ func (ec *executionContext) {{ $name }}(ctx context.Context, rawArgs map[string] var arg{{$i}} {{ $arg.TypeReference.GO | ref}} if tmp, ok := rawArgs[{{$arg.Name|quote}}]; ok { {{- if $arg.Directives }} - getArg0 := func(ctx context.Context) (interface{}, error) { return ec.{{ $arg.TypeReference.UnmarshalFunc }}(tmp) } + getArg0 := func(ctx context.Context) (interface{}, error) { return ec.{{ $arg.TypeReference.UnmarshalFunc }}(ctx, tmp) } {{- range $i, $directive := $arg.Directives }} getArg{{add $i 1}} := func(ctx context.Context) (res interface{}, err error) { @@ -30,7 +30,7 @@ func (ec *executionContext) {{ $name }}(ctx context.Context, rawArgs map[string] return nil, fmt.Errorf(`unexpected type %T from directive, should be {{ $arg.TypeReference.GO }}`, tmp) } {{- else }} - arg{{$i}}, err = ec.{{ $arg.TypeReference.UnmarshalFunc }}(tmp) + arg{{$i}}, err = ec.{{ $arg.TypeReference.UnmarshalFunc }}(ctx, tmp) if err != nil { return nil, err } diff --git a/codegen/config/binder.go b/codegen/config/binder.go index 5830941f4a2..7af8cbfe502 100644 --- a/codegen/config/binder.go +++ b/codegen/config/binder.go @@ -154,7 +154,7 @@ type TypeReference struct { Unmarshaler *types.Func // When using external marshalling functions this will point to the Unmarshal function } -func (ref TypeReference) Elem() *TypeReference { +func (ref *TypeReference) Elem() *TypeReference { if p, isPtr := ref.GO.(*types.Pointer); isPtr { return &TypeReference{ GO: p.Elem(), @@ -177,26 +177,26 @@ func (ref TypeReference) Elem() *TypeReference { return nil } -func (t TypeReference) IsPtr() bool { +func (t *TypeReference) IsPtr() bool { _, isPtr := t.GO.(*types.Pointer) return isPtr } -func (t TypeReference) IsSlice() bool { +func (t *TypeReference) IsSlice() bool { _, isSlice := t.GO.(*types.Slice) return isSlice } -func (t TypeReference) IsNamed() bool { +func (t *TypeReference) IsNamed() bool { _, isSlice := t.GO.(*types.Named) return isSlice } -func (t TypeReference) IsScalar() bool { +func (t *TypeReference) IsScalar() bool { return t.Definition.Kind == ast.Scalar } -func (t TypeReference) SelfMarshalling() bool { +func (t *TypeReference) SelfMarshalling() bool { it := t.GO if ptr, isPtr := it.(*types.Pointer); isPtr { it = ptr.Elem() @@ -215,7 +215,26 @@ func (t TypeReference) SelfMarshalling() bool { return false } -func (t TypeReference) UniquenessKey() string { +func (t *TypeReference) SelfUnmarshalling() bool { + it := t.GO + if ptr, isPtr := it.(*types.Pointer); isPtr { + it = ptr.Elem() + } + namedType, ok := it.(*types.Named) + if !ok { + return false + } + + for i := 0; i < namedType.NumMethods(); i++ { + switch namedType.Method(i).Name() { + case "UnmarshalGQL": + return true + } + } + return false +} + +func (t *TypeReference) UniquenessKey() string { var nullability = "O" if t.GQL.NonNull { nullability = "N" @@ -224,7 +243,7 @@ func (t TypeReference) UniquenessKey() string { return nullability + t.Definition.Name + "2" + templates.TypeIdentifier(t.GO) } -func (t TypeReference) MarshalFunc() string { +func (t *TypeReference) MarshalFunc() string { if t.Definition == nil { panic(errors.New("Definition missing for " + t.GQL.Name())) } @@ -236,7 +255,7 @@ func (t TypeReference) MarshalFunc() string { return "marshal" + t.UniquenessKey() } -func (t TypeReference) UnmarshalFunc() string { +func (t *TypeReference) UnmarshalFunc() string { if t.Definition == nil { panic(errors.New("Definition missing for " + t.GQL.Name())) } @@ -306,21 +325,6 @@ func (b *Binder) TypeReference(schemaType *ast.Type) (ret *TypeReference, err er ref.GO = obj.Type() } - if namedType, ok := ref.GO.(*types.Named); ok && ref.Unmarshaler == nil { - hasUnmarshal := false - for i := 0; i < namedType.NumMethods(); i++ { - switch namedType.Method(i).Name() { - case "UnmarshalGQL": - hasUnmarshal = true - } - } - - // Special case to reference generated unmarshal functions - if !hasUnmarshal { - ref.Unmarshaler = types.NewFunc(0, b.cfg.Exec.Pkg(), "ec.unmarshalInput"+schemaType.Name(), nil) - } - } - ref.GO = b.CopyModifiersFromAst(schemaType, def.Kind != ast.Interface, ref.GO) return ref, nil diff --git a/codegen/input.gotpl b/codegen/input.gotpl index 2897d7f3ebf..7345bf4fe16 100644 --- a/codegen/input.gotpl +++ b/codegen/input.gotpl @@ -1,6 +1,6 @@ {{- range $input := .Inputs }} {{- if not .HasUnmarshal }} - func (ec *executionContext) unmarshalInput{{ .Name }}(v interface{}) ({{.Type | ref}}, error) { + func (ec *executionContext) unmarshalInput{{ .Name }}(ctx context.Context, v interface{}) ({{.Type | ref}}, error) { var it {{.Type | ref}} var asMap = v.(map[string]interface{}) {{ range $field := .Fields}} @@ -16,10 +16,36 @@ {{- range $field := .Fields }} case {{$field.Name|quote}}: var err error - it.{{$field.GoFieldName}}, err = ec.{{ $field.TypeReference.UnmarshalFunc }}(v) - if err != nil { - return it, err - } + {{- if $field.Directives }} + getField0 := func(ctx context.Context) (interface{}, error) { return ec.{{ $field.TypeReference.UnmarshalFunc }}(ctx, v) } + + {{- range $i, $directive := $field.Directives }} + getField{{add $i 1}} := func(ctx context.Context) (res interface{}, err error) { + {{- range $dArg := $directive.Args }} + {{- if and $dArg.TypeReference.IsPtr ( notNil "Value" $dArg ) }} + {{ $dArg.VarName }} := {{ $dArg.Value | dump }} + {{- end }} + {{- end }} + n := getField{{$i}} + return ec.directives.{{$directive.Name|ucFirst}}({{$directive.ResolveArgs "it" "n" }}) + } + {{- end }} + + tmp, err := getField{{$field.Directives|len}}(ctx) + if err != nil { + return it, err + } + if data, ok := tmp.({{ $field.TypeReference.GO }}) ; ok { + it.{{$field.GoFieldName}} = data + } else { + return it, fmt.Errorf(`unexpected type %T from directive, should be {{ $field.TypeReference.GO }}`, tmp) + } + {{- else }} + it.{{$field.GoFieldName}}, err = ec.{{ $field.TypeReference.UnmarshalFunc }}(ctx, v) + if err != nil { + return it, err + } + {{- end }} {{- end }} } } diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index d556e070d47..ffa08771d18 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -43,9 +43,9 @@ type ResolverRoot interface { } type DirectiveRoot struct { - Length func(ctx context.Context, obj interface{}, next graphql.Resolver, min int, max *int, message string) (res interface{}, err error) + Length func(ctx context.Context, obj interface{}, next graphql.Resolver, min int, max *int) (res interface{}, err error) - Range func(ctx context.Context, obj interface{}, next graphql.Resolver, min *int, max *int, message *string) (res interface{}, err error) + Range func(ctx context.Context, obj interface{}, next graphql.Resolver, min *int, max *int) (res interface{}, err error) } type ComplexityRoot struct { @@ -604,7 +604,7 @@ func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{} } n := next next = func(ctx context.Context) (interface{}, error) { - return ec.directives.Length(ctx, obj, n, args["min"].(int), args["max"].(*int), args["message"].(string)) + return ec.directives.Length(ctx, obj, n, args["min"].(int), args["max"].(*int)) } } case "range": @@ -617,7 +617,7 @@ func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{} } n := next next = func(ctx context.Context) (interface{}, error) { - return ec.directives.Range(ctx, obj, n, args["min"].(*int), args["max"].(*int), args["message"].(*string)) + return ec.directives.Range(ctx, obj, n, args["min"].(*int), args["max"].(*int)) } } } @@ -812,8 +812,8 @@ type EmbeddedPointer { Title: String } -directive @length(min: Int!, max: Int, message: String!) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION -directive @range(min: Int = 0, max: Int, message: String) on ARGUMENT_DEFINITION +directive @length(min: Int!, max: Int) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION +directive @range(min: Int = 0, max: Int) on ARGUMENT_DEFINITION enum Status { OK @@ -831,7 +831,7 @@ func (ec *executionContext) dir_length_args(ctx context.Context, rawArgs map[str args := map[string]interface{}{} var arg0 int if tmp, ok := rawArgs["min"]; ok { - arg0, err = ec.unmarshalNInt2int(tmp) + arg0, err = ec.unmarshalNInt2int(ctx, tmp) if err != nil { return nil, err } @@ -839,20 +839,12 @@ func (ec *executionContext) dir_length_args(ctx context.Context, rawArgs map[str args["min"] = arg0 var arg1 *int if tmp, ok := rawArgs["max"]; ok { - arg1, err = ec.unmarshalOInt2ᚖint(tmp) + arg1, err = ec.unmarshalOInt2ᚖint(ctx, tmp) if err != nil { return nil, err } } args["max"] = arg1 - var arg2 string - if tmp, ok := rawArgs["message"]; ok { - arg2, err = ec.unmarshalNString2string(tmp) - if err != nil { - return nil, err - } - } - args["message"] = arg2 return args, nil } @@ -861,7 +853,7 @@ func (ec *executionContext) dir_range_args(ctx context.Context, rawArgs map[stri args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["min"]; ok { - arg0, err = ec.unmarshalOInt2ᚖint(tmp) + arg0, err = ec.unmarshalOInt2ᚖint(ctx, tmp) if err != nil { return nil, err } @@ -869,20 +861,12 @@ func (ec *executionContext) dir_range_args(ctx context.Context, rawArgs map[stri args["min"] = arg0 var arg1 *int if tmp, ok := rawArgs["max"]; ok { - arg1, err = ec.unmarshalOInt2ᚖint(tmp) + arg1, err = ec.unmarshalOInt2ᚖint(ctx, tmp) if err != nil { return nil, err } } args["max"] = arg1 - var arg2 *string - if tmp, ok := rawArgs["message"]; ok { - arg2, err = ec.unmarshalOString2ᚖstring(tmp) - if err != nil { - return nil, err - } - } - args["message"] = arg2 return args, nil } @@ -891,7 +875,7 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = ec.unmarshalNString2string(tmp) + arg0, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -905,11 +889,11 @@ func (ec *executionContext) field_Query_directiveArg_args(ctx context.Context, r args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["arg"]; ok { - getArg0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalNString2string(tmp) } + getArg0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalNString2string(ctx, tmp) } getArg1 := func(ctx context.Context) (res interface{}, err error) { max := 255 n := getArg0 - return ec.directives.Length(ctx, tmp, n, 1, &max, "invalid length") + return ec.directives.Length(ctx, tmp, n, 1, &max) } tmp, err = getArg1(ctx) @@ -931,7 +915,7 @@ func (ec *executionContext) field_Query_directiveInputNullable_args(ctx context. args := map[string]interface{}{} var arg0 *InputDirectives if tmp, ok := rawArgs["arg"]; ok { - arg0, err = ec.unmarshalOInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(tmp) + arg0, err = ec.unmarshalOInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(ctx, tmp) if err != nil { return nil, err } @@ -945,7 +929,7 @@ func (ec *executionContext) field_Query_directiveInput_args(ctx context.Context, args := map[string]interface{}{} var arg0 InputDirectives if tmp, ok := rawArgs["arg"]; ok { - arg0, err = ec.unmarshalNInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(tmp) + arg0, err = ec.unmarshalNInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(ctx, tmp) if err != nil { return nil, err } @@ -959,11 +943,11 @@ func (ec *executionContext) field_Query_directiveNullableArg_args(ctx context.Co args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["arg"]; ok { - getArg0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOInt2ᚖint(tmp) } + getArg0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOInt2ᚖint(ctx, tmp) } getArg1 := func(ctx context.Context) (res interface{}, err error) { min := 0 n := getArg0 - return ec.directives.Range(ctx, tmp, n, &min, nil, nil) + return ec.directives.Range(ctx, tmp, n, &min, nil) } tmp, err = getArg1(ctx) @@ -979,11 +963,11 @@ func (ec *executionContext) field_Query_directiveNullableArg_args(ctx context.Co args["arg"] = arg0 var arg1 *int if tmp, ok := rawArgs["arg2"]; ok { - getArg0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOInt2ᚖint(tmp) } + getArg0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalOInt2ᚖint(ctx, tmp) } getArg1 := func(ctx context.Context) (res interface{}, err error) { min := 0 n := getArg0 - return ec.directives.Range(ctx, tmp, n, &min, nil, nil) + return ec.directives.Range(ctx, tmp, n, &min, nil) } tmp, err = getArg1(ctx) @@ -1005,7 +989,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["break"]; ok { - arg0, err = ec.unmarshalNString2string(tmp) + arg0, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -1013,7 +997,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["break"] = arg0 var arg1 string if tmp, ok := rawArgs["default"]; ok { - arg1, err = ec.unmarshalNString2string(tmp) + arg1, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -1021,7 +1005,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["default"] = arg1 var arg2 string if tmp, ok := rawArgs["func"]; ok { - arg2, err = ec.unmarshalNString2string(tmp) + arg2, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -1029,7 +1013,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["func"] = arg2 var arg3 string if tmp, ok := rawArgs["interface"]; ok { - arg3, err = ec.unmarshalNString2string(tmp) + arg3, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -1037,7 +1021,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["interface"] = arg3 var arg4 string if tmp, ok := rawArgs["select"]; ok { - arg4, err = ec.unmarshalNString2string(tmp) + arg4, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -1045,7 +1029,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["select"] = arg4 var arg5 string if tmp, ok := rawArgs["case"]; ok { - arg5, err = ec.unmarshalNString2string(tmp) + arg5, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -1053,7 +1037,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["case"] = arg5 var arg6 string if tmp, ok := rawArgs["defer"]; ok { - arg6, err = ec.unmarshalNString2string(tmp) + arg6, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -1061,7 +1045,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["defer"] = arg6 var arg7 string if tmp, ok := rawArgs["go"]; ok { - arg7, err = ec.unmarshalNString2string(tmp) + arg7, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -1069,7 +1053,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["go"] = arg7 var arg8 string if tmp, ok := rawArgs["map"]; ok { - arg8, err = ec.unmarshalNString2string(tmp) + arg8, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -1077,7 +1061,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["map"] = arg8 var arg9 string if tmp, ok := rawArgs["struct"]; ok { - arg9, err = ec.unmarshalNString2string(tmp) + arg9, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -1085,7 +1069,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["struct"] = arg9 var arg10 string if tmp, ok := rawArgs["chan"]; ok { - arg10, err = ec.unmarshalNString2string(tmp) + arg10, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -1093,7 +1077,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["chan"] = arg10 var arg11 string if tmp, ok := rawArgs["else"]; ok { - arg11, err = ec.unmarshalNString2string(tmp) + arg11, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -1101,7 +1085,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["else"] = arg11 var arg12 string if tmp, ok := rawArgs["goto"]; ok { - arg12, err = ec.unmarshalNString2string(tmp) + arg12, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -1109,7 +1093,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["goto"] = arg12 var arg13 string if tmp, ok := rawArgs["package"]; ok { - arg13, err = ec.unmarshalNString2string(tmp) + arg13, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -1117,7 +1101,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["package"] = arg13 var arg14 string if tmp, ok := rawArgs["switch"]; ok { - arg14, err = ec.unmarshalNString2string(tmp) + arg14, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -1125,7 +1109,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["switch"] = arg14 var arg15 string if tmp, ok := rawArgs["const"]; ok { - arg15, err = ec.unmarshalNString2string(tmp) + arg15, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -1133,7 +1117,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["const"] = arg15 var arg16 string if tmp, ok := rawArgs["fallthrough"]; ok { - arg16, err = ec.unmarshalNString2string(tmp) + arg16, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -1141,7 +1125,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["fallthrough"] = arg16 var arg17 string if tmp, ok := rawArgs["if"]; ok { - arg17, err = ec.unmarshalNString2string(tmp) + arg17, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -1149,7 +1133,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["if"] = arg17 var arg18 string if tmp, ok := rawArgs["range"]; ok { - arg18, err = ec.unmarshalNString2string(tmp) + arg18, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -1157,7 +1141,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["range"] = arg18 var arg19 string if tmp, ok := rawArgs["type"]; ok { - arg19, err = ec.unmarshalNString2string(tmp) + arg19, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -1165,7 +1149,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["type"] = arg19 var arg20 string if tmp, ok := rawArgs["continue"]; ok { - arg20, err = ec.unmarshalNString2string(tmp) + arg20, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -1173,7 +1157,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["continue"] = arg20 var arg21 string if tmp, ok := rawArgs["for"]; ok { - arg21, err = ec.unmarshalNString2string(tmp) + arg21, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -1181,7 +1165,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["for"] = arg21 var arg22 string if tmp, ok := rawArgs["import"]; ok { - arg22, err = ec.unmarshalNString2string(tmp) + arg22, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -1189,7 +1173,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["import"] = arg22 var arg23 string if tmp, ok := rawArgs["return"]; ok { - arg23, err = ec.unmarshalNString2string(tmp) + arg23, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -1197,7 +1181,7 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra args["return"] = arg23 var arg24 string if tmp, ok := rawArgs["var"]; ok { - arg24, err = ec.unmarshalNString2string(tmp) + arg24, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -1211,7 +1195,7 @@ func (ec *executionContext) field_Query_keywords_args(ctx context.Context, rawAr args := map[string]interface{}{} var arg0 *Keywords if tmp, ok := rawArgs["input"]; ok { - arg0, err = ec.unmarshalOKeywords2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(tmp) + arg0, err = ec.unmarshalOKeywords2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(ctx, tmp) if err != nil { return nil, err } @@ -1225,7 +1209,7 @@ func (ec *executionContext) field_Query_mapInput_args(ctx context.Context, rawAr args := map[string]interface{}{} var arg0 map[string]interface{} if tmp, ok := rawArgs["input"]; ok { - arg0, err = ec.unmarshalOChanges2map(tmp) + arg0, err = ec.unmarshalOChanges2map(ctx, tmp) if err != nil { return nil, err } @@ -1239,7 +1223,7 @@ func (ec *executionContext) field_Query_nestedInputs_args(ctx context.Context, r args := map[string]interface{}{} var arg0 [][]*OuterInput if tmp, ok := rawArgs["input"]; ok { - arg0, err = ec.unmarshalOOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(tmp) + arg0, err = ec.unmarshalOOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(ctx, tmp) if err != nil { return nil, err } @@ -1253,7 +1237,7 @@ func (ec *executionContext) field_Query_nullableArg_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["arg"]; ok { - arg0, err = ec.unmarshalOInt2ᚖint(tmp) + arg0, err = ec.unmarshalOInt2ᚖint(ctx, tmp) if err != nil { return nil, err } @@ -1267,7 +1251,7 @@ func (ec *executionContext) field_Query_recursive_args(ctx context.Context, rawA args := map[string]interface{}{} var arg0 *RecursiveInputSlice if tmp, ok := rawArgs["input"]; ok { - arg0, err = ec.unmarshalORecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(tmp) + arg0, err = ec.unmarshalORecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(ctx, tmp) if err != nil { return nil, err } @@ -1281,7 +1265,7 @@ func (ec *executionContext) field_Query_user_args(ctx context.Context, rawArgs m args := map[string]interface{}{} var arg0 int if tmp, ok := rawArgs["id"]; ok { - arg0, err = ec.unmarshalNInt2int(tmp) + arg0, err = ec.unmarshalNInt2int(ctx, tmp) if err != nil { return nil, err } @@ -1295,7 +1279,7 @@ func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalOBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } @@ -1309,7 +1293,7 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalOBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } @@ -3252,7 +3236,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co // region **************************** input.gotpl ***************************** -func (ec *executionContext) unmarshalInputInnerDirectives(v interface{}) (InnerDirectives, error) { +func (ec *executionContext) unmarshalInputInnerDirectives(ctx context.Context, v interface{}) (InnerDirectives, error) { var it InnerDirectives var asMap = v.(map[string]interface{}) @@ -3260,17 +3244,28 @@ func (ec *executionContext) unmarshalInputInnerDirectives(v interface{}) (InnerD switch k { case "message": var err error - it.Message, err = ec.unmarshalNString2string(v) + getField0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalNString2string(ctx, v) } + getField1 := func(ctx context.Context) (res interface{}, err error) { + n := getField0 + return ec.directives.Length(ctx, it, n, 1, nil) + } + + tmp, err := getField1(ctx) if err != nil { return it, err } + if data, ok := tmp.(string); ok { + it.Message = data + } else { + return it, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp) + } } } return it, nil } -func (ec *executionContext) unmarshalInputInnerInput(v interface{}) (InnerInput, error) { +func (ec *executionContext) unmarshalInputInnerInput(ctx context.Context, v interface{}) (InnerInput, error) { var it InnerInput var asMap = v.(map[string]interface{}) @@ -3278,7 +3273,7 @@ func (ec *executionContext) unmarshalInputInnerInput(v interface{}) (InnerInput, switch k { case "id": var err error - it.ID, err = ec.unmarshalNInt2int(v) + it.ID, err = ec.unmarshalNInt2int(ctx, v) if err != nil { return it, err } @@ -3288,7 +3283,7 @@ func (ec *executionContext) unmarshalInputInnerInput(v interface{}) (InnerInput, return it, nil } -func (ec *executionContext) unmarshalInputInputDirectives(v interface{}) (InputDirectives, error) { +func (ec *executionContext) unmarshalInputInputDirectives(ctx context.Context, v interface{}) (InputDirectives, error) { var it InputDirectives var asMap = v.(map[string]interface{}) @@ -3296,19 +3291,31 @@ func (ec *executionContext) unmarshalInputInputDirectives(v interface{}) (InputD switch k { case "text": var err error - it.Text, err = ec.unmarshalNString2string(v) + getField0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalNString2string(ctx, v) } + getField1 := func(ctx context.Context) (res interface{}, err error) { + max := 7 + n := getField0 + return ec.directives.Length(ctx, it, n, 0, &max) + } + + tmp, err := getField1(ctx) if err != nil { return it, err } + if data, ok := tmp.(string); ok { + it.Text = data + } else { + return it, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp) + } case "inner": var err error - it.Inner, err = ec.unmarshalNInnerDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(v) + it.Inner, err = ec.unmarshalNInnerDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(ctx, v) if err != nil { return it, err } case "innerNullable": var err error - it.InnerNullable, err = ec.unmarshalOInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(v) + it.InnerNullable, err = ec.unmarshalOInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(ctx, v) if err != nil { return it, err } @@ -3318,7 +3325,7 @@ func (ec *executionContext) unmarshalInputInputDirectives(v interface{}) (InputD return it, nil } -func (ec *executionContext) unmarshalInputKeywords(v interface{}) (Keywords, error) { +func (ec *executionContext) unmarshalInputKeywords(ctx context.Context, v interface{}) (Keywords, error) { var it Keywords var asMap = v.(map[string]interface{}) @@ -3326,151 +3333,151 @@ func (ec *executionContext) unmarshalInputKeywords(v interface{}) (Keywords, err switch k { case "break": var err error - it.Break, err = ec.unmarshalNString2string(v) + it.Break, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "default": var err error - it.Default, err = ec.unmarshalNString2string(v) + it.Default, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "func": var err error - it.Func, err = ec.unmarshalNString2string(v) + it.Func, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "interface": var err error - it.Interface, err = ec.unmarshalNString2string(v) + it.Interface, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "select": var err error - it.Select, err = ec.unmarshalNString2string(v) + it.Select, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "case": var err error - it.Case, err = ec.unmarshalNString2string(v) + it.Case, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "defer": var err error - it.Defer, err = ec.unmarshalNString2string(v) + it.Defer, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "go": var err error - it.Go, err = ec.unmarshalNString2string(v) + it.Go, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "map": var err error - it.Map, err = ec.unmarshalNString2string(v) + it.Map, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "struct": var err error - it.Struct, err = ec.unmarshalNString2string(v) + it.Struct, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "chan": var err error - it.Chan, err = ec.unmarshalNString2string(v) + it.Chan, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "else": var err error - it.Else, err = ec.unmarshalNString2string(v) + it.Else, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "goto": var err error - it.Goto, err = ec.unmarshalNString2string(v) + it.Goto, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "package": var err error - it.Package, err = ec.unmarshalNString2string(v) + it.Package, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "switch": var err error - it.Switch, err = ec.unmarshalNString2string(v) + it.Switch, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "const": var err error - it.Const, err = ec.unmarshalNString2string(v) + it.Const, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "fallthrough": var err error - it.Fallthrough, err = ec.unmarshalNString2string(v) + it.Fallthrough, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "if": var err error - it.If, err = ec.unmarshalNString2string(v) + it.If, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "range": var err error - it.Range, err = ec.unmarshalNString2string(v) + it.Range, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "type": var err error - it.Type, err = ec.unmarshalNString2string(v) + it.Type, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "continue": var err error - it.Continue, err = ec.unmarshalNString2string(v) + it.Continue, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "for": var err error - it.For, err = ec.unmarshalNString2string(v) + it.For, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "import": var err error - it.Import, err = ec.unmarshalNString2string(v) + it.Import, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "return": var err error - it.Return, err = ec.unmarshalNString2string(v) + it.Return, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "var": var err error - it.Var, err = ec.unmarshalNString2string(v) + it.Var, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } @@ -3480,7 +3487,7 @@ func (ec *executionContext) unmarshalInputKeywords(v interface{}) (Keywords, err return it, nil } -func (ec *executionContext) unmarshalInputOuterInput(v interface{}) (OuterInput, error) { +func (ec *executionContext) unmarshalInputOuterInput(ctx context.Context, v interface{}) (OuterInput, error) { var it OuterInput var asMap = v.(map[string]interface{}) @@ -3488,7 +3495,7 @@ func (ec *executionContext) unmarshalInputOuterInput(v interface{}) (OuterInput, switch k { case "inner": var err error - it.Inner, err = ec.unmarshalNInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerInput(v) + it.Inner, err = ec.unmarshalNInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerInput(ctx, v) if err != nil { return it, err } @@ -3498,7 +3505,7 @@ func (ec *executionContext) unmarshalInputOuterInput(v interface{}) (OuterInput, return it, nil } -func (ec *executionContext) unmarshalInputRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { +func (ec *executionContext) unmarshalInputRecursiveInputSlice(ctx context.Context, v interface{}) (RecursiveInputSlice, error) { var it RecursiveInputSlice var asMap = v.(map[string]interface{}) @@ -3506,7 +3513,7 @@ func (ec *executionContext) unmarshalInputRecursiveInputSlice(v interface{}) (Re switch k { case "self": var err error - it.Self, err = ec.unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v) + it.Self, err = ec.unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(ctx, v) if err != nil { return it, err } @@ -4303,7 +4310,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (ec *executionContext) unmarshalNBoolean2bool(v interface{}) (bool, error) { +func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } @@ -4311,7 +4318,7 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se return graphql.MarshalBoolean(v) } -func (ec *executionContext) unmarshalNID2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalID(v) } @@ -4319,23 +4326,23 @@ func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.Selec return graphql.MarshalID(v) } -func (ec *executionContext) unmarshalNInnerDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(v interface{}) (InnerDirectives, error) { - return ec.unmarshalInputInnerDirectives(v) +func (ec *executionContext) unmarshalNInnerDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(ctx context.Context, v interface{}) (InnerDirectives, error) { + return ec.unmarshalInputInnerDirectives(ctx, v) } -func (ec *executionContext) unmarshalNInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerInput(v interface{}) (InnerInput, error) { - return ec.unmarshalInputInnerInput(v) +func (ec *executionContext) unmarshalNInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerInput(ctx context.Context, v interface{}) (InnerInput, error) { + return ec.unmarshalInputInnerInput(ctx, v) } func (ec *executionContext) marshalNInnerObject2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerObject(ctx context.Context, sel ast.SelectionSet, v InnerObject) graphql.Marshaler { return ec._InnerObject(ctx, sel, &v) } -func (ec *executionContext) unmarshalNInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v interface{}) (InputDirectives, error) { - return ec.unmarshalInputInputDirectives(v) +func (ec *executionContext) unmarshalNInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(ctx context.Context, v interface{}) (InputDirectives, error) { + return ec.unmarshalInputInputDirectives(ctx, v) } -func (ec *executionContext) unmarshalNInt2int(v interface{}) (int, error) { +func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{}) (int, error) { return graphql.UnmarshalInt(v) } @@ -4343,11 +4350,11 @@ func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.Selecti return graphql.MarshalInt(v) } -func (ec *executionContext) unmarshalNRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { - return ec.unmarshalInputRecursiveInputSlice(v) +func (ec *executionContext) unmarshalNRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(ctx context.Context, v interface{}) (RecursiveInputSlice, error) { + return ec.unmarshalInputRecursiveInputSlice(ctx, v) } -func (ec *executionContext) unmarshalNString2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -4355,11 +4362,11 @@ func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.S return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalNString2ᚖstring(v interface{}) (*string, error) { +func (ec *executionContext) unmarshalNString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalNString2string(v) + res, err := ec.unmarshalNString2string(ctx, v) return &res, err } @@ -4443,7 +4450,7 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq return ret } -func (ec *executionContext) unmarshalN__DirectiveLocation2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -4451,7 +4458,7 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(ctx context.Context, v interface{}) ([]string, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -4463,7 +4470,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{ var err error res := make([]string, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalN__DirectiveLocation2string(vSlice[i]) + res[i], err = ec.unmarshalN__DirectiveLocation2string(ctx, vSlice[i]) if err != nil { return nil, err } @@ -4590,7 +4597,7 @@ func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec.___Type(ctx, sel, v) } -func (ec *executionContext) unmarshalN__TypeKind2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -4598,7 +4605,7 @@ func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel a return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalOBoolean2bool(v interface{}) (bool, error) { +func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } @@ -4606,11 +4613,11 @@ func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.Se return graphql.MarshalBoolean(v) } -func (ec *executionContext) unmarshalOBoolean2ᚖbool(v interface{}) (*bool, error) { +func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOBoolean2bool(v) + res, err := ec.unmarshalOBoolean2bool(ctx, v) return &res, err } @@ -4621,7 +4628,7 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast return ec.marshalOBoolean2bool(ctx, sel, *v) } -func (ec *executionContext) unmarshalOChanges2map(v interface{}) (map[string]interface{}, error) { +func (ec *executionContext) unmarshalOChanges2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { return v.(map[string]interface{}), nil } @@ -4647,7 +4654,7 @@ func (ec *executionContext) marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec._Error(ctx, sel, v) } -func (ec *executionContext) unmarshalOFloat2float64(v interface{}) (float64, error) { +func (ec *executionContext) unmarshalOFloat2float64(ctx context.Context, v interface{}) (float64, error) { return graphql.UnmarshalFloat(v) } @@ -4655,31 +4662,31 @@ func (ec *executionContext) marshalOFloat2float64(ctx context.Context, sel ast.S return graphql.MarshalFloat(v) } -func (ec *executionContext) unmarshalOInnerDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(v interface{}) (InnerDirectives, error) { - return ec.unmarshalInputInnerDirectives(v) +func (ec *executionContext) unmarshalOInnerDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(ctx context.Context, v interface{}) (InnerDirectives, error) { + return ec.unmarshalInputInnerDirectives(ctx, v) } -func (ec *executionContext) unmarshalOInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(v interface{}) (*InnerDirectives, error) { +func (ec *executionContext) unmarshalOInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(ctx context.Context, v interface{}) (*InnerDirectives, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOInnerDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(v) + res, err := ec.unmarshalOInnerDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(ctx, v) return &res, err } -func (ec *executionContext) unmarshalOInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v interface{}) (InputDirectives, error) { - return ec.unmarshalInputInputDirectives(v) +func (ec *executionContext) unmarshalOInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(ctx context.Context, v interface{}) (InputDirectives, error) { + return ec.unmarshalInputInputDirectives(ctx, v) } -func (ec *executionContext) unmarshalOInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v interface{}) (*InputDirectives, error) { +func (ec *executionContext) unmarshalOInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(ctx context.Context, v interface{}) (*InputDirectives, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(v) + res, err := ec.unmarshalOInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(ctx, v) return &res, err } -func (ec *executionContext) unmarshalOInt2int(v interface{}) (int, error) { +func (ec *executionContext) unmarshalOInt2int(ctx context.Context, v interface{}) (int, error) { return graphql.UnmarshalInt(v) } @@ -4687,11 +4694,11 @@ func (ec *executionContext) marshalOInt2int(ctx context.Context, sel ast.Selecti return graphql.MarshalInt(v) } -func (ec *executionContext) unmarshalOInt2ᚖint(v interface{}) (*int, error) { +func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v interface{}) (*int, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOInt2int(v) + res, err := ec.unmarshalOInt2int(ctx, v) return &res, err } @@ -4724,15 +4731,15 @@ func (ec *executionContext) marshalOIt2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋco return ec._It(ctx, sel, v) } -func (ec *executionContext) unmarshalOKeywords2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(v interface{}) (Keywords, error) { - return ec.unmarshalInputKeywords(v) +func (ec *executionContext) unmarshalOKeywords2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(ctx context.Context, v interface{}) (Keywords, error) { + return ec.unmarshalInputKeywords(ctx, v) } -func (ec *executionContext) unmarshalOKeywords2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(v interface{}) (*Keywords, error) { +func (ec *executionContext) unmarshalOKeywords2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(ctx context.Context, v interface{}) (*Keywords, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOKeywords2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(v) + res, err := ec.unmarshalOKeywords2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(ctx, v) return &res, err } @@ -4747,11 +4754,11 @@ func (ec *executionContext) marshalOModelMethods2ᚖgithubᚗcomᚋ99designsᚋg return ec._ModelMethods(ctx, sel, v) } -func (ec *executionContext) unmarshalOOuterInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) (OuterInput, error) { - return ec.unmarshalInputOuterInput(v) +func (ec *executionContext) unmarshalOOuterInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(ctx context.Context, v interface{}) (OuterInput, error) { + return ec.unmarshalInputOuterInput(ctx, v) } -func (ec *executionContext) unmarshalOOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) ([][]*OuterInput, error) { +func (ec *executionContext) unmarshalOOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(ctx context.Context, v interface{}) ([][]*OuterInput, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -4763,7 +4770,7 @@ func (ec *executionContext) unmarshalOOuterInput2ᚕᚕᚖgithubᚗcomᚋ99desig var err error res := make([][]*OuterInput, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalOOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(vSlice[i]) + res[i], err = ec.unmarshalOOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(ctx, vSlice[i]) if err != nil { return nil, err } @@ -4771,7 +4778,7 @@ func (ec *executionContext) unmarshalOOuterInput2ᚕᚕᚖgithubᚗcomᚋ99desig return res, nil } -func (ec *executionContext) unmarshalOOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) ([]*OuterInput, error) { +func (ec *executionContext) unmarshalOOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(ctx context.Context, v interface{}) ([]*OuterInput, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -4783,7 +4790,7 @@ func (ec *executionContext) unmarshalOOuterInput2ᚕᚖgithubᚗcomᚋ99designs var err error res := make([]*OuterInput, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalOOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(vSlice[i]) + res[i], err = ec.unmarshalOOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(ctx, vSlice[i]) if err != nil { return nil, err } @@ -4791,11 +4798,11 @@ func (ec *executionContext) unmarshalOOuterInput2ᚕᚖgithubᚗcomᚋ99designs return res, nil } -func (ec *executionContext) unmarshalOOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v interface{}) (*OuterInput, error) { +func (ec *executionContext) unmarshalOOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(ctx context.Context, v interface{}) (*OuterInput, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOOuterInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(v) + res, err := ec.unmarshalOOuterInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(ctx, v) return &res, err } @@ -4872,11 +4879,11 @@ func (ec *executionContext) marshalOOuterObject2ᚖgithubᚗcomᚋ99designsᚋgq return ec._OuterObject(ctx, sel, v) } -func (ec *executionContext) unmarshalORecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v interface{}) (RecursiveInputSlice, error) { - return ec.unmarshalInputRecursiveInputSlice(v) +func (ec *executionContext) unmarshalORecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(ctx context.Context, v interface{}) (RecursiveInputSlice, error) { + return ec.unmarshalInputRecursiveInputSlice(ctx, v) } -func (ec *executionContext) unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v interface{}) ([]RecursiveInputSlice, error) { +func (ec *executionContext) unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(ctx context.Context, v interface{}) ([]RecursiveInputSlice, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -4888,7 +4895,7 @@ func (ec *executionContext) unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋ99de var err error res := make([]RecursiveInputSlice, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalNRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(vSlice[i]) + res[i], err = ec.unmarshalNRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(ctx, vSlice[i]) if err != nil { return nil, err } @@ -4896,11 +4903,11 @@ func (ec *executionContext) unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋ99de return res, nil } -func (ec *executionContext) unmarshalORecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v interface{}) (*RecursiveInputSlice, error) { +func (ec *executionContext) unmarshalORecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(ctx context.Context, v interface{}) (*RecursiveInputSlice, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalORecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(v) + res, err := ec.unmarshalORecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(ctx, v) return &res, err } @@ -4939,7 +4946,7 @@ func (ec *executionContext) marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) unmarshalOString2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -4947,11 +4954,11 @@ func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.S return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalOString2ᚖstring(v interface{}) (*string, error) { +func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOString2string(v) + res, err := ec.unmarshalOString2string(ctx, v) return &res, err } diff --git a/codegen/testserver/generated_test.go b/codegen/testserver/generated_test.go index a660f20d8bc..00b5b902466 100644 --- a/codegen/testserver/generated_test.go +++ b/codegen/testserver/generated_test.go @@ -19,7 +19,6 @@ import ( "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" "github.com/99designs/gqlgen/handler" - "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -204,55 +203,56 @@ func TestDirectives(t *testing.T) { NewExecutableSchema(Config{ Resolvers: resolvers, Directives: DirectiveRoot{ - Length: func(ctx context.Context, obj interface{}, next graphql.Resolver, min int, max *int, message string) (res interface{}, err error) { - if d, ok := obj.(string); ok { - if len(d) < min { - return nil, errors.New(message) - } - if max != nil && len(d) > *max { - return nil, errors.New(message) - } - return next(ctx) + Length: func(ctx context.Context, obj interface{}, next graphql.Resolver, min int, max *int) (interface{}, error) { + res, err := next(ctx) + if err != nil { + return nil, err } - return nil, errors.New(message) - }, - Range: func(ctx context.Context, obj interface{}, next graphql.Resolver, min *int, max *int, message *string) (res interface{}, err error) { - if obj == nil { - return next(ctx) + + s := res.(string) + if len(s) < min { + return nil, fmt.Errorf("too short") } - if message == nil { - err = errors.New("range invalid") - } else { - err = errors.New(*message) + if max != nil && len(s) > *max { + return nil, fmt.Errorf("too long") } - if d, ok := obj.(int); ok { - if min != nil && d < *min { - return nil, err + return res, nil + }, + Range: func(ctx context.Context, obj interface{}, next graphql.Resolver, min *int, max *int) (interface{}, error) { + res, err := next(ctx) + if err != nil { + return nil, err + } + + switch res := res.(type) { + case int: + if min != nil && res < *min { + return nil, fmt.Errorf("too small") } - if max != nil && d > *max { - return nil, err + if max != nil && res > *max { + return nil, fmt.Errorf("too large") } return next(ctx) - } - if d, ok := obj.(int64); ok { - if min != nil && int(d) < *min { - return nil, err + + case int64: + if min != nil && int(res) < *min { + return nil, fmt.Errorf("too small") } - if max != nil && int(d) > *max { - return nil, err + if max != nil && int(res) > *max { + return nil, fmt.Errorf("too large") } return next(ctx) - } - if d, ok := obj.(*int); ok { - if min != nil && *d < *min { - return nil, err + + case *int: + if min != nil && *res < *min { + return nil, fmt.Errorf("too small") } - if max != nil && *d > *max { - return nil, err + if max != nil && *res > *max { + return nil, fmt.Errorf("too large") } return next(ctx) } - return nil, err + return nil, fmt.Errorf("unsupported type %T", res) }, }, }), @@ -275,7 +275,7 @@ func TestDirectives(t *testing.T) { err := c.Post(`query { directiveArg(arg: "") }`, &resp) - require.EqualError(t, err, `[{"message":"invalid length","path":["directiveArg"]}]`) + require.EqualError(t, err, `[{"message":"too short","path":["directiveArg"]}]`) require.Nil(t, resp.DirectiveArg) }) t.Run("when function errors on nullable arg directives", func(t *testing.T) { @@ -285,7 +285,7 @@ func TestDirectives(t *testing.T) { err := c.Post(`query { directiveNullableArg(arg: -100) }`, &resp) - require.EqualError(t, err, `[{"message":"range invalid","path":["directiveNullableArg"]}]`) + require.EqualError(t, err, `[{"message":"too small","path":["directiveNullableArg"]}]`) require.Nil(t, resp.DirectiveNullableArg) }) t.Run("when function success on nullable arg directives", func(t *testing.T) { @@ -327,7 +327,7 @@ func TestDirectives(t *testing.T) { err := c.Post(`query { directiveInputNullable(arg: {text:"invalid text",inner:{message:"123"}}) }`, &resp) - require.EqualError(t, err, `[{"message":"not valid","path":["directiveInputNullable"]}]`) + require.EqualError(t, err, `[{"message":"too long","path":["directiveInputNullable"]}]`) require.Nil(t, resp.DirectiveInputNullable) }) t.Run("when function errors on inner directives", func(t *testing.T) { @@ -337,7 +337,7 @@ func TestDirectives(t *testing.T) { err := c.Post(`query { directiveInputNullable(arg: {text:"2",inner:{message:""}}) }`, &resp) - require.EqualError(t, err, `[{"message":"not valid","path":["directiveInputNullable"]}]`) + require.EqualError(t, err, `[{"message":"too short","path":["directiveInputNullable"]}]`) require.Nil(t, resp.DirectiveInputNullable) }) t.Run("when function errors on nullable inner directives", func(t *testing.T) { @@ -347,7 +347,7 @@ func TestDirectives(t *testing.T) { err := c.Post(`query { directiveInputNullable(arg: {text:"success",inner:{message:"1"},innerNullable:{message:""}}) }`, &resp) - require.EqualError(t, err, `[{"message":"not valid","path":["directiveInputNullable"]}]`) + require.EqualError(t, err, `[{"message":"too short","path":["directiveInputNullable"]}]`) require.Nil(t, resp.DirectiveInputNullable) }) t.Run("when function success", func(t *testing.T) { diff --git a/codegen/testserver/schema.graphql b/codegen/testserver/schema.graphql index d08a37d54c7..da8e967569b 100644 --- a/codegen/testserver/schema.graphql +++ b/codegen/testserver/schema.graphql @@ -165,8 +165,8 @@ type EmbeddedPointer { Title: String } -directive @length(min: Int!, max: Int, message: String!) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION -directive @range(min: Int = 0, max: Int, message: String) on ARGUMENT_DEFINITION +directive @length(min: Int!, max: Int) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION +directive @range(min: Int = 0, max: Int) on ARGUMENT_DEFINITION enum Status { OK diff --git a/codegen/type.gotpl b/codegen/type.gotpl index 6e852f96d16..2e343eb9906 100644 --- a/codegen/type.gotpl +++ b/codegen/type.gotpl @@ -1,9 +1,9 @@ {{- range $type := .ReferencedTypes }} {{ with $type.UnmarshalFunc }} - func (ec *executionContext) {{ . }}(v interface{}) ({{ $type.GO | ref }}, error) { + func (ec *executionContext) {{ . }}(ctx context.Context, v interface{}) ({{ $type.GO | ref }}, error) { {{- if $type.IsPtr }} if v == nil { return nil, nil } - res, err := ec.{{ $type.Elem.UnmarshalFunc }}(v) + res, err := ec.{{ $type.Elem.UnmarshalFunc }}(ctx, v) return &res, err {{- else if $type.IsSlice }} var vSlice []interface{} @@ -17,7 +17,7 @@ var err error res := make([]{{$type.GO.Elem | ref}}, len(vSlice)) for i := range vSlice { - res[i], err = ec.{{ $type.Elem.UnmarshalFunc }}(vSlice[i]) + res[i], err = ec.{{ $type.Elem.UnmarshalFunc }}(ctx, vSlice[i]) if err != nil { return nil, err } @@ -28,9 +28,11 @@ return {{ $type.Unmarshaler | call }}(v) {{- else if eq ($type.GO | ref) "map[string]interface{}" }} return v.(map[string]interface{}), nil - {{- else -}} + {{- else if $type.SelfUnmarshalling -}} var res {{ $type.GO | ref }} return res, res.UnmarshalGQL(v) + {{- else }} + return ec.unmarshalInput{{ $type.GQL.Name }}(ctx, v) {{- end }} {{- end }} } diff --git a/example/chat/generated.go b/example/chat/generated.go index 91491bf0250..bed886e40a9 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -313,7 +313,7 @@ func (ec *executionContext) field_Mutation_post_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["text"]; ok { - arg0, err = ec.unmarshalNString2string(tmp) + arg0, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -321,7 +321,7 @@ func (ec *executionContext) field_Mutation_post_args(ctx context.Context, rawArg args["text"] = arg0 var arg1 string if tmp, ok := rawArgs["username"]; ok { - arg1, err = ec.unmarshalNString2string(tmp) + arg1, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -329,7 +329,7 @@ func (ec *executionContext) field_Mutation_post_args(ctx context.Context, rawArg args["username"] = arg1 var arg2 string if tmp, ok := rawArgs["roomName"]; ok { - arg2, err = ec.unmarshalNString2string(tmp) + arg2, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -343,7 +343,7 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = ec.unmarshalNString2string(tmp) + arg0, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -357,7 +357,7 @@ func (ec *executionContext) field_Query_room_args(ctx context.Context, rawArgs m args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = ec.unmarshalNString2string(tmp) + arg0, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -371,7 +371,7 @@ func (ec *executionContext) field_Subscription_messageAdded_args(ctx context.Con args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["roomName"]; ok { - arg0, err = ec.unmarshalNString2string(tmp) + arg0, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -385,7 +385,7 @@ func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalOBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } @@ -399,7 +399,7 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalOBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } @@ -1931,7 +1931,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (ec *executionContext) unmarshalNBoolean2bool(v interface{}) (bool, error) { +func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } @@ -1939,7 +1939,7 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se return graphql.MarshalBoolean(v) } -func (ec *executionContext) unmarshalNID2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalID(v) } @@ -1982,7 +1982,7 @@ func (ec *executionContext) marshalNMessage2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) unmarshalNString2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -1990,7 +1990,7 @@ func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.S return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalNTime2timeᚐTime(v interface{}) (time.Time, error) { +func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v interface{}) (time.Time, error) { return graphql.UnmarshalTime(v) } @@ -2033,7 +2033,7 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq return ret } -func (ec *executionContext) unmarshalN__DirectiveLocation2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -2041,7 +2041,7 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(ctx context.Context, v interface{}) ([]string, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -2053,7 +2053,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{ var err error res := make([]string, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalN__DirectiveLocation2string(vSlice[i]) + res[i], err = ec.unmarshalN__DirectiveLocation2string(ctx, vSlice[i]) if err != nil { return nil, err } @@ -2180,7 +2180,7 @@ func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec.___Type(ctx, sel, v) } -func (ec *executionContext) unmarshalN__TypeKind2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -2188,7 +2188,7 @@ func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel a return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalOBoolean2bool(v interface{}) (bool, error) { +func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } @@ -2207,7 +2207,7 @@ func (ec *executionContext) marshalOChatroom2ᚖgithubᚗcomᚋ99designsᚋgqlge return ec._Chatroom(ctx, sel, v) } -func (ec *executionContext) unmarshalOString2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -2215,11 +2215,11 @@ func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.S return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalOString2ᚖstring(v interface{}) (*string, error) { +func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOString2string(v) + res, err := ec.unmarshalOString2string(ctx, v) return &res, err } diff --git a/example/config/generated.go b/example/config/generated.go index 1348176e7f1..5948b5904b5 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -270,7 +270,7 @@ func (ec *executionContext) field_Mutation_createTodo_args(ctx context.Context, args := map[string]interface{}{} var arg0 NewTodo if tmp, ok := rawArgs["input"]; ok { - arg0, err = ec.unmarshalNNewTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐNewTodo(tmp) + arg0, err = ec.unmarshalNNewTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐNewTodo(ctx, tmp) if err != nil { return nil, err } @@ -284,7 +284,7 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = ec.unmarshalNString2string(tmp) + arg0, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -298,7 +298,7 @@ func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalOBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } @@ -312,7 +312,7 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalOBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } @@ -1418,7 +1418,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co // region **************************** input.gotpl ***************************** -func (ec *executionContext) unmarshalInputNewTodo(v interface{}) (NewTodo, error) { +func (ec *executionContext) unmarshalInputNewTodo(ctx context.Context, v interface{}) (NewTodo, error) { var it NewTodo var asMap = v.(map[string]interface{}) @@ -1426,13 +1426,13 @@ func (ec *executionContext) unmarshalInputNewTodo(v interface{}) (NewTodo, error switch k { case "text": var err error - it.Text, err = ec.unmarshalNString2string(v) + it.Text, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "UserID": var err error - it.UserID, err = ec.unmarshalNString2string(v) + it.UserID, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } @@ -1848,7 +1848,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (ec *executionContext) unmarshalNBoolean2bool(v interface{}) (bool, error) { +func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } @@ -1856,7 +1856,7 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se return graphql.MarshalBoolean(v) } -func (ec *executionContext) unmarshalNID2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalID(v) } @@ -1864,7 +1864,7 @@ func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.Selec return graphql.MarshalID(v) } -func (ec *executionContext) unmarshalNInt2int(v interface{}) (int, error) { +func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{}) (int, error) { return graphql.UnmarshalInt(v) } @@ -1872,11 +1872,11 @@ func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.Selecti return graphql.MarshalInt(v) } -func (ec *executionContext) unmarshalNNewTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐNewTodo(v interface{}) (NewTodo, error) { - return ec.unmarshalInputNewTodo(v) +func (ec *executionContext) unmarshalNNewTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐNewTodo(ctx context.Context, v interface{}) (NewTodo, error) { + return ec.unmarshalInputNewTodo(ctx, v) } -func (ec *executionContext) unmarshalNString2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -1958,7 +1958,7 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq return ret } -func (ec *executionContext) unmarshalN__DirectiveLocation2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -1966,7 +1966,7 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(ctx context.Context, v interface{}) ([]string, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -1978,7 +1978,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{ var err error res := make([]string, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalN__DirectiveLocation2string(vSlice[i]) + res[i], err = ec.unmarshalN__DirectiveLocation2string(ctx, vSlice[i]) if err != nil { return nil, err } @@ -2105,7 +2105,7 @@ func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec.___Type(ctx, sel, v) } -func (ec *executionContext) unmarshalN__TypeKind2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -2113,7 +2113,7 @@ func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel a return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalOBoolean2bool(v interface{}) (bool, error) { +func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } @@ -2121,7 +2121,7 @@ func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.Se return graphql.MarshalBoolean(v) } -func (ec *executionContext) unmarshalOString2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -2129,11 +2129,11 @@ func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.S return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalOString2ᚖstring(v interface{}) (*string, error) { +func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOString2string(v) + res, err := ec.unmarshalOString2string(ctx, v) return &res, err } diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index 78761ab4fcf..d879aabae63 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -323,7 +323,7 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = ec.unmarshalNString2string(tmp) + arg0, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -337,7 +337,7 @@ func (ec *executionContext) field_Query_torture1d_args(ctx context.Context, rawA args := map[string]interface{}{} var arg0 []int if tmp, ok := rawArgs["customerIds"]; ok { - arg0, err = ec.unmarshalOInt2ᚕint(tmp) + arg0, err = ec.unmarshalOInt2ᚕint(ctx, tmp) if err != nil { return nil, err } @@ -351,7 +351,7 @@ func (ec *executionContext) field_Query_torture2d_args(ctx context.Context, rawA args := map[string]interface{}{} var arg0 [][]int if tmp, ok := rawArgs["customerIds"]; ok { - arg0, err = ec.unmarshalOInt2ᚕᚕint(tmp) + arg0, err = ec.unmarshalOInt2ᚕᚕint(ctx, tmp) if err != nil { return nil, err } @@ -365,7 +365,7 @@ func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalOBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } @@ -379,7 +379,7 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalOBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } @@ -2082,7 +2082,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (ec *executionContext) unmarshalNBoolean2bool(v interface{}) (bool, error) { +func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } @@ -2094,7 +2094,7 @@ func (ec *executionContext) marshalNCustomer2githubᚗcomᚋ99designsᚋgqlgen return ec._Customer(ctx, sel, &v) } -func (ec *executionContext) unmarshalNFloat2float64(v interface{}) (float64, error) { +func (ec *executionContext) unmarshalNFloat2float64(ctx context.Context, v interface{}) (float64, error) { return graphql.UnmarshalFloat(v) } @@ -2102,7 +2102,7 @@ func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.S return graphql.MarshalFloat(v) } -func (ec *executionContext) unmarshalNInt2int(v interface{}) (int, error) { +func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{}) (int, error) { return graphql.UnmarshalInt(v) } @@ -2118,7 +2118,7 @@ func (ec *executionContext) marshalNOrder2githubᚗcomᚋ99designsᚋgqlgenᚋex return ec._Order(ctx, sel, &v) } -func (ec *executionContext) unmarshalNString2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -2126,7 +2126,7 @@ func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.S return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalNTime2timeᚐTime(v interface{}) (time.Time, error) { +func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v interface{}) (time.Time, error) { return graphql.UnmarshalTime(v) } @@ -2169,7 +2169,7 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq return ret } -func (ec *executionContext) unmarshalN__DirectiveLocation2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -2177,7 +2177,7 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(ctx context.Context, v interface{}) ([]string, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -2189,7 +2189,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{ var err error res := make([]string, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalN__DirectiveLocation2string(vSlice[i]) + res[i], err = ec.unmarshalN__DirectiveLocation2string(ctx, vSlice[i]) if err != nil { return nil, err } @@ -2316,7 +2316,7 @@ func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec.___Type(ctx, sel, v) } -func (ec *executionContext) unmarshalN__TypeKind2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -2335,7 +2335,7 @@ func (ec *executionContext) marshalOAddress2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec._Address(ctx, sel, v) } -func (ec *executionContext) unmarshalOBoolean2bool(v interface{}) (bool, error) { +func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } @@ -2405,7 +2405,7 @@ func (ec *executionContext) marshalOCustomer2ᚕᚕgithubᚗcomᚋ99designsᚋgq return ret } -func (ec *executionContext) unmarshalOInt2ᚕint(v interface{}) ([]int, error) { +func (ec *executionContext) unmarshalOInt2ᚕint(ctx context.Context, v interface{}) ([]int, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -2417,7 +2417,7 @@ func (ec *executionContext) unmarshalOInt2ᚕint(v interface{}) ([]int, error) { var err error res := make([]int, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalNInt2int(vSlice[i]) + res[i], err = ec.unmarshalNInt2int(ctx, vSlice[i]) if err != nil { return nil, err } @@ -2434,7 +2434,7 @@ func (ec *executionContext) marshalOInt2ᚕint(ctx context.Context, sel ast.Sele return ret } -func (ec *executionContext) unmarshalOInt2ᚕᚕint(v interface{}) ([][]int, error) { +func (ec *executionContext) unmarshalOInt2ᚕᚕint(ctx context.Context, v interface{}) ([][]int, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -2446,7 +2446,7 @@ func (ec *executionContext) unmarshalOInt2ᚕᚕint(v interface{}) ([][]int, err var err error res := make([][]int, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalOInt2ᚕint(vSlice[i]) + res[i], err = ec.unmarshalOInt2ᚕint(ctx, vSlice[i]) if err != nil { return nil, err } @@ -2525,7 +2525,7 @@ func (ec *executionContext) marshalOOrder2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) unmarshalOString2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -2533,11 +2533,11 @@ func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.S return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalOString2ᚖstring(v interface{}) (*string, error) { +func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOString2string(v) + res, err := ec.unmarshalOString2string(ctx, v) return &res, err } diff --git a/example/scalars/generated.go b/example/scalars/generated.go index d5858509666..a8f60b0aeb1 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -294,7 +294,7 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = ec.unmarshalNString2string(tmp) + arg0, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -308,7 +308,7 @@ func (ec *executionContext) field_Query_search_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 *model.SearchArgs if tmp, ok := rawArgs["input"]; ok { - arg0, err = ec.unmarshalOSearchArgs2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(tmp) + arg0, err = ec.unmarshalOSearchArgs2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(ctx, tmp) if err != nil { return nil, err } @@ -322,7 +322,7 @@ func (ec *executionContext) field_Query_user_args(ctx context.Context, rawArgs m args := map[string]interface{}{} var arg0 external.ObjectID if tmp, ok := rawArgs["id"]; ok { - arg0, err = ec.unmarshalNID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(tmp) + arg0, err = ec.unmarshalNID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(ctx, tmp) if err != nil { return nil, err } @@ -336,7 +336,7 @@ func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalOBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } @@ -350,7 +350,7 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalOBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } @@ -1526,7 +1526,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co // region **************************** input.gotpl ***************************** -func (ec *executionContext) unmarshalInputSearchArgs(v interface{}) (model.SearchArgs, error) { +func (ec *executionContext) unmarshalInputSearchArgs(ctx context.Context, v interface{}) (model.SearchArgs, error) { var it model.SearchArgs var asMap = v.(map[string]interface{}) @@ -1534,19 +1534,19 @@ func (ec *executionContext) unmarshalInputSearchArgs(v interface{}) (model.Searc switch k { case "location": var err error - it.Location, err = ec.unmarshalOPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(v) + it.Location, err = ec.unmarshalOPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx, v) if err != nil { return it, err } case "createdAfter": var err error - it.CreatedAfter, err = ec.unmarshalOTimestamp2ᚖtimeᚐTime(v) + it.CreatedAfter, err = ec.unmarshalOTimestamp2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } case "isBanned": var err error - it.IsBanned, err = ec.unmarshalOBanned2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐBanned(v) + it.IsBanned, err = ec.unmarshalOBanned2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐBanned(ctx, v) if err != nil { return it, err } @@ -1944,7 +1944,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (ec *executionContext) unmarshalNBanned2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐBanned(v interface{}) (model.Banned, error) { +func (ec *executionContext) unmarshalNBanned2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐBanned(ctx context.Context, v interface{}) (model.Banned, error) { var res model.Banned return res, res.UnmarshalGQL(v) } @@ -1953,7 +1953,7 @@ func (ec *executionContext) marshalNBanned2githubᚗcomᚋ99designsᚋgqlgenᚋe return v } -func (ec *executionContext) unmarshalNBoolean2bool(v interface{}) (bool, error) { +func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } @@ -1961,7 +1961,7 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se return graphql.MarshalBoolean(v) } -func (ec *executionContext) unmarshalNID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(v interface{}) (external.ObjectID, error) { +func (ec *executionContext) unmarshalNID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(ctx context.Context, v interface{}) (external.ObjectID, error) { return model.UnmarshalID(v) } @@ -1969,7 +1969,7 @@ func (ec *executionContext) marshalNID2githubᚗcomᚋ99designsᚋgqlgenᚋexamp return model.MarshalID(v) } -func (ec *executionContext) unmarshalNPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(v interface{}) (model.Point, error) { +func (ec *executionContext) unmarshalNPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, v interface{}) (model.Point, error) { var res model.Point return res, res.UnmarshalGQL(v) } @@ -1978,7 +1978,7 @@ func (ec *executionContext) marshalNPoint2githubᚗcomᚋ99designsᚋgqlgenᚋex return v } -func (ec *executionContext) unmarshalNString2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -2056,7 +2056,7 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq return ret } -func (ec *executionContext) unmarshalN__DirectiveLocation2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -2064,7 +2064,7 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(ctx context.Context, v interface{}) ([]string, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -2076,7 +2076,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{ var err error res := make([]string, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalN__DirectiveLocation2string(vSlice[i]) + res[i], err = ec.unmarshalN__DirectiveLocation2string(ctx, vSlice[i]) if err != nil { return nil, err } @@ -2203,7 +2203,7 @@ func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec.___Type(ctx, sel, v) } -func (ec *executionContext) unmarshalN__TypeKind2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -2215,7 +2215,7 @@ func (ec *executionContext) marshalOAddress2githubᚗcomᚋ99designsᚋgqlgenᚋ return ec._Address(ctx, sel, &v) } -func (ec *executionContext) unmarshalOBanned2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐBanned(v interface{}) (model.Banned, error) { +func (ec *executionContext) unmarshalOBanned2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐBanned(ctx context.Context, v interface{}) (model.Banned, error) { var res model.Banned return res, res.UnmarshalGQL(v) } @@ -2224,7 +2224,7 @@ func (ec *executionContext) marshalOBanned2githubᚗcomᚋ99designsᚋgqlgenᚋe return v } -func (ec *executionContext) unmarshalOBoolean2bool(v interface{}) (bool, error) { +func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } @@ -2232,7 +2232,7 @@ func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.Se return graphql.MarshalBoolean(v) } -func (ec *executionContext) unmarshalOPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(v interface{}) (model.Point, error) { +func (ec *executionContext) unmarshalOPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, v interface{}) (model.Point, error) { var res model.Point return res, res.UnmarshalGQL(v) } @@ -2241,11 +2241,11 @@ func (ec *executionContext) marshalOPoint2githubᚗcomᚋ99designsᚋgqlgenᚋex return v } -func (ec *executionContext) unmarshalOPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(v interface{}) (*model.Point, error) { +func (ec *executionContext) unmarshalOPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, v interface{}) (*model.Point, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(v) + res, err := ec.unmarshalOPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx, v) return &res, err } @@ -2256,19 +2256,19 @@ func (ec *executionContext) marshalOPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgen return v } -func (ec *executionContext) unmarshalOSearchArgs2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v interface{}) (model.SearchArgs, error) { - return ec.unmarshalInputSearchArgs(v) +func (ec *executionContext) unmarshalOSearchArgs2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(ctx context.Context, v interface{}) (model.SearchArgs, error) { + return ec.unmarshalInputSearchArgs(ctx, v) } -func (ec *executionContext) unmarshalOSearchArgs2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v interface{}) (*model.SearchArgs, error) { +func (ec *executionContext) unmarshalOSearchArgs2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(ctx context.Context, v interface{}) (*model.SearchArgs, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOSearchArgs2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v) + res, err := ec.unmarshalOSearchArgs2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(ctx, v) return &res, err } -func (ec *executionContext) unmarshalOString2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -2276,11 +2276,11 @@ func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.S return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalOString2ᚖstring(v interface{}) (*string, error) { +func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOString2string(v) + res, err := ec.unmarshalOString2string(ctx, v) return &res, err } @@ -2291,7 +2291,7 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as return ec.marshalOString2string(ctx, sel, *v) } -func (ec *executionContext) unmarshalOTier2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐTier(v interface{}) (model.Tier, error) { +func (ec *executionContext) unmarshalOTier2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐTier(ctx context.Context, v interface{}) (model.Tier, error) { var res model.Tier return res, res.UnmarshalGQL(v) } @@ -2300,7 +2300,7 @@ func (ec *executionContext) marshalOTier2githubᚗcomᚋ99designsᚋgqlgenᚋexa return v } -func (ec *executionContext) unmarshalOTimestamp2timeᚐTime(v interface{}) (time.Time, error) { +func (ec *executionContext) unmarshalOTimestamp2timeᚐTime(ctx context.Context, v interface{}) (time.Time, error) { return model.UnmarshalTimestamp(v) } @@ -2308,11 +2308,11 @@ func (ec *executionContext) marshalOTimestamp2timeᚐTime(ctx context.Context, s return model.MarshalTimestamp(v) } -func (ec *executionContext) unmarshalOTimestamp2ᚖtimeᚐTime(v interface{}) (*time.Time, error) { +func (ec *executionContext) unmarshalOTimestamp2ᚖtimeᚐTime(ctx context.Context, v interface{}) (*time.Time, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOTimestamp2timeᚐTime(v) + res, err := ec.unmarshalOTimestamp2timeᚐTime(ctx, v) return &res, err } diff --git a/example/selection/generated.go b/example/selection/generated.go index cd674795ed1..f7a1b3b4236 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -241,7 +241,7 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = ec.unmarshalNString2string(tmp) + arg0, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -255,7 +255,7 @@ func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalOBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } @@ -269,7 +269,7 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalOBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } @@ -1731,7 +1731,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (ec *executionContext) unmarshalNBoolean2bool(v interface{}) (bool, error) { +func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } @@ -1743,7 +1743,7 @@ func (ec *executionContext) marshalNEvent2githubᚗcomᚋ99designsᚋgqlgenᚋex return ec._Event(ctx, sel, &v) } -func (ec *executionContext) unmarshalNString2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -1751,7 +1751,7 @@ func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.S return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalNTime2timeᚐTime(v interface{}) (time.Time, error) { +func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v interface{}) (time.Time, error) { return graphql.UnmarshalTime(v) } @@ -1794,7 +1794,7 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq return ret } -func (ec *executionContext) unmarshalN__DirectiveLocation2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -1802,7 +1802,7 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(ctx context.Context, v interface{}) ([]string, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -1814,7 +1814,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{ var err error res := make([]string, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalN__DirectiveLocation2string(vSlice[i]) + res[i], err = ec.unmarshalN__DirectiveLocation2string(ctx, vSlice[i]) if err != nil { return nil, err } @@ -1941,7 +1941,7 @@ func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec.___Type(ctx, sel, v) } -func (ec *executionContext) unmarshalN__TypeKind2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -1949,7 +1949,7 @@ func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel a return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalOBoolean2bool(v interface{}) (bool, error) { +func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } @@ -1988,7 +1988,7 @@ func (ec *executionContext) marshalOEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) unmarshalOString2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -1996,7 +1996,7 @@ func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.S return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalOString2ᚕstring(v interface{}) ([]string, error) { +func (ec *executionContext) unmarshalOString2ᚕstring(ctx context.Context, v interface{}) ([]string, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -2008,7 +2008,7 @@ func (ec *executionContext) unmarshalOString2ᚕstring(v interface{}) ([]string, var err error res := make([]string, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalNString2string(vSlice[i]) + res[i], err = ec.unmarshalNString2string(ctx, vSlice[i]) if err != nil { return nil, err } @@ -2025,11 +2025,11 @@ func (ec *executionContext) marshalOString2ᚕstring(ctx context.Context, sel as return ret } -func (ec *executionContext) unmarshalOString2ᚖstring(v interface{}) (*string, error) { +func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOString2string(v) + res, err := ec.unmarshalOString2string(ctx, v) return &res, err } diff --git a/example/starwars/generated.go b/example/starwars/generated.go index 88165adc243..052473f2f19 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -702,7 +702,7 @@ func (ec *executionContext) field_Droid_friendsConnection_args(ctx context.Conte args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["first"]; ok { - arg0, err = ec.unmarshalOInt2ᚖint(tmp) + arg0, err = ec.unmarshalOInt2ᚖint(ctx, tmp) if err != nil { return nil, err } @@ -710,7 +710,7 @@ func (ec *executionContext) field_Droid_friendsConnection_args(ctx context.Conte args["first"] = arg0 var arg1 *string if tmp, ok := rawArgs["after"]; ok { - arg1, err = ec.unmarshalOID2ᚖstring(tmp) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) if err != nil { return nil, err } @@ -724,7 +724,7 @@ func (ec *executionContext) field_Human_friendsConnection_args(ctx context.Conte args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["first"]; ok { - arg0, err = ec.unmarshalOInt2ᚖint(tmp) + arg0, err = ec.unmarshalOInt2ᚖint(ctx, tmp) if err != nil { return nil, err } @@ -732,7 +732,7 @@ func (ec *executionContext) field_Human_friendsConnection_args(ctx context.Conte args["first"] = arg0 var arg1 *string if tmp, ok := rawArgs["after"]; ok { - arg1, err = ec.unmarshalOID2ᚖstring(tmp) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) if err != nil { return nil, err } @@ -746,7 +746,7 @@ func (ec *executionContext) field_Human_height_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 LengthUnit if tmp, ok := rawArgs["unit"]; ok { - arg0, err = ec.unmarshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(tmp) + arg0, err = ec.unmarshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(ctx, tmp) if err != nil { return nil, err } @@ -760,7 +760,7 @@ func (ec *executionContext) field_Mutation_createReview_args(ctx context.Context args := map[string]interface{}{} var arg0 Episode if tmp, ok := rawArgs["episode"]; ok { - arg0, err = ec.unmarshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(tmp) + arg0, err = ec.unmarshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx, tmp) if err != nil { return nil, err } @@ -768,7 +768,7 @@ func (ec *executionContext) field_Mutation_createReview_args(ctx context.Context args["episode"] = arg0 var arg1 Review if tmp, ok := rawArgs["review"]; ok { - arg1, err = ec.unmarshalNReviewInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(tmp) + arg1, err = ec.unmarshalNReviewInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx, tmp) if err != nil { return nil, err } @@ -782,7 +782,7 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = ec.unmarshalNString2string(tmp) + arg0, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -796,7 +796,7 @@ func (ec *executionContext) field_Query_character_args(ctx context.Context, rawA args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["id"]; ok { - arg0, err = ec.unmarshalNID2string(tmp) + arg0, err = ec.unmarshalNID2string(ctx, tmp) if err != nil { return nil, err } @@ -810,7 +810,7 @@ func (ec *executionContext) field_Query_droid_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["id"]; ok { - arg0, err = ec.unmarshalNID2string(tmp) + arg0, err = ec.unmarshalNID2string(ctx, tmp) if err != nil { return nil, err } @@ -824,7 +824,7 @@ func (ec *executionContext) field_Query_hero_args(ctx context.Context, rawArgs m args := map[string]interface{}{} var arg0 *Episode if tmp, ok := rawArgs["episode"]; ok { - arg0, err = ec.unmarshalOEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(tmp) + arg0, err = ec.unmarshalOEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx, tmp) if err != nil { return nil, err } @@ -838,7 +838,7 @@ func (ec *executionContext) field_Query_human_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["id"]; ok { - arg0, err = ec.unmarshalNID2string(tmp) + arg0, err = ec.unmarshalNID2string(ctx, tmp) if err != nil { return nil, err } @@ -852,7 +852,7 @@ func (ec *executionContext) field_Query_reviews_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 Episode if tmp, ok := rawArgs["episode"]; ok { - arg0, err = ec.unmarshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(tmp) + arg0, err = ec.unmarshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx, tmp) if err != nil { return nil, err } @@ -860,7 +860,7 @@ func (ec *executionContext) field_Query_reviews_args(ctx context.Context, rawArg args["episode"] = arg0 var arg1 *time.Time if tmp, ok := rawArgs["since"]; ok { - arg1, err = ec.unmarshalOTime2ᚖtimeᚐTime(tmp) + arg1, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, tmp) if err != nil { return nil, err } @@ -874,7 +874,7 @@ func (ec *executionContext) field_Query_search_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["text"]; ok { - arg0, err = ec.unmarshalNString2string(tmp) + arg0, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -888,7 +888,7 @@ func (ec *executionContext) field_Query_starship_args(ctx context.Context, rawAr args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["id"]; ok { - arg0, err = ec.unmarshalNID2string(tmp) + arg0, err = ec.unmarshalNID2string(ctx, tmp) if err != nil { return nil, err } @@ -902,7 +902,7 @@ func (ec *executionContext) field_Starship_length_args(ctx context.Context, rawA args := map[string]interface{}{} var arg0 *LengthUnit if tmp, ok := rawArgs["unit"]; ok { - arg0, err = ec.unmarshalOLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(tmp) + arg0, err = ec.unmarshalOLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(ctx, tmp) if err != nil { return nil, err } @@ -916,7 +916,7 @@ func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalOBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } @@ -930,7 +930,7 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalOBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } @@ -2819,7 +2819,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co // region **************************** input.gotpl ***************************** -func (ec *executionContext) unmarshalInputReviewInput(v interface{}) (Review, error) { +func (ec *executionContext) unmarshalInputReviewInput(ctx context.Context, v interface{}) (Review, error) { var it Review var asMap = v.(map[string]interface{}) @@ -2827,19 +2827,19 @@ func (ec *executionContext) unmarshalInputReviewInput(v interface{}) (Review, er switch k { case "stars": var err error - it.Stars, err = ec.unmarshalNInt2int(v) + it.Stars, err = ec.unmarshalNInt2int(ctx, v) if err != nil { return it, err } case "commentary": var err error - it.Commentary, err = ec.unmarshalOString2ᚖstring(v) + it.Commentary, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } case "time": var err error - it.Time, err = ec.unmarshalOTime2timeᚐTime(v) + it.Time, err = ec.unmarshalOTime2timeᚐTime(ctx, v) if err != nil { return it, err } @@ -3552,7 +3552,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (ec *executionContext) unmarshalNBoolean2bool(v interface{}) (bool, error) { +func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } @@ -3564,7 +3564,7 @@ func (ec *executionContext) marshalNCharacter2githubᚗcomᚋ99designsᚋgqlgen return ec._Character(ctx, sel, &v) } -func (ec *executionContext) unmarshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v interface{}) (Episode, error) { +func (ec *executionContext) unmarshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, v interface{}) (Episode, error) { var res Episode return res, res.UnmarshalGQL(v) } @@ -3573,7 +3573,7 @@ func (ec *executionContext) marshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋ return v } -func (ec *executionContext) unmarshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v interface{}) ([]Episode, error) { +func (ec *executionContext) unmarshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, v interface{}) ([]Episode, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -3585,7 +3585,7 @@ func (ec *executionContext) unmarshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlg var err error res := make([]Episode, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(vSlice[i]) + res[i], err = ec.unmarshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx, vSlice[i]) if err != nil { return nil, err } @@ -3624,7 +3624,7 @@ func (ec *executionContext) marshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) unmarshalNFloat2float64(v interface{}) (float64, error) { +func (ec *executionContext) unmarshalNFloat2float64(ctx context.Context, v interface{}) (float64, error) { return graphql.UnmarshalFloat(v) } @@ -3640,7 +3640,7 @@ func (ec *executionContext) marshalNFriendsEdge2githubᚗcomᚋ99designsᚋgqlge return ec._FriendsEdge(ctx, sel, &v) } -func (ec *executionContext) unmarshalNID2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalID(v) } @@ -3648,7 +3648,7 @@ func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.Selec return graphql.MarshalID(v) } -func (ec *executionContext) unmarshalNInt2int(v interface{}) (int, error) { +func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{}) (int, error) { return graphql.UnmarshalInt(v) } @@ -3656,7 +3656,7 @@ func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.Selecti return graphql.MarshalInt(v) } -func (ec *executionContext) unmarshalNInt2ᚕint(v interface{}) ([]int, error) { +func (ec *executionContext) unmarshalNInt2ᚕint(ctx context.Context, v interface{}) ([]int, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -3668,7 +3668,7 @@ func (ec *executionContext) unmarshalNInt2ᚕint(v interface{}) ([]int, error) { var err error res := make([]int, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalNInt2int(vSlice[i]) + res[i], err = ec.unmarshalNInt2int(ctx, vSlice[i]) if err != nil { return nil, err } @@ -3685,7 +3685,7 @@ func (ec *executionContext) marshalNInt2ᚕint(ctx context.Context, sel ast.Sele return ret } -func (ec *executionContext) unmarshalNInt2ᚕᚕint(v interface{}) ([][]int, error) { +func (ec *executionContext) unmarshalNInt2ᚕᚕint(ctx context.Context, v interface{}) ([][]int, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -3697,7 +3697,7 @@ func (ec *executionContext) unmarshalNInt2ᚕᚕint(v interface{}) ([][]int, err var err error res := make([][]int, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalNInt2ᚕint(vSlice[i]) + res[i], err = ec.unmarshalNInt2ᚕint(ctx, vSlice[i]) if err != nil { return nil, err } @@ -3753,8 +3753,8 @@ func (ec *executionContext) marshalNReview2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) unmarshalNReviewInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(v interface{}) (Review, error) { - return ec.unmarshalInputReviewInput(v) +func (ec *executionContext) unmarshalNReviewInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx context.Context, v interface{}) (Review, error) { + return ec.unmarshalInputReviewInput(ctx, v) } func (ec *executionContext) marshalNSearchResult2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐSearchResult(ctx context.Context, sel ast.SelectionSet, v SearchResult) graphql.Marshaler { @@ -3796,7 +3796,7 @@ func (ec *executionContext) marshalNStarship2githubᚗcomᚋ99designsᚋgqlgen return ec._Starship(ctx, sel, &v) } -func (ec *executionContext) unmarshalNString2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -3839,7 +3839,7 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq return ret } -func (ec *executionContext) unmarshalN__DirectiveLocation2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -3847,7 +3847,7 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(ctx context.Context, v interface{}) ([]string, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -3859,7 +3859,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{ var err error res := make([]string, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalN__DirectiveLocation2string(vSlice[i]) + res[i], err = ec.unmarshalN__DirectiveLocation2string(ctx, vSlice[i]) if err != nil { return nil, err } @@ -3986,7 +3986,7 @@ func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec.___Type(ctx, sel, v) } -func (ec *executionContext) unmarshalN__TypeKind2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -3994,7 +3994,7 @@ func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel a return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalOBoolean2bool(v interface{}) (bool, error) { +func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } @@ -4048,7 +4048,7 @@ func (ec *executionContext) marshalODroid2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec._Droid(ctx, sel, v) } -func (ec *executionContext) unmarshalOEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v interface{}) (Episode, error) { +func (ec *executionContext) unmarshalOEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, v interface{}) (Episode, error) { var res Episode return res, res.UnmarshalGQL(v) } @@ -4057,11 +4057,11 @@ func (ec *executionContext) marshalOEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋ return v } -func (ec *executionContext) unmarshalOEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v interface{}) (*Episode, error) { +func (ec *executionContext) unmarshalOEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, v interface{}) (*Episode, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(v) + res, err := ec.unmarshalOEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx, v) return &res, err } @@ -4072,7 +4072,7 @@ func (ec *executionContext) marshalOEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgen return v } -func (ec *executionContext) unmarshalOFloat2float64(v interface{}) (float64, error) { +func (ec *executionContext) unmarshalOFloat2float64(ctx context.Context, v interface{}) (float64, error) { return graphql.UnmarshalFloat(v) } @@ -4122,7 +4122,7 @@ func (ec *executionContext) marshalOHuman2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec._Human(ctx, sel, v) } -func (ec *executionContext) unmarshalOID2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalOID2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalID(v) } @@ -4130,11 +4130,11 @@ func (ec *executionContext) marshalOID2string(ctx context.Context, sel ast.Selec return graphql.MarshalID(v) } -func (ec *executionContext) unmarshalOID2ᚖstring(v interface{}) (*string, error) { +func (ec *executionContext) unmarshalOID2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOID2string(v) + res, err := ec.unmarshalOID2string(ctx, v) return &res, err } @@ -4145,7 +4145,7 @@ func (ec *executionContext) marshalOID2ᚖstring(ctx context.Context, sel ast.Se return ec.marshalOID2string(ctx, sel, *v) } -func (ec *executionContext) unmarshalOInt2int(v interface{}) (int, error) { +func (ec *executionContext) unmarshalOInt2int(ctx context.Context, v interface{}) (int, error) { return graphql.UnmarshalInt(v) } @@ -4153,11 +4153,11 @@ func (ec *executionContext) marshalOInt2int(ctx context.Context, sel ast.Selecti return graphql.MarshalInt(v) } -func (ec *executionContext) unmarshalOInt2ᚖint(v interface{}) (*int, error) { +func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v interface{}) (*int, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOInt2int(v) + res, err := ec.unmarshalOInt2int(ctx, v) return &res, err } @@ -4168,7 +4168,7 @@ func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.Sele return ec.marshalOInt2int(ctx, sel, *v) } -func (ec *executionContext) unmarshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(v interface{}) (LengthUnit, error) { +func (ec *executionContext) unmarshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(ctx context.Context, v interface{}) (LengthUnit, error) { var res LengthUnit return res, res.UnmarshalGQL(v) } @@ -4177,11 +4177,11 @@ func (ec *executionContext) marshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgen return v } -func (ec *executionContext) unmarshalOLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(v interface{}) (*LengthUnit, error) { +func (ec *executionContext) unmarshalOLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(ctx context.Context, v interface{}) (*LengthUnit, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(v) + res, err := ec.unmarshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(ctx, v) return &res, err } @@ -4245,7 +4245,7 @@ func (ec *executionContext) marshalOStarship2ᚖgithubᚗcomᚋ99designsᚋgqlge return ec._Starship(ctx, sel, v) } -func (ec *executionContext) unmarshalOString2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -4253,11 +4253,11 @@ func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.S return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalOString2ᚖstring(v interface{}) (*string, error) { +func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOString2string(v) + res, err := ec.unmarshalOString2string(ctx, v) return &res, err } @@ -4268,7 +4268,7 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as return ec.marshalOString2string(ctx, sel, *v) } -func (ec *executionContext) unmarshalOTime2timeᚐTime(v interface{}) (time.Time, error) { +func (ec *executionContext) unmarshalOTime2timeᚐTime(ctx context.Context, v interface{}) (time.Time, error) { return graphql.UnmarshalTime(v) } @@ -4276,11 +4276,11 @@ func (ec *executionContext) marshalOTime2timeᚐTime(ctx context.Context, sel as return graphql.MarshalTime(v) } -func (ec *executionContext) unmarshalOTime2ᚖtimeᚐTime(v interface{}) (*time.Time, error) { +func (ec *executionContext) unmarshalOTime2ᚖtimeᚐTime(ctx context.Context, v interface{}) (*time.Time, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOTime2timeᚐTime(v) + res, err := ec.unmarshalOTime2timeᚐTime(ctx, v) return &res, err } diff --git a/example/todo/generated.go b/example/todo/generated.go index 8112480fc7e..fafd486a3f7 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -300,7 +300,7 @@ func (ec *executionContext) dir_hasRole_args(ctx context.Context, rawArgs map[st args := map[string]interface{}{} var arg0 Role if tmp, ok := rawArgs["role"]; ok { - arg0, err = ec.unmarshalNRole2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐRole(tmp) + arg0, err = ec.unmarshalNRole2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐRole(ctx, tmp) if err != nil { return nil, err } @@ -314,7 +314,7 @@ func (ec *executionContext) field_MyMutation_createTodo_args(ctx context.Context args := map[string]interface{}{} var arg0 TodoInput if tmp, ok := rawArgs["todo"]; ok { - arg0, err = ec.unmarshalNTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodoInput(tmp) + arg0, err = ec.unmarshalNTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodoInput(ctx, tmp) if err != nil { return nil, err } @@ -328,7 +328,7 @@ func (ec *executionContext) field_MyMutation_updateTodo_args(ctx context.Context args := map[string]interface{}{} var arg0 int if tmp, ok := rawArgs["id"]; ok { - arg0, err = ec.unmarshalNInt2int(tmp) + arg0, err = ec.unmarshalNInt2int(ctx, tmp) if err != nil { return nil, err } @@ -336,7 +336,7 @@ func (ec *executionContext) field_MyMutation_updateTodo_args(ctx context.Context args["id"] = arg0 var arg1 map[string]interface{} if tmp, ok := rawArgs["changes"]; ok { - arg1, err = ec.unmarshalNMap2map(tmp) + arg1, err = ec.unmarshalNMap2map(ctx, tmp) if err != nil { return nil, err } @@ -350,7 +350,7 @@ func (ec *executionContext) field_MyQuery___type_args(ctx context.Context, rawAr args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = ec.unmarshalNString2string(tmp) + arg0, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -364,7 +364,7 @@ func (ec *executionContext) field_MyQuery_todo_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 int if tmp, ok := rawArgs["id"]; ok { - arg0, err = ec.unmarshalNInt2int(tmp) + arg0, err = ec.unmarshalNInt2int(ctx, tmp) if err != nil { return nil, err } @@ -378,7 +378,7 @@ func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalOBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } @@ -392,7 +392,7 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalOBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } @@ -1477,7 +1477,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co // region **************************** input.gotpl ***************************** -func (ec *executionContext) unmarshalInputTodoInput(v interface{}) (TodoInput, error) { +func (ec *executionContext) unmarshalInputTodoInput(ctx context.Context, v interface{}) (TodoInput, error) { var it TodoInput var asMap = v.(map[string]interface{}) @@ -1485,13 +1485,13 @@ func (ec *executionContext) unmarshalInputTodoInput(v interface{}) (TodoInput, e switch k { case "text": var err error - it.Text, err = ec.unmarshalNString2string(v) + it.Text, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "done": var err error - it.Done, err = ec.unmarshalOBoolean2ᚖbool(v) + it.Done, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } @@ -1875,7 +1875,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (ec *executionContext) unmarshalNBoolean2bool(v interface{}) (bool, error) { +func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } @@ -1883,7 +1883,7 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se return graphql.MarshalBoolean(v) } -func (ec *executionContext) unmarshalNInt2int(v interface{}) (int, error) { +func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{}) (int, error) { return graphql.UnmarshalInt(v) } @@ -1891,7 +1891,7 @@ func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.Selecti return graphql.MarshalInt(v) } -func (ec *executionContext) unmarshalNMap2map(v interface{}) (map[string]interface{}, error) { +func (ec *executionContext) unmarshalNMap2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { return graphql.UnmarshalMap(v) } @@ -1899,7 +1899,7 @@ func (ec *executionContext) marshalNMap2map(ctx context.Context, sel ast.Selecti return graphql.MarshalMap(v) } -func (ec *executionContext) unmarshalNRole2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐRole(v interface{}) (Role, error) { +func (ec *executionContext) unmarshalNRole2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐRole(ctx context.Context, v interface{}) (Role, error) { var res Role return res, res.UnmarshalGQL(v) } @@ -1908,7 +1908,7 @@ func (ec *executionContext) marshalNRole2githubᚗcomᚋ99designsᚋgqlgenᚋexa return v } -func (ec *executionContext) unmarshalNString2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -1951,8 +1951,8 @@ func (ec *executionContext) marshalNTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ return ret } -func (ec *executionContext) unmarshalNTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodoInput(v interface{}) (TodoInput, error) { - return ec.unmarshalInputTodoInput(v) +func (ec *executionContext) unmarshalNTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodoInput(ctx context.Context, v interface{}) (TodoInput, error) { + return ec.unmarshalInputTodoInput(ctx, v) } func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { @@ -1990,7 +1990,7 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq return ret } -func (ec *executionContext) unmarshalN__DirectiveLocation2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -1998,7 +1998,7 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(ctx context.Context, v interface{}) ([]string, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -2010,7 +2010,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{ var err error res := make([]string, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalN__DirectiveLocation2string(vSlice[i]) + res[i], err = ec.unmarshalN__DirectiveLocation2string(ctx, vSlice[i]) if err != nil { return nil, err } @@ -2137,7 +2137,7 @@ func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec.___Type(ctx, sel, v) } -func (ec *executionContext) unmarshalN__TypeKind2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -2145,7 +2145,7 @@ func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel a return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalOBoolean2bool(v interface{}) (bool, error) { +func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } @@ -2153,11 +2153,11 @@ func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.Se return graphql.MarshalBoolean(v) } -func (ec *executionContext) unmarshalOBoolean2ᚖbool(v interface{}) (*bool, error) { +func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOBoolean2bool(v) + res, err := ec.unmarshalOBoolean2bool(ctx, v) return &res, err } @@ -2168,7 +2168,7 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast return ec.marshalOBoolean2bool(ctx, sel, *v) } -func (ec *executionContext) unmarshalOString2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -2176,11 +2176,11 @@ func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.S return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalOString2ᚖstring(v interface{}) (*string, error) { +func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOString2string(v) + res, err := ec.unmarshalOString2string(ctx, v) return &res, err } diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index 92fdcd2bf3c..b1a8c7bf049 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -369,7 +369,7 @@ func (ec *executionContext) field_MyMutation_createTodo_args(ctx context.Context args := map[string]interface{}{} var arg0 TodoInput if tmp, ok := rawArgs["todo"]; ok { - arg0, err = ec.unmarshalNTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodoInput(tmp) + arg0, err = ec.unmarshalNTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodoInput(ctx, tmp) if err != nil { return nil, err } @@ -383,7 +383,7 @@ func (ec *executionContext) field_MyQuery___type_args(ctx context.Context, rawAr args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = ec.unmarshalNString2string(tmp) + arg0, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -397,7 +397,7 @@ func (ec *executionContext) field_MyQuery_todo_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["id"]; ok { - arg0, err = ec.unmarshalNID2string(tmp) + arg0, err = ec.unmarshalNID2string(ctx, tmp) if err != nil { return nil, err } @@ -411,7 +411,7 @@ func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalOBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } @@ -425,7 +425,7 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalOBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } @@ -1483,7 +1483,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co // region **************************** input.gotpl ***************************** -func (ec *executionContext) unmarshalInputTodoInput(v interface{}) (TodoInput, error) { +func (ec *executionContext) unmarshalInputTodoInput(ctx context.Context, v interface{}) (TodoInput, error) { var it TodoInput var asMap = v.(map[string]interface{}) @@ -1491,7 +1491,7 @@ func (ec *executionContext) unmarshalInputTodoInput(v interface{}) (TodoInput, e switch k { case "text": var err error - it.Text, err = ec.unmarshalNString2string(v) + it.Text, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } @@ -1898,7 +1898,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (ec *executionContext) unmarshalNBoolean2bool(v interface{}) (bool, error) { +func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } @@ -1906,7 +1906,7 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se return graphql.MarshalBoolean(v) } -func (ec *executionContext) unmarshalNID2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalID(v) } @@ -1914,7 +1914,7 @@ func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.Selec return graphql.MarshalID(v) } -func (ec *executionContext) unmarshalNState2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐState(v interface{}) (State, error) { +func (ec *executionContext) unmarshalNState2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐState(ctx context.Context, v interface{}) (State, error) { var res State return res, res.UnmarshalGQL(v) } @@ -1923,7 +1923,7 @@ func (ec *executionContext) marshalNState2githubᚗcomᚋ99designsᚋgqlgenᚋex return v } -func (ec *executionContext) unmarshalNString2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -1966,8 +1966,8 @@ func (ec *executionContext) marshalNTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ return ret } -func (ec *executionContext) unmarshalNTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodoInput(v interface{}) (TodoInput, error) { - return ec.unmarshalInputTodoInput(v) +func (ec *executionContext) unmarshalNTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodoInput(ctx context.Context, v interface{}) (TodoInput, error) { + return ec.unmarshalInputTodoInput(ctx, v) } func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { @@ -2005,7 +2005,7 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq return ret } -func (ec *executionContext) unmarshalN__DirectiveLocation2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -2013,7 +2013,7 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(ctx context.Context, v interface{}) ([]string, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -2025,7 +2025,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{ var err error res := make([]string, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalN__DirectiveLocation2string(vSlice[i]) + res[i], err = ec.unmarshalN__DirectiveLocation2string(ctx, vSlice[i]) if err != nil { return nil, err } @@ -2152,7 +2152,7 @@ func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec.___Type(ctx, sel, v) } -func (ec *executionContext) unmarshalN__TypeKind2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -2160,7 +2160,7 @@ func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel a return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalOBoolean2bool(v interface{}) (bool, error) { +func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } @@ -2168,7 +2168,7 @@ func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.Se return graphql.MarshalBoolean(v) } -func (ec *executionContext) unmarshalOString2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -2176,11 +2176,11 @@ func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.S return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalOString2ᚖstring(v interface{}) (*string, error) { +func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOString2string(v) + res, err := ec.unmarshalOString2string(ctx, v) return &res, err } diff --git a/integration/generated.go b/integration/generated.go index 8d1f0b03a54..94c1c17078f 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -328,7 +328,7 @@ func (ec *executionContext) dir_magic_args(ctx context.Context, rawArgs map[stri args := map[string]interface{}{} var arg0 *int if tmp, ok := rawArgs["kind"]; ok { - arg0, err = ec.unmarshalOInt2ᚖint(tmp) + arg0, err = ec.unmarshalOInt2ᚖint(ctx, tmp) if err != nil { return nil, err } @@ -342,7 +342,7 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { - arg0, err = ec.unmarshalNString2string(tmp) + arg0, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } @@ -356,7 +356,7 @@ func (ec *executionContext) field_Query_date_args(ctx context.Context, rawArgs m args := map[string]interface{}{} var arg0 models.DateFilter if tmp, ok := rawArgs["filter"]; ok { - arg0, err = ec.unmarshalNDateFilter2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilter(tmp) + arg0, err = ec.unmarshalNDateFilter2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilter(ctx, tmp) if err != nil { return nil, err } @@ -370,7 +370,7 @@ func (ec *executionContext) field_Query_error_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 *models.ErrorType if tmp, ok := rawArgs["type"]; ok { - arg0, err = ec.unmarshalOErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(tmp) + arg0, err = ec.unmarshalOErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(ctx, tmp) if err != nil { return nil, err } @@ -384,7 +384,7 @@ func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, ra args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalOBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } @@ -398,7 +398,7 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { - arg0, err = ec.unmarshalOBoolean2bool(tmp) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } @@ -1551,7 +1551,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co // region **************************** input.gotpl ***************************** -func (ec *executionContext) unmarshalInputDateFilter(v interface{}) (models.DateFilter, error) { +func (ec *executionContext) unmarshalInputDateFilter(ctx context.Context, v interface{}) (models.DateFilter, error) { var it models.DateFilter var asMap = v.(map[string]interface{}) @@ -1566,19 +1566,19 @@ func (ec *executionContext) unmarshalInputDateFilter(v interface{}) (models.Date switch k { case "value": var err error - it.Value, err = ec.unmarshalNString2string(v) + it.Value, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } case "timezone": var err error - it.Timezone, err = ec.unmarshalOString2ᚖstring(v) + it.Timezone, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } case "op": var err error - it.Op, err = ec.unmarshalODATE_FILTER_OP2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(v) + it.Op, err = ec.unmarshalODATE_FILTER_OP2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(ctx, v) if err != nil { return it, err } @@ -2012,7 +2012,7 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (ec *executionContext) unmarshalNBoolean2bool(v interface{}) (bool, error) { +func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } @@ -2020,15 +2020,15 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se return graphql.MarshalBoolean(v) } -func (ec *executionContext) unmarshalNDateFilter2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilter(v interface{}) (models.DateFilter, error) { - return ec.unmarshalInputDateFilter(v) +func (ec *executionContext) unmarshalNDateFilter2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilter(ctx context.Context, v interface{}) (models.DateFilter, error) { + return ec.unmarshalInputDateFilter(ctx, v) } func (ec *executionContext) marshalNElement2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx context.Context, sel ast.SelectionSet, v models.Element) graphql.Marshaler { return ec._Element(ctx, sel, &v) } -func (ec *executionContext) unmarshalNString2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -2036,7 +2036,7 @@ func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.S return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalNString2ᚕstring(v interface{}) ([]string, error) { +func (ec *executionContext) unmarshalNString2ᚕstring(ctx context.Context, v interface{}) ([]string, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -2048,7 +2048,7 @@ func (ec *executionContext) unmarshalNString2ᚕstring(v interface{}) ([]string, var err error res := make([]string, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalNString2string(vSlice[i]) + res[i], err = ec.unmarshalNString2string(ctx, vSlice[i]) if err != nil { return nil, err } @@ -2100,7 +2100,7 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq return ret } -func (ec *executionContext) unmarshalN__DirectiveLocation2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -2108,7 +2108,7 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{}) ([]string, error) { +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(ctx context.Context, v interface{}) ([]string, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -2120,7 +2120,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(v interface{ var err error res := make([]string, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalN__DirectiveLocation2string(vSlice[i]) + res[i], err = ec.unmarshalN__DirectiveLocation2string(ctx, vSlice[i]) if err != nil { return nil, err } @@ -2247,7 +2247,7 @@ func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec.___Type(ctx, sel, v) } -func (ec *executionContext) unmarshalN__TypeKind2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -2255,7 +2255,7 @@ func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel a return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalOBoolean2bool(v interface{}) (bool, error) { +func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } @@ -2263,7 +2263,7 @@ func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.Se return graphql.MarshalBoolean(v) } -func (ec *executionContext) unmarshalOBoolean2ᚕbool(v interface{}) ([]bool, error) { +func (ec *executionContext) unmarshalOBoolean2ᚕbool(ctx context.Context, v interface{}) ([]bool, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -2275,7 +2275,7 @@ func (ec *executionContext) unmarshalOBoolean2ᚕbool(v interface{}) ([]bool, er var err error res := make([]bool, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalNBoolean2bool(vSlice[i]) + res[i], err = ec.unmarshalNBoolean2bool(ctx, vSlice[i]) if err != nil { return nil, err } @@ -2292,7 +2292,7 @@ func (ec *executionContext) marshalOBoolean2ᚕbool(ctx context.Context, sel ast return ret } -func (ec *executionContext) unmarshalODATE_FILTER_OP2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(v interface{}) (models.DateFilterOp, error) { +func (ec *executionContext) unmarshalODATE_FILTER_OP2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(ctx context.Context, v interface{}) (models.DateFilterOp, error) { var res models.DateFilterOp return res, res.UnmarshalGQL(v) } @@ -2301,11 +2301,11 @@ func (ec *executionContext) marshalODATE_FILTER_OP2githubᚗcomᚋ99designsᚋgq return v } -func (ec *executionContext) unmarshalODATE_FILTER_OP2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(v interface{}) (*models.DateFilterOp, error) { +func (ec *executionContext) unmarshalODATE_FILTER_OP2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(ctx context.Context, v interface{}) (*models.DateFilterOp, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalODATE_FILTER_OP2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(v) + res, err := ec.unmarshalODATE_FILTER_OP2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(ctx, v) return &res, err } @@ -2358,7 +2358,7 @@ func (ec *executionContext) marshalOElement2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec._Element(ctx, sel, v) } -func (ec *executionContext) unmarshalOErrorType2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(v interface{}) (models.ErrorType, error) { +func (ec *executionContext) unmarshalOErrorType2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(ctx context.Context, v interface{}) (models.ErrorType, error) { var res models.ErrorType return res, res.UnmarshalGQL(v) } @@ -2367,11 +2367,11 @@ func (ec *executionContext) marshalOErrorType2githubᚗcomᚋ99designsᚋgqlgen return v } -func (ec *executionContext) unmarshalOErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(v interface{}) (*models.ErrorType, error) { +func (ec *executionContext) unmarshalOErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(ctx context.Context, v interface{}) (*models.ErrorType, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOErrorType2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(v) + res, err := ec.unmarshalOErrorType2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(ctx, v) return &res, err } @@ -2382,7 +2382,7 @@ func (ec *executionContext) marshalOErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlg return v } -func (ec *executionContext) unmarshalOInt2int(v interface{}) (int, error) { +func (ec *executionContext) unmarshalOInt2int(ctx context.Context, v interface{}) (int, error) { return graphql.UnmarshalInt(v) } @@ -2390,11 +2390,11 @@ func (ec *executionContext) marshalOInt2int(ctx context.Context, sel ast.Selecti return graphql.MarshalInt(v) } -func (ec *executionContext) unmarshalOInt2ᚖint(v interface{}) (*int, error) { +func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v interface{}) (*int, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOInt2int(v) + res, err := ec.unmarshalOInt2int(ctx, v) return &res, err } @@ -2405,7 +2405,7 @@ func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.Sele return ec.marshalOInt2int(ctx, sel, *v) } -func (ec *executionContext) unmarshalOString2string(v interface{}) (string, error) { +func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -2413,11 +2413,11 @@ func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.S return graphql.MarshalString(v) } -func (ec *executionContext) unmarshalOString2ᚖstring(v interface{}) (*string, error) { +func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOString2string(v) + res, err := ec.unmarshalOString2string(ctx, v) return &res, err } From 3015624baf4f280a1b6812b39ddb1c2506ccd4a7 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Wed, 6 Feb 2019 15:50:21 +1100 Subject: [PATCH 069/147] Regen dataloader with correct version --- example/dataloader/addressloader_gen.go | 23 +++++++++++++++++++++- example/dataloader/itemsliceloader_gen.go | 23 +++++++++++++++++++++- example/dataloader/ordersliceloader_gen.go | 23 +++++++++++++++++++++- 3 files changed, 66 insertions(+), 3 deletions(-) diff --git a/example/dataloader/addressloader_gen.go b/example/dataloader/addressloader_gen.go index 0465446faa7..90e1d433fc5 100644 --- a/example/dataloader/addressloader_gen.go +++ b/example/dataloader/addressloader_gen.go @@ -1,4 +1,4 @@ -// generated by github.com/vektah/dataloaden ; DO NOT EDIT +// Code generated by github.com/vektah/dataloaden, DO NOT EDIT. package dataloader @@ -7,6 +7,27 @@ import ( "time" ) +// AddressLoaderConfig captures the config to create a new AddressLoader +type AddressLoaderConfig struct { + // Fetch is a method that provides the data for the loader + Fetch func(keys []int) ([]*Address, []error) + + // Wait is how long wait before sending a batch + Wait time.Duration + + // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit + MaxBatch int +} + +// NewAddressLoader creates a new AddressLoader given a fetch, wait, and maxBatch +func NewAddressLoader(config AddressLoaderConfig) *AddressLoader { + return &AddressLoader{ + fetch: config.Fetch, + wait: config.Wait, + maxBatch: config.MaxBatch, + } +} + // AddressLoader batches and caches requests type AddressLoader struct { // this method provides the data for the loader diff --git a/example/dataloader/itemsliceloader_gen.go b/example/dataloader/itemsliceloader_gen.go index 55f21b4cae5..5fa10078401 100644 --- a/example/dataloader/itemsliceloader_gen.go +++ b/example/dataloader/itemsliceloader_gen.go @@ -1,4 +1,4 @@ -// generated by github.com/vektah/dataloaden ; DO NOT EDIT +// Code generated by github.com/vektah/dataloaden, DO NOT EDIT. package dataloader @@ -7,6 +7,27 @@ import ( "time" ) +// ItemSliceLoaderConfig captures the config to create a new ItemSliceLoader +type ItemSliceLoaderConfig struct { + // Fetch is a method that provides the data for the loader + Fetch func(keys []int) ([][]Item, []error) + + // Wait is how long wait before sending a batch + Wait time.Duration + + // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit + MaxBatch int +} + +// NewItemSliceLoader creates a new ItemSliceLoader given a fetch, wait, and maxBatch +func NewItemSliceLoader(config ItemSliceLoaderConfig) *ItemSliceLoader { + return &ItemSliceLoader{ + fetch: config.Fetch, + wait: config.Wait, + maxBatch: config.MaxBatch, + } +} + // ItemSliceLoader batches and caches requests type ItemSliceLoader struct { // this method provides the data for the loader diff --git a/example/dataloader/ordersliceloader_gen.go b/example/dataloader/ordersliceloader_gen.go index 6b168ec1fb4..e76e24d31f0 100644 --- a/example/dataloader/ordersliceloader_gen.go +++ b/example/dataloader/ordersliceloader_gen.go @@ -1,4 +1,4 @@ -// generated by github.com/vektah/dataloaden ; DO NOT EDIT +// Code generated by github.com/vektah/dataloaden, DO NOT EDIT. package dataloader @@ -7,6 +7,27 @@ import ( "time" ) +// OrderSliceLoaderConfig captures the config to create a new OrderSliceLoader +type OrderSliceLoaderConfig struct { + // Fetch is a method that provides the data for the loader + Fetch func(keys []int) ([][]Order, []error) + + // Wait is how long wait before sending a batch + Wait time.Duration + + // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit + MaxBatch int +} + +// NewOrderSliceLoader creates a new OrderSliceLoader given a fetch, wait, and maxBatch +func NewOrderSliceLoader(config OrderSliceLoaderConfig) *OrderSliceLoader { + return &OrderSliceLoader{ + fetch: config.Fetch, + wait: config.Wait, + maxBatch: config.MaxBatch, + } +} + // OrderSliceLoader batches and caches requests type OrderSliceLoader struct { // this method provides the data for the loader From 6af3d85da38a4768598f2a0a07be2da6c3f1b5f3 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Wed, 6 Feb 2019 16:49:19 +1100 Subject: [PATCH 070/147] Allow multiple field bind types --- codegen/args.go | 2 +- codegen/config/binder.go | 91 ++++++++++++++++++++------------ codegen/config/config.go | 97 +++++++++++++++++------------------ codegen/config/config_test.go | 12 ++--- codegen/directive.go | 2 +- codegen/errors_test.go | 8 +-- codegen/field.go | 48 +++++++++-------- codegen/interface.go | 4 +- codegen/object.go | 2 +- example/todo/generated.go | 12 ++++- example/todo/schema.graphql | 2 +- plugin/modelgen/models.go | 5 +- 12 files changed, 163 insertions(+), 122 deletions(-) diff --git a/codegen/args.go b/codegen/args.go index ea3bacbff19..8b2d624fec6 100644 --- a/codegen/args.go +++ b/codegen/args.go @@ -41,7 +41,7 @@ func (b *builder) buildArg(obj *Object, arg *ast.ArgumentDefinition) (*FieldArgu ) } - tr, err := b.Binder.TypeReference(arg.Type) + tr, err := b.Binder.TypeReference(arg.Type, nil) if err != nil { return nil, err } diff --git a/codegen/config/binder.go b/codegen/config/binder.go index 7af8cbfe502..305bc23b6bb 100644 --- a/codegen/config/binder.go +++ b/codegen/config/binder.go @@ -81,21 +81,21 @@ func (b *Binder) getPkg(find string) *packages.Package { var MapType = types.NewMap(types.Typ[types.String], types.NewInterfaceType(nil, nil).Complete()) var InterfaceType = types.NewInterfaceType(nil, nil) -func (b *Binder) FindUserObject(name string) (types.Type, error) { - userEntry, ok := b.cfg.Models[name] - if !ok { +func (b *Binder) DefaultUserObject(name string) (types.Type, error) { + models := b.cfg.Models[name].Model + if len(models) == 0 { return nil, fmt.Errorf(name + " not found") } - if userEntry.Model == "map[string]interface{}" { + if models[0] == "map[string]interface{}" { return MapType, nil } - if userEntry.Model == "interface{}" { + if models[0] == "interface{}" { return InterfaceType, nil } - pkgName, typeName := code.PkgAndType(userEntry.Model) + pkgName, typeName := code.PkgAndType(models[0]) if pkgName == "" { return nil, fmt.Errorf("missing package name for %s", name) } @@ -271,7 +271,23 @@ func (b *Binder) PushRef(ret *TypeReference) { b.References = append(b.References, ret) } -func (b *Binder) TypeReference(schemaType *ast.Type) (ret *TypeReference, err error) { +func isMap(t types.Type) bool { + if t == nil { + return true + } + _, ok := t.(*types.Map) + return ok +} + +func isIntf(t types.Type) bool { + if t == nil { + return true + } + _, ok := t.(*types.Interface) + return ok +} + +func (b *Binder) TypeReference(schemaType *ast.Type, bindTarget types.Type) (ret *TypeReference, err error) { var pkgName, typeName string def := b.schema.Types[schemaType.Name()] defer func() { @@ -280,8 +296,11 @@ func (b *Binder) TypeReference(schemaType *ast.Type) (ret *TypeReference, err er } }() - if userEntry, ok := b.cfg.Models[schemaType.Name()]; ok && userEntry.Model != "" { - if userEntry.Model == "map[string]interface{}" { + for _, model := range b.cfg.Models[schemaType.Name()].Model { + if model == "map[string]interface{}" { + if !isMap(bindTarget) { + continue + } return &TypeReference{ Definition: def, GQL: schemaType, @@ -289,7 +308,10 @@ func (b *Binder) TypeReference(schemaType *ast.Type) (ret *TypeReference, err er }, nil } - if userEntry.Model == "interface{}" { + if model == "interface{}" { + if !isIntf(bindTarget) { + continue + } return &TypeReference{ Definition: def, GQL: schemaType, @@ -297,37 +319,42 @@ func (b *Binder) TypeReference(schemaType *ast.Type) (ret *TypeReference, err er }, nil } - pkgName, typeName = code.PkgAndType(userEntry.Model) + pkgName, typeName = code.PkgAndType(model) if pkgName == "" { return nil, fmt.Errorf("missing package name for %s", schemaType.Name()) } - } else { - pkgName = "github.com/99designs/gqlgen/graphql" - typeName = "String" - } + ref := &TypeReference{ + Definition: def, + GQL: schemaType, + } - ref := &TypeReference{ - Definition: def, - GQL: schemaType, - } + obj, err := b.FindObject(pkgName, typeName) + if err != nil { + return nil, err + } - obj, err := b.FindObject(pkgName, typeName) - if err != nil { - return nil, err - } + if fun, isFunc := obj.(*types.Func); isFunc { + ref.GO = fun.Type().(*types.Signature).Params().At(0).Type() + ref.Marshaler = fun + ref.Unmarshaler = types.NewFunc(0, fun.Pkg(), "Unmarshal"+typeName, nil) + } else { + ref.GO = obj.Type() + } - if fun, isFunc := obj.(*types.Func); isFunc { - ref.GO = fun.Type().(*types.Signature).Params().At(0).Type() - ref.Marshaler = fun - ref.Unmarshaler = types.NewFunc(0, fun.Pkg(), "Unmarshal"+typeName, nil) - } else { - ref.GO = obj.Type() - } + ref.GO = b.CopyModifiersFromAst(schemaType, def.Kind != ast.Interface, ref.GO) - ref.GO = b.CopyModifiersFromAst(schemaType, def.Kind != ast.Interface, ref.GO) + if bindTarget != nil { + if err = code.CompatibleTypes(ref.GO, bindTarget); err != nil { + continue + } + ref.GO = bindTarget + } + + return ref, nil + } - return ref, nil + return nil, fmt.Errorf("not found") } func (b *Binder) CopyModifiersFromAst(t *ast.Type, usePtr bool, base types.Type) types.Type { diff --git a/codegen/config/config.go b/codegen/config/config.go index 4673c65c78f..2c0b11efb1d 100644 --- a/codegen/config/config.go +++ b/codegen/config/config.go @@ -2,14 +2,13 @@ package config import ( "fmt" + "go/types" "io/ioutil" "os" "path/filepath" "sort" "strings" - "go/types" - "github.com/99designs/gqlgen/internal/code" "github.com/pkg/errors" "github.com/vektah/gqlparser" @@ -18,12 +17,12 @@ import ( ) type Config struct { - SchemaFilename SchemaFilenames `yaml:"schema,omitempty"` - Exec PackageConfig `yaml:"exec"` - Model PackageConfig `yaml:"model"` - Resolver PackageConfig `yaml:"resolver,omitempty"` - Models TypeMap `yaml:"models,omitempty"` - StructTag string `yaml:"struct_tag,omitempty"` + SchemaFilename StringList `yaml:"schema,omitempty"` + Exec PackageConfig `yaml:"exec"` + Model PackageConfig `yaml:"model"` + Resolver PackageConfig `yaml:"resolver,omitempty"` + Models TypeMap `yaml:"models,omitempty"` + StructTag string `yaml:"struct_tag,omitempty"` } var cfgFilenames = []string{".gqlgen.yml", "gqlgen.yml", "gqlgen.yaml"} @@ -31,7 +30,7 @@ var cfgFilenames = []string{".gqlgen.yml", "gqlgen.yml", "gqlgen.yaml"} // DefaultConfig creates a copy of the default config func DefaultConfig() *Config { return &Config{ - SchemaFilename: SchemaFilenames{"schema.graphql"}, + SchemaFilename: StringList{"schema.graphql"}, Model: PackageConfig{Filename: "models_gen.go"}, Exec: PackageConfig{Filename: "generated.go"}, } @@ -66,7 +65,7 @@ func LoadConfig(filename string) (*Config, error) { } preGlobbing := config.SchemaFilename - config.SchemaFilename = SchemaFilenames{} + config.SchemaFilename = StringList{} for _, f := range preGlobbing { matches, err := filepath.Glob(f) if err != nil { @@ -91,7 +90,7 @@ type PackageConfig struct { } type TypeMapEntry struct { - Model string `yaml:"model"` + Model StringList `yaml:"model"` Fields map[string]TypeMapField `yaml:"fields,omitempty"` } @@ -100,9 +99,9 @@ type TypeMapField struct { FieldName string `yaml:"fieldName"` } -type SchemaFilenames []string +type StringList []string -func (a *SchemaFilenames) UnmarshalYAML(unmarshal func(interface{}) error) error { +func (a *StringList) UnmarshalYAML(unmarshal func(interface{}) error) error { var single string err := unmarshal(&single) if err == nil { @@ -120,7 +119,7 @@ func (a *SchemaFilenames) UnmarshalYAML(unmarshal func(interface{}) error) error return nil } -func (a SchemaFilenames) Has(file string) bool { +func (a StringList) Has(file string) bool { for _, existing := range a { if existing == file { return true @@ -198,13 +197,15 @@ func (tm TypeMap) Exists(typeName string) bool { func (tm TypeMap) UserDefined(typeName string) bool { m, ok := tm[typeName] - return ok && m.Model != "" + return ok && len(m.Model) > 0 } func (tm TypeMap) Check() error { for typeName, entry := range tm { - if strings.LastIndex(entry.Model, ".") < strings.LastIndex(entry.Model, "/") { - return fmt.Errorf("model %s: invalid type specifier \"%s\" - you need to specify a struct to map to", typeName, entry.Model) + for _, model := range entry.Model { + if strings.LastIndex(model, ".") < strings.LastIndex(model, "/") { + return fmt.Errorf("model %s: invalid type specifier \"%s\" - you need to specify a struct to map to", typeName, entry.Model) + } } } return nil @@ -214,14 +215,16 @@ func (tm TypeMap) ReferencedPackages() []string { var pkgs []string for _, typ := range tm { - if typ.Model == "map[string]interface{}" { - continue - } - pkg, _ := code.PkgAndType(typ.Model) - if pkg == "" || inStrSlice(pkgs, pkg) { - continue + for _, model := range typ.Model { + if model == "map[string]interface{}" || model == "interface{}" { + continue + } + pkg, _ := code.PkgAndType(model) + if pkg == "" || inStrSlice(pkgs, pkg) { + continue + } + pkgs = append(pkgs, pkg) } - pkgs = append(pkgs, pkg) } sort.Slice(pkgs, func(i, j int) bool { @@ -232,7 +235,7 @@ func (tm TypeMap) ReferencedPackages() []string { func (tm TypeMap) Add(Name string, goType string) { modelCfg := tm[Name] - modelCfg.Model = goType + modelCfg.Model = append(modelCfg.Model, goType) tm[Name] = modelCfg } @@ -302,21 +305,26 @@ func (c *Config) normalize() error { func (c *Config) InjectBuiltins(s *ast.Schema) { builtins := TypeMap{ - "__Directive": {Model: "github.com/99designs/gqlgen/graphql/introspection.Directive"}, - "__DirectiveLocation": {Model: "github.com/99designs/gqlgen/graphql.String"}, - "__Type": {Model: "github.com/99designs/gqlgen/graphql/introspection.Type"}, - "__TypeKind": {Model: "github.com/99designs/gqlgen/graphql.String"}, - "__Field": {Model: "github.com/99designs/gqlgen/graphql/introspection.Field"}, - "__EnumValue": {Model: "github.com/99designs/gqlgen/graphql/introspection.EnumValue"}, - "__InputValue": {Model: "github.com/99designs/gqlgen/graphql/introspection.InputValue"}, - "__Schema": {Model: "github.com/99designs/gqlgen/graphql/introspection.Schema"}, - "Int": {Model: "github.com/99designs/gqlgen/graphql.Int"}, - "Float": {Model: "github.com/99designs/gqlgen/graphql.Float"}, - "String": {Model: "github.com/99designs/gqlgen/graphql.String"}, - "Boolean": {Model: "github.com/99designs/gqlgen/graphql.Boolean"}, - "ID": {Model: "github.com/99designs/gqlgen/graphql.ID"}, - "Time": {Model: "github.com/99designs/gqlgen/graphql.Time"}, - "Map": {Model: "github.com/99designs/gqlgen/graphql.Map"}, + "__Directive": {Model: StringList{"github.com/99designs/gqlgen/graphql/introspection.Directive"}}, + "__DirectiveLocation": {Model: StringList{"github.com/99designs/gqlgen/graphql.String"}}, + "__Type": {Model: StringList{"github.com/99designs/gqlgen/graphql/introspection.Type"}}, + "__TypeKind": {Model: StringList{"github.com/99designs/gqlgen/graphql.String"}}, + "__Field": {Model: StringList{"github.com/99designs/gqlgen/graphql/introspection.Field"}}, + "__EnumValue": {Model: StringList{"github.com/99designs/gqlgen/graphql/introspection.EnumValue"}}, + "__InputValue": {Model: StringList{"github.com/99designs/gqlgen/graphql/introspection.InputValue"}}, + "__Schema": {Model: StringList{"github.com/99designs/gqlgen/graphql/introspection.Schema"}}, + "Int": {Model: StringList{"github.com/99designs/gqlgen/graphql.Int"}}, + "Float": {Model: StringList{"github.com/99designs/gqlgen/graphql.Float"}}, + "String": {Model: StringList{"github.com/99designs/gqlgen/graphql.String"}}, + "Boolean": {Model: StringList{"github.com/99designs/gqlgen/graphql.Boolean"}}, + "Time": {Model: StringList{"github.com/99designs/gqlgen/graphql.Time"}}, + "Map": {Model: StringList{"github.com/99designs/gqlgen/graphql.Map"}}, + "ID": { + Model: StringList{ + "github.com/99designs/gqlgen/graphql.ID", + "github.com/99designs/gqlgen/graphql.Int", + }, + }, } for typeName, entry := range builtins { @@ -326,15 +334,6 @@ func (c *Config) InjectBuiltins(s *ast.Schema) { } } -func (c *TypeMapEntry) PkgAndType() (string, string) { - parts := strings.Split(c.Model, ".") - if len(parts) == 1 { - return "", c.Model - } - - return normalizeVendor(strings.Join(parts[:len(parts)-1], ".")), parts[len(parts)-1] -} - func (c *Config) LoadSchema() (*ast.Schema, map[string]string, error) { schemaStrings := map[string]string{} diff --git a/codegen/config/config_test.go b/codegen/config/config_test.go index 2647a7fc600..3f6ee668ac7 100644 --- a/codegen/config/config_test.go +++ b/codegen/config/config_test.go @@ -37,7 +37,7 @@ func TestLoadDefaultConfig(t *testing.T) { cfg, err = LoadConfigFromDefaultLocations() require.NoError(t, err) - require.Equal(t, SchemaFilenames{"inner"}, cfg.SchemaFilename) + require.Equal(t, StringList{"inner"}, cfg.SchemaFilename) }) t.Run("will find config in parent dirs", func(t *testing.T) { @@ -46,7 +46,7 @@ func TestLoadDefaultConfig(t *testing.T) { cfg, err = LoadConfigFromDefaultLocations() require.NoError(t, err) - require.Equal(t, SchemaFilenames{"outer"}, cfg.SchemaFilename) + require.Equal(t, StringList{"outer"}, cfg.SchemaFilename) }) t.Run("will return error if config doesn't exist", func(t *testing.T) { @@ -61,10 +61,10 @@ func TestLoadDefaultConfig(t *testing.T) { func TestReferencedPackages(t *testing.T) { t.Run("valid", func(t *testing.T) { tm := TypeMap{ - "Foo": {Model: "github.com/test.Foo"}, - "Bar": {Model: "github.com/test.Bar"}, - "Baz": {Model: "github.com/otherpkg.Baz"}, - "Map": {Model: "map[string]interface{}"}, + "Foo": {Model: StringList{"github.com/test.Foo"}}, + "Bar": {Model: StringList{"github.com/test.Bar"}}, + "Baz": {Model: StringList{"github.com/otherpkg.Baz"}}, + "Map": {Model: StringList{"map[string]interface{}"}}, "SkipResolver": { Fields: map[string]TypeMapField{ "field": {Resolver: false}, diff --git a/codegen/directive.go b/codegen/directive.go index d13ae4fee5b..37c496bf5a6 100644 --- a/codegen/directive.go +++ b/codegen/directive.go @@ -33,7 +33,7 @@ func (b *builder) buildDirectives() (map[string]*Directive, error) { return nil, errors.Errorf("%s cannot be used as argument of directive %s(%s) only input and scalar types are allowed", arg.Type, dir.Name, arg.Name) } - tr, err := b.Binder.TypeReference(arg.Type) + tr, err := b.Binder.TypeReference(arg.Type, nil) if err != nil { return nil, err } diff --git a/codegen/errors_test.go b/codegen/errors_test.go index 53c213aed5a..2e5eaebf1b9 100644 --- a/codegen/errors_test.go +++ b/codegen/errors_test.go @@ -21,13 +21,13 @@ func TestTypeInInput(t *testing.T) { func generate(name string, schemaFilename string) error { _, err := BuildData(&config.Config{ - SchemaFilename: config.SchemaFilenames{schemaFilename}, + SchemaFilename: config.StringList{schemaFilename}, Exec: config.PackageConfig{Filename: "gen/" + name + "/exec.go"}, Model: config.PackageConfig{Filename: "gen/" + name + "/model.go"}, Models: map[string]config.TypeMapEntry{ - "Item": {Model: "map[string]interface{}"}, - "Bookmarkable": {Model: "interface{}"}, - "BookmarkableInput": {Model: "interface{}"}, + "Item": {Model: config.StringList{"map[string]interface{}"}}, + "Bookmarkable": {Model: config.StringList{"interface{}"}}, + "BookmarkableInput": {Model: config.StringList{"interface{}"}}, }, }) diff --git a/codegen/field.go b/codegen/field.go index c10666e28f1..24daaa71cf0 100644 --- a/codegen/field.go +++ b/codegen/field.go @@ -10,7 +10,6 @@ import ( "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/codegen/templates" - "github.com/99designs/gqlgen/internal/code" "github.com/pkg/errors" "github.com/vektah/gqlparser/ast" ) @@ -37,14 +36,20 @@ func (b *builder) buildField(obj *Object, field *ast.FieldDefinition) (*Field, e return nil, err } - tr, err := b.Binder.TypeReference(field.Type) - if err != nil { - return nil, err + def := b.Schema.Types[field.Type.Name()] + + if obj.Kind == ast.InputObject && !def.IsInputType() { + return nil, errors.Errorf( + "%s.%s: cannot use %s because %s is not a valid input type", + obj.Name, + field.Name, + def.Name, + def.Kind, + ) } f := Field{ FieldDefinition: field, - TypeReference: tr, Object: obj, Directives: dirs, GoFieldName: templates.ToGo(field.Name), @@ -52,16 +57,6 @@ func (b *builder) buildField(obj *Object, field *ast.FieldDefinition) (*Field, e GoReceiverName: "obj", } - if obj.Kind == ast.InputObject && !f.TypeReference.Definition.IsInputType() { - return nil, errors.Errorf( - "%s.%s: cannot use %s because %s is not a valid input type", - obj.Name, - field.Name, - f.TypeReference.Definition.Name, - f.TypeReference.Definition.Kind, - ) - } - if field.DefaultValue != nil { var err error f.Default, err = field.DefaultValue.Value(nil) @@ -86,6 +81,15 @@ func (b *builder) buildField(obj *Object, field *ast.FieldDefinition) (*Field, e } func (b *builder) bindField(obj *Object, f *Field) error { + defer func() { + if f.TypeReference == nil { + tr, err := b.Binder.TypeReference(f.Type, nil) + if err != nil { + panic(err) + } + f.TypeReference = tr + } + }() switch { case f.Name == "__schema": f.GoFieldType = GoFieldMethod @@ -152,28 +156,30 @@ func (b *builder) bindField(obj *Object, f *Field) error { } result := sig.Results().At(0) - if err = code.CompatibleTypes(f.TypeReference.GO, result.Type()); err != nil { - return errors.Wrapf(err, "%s:%d %s is not compatible with %s", pos.Filename, pos.Line, f.TypeReference.GO.String(), result.Type().String()) + tr, err := b.Binder.TypeReference(f.Type, result.Type()) + if err != nil { + return err } // success, args and return type match. Bind to method f.GoFieldType = GoFieldMethod f.GoReceiverName = "obj" f.GoFieldName = target.Name() - f.TypeReference.GO = result.Type() + f.TypeReference = tr return nil case *types.Var: - if err = code.CompatibleTypes(f.TypeReference.GO, target.Type()); err != nil { - return errors.Wrapf(err, "%s:%d %s is not compatible with %s", pos.Filename, pos.Line, f.TypeReference.GO.String(), target.Type().String()) + tr, err := b.Binder.TypeReference(f.Type, target.Type()) + if err != nil { + return err } // success, bind to var f.GoFieldType = GoFieldVariable f.GoReceiverName = "obj" f.GoFieldName = target.Name() - f.TypeReference.GO = target.Type() + f.TypeReference = tr return nil default: diff --git a/codegen/interface.go b/codegen/interface.go index ee67592508c..f59e8ed0715 100644 --- a/codegen/interface.go +++ b/codegen/interface.go @@ -21,7 +21,7 @@ type InterfaceImplementor struct { } func (b *builder) buildInterface(typ *ast.Definition) *Interface { - obj, err := b.Binder.FindUserObject(typ.Name) + obj, err := b.Binder.DefaultUserObject(typ.Name) if err != nil { panic(err) } @@ -33,7 +33,7 @@ func (b *builder) buildInterface(typ *ast.Definition) *Interface { } for _, implementor := range b.Schema.GetPossibleTypes(typ) { - obj, err := b.Binder.FindUserObject(implementor.Name) + obj, err := b.Binder.DefaultUserObject(implementor.Name) if err != nil { panic(err) } diff --git a/codegen/object.go b/codegen/object.go index 243b35371a4..70429a21ca7 100644 --- a/codegen/object.go +++ b/codegen/object.go @@ -52,7 +52,7 @@ func (b *builder) buildObject(typ *ast.Definition) (*Object, error) { } if !obj.Root { - goObject, err := b.Binder.FindUserObject(typ.Name) + goObject, err := b.Binder.DefaultUserObject(typ.Name) if err != nil { return nil, err } diff --git a/example/todo/generated.go b/example/todo/generated.go index fafd486a3f7..5701c0ba3eb 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -266,7 +266,7 @@ type MyMutation { } type Todo { - id: Int! + id: ID! text: String! done: Boolean! @hasRole(role: OWNER) # only the owner can see if a todo is done } @@ -623,7 +623,7 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalNID2int(ctx, field.Selections, res) } func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { @@ -1883,6 +1883,14 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se return graphql.MarshalBoolean(v) } +func (ec *executionContext) unmarshalNID2int(ctx context.Context, v interface{}) (int, error) { + return graphql.UnmarshalInt(v) +} + +func (ec *executionContext) marshalNID2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { + return graphql.MarshalInt(v) +} + func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{}) (int, error) { return graphql.UnmarshalInt(v) } diff --git a/example/todo/schema.graphql b/example/todo/schema.graphql index b4263454cb8..3d1c6743806 100644 --- a/example/todo/schema.graphql +++ b/example/todo/schema.graphql @@ -15,7 +15,7 @@ type MyMutation { } type Todo { - id: Int! + id: ID! text: String! done: Boolean! @hasRole(role: OWNER) # only the owner can see if a todo is done } diff --git a/plugin/modelgen/models.go b/plugin/modelgen/models.go index 841684f9739..2be7dfb2cfa 100644 --- a/plugin/modelgen/models.go +++ b/plugin/modelgen/models.go @@ -4,6 +4,8 @@ import ( "go/types" "sort" + "github.com/99designs/gqlgen/internal/code" + "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/codegen/templates" "github.com/99designs/gqlgen/plugin" @@ -112,8 +114,7 @@ func (m *Plugin) MutateConfig(cfg *config.Config) error { var typ types.Type if cfg.Models.UserDefined(field.Type.Name()) { - model := cfg.Models[field.Type.Name()] - pkg, typeName := model.PkgAndType() + pkg, typeName := code.PkgAndType(cfg.Models[field.Type.Name()].Model[0]) typ, err = binder.FindType(pkg, typeName) if err != nil { return err From 956d03063de0e021ec7d23e4a6695fdafe0a01f6 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Wed, 6 Feb 2019 17:09:11 +1100 Subject: [PATCH 071/147] Arg type binding --- codegen/args.go | 7 ++++++- codegen/config/config.go | 2 +- example/chat/generated.go | 15 +++++++++++++++ example/config/generated.go | 15 +++++++++++++++ example/dataloader/generated.go | 15 +++++++++++++++ example/scalars/generated.go | 15 +++++++++++++++ example/selection/generated.go | 15 +++++++++++++++ example/starwars/generated.go | 15 +++++++++++++++ example/todo/generated.go | 20 ++++++-------------- example/todo/gqlgen.yml | 4 ++++ example/todo/schema.graphql | 4 ++-- example/todo/todo_test.go | 22 +++++++++++----------- example/type-system-extension/generated.go | 15 +++++++++++++++ graphql/id.go | 21 +++++++++++++++++++++ integration/generated.go | 15 +++++++++++++++ 15 files changed, 171 insertions(+), 29 deletions(-) diff --git a/codegen/args.go b/codegen/args.go index 8b2d624fec6..aa57026b5f9 100644 --- a/codegen/args.go +++ b/codegen/args.go @@ -76,7 +76,12 @@ nextArg: param := params.At(j) for _, oldArg := range field.Args { if strings.EqualFold(oldArg.Name, param.Name()) { - oldArg.TypeReference.GO = param.Type() + tr, err := b.Binder.TypeReference(oldArg.Type, param.Type()) + if err != nil { + return err + } + oldArg.TypeReference = tr + newArgs = append(newArgs, oldArg) continue nextArg } diff --git a/codegen/config/config.go b/codegen/config/config.go index 2c0b11efb1d..72525401f96 100644 --- a/codegen/config/config.go +++ b/codegen/config/config.go @@ -322,7 +322,7 @@ func (c *Config) InjectBuiltins(s *ast.Schema) { "ID": { Model: StringList{ "github.com/99designs/gqlgen/graphql.ID", - "github.com/99designs/gqlgen/graphql.Int", + "github.com/99designs/gqlgen/graphql.IntID", }, }, } diff --git a/example/chat/generated.go b/example/chat/generated.go index bed886e40a9..ef30d9e7dbc 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -2196,6 +2196,21 @@ func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.Se return graphql.MarshalBoolean(v) } +func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOBoolean2bool(ctx, v) + return &res, err +} + +func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOBoolean2bool(ctx, sel, *v) +} + func (ec *executionContext) marshalOChatroom2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐChatroom(ctx context.Context, sel ast.SelectionSet, v Chatroom) graphql.Marshaler { return ec._Chatroom(ctx, sel, &v) } diff --git a/example/config/generated.go b/example/config/generated.go index 5948b5904b5..13f7e653d93 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -2121,6 +2121,21 @@ func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.Se return graphql.MarshalBoolean(v) } +func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOBoolean2bool(ctx, v) + return &res, err +} + +func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOBoolean2bool(ctx, sel, *v) +} + func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index d879aabae63..affd3f2ca22 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -2343,6 +2343,21 @@ func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.Se return graphql.MarshalBoolean(v) } +func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOBoolean2bool(ctx, v) + return &res, err +} + +func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOBoolean2bool(ctx, sel, *v) +} + func (ec *executionContext) marshalOCustomer2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v []Customer) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup diff --git a/example/scalars/generated.go b/example/scalars/generated.go index a8f60b0aeb1..a586d8aea82 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -2232,6 +2232,21 @@ func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.Se return graphql.MarshalBoolean(v) } +func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOBoolean2bool(ctx, v) + return &res, err +} + +func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOBoolean2bool(ctx, sel, *v) +} + func (ec *executionContext) unmarshalOPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, v interface{}) (model.Point, error) { var res model.Point return res, res.UnmarshalGQL(v) diff --git a/example/selection/generated.go b/example/selection/generated.go index f7a1b3b4236..6f687081bc6 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -1957,6 +1957,21 @@ func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.Se return graphql.MarshalBoolean(v) } +func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOBoolean2bool(ctx, v) + return &res, err +} + +func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOBoolean2bool(ctx, sel, *v) +} + func (ec *executionContext) marshalOEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋselectionᚐEvent(ctx context.Context, sel ast.SelectionSet, v []Event) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup diff --git a/example/starwars/generated.go b/example/starwars/generated.go index 052473f2f19..c4988d793a4 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -4002,6 +4002,21 @@ func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.Se return graphql.MarshalBoolean(v) } +func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOBoolean2bool(ctx, v) + return &res, err +} + +func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOBoolean2bool(ctx, sel, *v) +} + func (ec *executionContext) marshalOCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v Character) graphql.Marshaler { return ec._Character(ctx, sel, &v) } diff --git a/example/todo/generated.go b/example/todo/generated.go index 5701c0ba3eb..7594b719295 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -255,14 +255,14 @@ var parsedSchema = gqlparser.MustLoadSchema( } type MyQuery { - todo(id: Int!): Todo + todo(id: ID!): Todo lastTodo: Todo todos: [Todo!]! } type MyMutation { createTodo(todo: TodoInput!): Todo! - updateTodo(id: Int!, changes: Map!): Todo + updateTodo(id: ID!, changes: Map!): Todo } type Todo { @@ -328,7 +328,7 @@ func (ec *executionContext) field_MyMutation_updateTodo_args(ctx context.Context args := map[string]interface{}{} var arg0 int if tmp, ok := rawArgs["id"]; ok { - arg0, err = ec.unmarshalNInt2int(ctx, tmp) + arg0, err = ec.unmarshalNID2int(ctx, tmp) if err != nil { return nil, err } @@ -364,7 +364,7 @@ func (ec *executionContext) field_MyQuery_todo_args(ctx context.Context, rawArgs args := map[string]interface{}{} var arg0 int if tmp, ok := rawArgs["id"]; ok { - arg0, err = ec.unmarshalNInt2int(ctx, tmp) + arg0, err = ec.unmarshalNID2int(ctx, tmp) if err != nil { return nil, err } @@ -1884,19 +1884,11 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se } func (ec *executionContext) unmarshalNID2int(ctx context.Context, v interface{}) (int, error) { - return graphql.UnmarshalInt(v) + return graphql.UnmarshalIntID(v) } func (ec *executionContext) marshalNID2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - return graphql.MarshalInt(v) -} - -func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{}) (int, error) { - return graphql.UnmarshalInt(v) -} - -func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - return graphql.MarshalInt(v) + return graphql.MarshalIntID(v) } func (ec *executionContext) unmarshalNMap2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { diff --git a/example/todo/gqlgen.yml b/example/todo/gqlgen.yml index 5404738eb21..c9fe56375e5 100644 --- a/example/todo/gqlgen.yml +++ b/example/todo/gqlgen.yml @@ -1,3 +1,7 @@ models: Todo: model: github.com/99designs/gqlgen/example/todo.Todo + ID: + model: # override the default id marshaller to use ints + - github.com/99designs/gqlgen/graphql.IntID + - github.com/99designs/gqlgen/graphql.ID diff --git a/example/todo/schema.graphql b/example/todo/schema.graphql index 3d1c6743806..8adac85147e 100644 --- a/example/todo/schema.graphql +++ b/example/todo/schema.graphql @@ -4,14 +4,14 @@ schema { } type MyQuery { - todo(id: Int!): Todo + todo(id: ID!): Todo lastTodo: Todo todos: [Todo!]! } type MyMutation { createTodo(todo: TodoInput!): Todo! - updateTodo(id: Int!, changes: Map!): Todo + updateTodo(id: ID!, changes: Map!): Todo } type Todo { diff --git a/example/todo/todo_test.go b/example/todo/todo_test.go index 04a4d557ec9..2b3296d72a8 100644 --- a/example/todo/todo_test.go +++ b/example/todo/todo_test.go @@ -15,18 +15,18 @@ func TestTodo(t *testing.T) { c := client.New(srv.URL) var resp struct { - CreateTodo struct{ ID int } + CreateTodo struct{ ID string } } c.MustPost(`mutation { createTodo(todo:{text:"Fery important"}) { id } }`, &resp) - require.Equal(t, 5, resp.CreateTodo.ID) + require.Equal(t, "5", resp.CreateTodo.ID) t.Run("update the todo text", func(t *testing.T) { var resp struct { UpdateTodo struct{ Text string } } c.MustPost( - `mutation($id: Int!, $text: String!) { updateTodo(id: $id, changes:{text:$text}) { text } }`, + `mutation($id: ID!, $text: String!) { updateTodo(id: $id, changes:{text:$text}) { text } }`, &resp, client.Var("id", 5), client.Var("text", "Very important"), @@ -58,12 +58,12 @@ func TestTodo(t *testing.T) { t.Run("select with alias", func(t *testing.T) { var resp struct { A struct{ Text string } - B struct{ ID int } + B struct{ ID string } } c.MustPost(`{ a: todo(id:1) { text } b: todo(id:2) { id } }`, &resp) require.Equal(t, "A todo not to forget", resp.A.Text) - require.Equal(t, 2, resp.B.ID) + require.Equal(t, "2", resp.B.ID) }) t.Run("find a missing todo", func(t *testing.T) { @@ -101,17 +101,17 @@ func TestTodo(t *testing.T) { t.Run("select all", func(t *testing.T) { var resp struct { Todo struct { - ID int + ID string Text string Done bool } LastTodo struct { - ID int + ID string Text string Done bool } Todos []struct { - ID int + ID string Text string } } @@ -121,11 +121,11 @@ func TestTodo(t *testing.T) { todos { id text } }`, &resp) - require.Equal(t, 1, resp.Todo.ID) - require.Equal(t, 5, resp.LastTodo.ID) + require.Equal(t, "1", resp.Todo.ID) + require.Equal(t, "5", resp.LastTodo.ID) require.Len(t, resp.Todos, 5) require.Equal(t, "Very important", resp.LastTodo.Text) - require.Equal(t, 5, resp.LastTodo.ID) + require.Equal(t, "5", resp.LastTodo.ID) }) t.Run("introspection", func(t *testing.T) { diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index b1a8c7bf049..cd28b4ee1cc 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -2168,6 +2168,21 @@ func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.Se return graphql.MarshalBoolean(v) } +func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOBoolean2bool(ctx, v) + return &res, err +} + +func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOBoolean2bool(ctx, sel, *v) +} + func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } diff --git a/graphql/id.go b/graphql/id.go index a5a7960f346..4f532037d08 100644 --- a/graphql/id.go +++ b/graphql/id.go @@ -34,3 +34,24 @@ func UnmarshalID(v interface{}) (string, error) { return "", fmt.Errorf("%T is not a string", v) } } + +func MarshalIntID(i int) Marshaler { + return WriterFunc(func(w io.Writer) { + writeQuotedString(w, strconv.Itoa(i)) + }) +} + +func UnmarshalIntID(v interface{}) (int, error) { + switch v := v.(type) { + case string: + return strconv.Atoi(v) + case int: + return v, nil + case int64: + return int(v), nil + case json.Number: + return strconv.Atoi(string(v)) + default: + return 0, fmt.Errorf("%T is not an int", v) + } +} diff --git a/integration/generated.go b/integration/generated.go index 94c1c17078f..b5200eb2453 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -2292,6 +2292,21 @@ func (ec *executionContext) marshalOBoolean2ᚕbool(ctx context.Context, sel ast return ret } +func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOBoolean2bool(ctx, v) + return &res, err +} + +func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOBoolean2bool(ctx, sel, *v) +} + func (ec *executionContext) unmarshalODATE_FILTER_OP2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(ctx context.Context, v interface{}) (models.DateFilterOp, error) { var res models.DateFilterOp return res, res.UnmarshalGQL(v) From 42131868df3225cc1960e205dc56f769c03bb285 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Wed, 6 Feb 2019 17:18:36 +1100 Subject: [PATCH 072/147] Linting fixes --- codegen/field.go | 2 +- codegen/generate.go | 2 +- codegen/templates/import_test.go | 7 +++---- codegen/templates/templates.go | 3 +++ codegen/testserver/generated.go | 2 ++ docs/content/config.md | 9 ++++++++- example/chat/generated.go | 2 ++ example/config/generated.go | 2 ++ example/dataloader/generated.go | 2 ++ example/scalars/generated.go | 2 ++ example/selection/generated.go | 2 ++ example/starwars/generated.go | 2 ++ example/todo/generated.go | 2 ++ example/type-system-extension/generated.go | 2 ++ generate.go | 9 --------- integration/generated.go | 2 ++ 16 files changed, 36 insertions(+), 16 deletions(-) diff --git a/codegen/field.go b/codegen/field.go index 24daaa71cf0..6d64a3b8e9e 100644 --- a/codegen/field.go +++ b/codegen/field.go @@ -74,7 +74,7 @@ func (b *builder) buildField(obj *Object, field *ast.FieldDefinition) (*Field, e } if err = b.bindField(obj, &f); err != nil { - log.Printf(err.Error()) + log.Println(err.Error()) } return &f, nil diff --git a/codegen/generate.go b/codegen/generate.go index a32e329e60c..eafa3f87434 100644 --- a/codegen/generate.go +++ b/codegen/generate.go @@ -10,6 +10,6 @@ func GenerateCode(data *Data) error { Filename: data.Config.Exec.Filename, Data: data, RegionTags: true, - GeneratedHeader: false, + GeneratedHeader: true, }) } diff --git a/codegen/templates/import_test.go b/codegen/templates/import_test.go index 437bf7438b0..b055beb724f 100644 --- a/codegen/templates/import_test.go +++ b/codegen/templates/import_test.go @@ -1,11 +1,10 @@ package templates import ( + "go/types" "os" "testing" - "go/types" - "github.com/stretchr/testify/require" ) @@ -68,8 +67,8 @@ bar1 "github.com/99designs/gqlgen/codegen/templates/testdata/b/bar" t.Run("aliased imports will not collide", func(t *testing.T) { a := Imports{destDir: wd} - a.Reserve(aBar, "abar") - a.Reserve(bBar, "bbar") + _, _ = a.Reserve(aBar, "abar") + _, _ = a.Reserve(bBar, "bbar") require.Equal(t, `abar "github.com/99designs/gqlgen/codegen/templates/testdata/a/bar" bbar "github.com/99designs/gqlgen/codegen/templates/testdata/b/bar"`, a.String()) diff --git a/codegen/templates/templates.go b/codegen/templates/templates.go index 9cf65eeed8b..0282f32c0a2 100644 --- a/codegen/templates/templates.go +++ b/codegen/templates/templates.go @@ -45,6 +45,9 @@ func Render(cfg Options) error { var roots []string // load all the templates in the directory err := filepath.Walk(rootDir, func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } name := filepath.ToSlash(strings.TrimPrefix(path, rootDir+string(os.PathSeparator))) if !strings.HasSuffix(info.Name(), ".gotpl") { return nil diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index ffa08771d18..01e4719d104 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -1,3 +1,5 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + package testserver import ( diff --git a/docs/content/config.md b/docs/content/config.md index bf219bb89f1..93118c4f682 100644 --- a/docs/content/config.md +++ b/docs/content/config.md @@ -50,7 +50,14 @@ models: fields: id: resolver: true # force a resolver to be generated - fieldName: todoId # bind to a different go field name + fieldName: todoId # bind to a different go field name + # model also accepts multiple backing go types. When mapping onto structs + # any of these types can be used, the first one is used as the default for + # resolver args. + ID: + model: + - github.com/99designs/gqlgen/graphql.IntID + - github.com/99designs/gqlgen/graphql.ID ``` Everything has defaults, so add things as you need. diff --git a/example/chat/generated.go b/example/chat/generated.go index ef30d9e7dbc..740cd4b20e2 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -1,3 +1,5 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + package chat import ( diff --git a/example/config/generated.go b/example/config/generated.go index 13f7e653d93..17e04c5d0bc 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -1,3 +1,5 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + package config import ( diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index affd3f2ca22..5f789a7e639 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -1,3 +1,5 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + package dataloader import ( diff --git a/example/scalars/generated.go b/example/scalars/generated.go index a586d8aea82..60a3c8c091d 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -1,3 +1,5 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + package scalars import ( diff --git a/example/selection/generated.go b/example/selection/generated.go index 6f687081bc6..16ef946384b 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -1,3 +1,5 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + package selection import ( diff --git a/example/starwars/generated.go b/example/starwars/generated.go index c4988d793a4..eadab3d5563 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -1,3 +1,5 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + package starwars import ( diff --git a/example/todo/generated.go b/example/todo/generated.go index 7594b719295..97c638394f3 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -1,3 +1,5 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + package todo import ( diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index cd28b4ee1cc..79575cf6e9b 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -1,3 +1,5 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + package type_system_extension import ( diff --git a/generate.go b/generate.go index b9e83d400c8..86c64b7a12b 100644 --- a/generate.go +++ b/generate.go @@ -1,7 +1,6 @@ package gqlgen import ( - "path/filepath" "syscall" "github.com/99designs/gqlgen/codegen" @@ -75,11 +74,3 @@ func validate(cfg *config.Config) error { } return nil } - -func abs(path string) string { - absPath, err := filepath.Abs(path) - if err != nil { - panic(err) - } - return filepath.ToSlash(absPath) -} diff --git a/integration/generated.go b/integration/generated.go index b5200eb2453..82a43f247e4 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -1,3 +1,5 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + package integration import ( From b26b915ea6f5a8529cc63c1f5285118426868510 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Thu, 7 Feb 2019 10:29:20 +1100 Subject: [PATCH 073/147] Move input validation into gqlparser see https://github.com/vektah/gqlparser/pull/96 --- codegen/args.go | 10 -------- codegen/directive.go | 5 ---- codegen/errors_test.go | 35 ---------------------------- codegen/field.go | 12 ---------- codegen/testdata/typeinput.graphqls | 7 ------ codegen/testdata/unioninput.graphqls | 5 ---- 6 files changed, 74 deletions(-) delete mode 100644 codegen/errors_test.go delete mode 100644 codegen/testdata/typeinput.graphqls delete mode 100644 codegen/testdata/unioninput.graphqls diff --git a/codegen/args.go b/codegen/args.go index aa57026b5f9..b5690e7d78b 100644 --- a/codegen/args.go +++ b/codegen/args.go @@ -31,16 +31,6 @@ func (f *FieldArgument) Stream() bool { } func (b *builder) buildArg(obj *Object, arg *ast.ArgumentDefinition) (*FieldArgument, error) { - def := b.Schema.Types[arg.Type.Name()] - if !def.IsInputType() { - return nil, errors.Errorf( - "cannot use %s as argument %s because %s is not a valid input type", - arg.Type.String(), - arg.Name, - def.Kind, - ) - } - tr, err := b.Binder.TypeReference(arg.Type, nil) if err != nil { return nil, err diff --git a/codegen/directive.go b/codegen/directive.go index 37c496bf5a6..52f3cbae7b5 100644 --- a/codegen/directive.go +++ b/codegen/directive.go @@ -28,11 +28,6 @@ func (b *builder) buildDirectives() (map[string]*Directive, error) { var args []*FieldArgument for _, arg := range dir.Arguments { - def := b.Schema.Types[arg.Type.Name()] - if !def.IsInputType() { - return nil, errors.Errorf("%s cannot be used as argument of directive %s(%s) only input and scalar types are allowed", arg.Type, dir.Name, arg.Name) - } - tr, err := b.Binder.TypeReference(arg.Type, nil) if err != nil { return nil, err diff --git a/codegen/errors_test.go b/codegen/errors_test.go deleted file mode 100644 index 2e5eaebf1b9..00000000000 --- a/codegen/errors_test.go +++ /dev/null @@ -1,35 +0,0 @@ -package codegen - -import ( - "testing" - - "github.com/99designs/gqlgen/codegen/config" - "github.com/stretchr/testify/require" -) - -func TestTypeUnionAsInput(t *testing.T) { - err := generate("inputunion", `testdata/unioninput.graphqls`) - - require.EqualError(t, err, "unable to build object definition: cannot use Bookmarkable! as argument b because UNION is not a valid input type") -} - -func TestTypeInInput(t *testing.T) { - err := generate("typeinput", `testdata/typeinput.graphqls`) - - require.EqualError(t, err, "unable to build input definition: BookmarkableInput.item: cannot use Item because OBJECT is not a valid input type") -} - -func generate(name string, schemaFilename string) error { - _, err := BuildData(&config.Config{ - SchemaFilename: config.StringList{schemaFilename}, - Exec: config.PackageConfig{Filename: "gen/" + name + "/exec.go"}, - Model: config.PackageConfig{Filename: "gen/" + name + "/model.go"}, - Models: map[string]config.TypeMapEntry{ - "Item": {Model: config.StringList{"map[string]interface{}"}}, - "Bookmarkable": {Model: config.StringList{"interface{}"}}, - "BookmarkableInput": {Model: config.StringList{"interface{}"}}, - }, - }) - - return err -} diff --git a/codegen/field.go b/codegen/field.go index 6d64a3b8e9e..42dce261004 100644 --- a/codegen/field.go +++ b/codegen/field.go @@ -36,18 +36,6 @@ func (b *builder) buildField(obj *Object, field *ast.FieldDefinition) (*Field, e return nil, err } - def := b.Schema.Types[field.Type.Name()] - - if obj.Kind == ast.InputObject && !def.IsInputType() { - return nil, errors.Errorf( - "%s.%s: cannot use %s because %s is not a valid input type", - obj.Name, - field.Name, - def.Name, - def.Kind, - ) - } - f := Field{ FieldDefinition: field, Object: obj, diff --git a/codegen/testdata/typeinput.graphqls b/codegen/testdata/typeinput.graphqls deleted file mode 100644 index ba0438afca4..00000000000 --- a/codegen/testdata/typeinput.graphqls +++ /dev/null @@ -1,7 +0,0 @@ -type Query { - addBookmark(b: BookmarkableInput!): Boolean! -} -type Item {name: String} -input BookmarkableInput { - item: Item -} diff --git a/codegen/testdata/unioninput.graphqls b/codegen/testdata/unioninput.graphqls deleted file mode 100644 index b1a17b1dd1f..00000000000 --- a/codegen/testdata/unioninput.graphqls +++ /dev/null @@ -1,5 +0,0 @@ -type Query { - addBookmark(b: Bookmarkable!): Boolean! -} -type Item {name: String} -union Bookmarkable = Item From c5e3dd44959d59bef6830cbe2652498e49b53089 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Thu, 7 Feb 2019 20:10:15 +1100 Subject: [PATCH 074/147] add stub generation plugin --- codegen/field.go | 5 +-- codegen/generated!.gotpl | 4 ++- plugin/resolvergen/resolver.gotpl | 2 +- plugin/stubgen/stubs.go | 39 +++++++++++++++++++++ plugin/stubgen/stubs.gotpl | 57 +++++++++++++++++++++++++++++++ testdata/gqlgen.go | 3 +- 6 files changed, 103 insertions(+), 7 deletions(-) create mode 100644 plugin/stubgen/stubs.go create mode 100644 plugin/stubgen/stubs.gotpl diff --git a/codegen/field.go b/codegen/field.go index 42dce261004..1c9c129bf28 100644 --- a/codegen/field.go +++ b/codegen/field.go @@ -325,10 +325,7 @@ func (f *Field) ResolverType() string { } func (f *Field) ShortResolverDeclaration() string { - if !f.IsResolver { - return "" - } - res := fmt.Sprintf("%s(ctx context.Context", f.GoFieldName) + res := "(ctx context.Context" if !f.Object.Root { res += fmt.Sprintf(", obj *%s", templates.CurrentImports.LookupType(f.Object.Type)) diff --git a/codegen/generated!.gotpl b/codegen/generated!.gotpl index 5833ee61c3e..31486bd550e 100644 --- a/codegen/generated!.gotpl +++ b/codegen/generated!.gotpl @@ -60,7 +60,9 @@ type ComplexityRoot struct { {{ if $object.HasResolvers }} type {{$object.Name}}Resolver interface { {{ range $field := $object.Fields -}} - {{ $field.ShortResolverDeclaration }} + {{- if $field.IsResolver }} + {{- $field.GoFieldName}}{{ $field.ShortResolverDeclaration }} + {{- end }} {{ end }} } {{- end }} diff --git a/plugin/resolvergen/resolver.gotpl b/plugin/resolvergen/resolver.gotpl index 65625f51a5e..7d95e6903ce 100644 --- a/plugin/resolvergen/resolver.gotpl +++ b/plugin/resolvergen/resolver.gotpl @@ -31,7 +31,7 @@ type {{.ResolverType}} struct {} {{ range $field := $object.Fields -}} {{- if $field.IsResolver -}} - func (r *{{lcFirst $object.Name}}Resolver) {{ $field.ShortResolverDeclaration }} { + func (r *{{lcFirst $object.Name}}Resolver) {{$field.GoFieldName}}{{ $field.ShortResolverDeclaration }} { panic("not implemented") } {{ end -}} diff --git a/plugin/stubgen/stubs.go b/plugin/stubgen/stubs.go new file mode 100644 index 00000000000..f00cf924d73 --- /dev/null +++ b/plugin/stubgen/stubs.go @@ -0,0 +1,39 @@ +package stubgen + +import ( + "github.com/99designs/gqlgen/codegen" + "github.com/99designs/gqlgen/codegen/templates" + "github.com/99designs/gqlgen/plugin" +) + +func New(filename string, typename string) plugin.Plugin { + return &Plugin{filename: filename, typeName: typename} +} + +type Plugin struct { + filename string + typeName string +} + +var _ plugin.CodeGenerator = &Plugin{} + +func (m *Plugin) Name() string { + return "stubgen" +} +func (m *Plugin) GenerateCode(data *codegen.Data) error { + return templates.Render(templates.Options{ + PackageName: data.Config.Resolver.Package, + Filename: m.filename, + Data: &ResolverBuild{ + Data: data, + TypeName: m.typeName, + }, + GeneratedHeader: false, + }) +} + +type ResolverBuild struct { + *codegen.Data + + TypeName string +} diff --git a/plugin/stubgen/stubs.gotpl b/plugin/stubgen/stubs.gotpl new file mode 100644 index 00000000000..d8adbf0b2c6 --- /dev/null +++ b/plugin/stubgen/stubs.gotpl @@ -0,0 +1,57 @@ +{{ reserveImport "context" }} +{{ reserveImport "fmt" }} +{{ reserveImport "io" }} +{{ reserveImport "strconv" }} +{{ reserveImport "time" }} +{{ reserveImport "sync" }} +{{ reserveImport "errors" }} +{{ reserveImport "bytes" }} + +{{ reserveImport "github.com/99designs/gqlgen/handler" }} +{{ reserveImport "github.com/vektah/gqlparser" }} +{{ reserveImport "github.com/vektah/gqlparser/ast" }} +{{ reserveImport "github.com/99designs/gqlgen/graphql" }} +{{ reserveImport "github.com/99designs/gqlgen/graphql/introspection" }} + +{{ $root := . }} + +type {{$root.TypeName}} struct { + {{ range $object := .Objects }} + {{- if $object.HasResolvers }} + {{$object.Name}}Resolver struct { + {{- range $field := $object.Fields }} + {{- if $field.IsResolver }} + {{- $field.GoFieldName}} func{{ $field.ShortResolverDeclaration }} + {{ end }} + {{- end }} + } + {{- end }} + {{- end }} +} + +{{ range $object := .Objects -}} + {{- if $object.HasResolvers -}} + func (r *{{$.TypeName}}) {{$object.Name}}() {{ $object.ResolverInterface | ref }} { + return &{{lcFirst $root.TypeName}}{{$object.Name}}{r} + } + {{ end -}} +{{ end }} + +{{ range $object := .Objects -}} + {{- if $object.HasResolvers -}} + type {{lcFirst $root.TypeName}}{{$object.Name}} struct { *{{$root.TypeName}} } + + {{ range $field := $object.Fields -}} + {{- if $field.IsResolver -}} + func (r *{{lcFirst $root.TypeName}}{{$object.Name}}) {{$field.GoFieldName}}{{ $field.ShortResolverDeclaration }} { + return r.{{$object.Name}}Resolver.{{$field.GoFieldName}}(ctx, + {{- if not $object.Root }}obj,{{end -}} + {{- range $arg := $field.Args}} + {{$arg.VarName}}, + {{- end }} + ) + } + {{ end -}} + {{ end -}} + {{ end -}} +{{ end }} diff --git a/testdata/gqlgen.go b/testdata/gqlgen.go index 6b37275a0dc..d51bfc0ce3f 100644 --- a/testdata/gqlgen.go +++ b/testdata/gqlgen.go @@ -9,6 +9,7 @@ import ( "github.com/99designs/gqlgen" "github.com/99designs/gqlgen/codegen/config" + "github.com/99designs/gqlgen/plugin/stubgen" ) func main() { @@ -22,7 +23,7 @@ func main() { os.Exit(2) } - err = gqlgen.Generate(cfg) + err = gqlgen.Generate(cfg, gqlgen.AddPlugin(stubgen.New(cfg.Exec.Dir()+"/stubs.go", "Stub"))) if err != nil { fmt.Fprintln(os.Stderr, err.Error()) os.Exit(3) From 787b38d8589a5b4169464a46ab5bd1e87573221c Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Thu, 7 Feb 2019 20:44:57 +1100 Subject: [PATCH 075/147] Break testserver tests down into smaller files using stubs --- codegen/testserver/directive_test.go | 210 ++++ codegen/testserver/generated_test.go | 941 +----------------- codegen/testserver/introspection_test.go | 95 ++ codegen/testserver/middleware_test.go | 66 ++ codegen/testserver/modelmethod_test.go | 48 + codegen/testserver/nulls_test.go | 83 ++ codegen/testserver/response_extension_test.go | 34 + codegen/testserver/stub.go | 146 +++ codegen/testserver/subscription_test.go | 139 +++ codegen/testserver/tracer_test.go | 352 +++++++ handler/graphql_test.go | 10 +- plugin/stubgen/stubs.go | 14 +- plugin/stubgen/stubs.gotpl | 2 +- testdata/gqlgen.go | 11 +- 14 files changed, 1203 insertions(+), 948 deletions(-) create mode 100644 codegen/testserver/directive_test.go create mode 100644 codegen/testserver/introspection_test.go create mode 100644 codegen/testserver/middleware_test.go create mode 100644 codegen/testserver/modelmethod_test.go create mode 100644 codegen/testserver/nulls_test.go create mode 100644 codegen/testserver/response_extension_test.go create mode 100644 codegen/testserver/stub.go create mode 100644 codegen/testserver/subscription_test.go create mode 100644 codegen/testserver/tracer_test.go diff --git a/codegen/testserver/directive_test.go b/codegen/testserver/directive_test.go new file mode 100644 index 00000000000..cdb10632e2e --- /dev/null +++ b/codegen/testserver/directive_test.go @@ -0,0 +1,210 @@ +package testserver + +import ( + "context" + "fmt" + "net/http/httptest" + "testing" + + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/handler" + "github.com/stretchr/testify/require" +) + +func TestDirectives(t *testing.T) { + resolvers := &Stub{} + resolvers.QueryResolver.DirectiveArg = func(ctx context.Context, arg string) (i *string, e error) { + s := "Ok" + return &s, nil + } + + resolvers.QueryResolver.DirectiveInput = func(ctx context.Context, arg InputDirectives) (i *string, e error) { + s := "Ok" + return &s, nil + } + + resolvers.QueryResolver.DirectiveInputNullable = func(ctx context.Context, arg *InputDirectives) (i *string, e error) { + s := "Ok" + return &s, nil + } + + resolvers.QueryResolver.DirectiveNullableArg = func(ctx context.Context, arg *int, arg2 *int) (i *string, e error) { + s := "Ok" + return &s, nil + } + + srv := httptest.NewServer( + handler.GraphQL( + NewExecutableSchema(Config{ + Resolvers: resolvers, + Directives: DirectiveRoot{ + Length: func(ctx context.Context, obj interface{}, next graphql.Resolver, min int, max *int) (interface{}, error) { + res, err := next(ctx) + if err != nil { + return nil, err + } + + s := res.(string) + if len(s) < min { + return nil, fmt.Errorf("too short") + } + if max != nil && len(s) > *max { + return nil, fmt.Errorf("too long") + } + return res, nil + }, + Range: func(ctx context.Context, obj interface{}, next graphql.Resolver, min *int, max *int) (interface{}, error) { + res, err := next(ctx) + if err != nil { + return nil, err + } + + switch res := res.(type) { + case int: + if min != nil && res < *min { + return nil, fmt.Errorf("too small") + } + if max != nil && res > *max { + return nil, fmt.Errorf("too large") + } + return next(ctx) + + case int64: + if min != nil && int(res) < *min { + return nil, fmt.Errorf("too small") + } + if max != nil && int(res) > *max { + return nil, fmt.Errorf("too large") + } + return next(ctx) + + case *int: + if min != nil && *res < *min { + return nil, fmt.Errorf("too small") + } + if max != nil && *res > *max { + return nil, fmt.Errorf("too large") + } + return next(ctx) + } + return nil, fmt.Errorf("unsupported type %T", res) + }, + }, + }), + handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + path, _ := ctx.Value("path").([]int) + return next(context.WithValue(ctx, "path", append(path, 1))) + }), + handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + path, _ := ctx.Value("path").([]int) + return next(context.WithValue(ctx, "path", append(path, 2))) + }), + )) + c := client.New(srv.URL) + + t.Run("arg directives", func(t *testing.T) { + t.Run("when function errors on directives", func(t *testing.T) { + var resp struct { + DirectiveArg *string + } + + err := c.Post(`query { directiveArg(arg: "") }`, &resp) + + require.EqualError(t, err, `[{"message":"too short","path":["directiveArg"]}]`) + require.Nil(t, resp.DirectiveArg) + }) + t.Run("when function errors on nullable arg directives", func(t *testing.T) { + var resp struct { + DirectiveNullableArg *string + } + + err := c.Post(`query { directiveNullableArg(arg: -100) }`, &resp) + + require.EqualError(t, err, `[{"message":"too small","path":["directiveNullableArg"]}]`) + require.Nil(t, resp.DirectiveNullableArg) + }) + t.Run("when function success on nullable arg directives", func(t *testing.T) { + var resp struct { + DirectiveNullableArg *string + } + + err := c.Post(`query { directiveNullableArg }`, &resp) + + require.Nil(t, err) + require.Equal(t, "Ok", *resp.DirectiveNullableArg) + }) + t.Run("when function success on valid nullable arg directives", func(t *testing.T) { + var resp struct { + DirectiveNullableArg *string + } + + err := c.Post(`query { directiveNullableArg(arg: 1) }`, &resp) + + require.Nil(t, err) + require.Equal(t, "Ok", *resp.DirectiveNullableArg) + }) + t.Run("when function success", func(t *testing.T) { + var resp struct { + DirectiveArg *string + } + + err := c.Post(`query { directiveArg(arg: "test") }`, &resp) + + require.Nil(t, err) + require.Equal(t, "Ok", *resp.DirectiveArg) + }) + }) + t.Run("input field directives", func(t *testing.T) { + t.Run("when function errors on directives", func(t *testing.T) { + var resp struct { + DirectiveInputNullable *string + } + + err := c.Post(`query { directiveInputNullable(arg: {text:"invalid text",inner:{message:"123"}}) }`, &resp) + + require.EqualError(t, err, `[{"message":"too long","path":["directiveInputNullable"]}]`) + require.Nil(t, resp.DirectiveInputNullable) + }) + t.Run("when function errors on inner directives", func(t *testing.T) { + var resp struct { + DirectiveInputNullable *string + } + + err := c.Post(`query { directiveInputNullable(arg: {text:"2",inner:{message:""}}) }`, &resp) + + require.EqualError(t, err, `[{"message":"too short","path":["directiveInputNullable"]}]`) + require.Nil(t, resp.DirectiveInputNullable) + }) + t.Run("when function errors on nullable inner directives", func(t *testing.T) { + var resp struct { + DirectiveInputNullable *string + } + + err := c.Post(`query { directiveInputNullable(arg: {text:"success",inner:{message:"1"},innerNullable:{message:""}}) }`, &resp) + + require.EqualError(t, err, `[{"message":"too short","path":["directiveInputNullable"]}]`) + require.Nil(t, resp.DirectiveInputNullable) + }) + t.Run("when function success", func(t *testing.T) { + var resp struct { + DirectiveInputNullable *string + } + + err := c.Post(`query { directiveInputNullable(arg: {text:"23",inner:{message:"1"}}) }`, &resp) + + require.Nil(t, err) + require.Equal(t, "Ok", *resp.DirectiveInputNullable) + }) + t.Run("when function inner nullable success", func(t *testing.T) { + var resp struct { + DirectiveInputNullable *string + } + + err := c.Post(`query { directiveInputNullable(arg: {text:"23",inner:{message:"1"},innerNullable:{message:"success"}}) }`, &resp) + + require.Nil(t, err) + require.Equal(t, "Ok", *resp.DirectiveInputNullable) + }) + }) +} diff --git a/codegen/testserver/generated_test.go b/codegen/testserver/generated_test.go index 00b5b902466..51547ae62c7 100644 --- a/codegen/testserver/generated_test.go +++ b/codegen/testserver/generated_test.go @@ -1,25 +1,14 @@ //go:generate rm -f resolver.go -//go:generate go run ../../testdata/gqlgen.go +//go:generate go run ../../testdata/gqlgen.go -stub stub.go package testserver import ( - "context" - "fmt" "net/http" - "net/http/httptest" "reflect" - "runtime" - "sort" - "sync" "testing" - "time" - "github.com/99designs/gqlgen/client" - "github.com/99designs/gqlgen/graphql" - "github.com/99designs/gqlgen/graphql/introspection" "github.com/99designs/gqlgen/handler" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -35,935 +24,9 @@ func TestForcedResolverFieldIsPointer(t *testing.T) { require.Equal(t, "*testserver.Circle", field.Type.Out(0).String()) } -func TestGeneratedServer(t *testing.T) { - resolvers := &testResolver{tick: make(chan string, 1)} - - srv := httptest.NewServer( - handler.GraphQL( - NewExecutableSchema(Config{Resolvers: resolvers}), - handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { - path, _ := ctx.Value("path").([]int) - return next(context.WithValue(ctx, "path", append(path, 1))) - }), - handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { - path, _ := ctx.Value("path").([]int) - return next(context.WithValue(ctx, "path", append(path, 2))) - }), - )) - c := client.New(srv.URL) - - t.Run("null bubbling", func(t *testing.T) { - t.Run("when function errors on non required field", func(t *testing.T) { - var resp struct { - Valid string - ErrorBubble *struct { - Id string - ErrorOnNonRequiredField *string - } - } - err := c.Post(`query { valid, errorBubble { id, errorOnNonRequiredField } }`, &resp) - - require.EqualError(t, err, `[{"message":"boom","path":["errorBubble","errorOnNonRequiredField"]}]`) - require.Equal(t, "E1234", resp.ErrorBubble.Id) - require.Nil(t, resp.ErrorBubble.ErrorOnNonRequiredField) - require.Equal(t, "Ok", resp.Valid) - }) - - t.Run("when function errors", func(t *testing.T) { - var resp struct { - Valid string - ErrorBubble *struct { - NilOnRequiredField string - } - } - err := c.Post(`query { valid, errorBubble { id, errorOnRequiredField } }`, &resp) - - require.EqualError(t, err, `[{"message":"boom","path":["errorBubble","errorOnRequiredField"]}]`) - require.Nil(t, resp.ErrorBubble) - require.Equal(t, "Ok", resp.Valid) - }) - - t.Run("when user returns null on required field", func(t *testing.T) { - var resp struct { - Valid string - ErrorBubble *struct { - NilOnRequiredField string - } - } - err := c.Post(`query { valid, errorBubble { id, nilOnRequiredField } }`, &resp) - - require.EqualError(t, err, `[{"message":"must not be null","path":["errorBubble","nilOnRequiredField"]}]`) - require.Nil(t, resp.ErrorBubble) - require.Equal(t, "Ok", resp.Valid) - }) - - }) - - t.Run("middleware", func(t *testing.T) { - var resp struct { - User struct { - ID int - Friends []struct { - ID int - } - } - } - - called := false - resolvers.userFriends = func(ctx context.Context, obj *User) ([]User, error) { - assert.Equal(t, []int{1, 2, 1, 2}, ctx.Value("path")) - called = true - return []User{}, nil - } - - err := c.Post(`query { user(id: 1) { id, friends { id } } }`, &resp) - - require.NoError(t, err) - require.True(t, called) - }) - - t.Run("subscriptions", func(t *testing.T) { - t.Run("wont leak goroutines", func(t *testing.T) { - runtime.GC() // ensure no go-routines left from preceding tests - initialGoroutineCount := runtime.NumGoroutine() - - sub := c.Websocket(`subscription { updated }`) - - resolvers.tick <- "message" - - var msg struct { - resp struct { - Updated string - } - } - - err := sub.Next(&msg.resp) - require.NoError(t, err) - require.Equal(t, "message", msg.resp.Updated) - sub.Close() - - // need a little bit of time for goroutines to settle - start := time.Now() - for time.Since(start).Seconds() < 2 && initialGoroutineCount != runtime.NumGoroutine() { - time.Sleep(5 * time.Millisecond) - } - - require.Equal(t, initialGoroutineCount, runtime.NumGoroutine()) - }) - - t.Run("will parse init payload", func(t *testing.T) { - sub := c.WebsocketWithPayload(`subscription { initPayload }`, map[string]interface{}{ - "Authorization": "Bearer of the curse", - "number": 32, - "strings": []string{"hello", "world"}, - }) - - var msg struct { - resp struct { - InitPayload string - } - } - - err := sub.Next(&msg.resp) - require.NoError(t, err) - require.Equal(t, "AUTH:Bearer of the curse", msg.resp.InitPayload) - err = sub.Next(&msg.resp) - require.NoError(t, err) - require.Equal(t, "Authorization = \"Bearer of the curse\"", msg.resp.InitPayload) - err = sub.Next(&msg.resp) - require.NoError(t, err) - require.Equal(t, "number = 32", msg.resp.InitPayload) - err = sub.Next(&msg.resp) - require.NoError(t, err) - require.Equal(t, "strings = []interface {}{\"hello\", \"world\"}", msg.resp.InitPayload) - sub.Close() - }) - }) - - t.Run("null args", func(t *testing.T) { - var resp struct { - NullableArg *string - } - err := c.Post(`query { nullableArg(arg: null) }`, &resp) - require.Nil(t, err) - require.Equal(t, "Ok", *resp.NullableArg) - }) - +func TestEnums(t *testing.T) { t.Run("list of enums", func(t *testing.T) { require.Equal(t, StatusOk, AllStatus[0]) require.Equal(t, StatusError, AllStatus[1]) }) } - -func TestDirectives(t *testing.T) { - resolvers := &testResolver{tick: make(chan string, 1)} - - srv := httptest.NewServer( - handler.GraphQL( - NewExecutableSchema(Config{ - Resolvers: resolvers, - Directives: DirectiveRoot{ - Length: func(ctx context.Context, obj interface{}, next graphql.Resolver, min int, max *int) (interface{}, error) { - res, err := next(ctx) - if err != nil { - return nil, err - } - - s := res.(string) - if len(s) < min { - return nil, fmt.Errorf("too short") - } - if max != nil && len(s) > *max { - return nil, fmt.Errorf("too long") - } - return res, nil - }, - Range: func(ctx context.Context, obj interface{}, next graphql.Resolver, min *int, max *int) (interface{}, error) { - res, err := next(ctx) - if err != nil { - return nil, err - } - - switch res := res.(type) { - case int: - if min != nil && res < *min { - return nil, fmt.Errorf("too small") - } - if max != nil && res > *max { - return nil, fmt.Errorf("too large") - } - return next(ctx) - - case int64: - if min != nil && int(res) < *min { - return nil, fmt.Errorf("too small") - } - if max != nil && int(res) > *max { - return nil, fmt.Errorf("too large") - } - return next(ctx) - - case *int: - if min != nil && *res < *min { - return nil, fmt.Errorf("too small") - } - if max != nil && *res > *max { - return nil, fmt.Errorf("too large") - } - return next(ctx) - } - return nil, fmt.Errorf("unsupported type %T", res) - }, - }, - }), - handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { - path, _ := ctx.Value("path").([]int) - return next(context.WithValue(ctx, "path", append(path, 1))) - }), - handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { - path, _ := ctx.Value("path").([]int) - return next(context.WithValue(ctx, "path", append(path, 2))) - }), - )) - c := client.New(srv.URL) - - t.Run("arg directives", func(t *testing.T) { - t.Run("when function errors on directives", func(t *testing.T) { - var resp struct { - DirectiveArg *string - } - - err := c.Post(`query { directiveArg(arg: "") }`, &resp) - - require.EqualError(t, err, `[{"message":"too short","path":["directiveArg"]}]`) - require.Nil(t, resp.DirectiveArg) - }) - t.Run("when function errors on nullable arg directives", func(t *testing.T) { - var resp struct { - DirectiveNullableArg *string - } - - err := c.Post(`query { directiveNullableArg(arg: -100) }`, &resp) - - require.EqualError(t, err, `[{"message":"too small","path":["directiveNullableArg"]}]`) - require.Nil(t, resp.DirectiveNullableArg) - }) - t.Run("when function success on nullable arg directives", func(t *testing.T) { - var resp struct { - DirectiveNullableArg *string - } - - err := c.Post(`query { directiveNullableArg }`, &resp) - - require.Nil(t, err) - require.Equal(t, "Ok", *resp.DirectiveNullableArg) - }) - t.Run("when function success on valid nullable arg directives", func(t *testing.T) { - var resp struct { - DirectiveNullableArg *string - } - - err := c.Post(`query { directiveNullableArg(arg: 1) }`, &resp) - - require.Nil(t, err) - require.Equal(t, "Ok", *resp.DirectiveNullableArg) - }) - t.Run("when function success", func(t *testing.T) { - var resp struct { - DirectiveArg *string - } - - err := c.Post(`query { directiveArg(arg: "test") }`, &resp) - - require.Nil(t, err) - require.Equal(t, "Ok", *resp.DirectiveArg) - }) - }) - t.Run("input field directives", func(t *testing.T) { - t.Run("when function errors on directives", func(t *testing.T) { - var resp struct { - DirectiveInputNullable *string - } - - err := c.Post(`query { directiveInputNullable(arg: {text:"invalid text",inner:{message:"123"}}) }`, &resp) - - require.EqualError(t, err, `[{"message":"too long","path":["directiveInputNullable"]}]`) - require.Nil(t, resp.DirectiveInputNullable) - }) - t.Run("when function errors on inner directives", func(t *testing.T) { - var resp struct { - DirectiveInputNullable *string - } - - err := c.Post(`query { directiveInputNullable(arg: {text:"2",inner:{message:""}}) }`, &resp) - - require.EqualError(t, err, `[{"message":"too short","path":["directiveInputNullable"]}]`) - require.Nil(t, resp.DirectiveInputNullable) - }) - t.Run("when function errors on nullable inner directives", func(t *testing.T) { - var resp struct { - DirectiveInputNullable *string - } - - err := c.Post(`query { directiveInputNullable(arg: {text:"success",inner:{message:"1"},innerNullable:{message:""}}) }`, &resp) - - require.EqualError(t, err, `[{"message":"too short","path":["directiveInputNullable"]}]`) - require.Nil(t, resp.DirectiveInputNullable) - }) - t.Run("when function success", func(t *testing.T) { - var resp struct { - DirectiveInputNullable *string - } - - err := c.Post(`query { directiveInputNullable(arg: {text:"23",inner:{message:"1"}}) }`, &resp) - - require.Nil(t, err) - require.Equal(t, "Ok", *resp.DirectiveInputNullable) - }) - t.Run("when function inner nullable success", func(t *testing.T) { - var resp struct { - DirectiveInputNullable *string - } - - err := c.Post(`query { directiveInputNullable(arg: {text:"23",inner:{message:"1"},innerNullable:{message:"success"}}) }`, &resp) - - require.Nil(t, err) - require.Equal(t, "Ok", *resp.DirectiveInputNullable) - }) - }) -} - -func TestIntrospection(t *testing.T) { - t.Run("disabled", func(t *testing.T) { - resolvers := &testResolver{tick: make(chan string, 1)} - - srv := httptest.NewServer( - handler.GraphQL( - NewExecutableSchema(Config{Resolvers: resolvers}), - handler.IntrospectionEnabled(false), - ), - ) - - c := client.New(srv.URL) - - var resp interface{} - err := c.Post(introspection.Query, &resp) - require.EqualError(t, err, "[{\"message\":\"introspection disabled\",\"path\":[\"__schema\"]}]") - }) - - t.Run("enabled by default", func(t *testing.T) { - resolvers := &testResolver{tick: make(chan string, 1)} - - srv := httptest.NewServer( - handler.GraphQL( - NewExecutableSchema(Config{Resolvers: resolvers}), - ), - ) - - c := client.New(srv.URL) - - var resp interface{} - err := c.Post(introspection.Query, &resp) - require.NoError(t, err) - - t.Run("does not return empty deprecation strings", func(t *testing.T) { - q := `{ - __type(name:"InnerObject") { - fields { - name - deprecationReason - } - } - }` - - c := client.New(srv.URL) - var resp struct { - Type struct { - Fields []struct { - Name string - DeprecationReason *string - } - } `json:"__type"` - } - err := c.Post(q, &resp) - require.NoError(t, err) - - require.Equal(t, "id", resp.Type.Fields[0].Name) - require.Nil(t, resp.Type.Fields[0].DeprecationReason) - }) - }) - - t.Run("disabled by middleware", func(t *testing.T) { - resolvers := &testResolver{tick: make(chan string, 1)} - - srv := httptest.NewServer( - handler.GraphQL( - NewExecutableSchema(Config{Resolvers: resolvers}), - handler.RequestMiddleware(func(ctx context.Context, next func(ctx context.Context) []byte) []byte { - graphql.GetRequestContext(ctx).DisableIntrospection = true - - return next(ctx) - }), - ), - ) - - c := client.New(srv.URL) - - var resp interface{} - err := c.Post(introspection.Query, &resp) - require.EqualError(t, err, "[{\"message\":\"introspection disabled\",\"path\":[\"__schema\"]}]") - }) - -} - -var _ graphql.Tracer = (*testTracer)(nil) - -type testTracer struct { - id int - append func(string) -} - -func (tt *testTracer) StartOperationParsing(ctx context.Context) context.Context { - line := fmt.Sprintf("op:p:start:%d", tt.id) - - tracerLogs, _ := ctx.Value("tracer").([]string) - ctx = context.WithValue(ctx, "tracer", append(append([]string{}, tracerLogs...), line)) - tt.append(line) - - return ctx -} - -func (tt *testTracer) EndOperationParsing(ctx context.Context) { - tt.append(fmt.Sprintf("op:p:end:%d", tt.id)) -} - -func (tt *testTracer) StartOperationValidation(ctx context.Context) context.Context { - line := fmt.Sprintf("op:v:start:%d", tt.id) - - tracerLogs, _ := ctx.Value("tracer").([]string) - ctx = context.WithValue(ctx, "tracer", append(append([]string{}, tracerLogs...), line)) - tt.append(line) - - return ctx -} - -func (tt *testTracer) EndOperationValidation(ctx context.Context) { - tt.append(fmt.Sprintf("op:v:end:%d", tt.id)) -} - -func (tt *testTracer) StartOperationExecution(ctx context.Context) context.Context { - line := fmt.Sprintf("op:e:start:%d", tt.id) - - tracerLogs, _ := ctx.Value("tracer").([]string) - ctx = context.WithValue(ctx, "tracer", append(append([]string{}, tracerLogs...), line)) - tt.append(line) - - return ctx -} - -func (tt *testTracer) StartFieldExecution(ctx context.Context, field graphql.CollectedField) context.Context { - line := fmt.Sprintf("field'a:e:start:%d:%s", tt.id, field.Name) - - tracerLogs, _ := ctx.Value("tracer").([]string) - ctx = context.WithValue(ctx, "tracer", append(append([]string{}, tracerLogs...), line)) - tt.append(line) - - return ctx -} - -func (tt *testTracer) StartFieldResolverExecution(ctx context.Context, rc *graphql.ResolverContext) context.Context { - line := fmt.Sprintf("field'b:e:start:%d:%v", tt.id, rc.Path()) - - tracerLogs, _ := ctx.Value("tracer").([]string) - ctx = context.WithValue(ctx, "tracer", append(append([]string{}, tracerLogs...), line)) - tt.append(line) - - return ctx -} - -func (tt *testTracer) StartFieldChildExecution(ctx context.Context) context.Context { - line := fmt.Sprintf("field'c:e:start:%d", tt.id) - - tracerLogs, _ := ctx.Value("tracer").([]string) - ctx = context.WithValue(ctx, "tracer", append(append([]string{}, tracerLogs...), line)) - tt.append(line) - - return ctx -} - -func (tt *testTracer) EndFieldExecution(ctx context.Context) { - tt.append(fmt.Sprintf("field:e:end:%d", tt.id)) -} - -func (tt *testTracer) EndOperationExecution(ctx context.Context) { - tt.append(fmt.Sprintf("op:e:end:%d", tt.id)) -} - -var _ graphql.Tracer = (*configurableTracer)(nil) - -type configurableTracer struct { - StartOperationParsingCallback func(ctx context.Context) context.Context - EndOperationParsingCallback func(ctx context.Context) - StartOperationValidationCallback func(ctx context.Context) context.Context - EndOperationValidationCallback func(ctx context.Context) - StartOperationExecutionCallback func(ctx context.Context) context.Context - StartFieldExecutionCallback func(ctx context.Context, field graphql.CollectedField) context.Context - StartFieldResolverExecutionCallback func(ctx context.Context, rc *graphql.ResolverContext) context.Context - StartFieldChildExecutionCallback func(ctx context.Context) context.Context - EndFieldExecutionCallback func(ctx context.Context) - EndOperationExecutionCallback func(ctx context.Context) -} - -func (ct *configurableTracer) StartOperationParsing(ctx context.Context) context.Context { - if f := ct.StartOperationParsingCallback; f != nil { - ctx = f(ctx) - } - return ctx -} - -func (ct *configurableTracer) EndOperationParsing(ctx context.Context) { - if f := ct.EndOperationParsingCallback; f != nil { - f(ctx) - } -} - -func (ct *configurableTracer) StartOperationValidation(ctx context.Context) context.Context { - if f := ct.StartOperationValidationCallback; f != nil { - ctx = f(ctx) - } - return ctx -} - -func (ct *configurableTracer) EndOperationValidation(ctx context.Context) { - if f := ct.EndOperationValidationCallback; f != nil { - f(ctx) - } -} - -func (ct *configurableTracer) StartOperationExecution(ctx context.Context) context.Context { - if f := ct.StartOperationExecutionCallback; f != nil { - ctx = f(ctx) - } - return ctx -} - -func (ct *configurableTracer) StartFieldExecution(ctx context.Context, field graphql.CollectedField) context.Context { - if f := ct.StartFieldExecutionCallback; f != nil { - ctx = f(ctx, field) - } - return ctx -} - -func (ct *configurableTracer) StartFieldResolverExecution(ctx context.Context, rc *graphql.ResolverContext) context.Context { - if f := ct.StartFieldResolverExecutionCallback; f != nil { - ctx = f(ctx, rc) - } - return ctx -} - -func (ct *configurableTracer) StartFieldChildExecution(ctx context.Context) context.Context { - if f := ct.StartFieldChildExecutionCallback; f != nil { - ctx = f(ctx) - } - return ctx -} - -func (ct *configurableTracer) EndFieldExecution(ctx context.Context) { - if f := ct.EndFieldExecutionCallback; f != nil { - f(ctx) - } -} - -func (ct *configurableTracer) EndOperationExecution(ctx context.Context) { - if f := ct.EndOperationExecutionCallback; f != nil { - f(ctx) - } -} - -func TestTracer(t *testing.T) { - t.Run("called in the correct order", func(t *testing.T) { - resolvers := &testResolver{tick: make(chan string, 1)} - - var tracerLog []string - var mu sync.Mutex - - srv := httptest.NewServer( - handler.GraphQL( - NewExecutableSchema(Config{Resolvers: resolvers}), - handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { - path, _ := ctx.Value("path").([]int) - return next(context.WithValue(ctx, "path", append(path, 1))) - }), - handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { - path, _ := ctx.Value("path").([]int) - return next(context.WithValue(ctx, "path", append(path, 2))) - }), - handler.Tracer(&testTracer{ - id: 1, - append: func(s string) { - mu.Lock() - defer mu.Unlock() - tracerLog = append(tracerLog, s) - }, - }), - handler.Tracer(&testTracer{ - id: 2, - append: func(s string) { - mu.Lock() - defer mu.Unlock() - tracerLog = append(tracerLog, s) - }, - }), - )) - defer srv.Close() - c := client.New(srv.URL) - - var resp struct { - User struct { - ID int - Friends []struct { - ID int - } - } - } - - called := false - resolvers.userFriends = func(ctx context.Context, obj *User) ([]User, error) { - assert.Equal(t, []string{ - "op:p:start:1", "op:p:start:2", - "op:v:start:1", "op:v:start:2", - "op:e:start:1", "op:e:start:2", - "field'a:e:start:1:user", "field'a:e:start:2:user", - "field'b:e:start:1:[user]", "field'b:e:start:2:[user]", - "field'c:e:start:1", "field'c:e:start:2", - "field'a:e:start:1:friends", "field'a:e:start:2:friends", - "field'b:e:start:1:[user friends]", "field'b:e:start:2:[user friends]", - }, ctx.Value("tracer")) - called = true - return []User{}, nil - } - - err := c.Post(`query { user(id: 1) { id, friends { id } } }`, &resp) - - require.NoError(t, err) - require.True(t, called) - mu.Lock() - defer mu.Unlock() - assert.Equal(t, []string{ - "op:p:start:1", "op:p:start:2", - "op:p:end:2", "op:p:end:1", - - "op:v:start:1", "op:v:start:2", - "op:v:end:2", "op:v:end:1", - - "op:e:start:1", "op:e:start:2", - - "field'a:e:start:1:user", "field'a:e:start:2:user", - "field'b:e:start:1:[user]", "field'b:e:start:2:[user]", - "field'c:e:start:1", "field'c:e:start:2", - "field'a:e:start:1:id", "field'a:e:start:2:id", - "field'b:e:start:1:[user id]", "field'b:e:start:2:[user id]", - "field'c:e:start:1", "field'c:e:start:2", - "field:e:end:2", "field:e:end:1", - "field'a:e:start:1:friends", "field'a:e:start:2:friends", - "field'b:e:start:1:[user friends]", "field'b:e:start:2:[user friends]", - "field'c:e:start:1", "field'c:e:start:2", - "field:e:end:2", "field:e:end:1", - "field:e:end:2", "field:e:end:1", - - "op:e:end:2", "op:e:end:1", - }, tracerLog) - }) - - t.Run("take ctx over from prev step", func(t *testing.T) { - resolvers := &testResolver{tick: make(chan string, 1)} - - configurableTracer := &configurableTracer{ - StartOperationParsingCallback: func(ctx context.Context) context.Context { - return context.WithValue(ctx, "StartOperationParsing", true) - }, - EndOperationParsingCallback: func(ctx context.Context) { - assert.NotNil(t, ctx.Value("StartOperationParsing")) - }, - - StartOperationValidationCallback: func(ctx context.Context) context.Context { - return context.WithValue(ctx, "StartOperationValidation", true) - }, - EndOperationValidationCallback: func(ctx context.Context) { - assert.NotNil(t, ctx.Value("StartOperationParsing")) - assert.NotNil(t, ctx.Value("StartOperationValidation")) - }, - - StartOperationExecutionCallback: func(ctx context.Context) context.Context { - return context.WithValue(ctx, "StartOperationExecution", true) - }, - StartFieldExecutionCallback: func(ctx context.Context, field graphql.CollectedField) context.Context { - return context.WithValue(ctx, "StartFieldExecution", true) - }, - StartFieldResolverExecutionCallback: func(ctx context.Context, rc *graphql.ResolverContext) context.Context { - return context.WithValue(ctx, "StartFieldResolverExecution", true) - }, - StartFieldChildExecutionCallback: func(ctx context.Context) context.Context { - return context.WithValue(ctx, "StartFieldChildExecution", true) - }, - EndFieldExecutionCallback: func(ctx context.Context) { - assert.NotNil(t, ctx.Value("StartOperationParsing")) - assert.NotNil(t, ctx.Value("StartOperationValidation")) - assert.NotNil(t, ctx.Value("StartOperationExecution")) - assert.NotNil(t, ctx.Value("StartFieldExecution")) - assert.NotNil(t, ctx.Value("StartFieldResolverExecution")) - assert.NotNil(t, ctx.Value("StartFieldChildExecution")) - }, - - EndOperationExecutionCallback: func(ctx context.Context) { - assert.NotNil(t, ctx.Value("StartOperationParsing")) - assert.NotNil(t, ctx.Value("StartOperationValidation")) - assert.NotNil(t, ctx.Value("StartOperationExecution")) - }, - } - - srv := httptest.NewServer( - handler.GraphQL( - NewExecutableSchema(Config{Resolvers: resolvers}), - handler.Tracer(configurableTracer), - )) - defer srv.Close() - c := client.New(srv.URL) - - var resp struct { - User struct { - ID int - Friends []struct { - ID int - } - } - } - - called := false - resolvers.userFriends = func(ctx context.Context, obj *User) ([]User, error) { - called = true - return []User{}, nil - } - - err := c.Post(`query { user(id: 1) { id, friends { id } } }`, &resp) - - require.NoError(t, err) - require.True(t, called) - }) - - t.Run("model methods", func(t *testing.T) { - srv := httptest.NewServer( - handler.GraphQL( - NewExecutableSchema(Config{Resolvers: &testResolver{}}), - )) - defer srv.Close() - c := client.New(srv.URL) - t.Run("without context", func(t *testing.T) { - var resp struct { - ModelMethods struct { - NoContext bool - } - } - err := c.Post(`query { modelMethods{ noContext } }`, &resp) - require.NoError(t, err) - require.True(t, resp.ModelMethods.NoContext) - }) - t.Run("with context", func(t *testing.T) { - var resp struct { - ModelMethods struct { - WithContext bool - } - } - err := c.Post(`query { modelMethods{ withContext } }`, &resp) - require.NoError(t, err) - require.True(t, resp.ModelMethods.WithContext) - }) - }) -} - -func TestResponseExtension(t *testing.T) { - srv := httptest.NewServer(handler.GraphQL( - NewExecutableSchema(Config{ - Resolvers: &testResolver{}, - }), - handler.RequestMiddleware(func(ctx context.Context, next func(ctx context.Context) []byte) []byte { - rctx := graphql.GetRequestContext(ctx) - if err := rctx.RegisterExtension("example", "value"); err != nil { - panic(err) - } - return next(ctx) - }), - )) - c := client.New(srv.URL) - - raw, _ := c.RawPost(`query { valid }`) - require.Equal(t, raw.Extensions["example"], "value") -} - -type testResolver struct { - tick chan string - userFriends func(ctx context.Context, obj *User) ([]User, error) -} - -func (r *testResolver) ForcedResolver() ForcedResolverResolver { - return &forcedResolverResolver{nil} -} - -func (r *testResolver) User() UserResolver { - return &testUserResolver{r} -} - -func (r *testResolver) Query() QueryResolver { - return &testQueryResolver{} -} -func (r *testResolver) ModelMethods() ModelMethodsResolver { - return &testModelMethodsResolver{} -} - -type testModelMethodsResolver struct{} - -func (r *testModelMethodsResolver) ResolverField(ctx context.Context, obj *ModelMethods) (bool, error) { - return true, nil -} - -type testQueryResolver struct{ queryResolver } - -func (r *testQueryResolver) ErrorBubble(ctx context.Context) (*Error, error) { - return &Error{ID: "E1234"}, nil -} - -func (r *testQueryResolver) Valid(ctx context.Context) (string, error) { - return "Ok", nil -} - -func (r *testQueryResolver) User(ctx context.Context, id int) (User, error) { - return User{ID: 1}, nil -} - -func (r *testQueryResolver) NullableArg(ctx context.Context, arg *int) (*string, error) { - s := "Ok" - return &s, nil -} - -func (r *testQueryResolver) DirectiveArg(ctx context.Context, arg string) (*string, error) { - s := "Ok" - return &s, nil -} - -func (r *testQueryResolver) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int) (*string, error) { - s := "Ok" - return &s, nil -} - -func (r *testQueryResolver) DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) { - s := "Ok" - return &s, nil -} - -func (r *testQueryResolver) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) { - s := "Ok" - return &s, nil -} - -func (r *testQueryResolver) ModelMethods(ctx context.Context) (*ModelMethods, error) { - return &ModelMethods{}, nil -} - -func (r *testResolver) Subscription() SubscriptionResolver { - return &testSubscriptionResolver{r} -} - -type testUserResolver struct{ *testResolver } - -func (r *testResolver) Friends(ctx context.Context, obj *User) ([]User, error) { - return r.userFriends(ctx, obj) -} - -type testSubscriptionResolver struct{ *testResolver } - -func (r *testSubscriptionResolver) Updated(ctx context.Context) (<-chan string, error) { - res := make(chan string, 1) - - go func() { - for { - select { - case t := <-r.tick: - res <- t - case <-ctx.Done(): - close(res) - return - } - } - }() - return res, nil -} - -func (r *testSubscriptionResolver) InitPayload(ctx context.Context) (<-chan string, error) { - payload := handler.GetInitPayload(ctx) - channel := make(chan string, len(payload)+1) - - go func() { - <-ctx.Done() - close(channel) - }() - - // Test the helper function separately - auth := payload.Authorization() - if auth != "" { - channel <- "AUTH:" + auth - } else { - channel <- "AUTH:NONE" - } - - // Send them over the channel in alphabetic order - keys := make([]string, 0, len(payload)) - for key := range payload { - keys = append(keys, key) - } - sort.Strings(keys) - for _, key := range keys { - channel <- fmt.Sprintf("%s = %#+v", key, payload[key]) - } - - return channel, nil -} diff --git a/codegen/testserver/introspection_test.go b/codegen/testserver/introspection_test.go new file mode 100644 index 00000000000..546390749ae --- /dev/null +++ b/codegen/testserver/introspection_test.go @@ -0,0 +1,95 @@ +package testserver + +import ( + "context" + "net/http/httptest" + "testing" + + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql/introspection" + "github.com/99designs/gqlgen/handler" + "github.com/stretchr/testify/require" +) + +func TestIntrospection(t *testing.T) { + t.Run("disabled", func(t *testing.T) { + resolvers := &Stub{} + + srv := httptest.NewServer( + handler.GraphQL( + NewExecutableSchema(Config{Resolvers: resolvers}), + handler.IntrospectionEnabled(false), + ), + ) + + c := client.New(srv.URL) + + var resp interface{} + err := c.Post(introspection.Query, &resp) + require.EqualError(t, err, "[{\"message\":\"introspection disabled\",\"path\":[\"__schema\"]}]") + }) + + t.Run("enabled by default", func(t *testing.T) { + resolvers := &Stub{} + + srv := httptest.NewServer( + handler.GraphQL( + NewExecutableSchema(Config{Resolvers: resolvers}), + ), + ) + + c := client.New(srv.URL) + + var resp interface{} + err := c.Post(introspection.Query, &resp) + require.NoError(t, err) + + t.Run("does not return empty deprecation strings", func(t *testing.T) { + q := `{ + __type(name:"InnerObject") { + fields { + name + deprecationReason + } + } + }` + + c := client.New(srv.URL) + var resp struct { + Type struct { + Fields []struct { + Name string + DeprecationReason *string + } + } `json:"__type"` + } + err := c.Post(q, &resp) + require.NoError(t, err) + + require.Equal(t, "id", resp.Type.Fields[0].Name) + require.Nil(t, resp.Type.Fields[0].DeprecationReason) + }) + }) + + t.Run("disabled by middleware", func(t *testing.T) { + resolvers := &Stub{} + + srv := httptest.NewServer( + handler.GraphQL( + NewExecutableSchema(Config{Resolvers: resolvers}), + handler.RequestMiddleware(func(ctx context.Context, next func(ctx context.Context) []byte) []byte { + graphql.GetRequestContext(ctx).DisableIntrospection = true + + return next(ctx) + }), + ), + ) + + c := client.New(srv.URL) + + var resp interface{} + err := c.Post(introspection.Query, &resp) + require.EqualError(t, err, "[{\"message\":\"introspection disabled\",\"path\":[\"__schema\"]}]") + }) +} diff --git a/codegen/testserver/middleware_test.go b/codegen/testserver/middleware_test.go new file mode 100644 index 00000000000..231b839cfea --- /dev/null +++ b/codegen/testserver/middleware_test.go @@ -0,0 +1,66 @@ +package testserver + +import ( + "context" + "net/http/httptest" + "testing" + + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/handler" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestMiddleware(t *testing.T) { + resolvers := &Stub{} + resolvers.QueryResolver.ErrorBubble = func(ctx context.Context) (i *Error, e error) { + return &Error{ID: "E1234"}, nil + } + + resolvers.QueryResolver.User = func(ctx context.Context, id int) (user User, e error) { + return User{ID: 1}, nil + } + + resolvers.UserResolver.Friends = func(ctx context.Context, obj *User) (users []User, e error) { + return []User{{ID: 1}}, nil + } + + srv := httptest.NewServer( + handler.GraphQL( + NewExecutableSchema(Config{Resolvers: resolvers}), + handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + path, _ := ctx.Value("path").([]int) + return next(context.WithValue(ctx, "path", append(path, 1))) + }), + handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + path, _ := ctx.Value("path").([]int) + return next(context.WithValue(ctx, "path", append(path, 2))) + }), + )) + + c := client.New(srv.URL) + + var resp struct { + User struct { + ID int + Friends []struct { + ID int + } + } + } + + called := false + resolvers.UserResolver.Friends = func(ctx context.Context, obj *User) ([]User, error) { + assert.Equal(t, []int{1, 2, 1, 2}, ctx.Value("path")) + called = true + return []User{}, nil + } + + err := c.Post(`query { user(id: 1) { id, friends { id } } }`, &resp) + + require.NoError(t, err) + require.True(t, called) + +} diff --git a/codegen/testserver/modelmethod_test.go b/codegen/testserver/modelmethod_test.go new file mode 100644 index 00000000000..d484aa745af --- /dev/null +++ b/codegen/testserver/modelmethod_test.go @@ -0,0 +1,48 @@ +package testserver + +import ( + "context" + "net/http/httptest" + "testing" + + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/handler" + "github.com/stretchr/testify/require" +) + +func TestModelMethods(t *testing.T) { + resolver := &Stub{} + resolver.QueryResolver.ModelMethods = func(ctx context.Context) (methods *ModelMethods, e error) { + return &ModelMethods{}, nil + } + resolver.ModelMethodsResolver.ResolverField = func(ctx context.Context, obj *ModelMethods) (b bool, e error) { + return true, nil + } + + srv := httptest.NewServer( + handler.GraphQL( + NewExecutableSchema(Config{Resolvers: resolver}), + )) + defer srv.Close() + c := client.New(srv.URL) + t.Run("without context", func(t *testing.T) { + var resp struct { + ModelMethods struct { + NoContext bool + } + } + err := c.Post(`query { modelMethods{ noContext } }`, &resp) + require.NoError(t, err) + require.True(t, resp.ModelMethods.NoContext) + }) + t.Run("with context", func(t *testing.T) { + var resp struct { + ModelMethods struct { + WithContext bool + } + } + err := c.Post(`query { modelMethods{ withContext } }`, &resp) + require.NoError(t, err) + require.True(t, resp.ModelMethods.WithContext) + }) +} diff --git a/codegen/testserver/nulls_test.go b/codegen/testserver/nulls_test.go new file mode 100644 index 00000000000..b70935db11d --- /dev/null +++ b/codegen/testserver/nulls_test.go @@ -0,0 +1,83 @@ +package testserver + +import ( + "context" + "net/http/httptest" + "testing" + + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/handler" + "github.com/stretchr/testify/require" +) + +func TestNullBubbling(t *testing.T) { + resolvers := &Stub{} + resolvers.QueryResolver.Valid = func(ctx context.Context) (s string, e error) { + return "Ok", nil + } + + resolvers.QueryResolver.ErrorBubble = func(ctx context.Context) (i *Error, e error) { + return &Error{ID: "E1234"}, nil + } + + srv := httptest.NewServer(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolvers}))) + c := client.New(srv.URL) + + t.Run("when function errors on non required field", func(t *testing.T) { + var resp struct { + Valid string + ErrorBubble *struct { + Id string + ErrorOnNonRequiredField *string + } + } + err := c.Post(`query { valid, errorBubble { id, errorOnNonRequiredField } }`, &resp) + + require.EqualError(t, err, `[{"message":"boom","path":["errorBubble","errorOnNonRequiredField"]}]`) + require.Equal(t, "E1234", resp.ErrorBubble.Id) + require.Nil(t, resp.ErrorBubble.ErrorOnNonRequiredField) + require.Equal(t, "Ok", resp.Valid) + }) + + t.Run("when function errors", func(t *testing.T) { + var resp struct { + Valid string + ErrorBubble *struct { + NilOnRequiredField string + } + } + err := c.Post(`query { valid, errorBubble { id, errorOnRequiredField } }`, &resp) + + require.EqualError(t, err, `[{"message":"boom","path":["errorBubble","errorOnRequiredField"]}]`) + require.Nil(t, resp.ErrorBubble) + require.Equal(t, "Ok", resp.Valid) + }) + + t.Run("when user returns null on required field", func(t *testing.T) { + var resp struct { + Valid string + ErrorBubble *struct { + NilOnRequiredField string + } + } + err := c.Post(`query { valid, errorBubble { id, nilOnRequiredField } }`, &resp) + + require.EqualError(t, err, `[{"message":"must not be null","path":["errorBubble","nilOnRequiredField"]}]`) + require.Nil(t, resp.ErrorBubble) + require.Equal(t, "Ok", resp.Valid) + }) + + t.Run("null args", func(t *testing.T) { + var resp struct { + NullableArg *string + } + resolvers.QueryResolver.NullableArg = func(ctx context.Context, arg *int) (i *string, e error) { + v := "Ok" + return &v, nil + } + + err := c.Post(`query { nullableArg(arg: null) }`, &resp) + require.Nil(t, err) + require.Equal(t, "Ok", *resp.NullableArg) + }) +} diff --git a/codegen/testserver/response_extension_test.go b/codegen/testserver/response_extension_test.go new file mode 100644 index 00000000000..026aa31716b --- /dev/null +++ b/codegen/testserver/response_extension_test.go @@ -0,0 +1,34 @@ +package testserver + +import ( + "context" + "net/http/httptest" + "testing" + + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/handler" + "github.com/stretchr/testify/require" +) + +func TestResponseExtension(t *testing.T) { + resolvers := &Stub{} + resolvers.QueryResolver.Valid = func(ctx context.Context) (s string, e error) { + return "Ok", nil + } + + srv := httptest.NewServer(handler.GraphQL( + NewExecutableSchema(Config{Resolvers: resolvers}), + handler.RequestMiddleware(func(ctx context.Context, next func(ctx context.Context) []byte) []byte { + rctx := graphql.GetRequestContext(ctx) + if err := rctx.RegisterExtension("example", "value"); err != nil { + panic(err) + } + return next(ctx) + }), + )) + c := client.New(srv.URL) + + raw, _ := c.RawPost(`query { valid }`) + require.Equal(t, raw.Extensions["example"], "value") +} diff --git a/codegen/testserver/stub.go b/codegen/testserver/stub.go new file mode 100644 index 00000000000..09712806267 --- /dev/null +++ b/codegen/testserver/stub.go @@ -0,0 +1,146 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + +package testserver + +import ( + "context" + + introspection1 "github.com/99designs/gqlgen/codegen/testserver/introspection" + "github.com/99designs/gqlgen/codegen/testserver/invalid-packagename" +) + +type Stub struct { + ForcedResolverResolver struct { + Field func(ctx context.Context, obj *ForcedResolver) (*Circle, error) + } + ModelMethodsResolver struct { + ResolverField func(ctx context.Context, obj *ModelMethods) (bool, error) + } + QueryResolver struct { + InvalidIdentifier func(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) + Collision func(ctx context.Context) (*introspection1.It, error) + MapInput func(ctx context.Context, input map[string]interface{}) (*bool, error) + Recursive func(ctx context.Context, input *RecursiveInputSlice) (*bool, error) + NestedInputs func(ctx context.Context, input [][]*OuterInput) (*bool, error) + NestedOutputs func(ctx context.Context) ([][]*OuterObject, error) + Keywords func(ctx context.Context, input *Keywords) (bool, error) + Shapes func(ctx context.Context) ([]Shape, error) + ErrorBubble func(ctx context.Context) (*Error, error) + ModelMethods func(ctx context.Context) (*ModelMethods, error) + Valid func(ctx context.Context) (string, error) + User func(ctx context.Context, id int) (User, error) + NullableArg func(ctx context.Context, arg *int) (*string, error) + DirectiveArg func(ctx context.Context, arg string) (*string, error) + DirectiveNullableArg func(ctx context.Context, arg *int, arg2 *int) (*string, error) + DirectiveInputNullable func(ctx context.Context, arg *InputDirectives) (*string, error) + DirectiveInput func(ctx context.Context, arg InputDirectives) (*string, error) + KeywordArgs func(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) + } + SubscriptionResolver struct { + Updated func(ctx context.Context) (<-chan string, error) + InitPayload func(ctx context.Context) (<-chan string, error) + } + UserResolver struct { + Friends func(ctx context.Context, obj *User) ([]User, error) + } +} + +func (r *Stub) ForcedResolver() ForcedResolverResolver { + return &stubForcedResolver{r} +} +func (r *Stub) ModelMethods() ModelMethodsResolver { + return &stubModelMethods{r} +} +func (r *Stub) Query() QueryResolver { + return &stubQuery{r} +} +func (r *Stub) Subscription() SubscriptionResolver { + return &stubSubscription{r} +} +func (r *Stub) User() UserResolver { + return &stubUser{r} +} + +type stubForcedResolver struct{ *Stub } + +func (r *stubForcedResolver) Field(ctx context.Context, obj *ForcedResolver) (*Circle, error) { + return r.ForcedResolverResolver.Field(ctx, obj) +} + +type stubModelMethods struct{ *Stub } + +func (r *stubModelMethods) ResolverField(ctx context.Context, obj *ModelMethods) (bool, error) { + return r.ModelMethodsResolver.ResolverField(ctx, obj) +} + +type stubQuery struct{ *Stub } + +func (r *stubQuery) InvalidIdentifier(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) { + return r.QueryResolver.InvalidIdentifier(ctx) +} +func (r *stubQuery) Collision(ctx context.Context) (*introspection1.It, error) { + return r.QueryResolver.Collision(ctx) +} +func (r *stubQuery) MapInput(ctx context.Context, input map[string]interface{}) (*bool, error) { + return r.QueryResolver.MapInput(ctx, input) +} +func (r *stubQuery) Recursive(ctx context.Context, input *RecursiveInputSlice) (*bool, error) { + return r.QueryResolver.Recursive(ctx, input) +} +func (r *stubQuery) NestedInputs(ctx context.Context, input [][]*OuterInput) (*bool, error) { + return r.QueryResolver.NestedInputs(ctx, input) +} +func (r *stubQuery) NestedOutputs(ctx context.Context) ([][]*OuterObject, error) { + return r.QueryResolver.NestedOutputs(ctx) +} +func (r *stubQuery) Keywords(ctx context.Context, input *Keywords) (bool, error) { + return r.QueryResolver.Keywords(ctx, input) +} +func (r *stubQuery) Shapes(ctx context.Context) ([]Shape, error) { + return r.QueryResolver.Shapes(ctx) +} +func (r *stubQuery) ErrorBubble(ctx context.Context) (*Error, error) { + return r.QueryResolver.ErrorBubble(ctx) +} +func (r *stubQuery) ModelMethods(ctx context.Context) (*ModelMethods, error) { + return r.QueryResolver.ModelMethods(ctx) +} +func (r *stubQuery) Valid(ctx context.Context) (string, error) { + return r.QueryResolver.Valid(ctx) +} +func (r *stubQuery) User(ctx context.Context, id int) (User, error) { + return r.QueryResolver.User(ctx, id) +} +func (r *stubQuery) NullableArg(ctx context.Context, arg *int) (*string, error) { + return r.QueryResolver.NullableArg(ctx, arg) +} +func (r *stubQuery) DirectiveArg(ctx context.Context, arg string) (*string, error) { + return r.QueryResolver.DirectiveArg(ctx, arg) +} +func (r *stubQuery) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int) (*string, error) { + return r.QueryResolver.DirectiveNullableArg(ctx, arg, arg2) +} +func (r *stubQuery) DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) { + return r.QueryResolver.DirectiveInputNullable(ctx, arg) +} +func (r *stubQuery) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) { + return r.QueryResolver.DirectiveInput(ctx, arg) +} +func (r *stubQuery) KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) { + return r.QueryResolver.KeywordArgs(ctx, breakArg, defaultArg, funcArg, interfaceArg, selectArg, caseArg, deferArg, goArg, mapArg, structArg, chanArg, elseArg, gotoArg, packageArg, switchArg, constArg, fallthroughArg, ifArg, rangeArg, typeArg, continueArg, forArg, importArg, returnArg, varArg) +} + +type stubSubscription struct{ *Stub } + +func (r *stubSubscription) Updated(ctx context.Context) (<-chan string, error) { + return r.SubscriptionResolver.Updated(ctx) +} +func (r *stubSubscription) InitPayload(ctx context.Context) (<-chan string, error) { + return r.SubscriptionResolver.InitPayload(ctx) +} + +type stubUser struct{ *Stub } + +func (r *stubUser) Friends(ctx context.Context, obj *User) ([]User, error) { + return r.UserResolver.Friends(ctx, obj) +} diff --git a/codegen/testserver/subscription_test.go b/codegen/testserver/subscription_test.go new file mode 100644 index 00000000000..16fdc8007e3 --- /dev/null +++ b/codegen/testserver/subscription_test.go @@ -0,0 +1,139 @@ +package testserver + +import ( + "context" + "fmt" + "net/http/httptest" + "runtime" + "sort" + "testing" + "time" + + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/handler" + "github.com/stretchr/testify/require" +) + +func TestSubscriptions(t *testing.T) { + tick := make(chan string, 1) + + resolvers := &Stub{} + + resolvers.SubscriptionResolver.InitPayload = func(ctx context.Context) (strings <-chan string, e error) { + payload := handler.GetInitPayload(ctx) + channel := make(chan string, len(payload)+1) + + go func() { + <-ctx.Done() + close(channel) + }() + + // Test the helper function separately + auth := payload.Authorization() + if auth != "" { + channel <- "AUTH:" + auth + } else { + channel <- "AUTH:NONE" + } + + // Send them over the channel in alphabetic order + keys := make([]string, 0, len(payload)) + for key := range payload { + keys = append(keys, key) + } + sort.Strings(keys) + for _, key := range keys { + channel <- fmt.Sprintf("%s = %#+v", key, payload[key]) + } + + return channel, nil + } + + resolvers.SubscriptionResolver.Updated = func(ctx context.Context) (<-chan string, error) { + res := make(chan string, 1) + + go func() { + for { + select { + case t := <-tick: + res <- t + case <-ctx.Done(): + close(res) + return + } + } + }() + return res, nil + } + + srv := httptest.NewServer( + handler.GraphQL( + NewExecutableSchema(Config{Resolvers: resolvers}), + handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + path, _ := ctx.Value("path").([]int) + return next(context.WithValue(ctx, "path", append(path, 1))) + }), + handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + path, _ := ctx.Value("path").([]int) + return next(context.WithValue(ctx, "path", append(path, 2))) + }), + )) + c := client.New(srv.URL) + + t.Run("wont leak goroutines", func(t *testing.T) { + runtime.GC() // ensure no go-routines left from preceding tests + initialGoroutineCount := runtime.NumGoroutine() + + sub := c.Websocket(`subscription { updated }`) + + tick <- "message" + + var msg struct { + resp struct { + Updated string + } + } + + err := sub.Next(&msg.resp) + require.NoError(t, err) + require.Equal(t, "message", msg.resp.Updated) + sub.Close() + + // need a little bit of time for goroutines to settle + start := time.Now() + for time.Since(start).Seconds() < 2 && initialGoroutineCount != runtime.NumGoroutine() { + time.Sleep(5 * time.Millisecond) + } + + require.Equal(t, initialGoroutineCount, runtime.NumGoroutine()) + }) + + t.Run("will parse init payload", func(t *testing.T) { + sub := c.WebsocketWithPayload(`subscription { initPayload }`, map[string]interface{}{ + "Authorization": "Bearer of the curse", + "number": 32, + "strings": []string{"hello", "world"}, + }) + + var msg struct { + resp struct { + InitPayload string + } + } + + err := sub.Next(&msg.resp) + require.NoError(t, err) + require.Equal(t, "AUTH:Bearer of the curse", msg.resp.InitPayload) + err = sub.Next(&msg.resp) + require.NoError(t, err) + require.Equal(t, "Authorization = \"Bearer of the curse\"", msg.resp.InitPayload) + err = sub.Next(&msg.resp) + require.NoError(t, err) + require.Equal(t, "number = 32", msg.resp.InitPayload) + err = sub.Next(&msg.resp) + require.NoError(t, err) + require.Equal(t, "strings = []interface {}{\"hello\", \"world\"}", msg.resp.InitPayload) + sub.Close() + }) +} diff --git a/codegen/testserver/tracer_test.go b/codegen/testserver/tracer_test.go new file mode 100644 index 00000000000..d0fad686b0e --- /dev/null +++ b/codegen/testserver/tracer_test.go @@ -0,0 +1,352 @@ +package testserver + +import ( + "context" + "fmt" + "net/http/httptest" + "sync" + "testing" + + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/handler" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestTracer(t *testing.T) { + resolvers := &Stub{} + resolvers.QueryResolver.User = func(ctx context.Context, id int) (user User, e error) { + return User{ID: 1}, nil + } + t.Run("called in the correct order", func(t *testing.T) { + var tracerLog []string + var mu sync.Mutex + + srv := httptest.NewServer( + handler.GraphQL( + NewExecutableSchema(Config{Resolvers: resolvers}), + handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + path, _ := ctx.Value("path").([]int) + return next(context.WithValue(ctx, "path", append(path, 1))) + }), + handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + path, _ := ctx.Value("path").([]int) + return next(context.WithValue(ctx, "path", append(path, 2))) + }), + handler.Tracer(&testTracer{ + id: 1, + append: func(s string) { + mu.Lock() + defer mu.Unlock() + tracerLog = append(tracerLog, s) + }, + }), + handler.Tracer(&testTracer{ + id: 2, + append: func(s string) { + mu.Lock() + defer mu.Unlock() + tracerLog = append(tracerLog, s) + }, + }), + )) + defer srv.Close() + c := client.New(srv.URL) + + var resp struct { + User struct { + ID int + Friends []struct { + ID int + } + } + } + + called := false + resolvers.UserResolver.Friends = func(ctx context.Context, obj *User) ([]User, error) { + assert.Equal(t, []string{ + "op:p:start:1", "op:p:start:2", + "op:v:start:1", "op:v:start:2", + "op:e:start:1", "op:e:start:2", + "field'a:e:start:1:user", "field'a:e:start:2:user", + "field'b:e:start:1:[user]", "field'b:e:start:2:[user]", + "field'c:e:start:1", "field'c:e:start:2", + "field'a:e:start:1:friends", "field'a:e:start:2:friends", + "field'b:e:start:1:[user friends]", "field'b:e:start:2:[user friends]", + }, ctx.Value("tracer")) + called = true + return []User{}, nil + } + + err := c.Post(`query { user(id: 1) { id, friends { id } } }`, &resp) + + require.NoError(t, err) + require.True(t, called) + mu.Lock() + defer mu.Unlock() + assert.Equal(t, []string{ + "op:p:start:1", "op:p:start:2", + "op:p:end:2", "op:p:end:1", + + "op:v:start:1", "op:v:start:2", + "op:v:end:2", "op:v:end:1", + + "op:e:start:1", "op:e:start:2", + + "field'a:e:start:1:user", "field'a:e:start:2:user", + "field'b:e:start:1:[user]", "field'b:e:start:2:[user]", + "field'c:e:start:1", "field'c:e:start:2", + "field'a:e:start:1:id", "field'a:e:start:2:id", + "field'b:e:start:1:[user id]", "field'b:e:start:2:[user id]", + "field'c:e:start:1", "field'c:e:start:2", + "field:e:end:2", "field:e:end:1", + "field'a:e:start:1:friends", "field'a:e:start:2:friends", + "field'b:e:start:1:[user friends]", "field'b:e:start:2:[user friends]", + "field'c:e:start:1", "field'c:e:start:2", + "field:e:end:2", "field:e:end:1", + "field:e:end:2", "field:e:end:1", + + "op:e:end:2", "op:e:end:1", + }, tracerLog) + }) + + t.Run("take ctx over from prev step", func(t *testing.T) { + + configurableTracer := &configurableTracer{ + StartOperationParsingCallback: func(ctx context.Context) context.Context { + return context.WithValue(ctx, "StartOperationParsing", true) + }, + EndOperationParsingCallback: func(ctx context.Context) { + assert.NotNil(t, ctx.Value("StartOperationParsing")) + }, + + StartOperationValidationCallback: func(ctx context.Context) context.Context { + return context.WithValue(ctx, "StartOperationValidation", true) + }, + EndOperationValidationCallback: func(ctx context.Context) { + assert.NotNil(t, ctx.Value("StartOperationParsing")) + assert.NotNil(t, ctx.Value("StartOperationValidation")) + }, + + StartOperationExecutionCallback: func(ctx context.Context) context.Context { + return context.WithValue(ctx, "StartOperationExecution", true) + }, + StartFieldExecutionCallback: func(ctx context.Context, field graphql.CollectedField) context.Context { + return context.WithValue(ctx, "StartFieldExecution", true) + }, + StartFieldResolverExecutionCallback: func(ctx context.Context, rc *graphql.ResolverContext) context.Context { + return context.WithValue(ctx, "StartFieldResolverExecution", true) + }, + StartFieldChildExecutionCallback: func(ctx context.Context) context.Context { + return context.WithValue(ctx, "StartFieldChildExecution", true) + }, + EndFieldExecutionCallback: func(ctx context.Context) { + assert.NotNil(t, ctx.Value("StartOperationParsing")) + assert.NotNil(t, ctx.Value("StartOperationValidation")) + assert.NotNil(t, ctx.Value("StartOperationExecution")) + assert.NotNil(t, ctx.Value("StartFieldExecution")) + assert.NotNil(t, ctx.Value("StartFieldResolverExecution")) + assert.NotNil(t, ctx.Value("StartFieldChildExecution")) + }, + + EndOperationExecutionCallback: func(ctx context.Context) { + assert.NotNil(t, ctx.Value("StartOperationParsing")) + assert.NotNil(t, ctx.Value("StartOperationValidation")) + assert.NotNil(t, ctx.Value("StartOperationExecution")) + }, + } + + srv := httptest.NewServer( + handler.GraphQL( + NewExecutableSchema(Config{Resolvers: resolvers}), + handler.Tracer(configurableTracer), + )) + defer srv.Close() + c := client.New(srv.URL) + + var resp struct { + User struct { + ID int + Friends []struct { + ID int + } + } + } + + called := false + resolvers.UserResolver.Friends = func(ctx context.Context, obj *User) ([]User, error) { + called = true + return []User{}, nil + } + + err := c.Post(`query { user(id: 1) { id, friends { id } } }`, &resp) + + require.NoError(t, err) + require.True(t, called) + }) +} + +var _ graphql.Tracer = (*configurableTracer)(nil) + +type configurableTracer struct { + StartOperationParsingCallback func(ctx context.Context) context.Context + EndOperationParsingCallback func(ctx context.Context) + StartOperationValidationCallback func(ctx context.Context) context.Context + EndOperationValidationCallback func(ctx context.Context) + StartOperationExecutionCallback func(ctx context.Context) context.Context + StartFieldExecutionCallback func(ctx context.Context, field graphql.CollectedField) context.Context + StartFieldResolverExecutionCallback func(ctx context.Context, rc *graphql.ResolverContext) context.Context + StartFieldChildExecutionCallback func(ctx context.Context) context.Context + EndFieldExecutionCallback func(ctx context.Context) + EndOperationExecutionCallback func(ctx context.Context) +} + +func (ct *configurableTracer) StartOperationParsing(ctx context.Context) context.Context { + if f := ct.StartOperationParsingCallback; f != nil { + ctx = f(ctx) + } + return ctx +} + +func (ct *configurableTracer) EndOperationParsing(ctx context.Context) { + if f := ct.EndOperationParsingCallback; f != nil { + f(ctx) + } +} + +func (ct *configurableTracer) StartOperationValidation(ctx context.Context) context.Context { + if f := ct.StartOperationValidationCallback; f != nil { + ctx = f(ctx) + } + return ctx +} + +func (ct *configurableTracer) EndOperationValidation(ctx context.Context) { + if f := ct.EndOperationValidationCallback; f != nil { + f(ctx) + } +} + +func (ct *configurableTracer) StartOperationExecution(ctx context.Context) context.Context { + if f := ct.StartOperationExecutionCallback; f != nil { + ctx = f(ctx) + } + return ctx +} + +func (ct *configurableTracer) StartFieldExecution(ctx context.Context, field graphql.CollectedField) context.Context { + if f := ct.StartFieldExecutionCallback; f != nil { + ctx = f(ctx, field) + } + return ctx +} + +func (ct *configurableTracer) StartFieldResolverExecution(ctx context.Context, rc *graphql.ResolverContext) context.Context { + if f := ct.StartFieldResolverExecutionCallback; f != nil { + ctx = f(ctx, rc) + } + return ctx +} + +func (ct *configurableTracer) StartFieldChildExecution(ctx context.Context) context.Context { + if f := ct.StartFieldChildExecutionCallback; f != nil { + ctx = f(ctx) + } + return ctx +} + +func (ct *configurableTracer) EndFieldExecution(ctx context.Context) { + if f := ct.EndFieldExecutionCallback; f != nil { + f(ctx) + } +} + +func (ct *configurableTracer) EndOperationExecution(ctx context.Context) { + if f := ct.EndOperationExecutionCallback; f != nil { + f(ctx) + } +} + +var _ graphql.Tracer = (*testTracer)(nil) + +type testTracer struct { + id int + append func(string) +} + +func (tt *testTracer) StartOperationParsing(ctx context.Context) context.Context { + line := fmt.Sprintf("op:p:start:%d", tt.id) + + tracerLogs, _ := ctx.Value("tracer").([]string) + ctx = context.WithValue(ctx, "tracer", append(append([]string{}, tracerLogs...), line)) + tt.append(line) + + return ctx +} + +func (tt *testTracer) EndOperationParsing(ctx context.Context) { + tt.append(fmt.Sprintf("op:p:end:%d", tt.id)) +} + +func (tt *testTracer) StartOperationValidation(ctx context.Context) context.Context { + line := fmt.Sprintf("op:v:start:%d", tt.id) + + tracerLogs, _ := ctx.Value("tracer").([]string) + ctx = context.WithValue(ctx, "tracer", append(append([]string{}, tracerLogs...), line)) + tt.append(line) + + return ctx +} + +func (tt *testTracer) EndOperationValidation(ctx context.Context) { + tt.append(fmt.Sprintf("op:v:end:%d", tt.id)) +} + +func (tt *testTracer) StartOperationExecution(ctx context.Context) context.Context { + line := fmt.Sprintf("op:e:start:%d", tt.id) + + tracerLogs, _ := ctx.Value("tracer").([]string) + ctx = context.WithValue(ctx, "tracer", append(append([]string{}, tracerLogs...), line)) + tt.append(line) + + return ctx +} + +func (tt *testTracer) StartFieldExecution(ctx context.Context, field graphql.CollectedField) context.Context { + line := fmt.Sprintf("field'a:e:start:%d:%s", tt.id, field.Name) + + tracerLogs, _ := ctx.Value("tracer").([]string) + ctx = context.WithValue(ctx, "tracer", append(append([]string{}, tracerLogs...), line)) + tt.append(line) + + return ctx +} + +func (tt *testTracer) StartFieldResolverExecution(ctx context.Context, rc *graphql.ResolverContext) context.Context { + line := fmt.Sprintf("field'b:e:start:%d:%v", tt.id, rc.Path()) + + tracerLogs, _ := ctx.Value("tracer").([]string) + ctx = context.WithValue(ctx, "tracer", append(append([]string{}, tracerLogs...), line)) + tt.append(line) + + return ctx +} + +func (tt *testTracer) StartFieldChildExecution(ctx context.Context) context.Context { + line := fmt.Sprintf("field'c:e:start:%d", tt.id) + + tracerLogs, _ := ctx.Value("tracer").([]string) + ctx = context.WithValue(ctx, "tracer", append(append([]string{}, tracerLogs...), line)) + tt.append(line) + + return ctx +} + +func (tt *testTracer) EndFieldExecution(ctx context.Context) { + tt.append(fmt.Sprintf("field:e:end:%d", tt.id)) +} + +func (tt *testTracer) EndOperationExecution(ctx context.Context) { + tt.append(fmt.Sprintf("op:e:end:%d", tt.id)) +} diff --git a/handler/graphql_test.go b/handler/graphql_test.go index 4ea8cb58088..e6c2d9063e1 100644 --- a/handler/graphql_test.go +++ b/handler/graphql_test.go @@ -45,35 +45,35 @@ func TestHandlerPOST(t *testing.T) { t.Run("decode failure", func(t *testing.T) { resp := doRequest(h, "POST", "/graphql", "notjson") assert.Equal(t, http.StatusBadRequest, resp.Code) - assert.Equal(t, resp.HeaderMap.Get("Content-Type"), "application/json") + assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") assert.Equal(t, `{"errors":[{"message":"json body could not be decoded: invalid character 'o' in literal null (expecting 'u')"}],"data":null}`, resp.Body.String()) }) t.Run("parse failure", func(t *testing.T) { resp := doRequest(h, "POST", "/graphql", `{"query": "!"}`) assert.Equal(t, http.StatusUnprocessableEntity, resp.Code) - assert.Equal(t, resp.HeaderMap.Get("Content-Type"), "application/json") + assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") assert.Equal(t, `{"errors":[{"message":"Unexpected !","locations":[{"line":1,"column":1}]}],"data":null}`, resp.Body.String()) }) t.Run("validation failure", func(t *testing.T) { resp := doRequest(h, "POST", "/graphql", `{"query": "{ me { title }}"}`) assert.Equal(t, http.StatusUnprocessableEntity, resp.Code) - assert.Equal(t, resp.HeaderMap.Get("Content-Type"), "application/json") + assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") assert.Equal(t, `{"errors":[{"message":"Cannot query field \"title\" on type \"User\".","locations":[{"line":1,"column":8}]}],"data":null}`, resp.Body.String()) }) t.Run("invalid variable", func(t *testing.T) { resp := doRequest(h, "POST", "/graphql", `{"query": "query($id:Int!){user(id:$id){name}}","variables":{"id":false}}`) assert.Equal(t, http.StatusUnprocessableEntity, resp.Code) - assert.Equal(t, resp.HeaderMap.Get("Content-Type"), "application/json") + assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") assert.Equal(t, `{"errors":[{"message":"cannot use bool as Int","path":["variable","id"]}],"data":null}`, resp.Body.String()) }) t.Run("execution failure", func(t *testing.T) { resp := doRequest(h, "POST", "/graphql", `{"query": "mutation { me { name } }"}`) assert.Equal(t, http.StatusOK, resp.Code) - assert.Equal(t, resp.HeaderMap.Get("Content-Type"), "application/json") + assert.Equal(t, resp.Header().Get("Content-Type"), "application/json") assert.Equal(t, `{"errors":[{"message":"mutations are not supported"}],"data":null}`, resp.Body.String()) }) } diff --git a/plugin/stubgen/stubs.go b/plugin/stubgen/stubs.go index f00cf924d73..44982b79e59 100644 --- a/plugin/stubgen/stubs.go +++ b/plugin/stubgen/stubs.go @@ -1,7 +1,10 @@ package stubgen import ( + "syscall" + "github.com/99designs/gqlgen/codegen" + "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/codegen/templates" "github.com/99designs/gqlgen/plugin" ) @@ -16,19 +19,26 @@ type Plugin struct { } var _ plugin.CodeGenerator = &Plugin{} +var _ plugin.ConfigMutator = &Plugin{} func (m *Plugin) Name() string { return "stubgen" } + +func (m *Plugin) MutateConfig(cfg *config.Config) error { + _ = syscall.Unlink(m.filename) + return nil +} + func (m *Plugin) GenerateCode(data *codegen.Data) error { return templates.Render(templates.Options{ - PackageName: data.Config.Resolver.Package, + PackageName: data.Config.Exec.Package, Filename: m.filename, Data: &ResolverBuild{ Data: data, TypeName: m.typeName, }, - GeneratedHeader: false, + GeneratedHeader: true, }) } diff --git a/plugin/stubgen/stubs.gotpl b/plugin/stubgen/stubs.gotpl index d8adbf0b2c6..c1e9b313149 100644 --- a/plugin/stubgen/stubs.gotpl +++ b/plugin/stubgen/stubs.gotpl @@ -47,7 +47,7 @@ type {{$root.TypeName}} struct { return r.{{$object.Name}}Resolver.{{$field.GoFieldName}}(ctx, {{- if not $object.Root }}obj,{{end -}} {{- range $arg := $field.Args}} - {{$arg.VarName}}, + {{- $arg.VarName}}, {{- end }} ) } diff --git a/testdata/gqlgen.go b/testdata/gqlgen.go index d51bfc0ce3f..d69313e9e8e 100644 --- a/testdata/gqlgen.go +++ b/testdata/gqlgen.go @@ -1,6 +1,7 @@ package main import ( + "flag" "fmt" "io/ioutil" "log" @@ -13,6 +14,9 @@ import ( ) func main() { + stub := flag.String("stub", "", "name of stub file to generate") + flag.Parse() + log.SetOutput(ioutil.Discard) start := time.Now() @@ -23,7 +27,12 @@ func main() { os.Exit(2) } - err = gqlgen.Generate(cfg, gqlgen.AddPlugin(stubgen.New(cfg.Exec.Dir()+"/stubs.go", "Stub"))) + var options []gqlgen.Option + if *stub != "" { + options = append(options, gqlgen.AddPlugin(stubgen.New(*stub, "Stub"))) + } + + err = gqlgen.Generate(cfg, options...) if err != nil { fmt.Fprintln(os.Stderr, err.Error()) os.Exit(3) From 7a82ab43a060b334d19c51a353a8924857dd39bb Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Thu, 7 Feb 2019 21:05:38 +1100 Subject: [PATCH 076/147] Test for #487 --- codegen/testserver/generated.go | 100 ++++++++++++++++++++++++++++++ codegen/testserver/input_test.go | 34 ++++++++++ codegen/testserver/resolver.go | 3 + codegen/testserver/schema.graphql | 1 + codegen/testserver/stub.go | 4 ++ 5 files changed, 142 insertions(+) create mode 100644 codegen/testserver/input_test.go diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 01e4719d104..44b59803780 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -112,6 +112,7 @@ type ComplexityRoot struct { DirectiveNullableArg func(childComplexity int, arg *int, arg2 *int) int DirectiveInputNullable func(childComplexity int, arg *InputDirectives) int DirectiveInput func(childComplexity int, arg InputDirectives) int + InputSlice func(childComplexity int, arg []string) int KeywordArgs func(childComplexity int, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) int } @@ -156,6 +157,7 @@ type QueryResolver interface { DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int) (*string, error) DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) + InputSlice(ctx context.Context, arg []string) (bool, error) KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) } type SubscriptionResolver interface { @@ -462,6 +464,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.DirectiveInput(childComplexity, args["arg"].(InputDirectives)), true + case "Query.inputSlice": + if e.complexity.Query.InputSlice == nil { + break + } + + args, err := ec.field_Query_inputSlice_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.InputSlice(childComplexity, args["arg"].([]string)), true + case "Query.keywordArgs": if e.complexity.Query.KeywordArgs == nil { break @@ -665,6 +679,7 @@ var parsedSchema = gqlparser.MustLoadSchema( directiveNullableArg(arg: Int @range(min:0), arg2: Int @range): String directiveInputNullable(arg: InputDirectives): String directiveInput(arg: InputDirectives!): String + inputSlice(arg: [String!]!): Boolean! } type Subscription { @@ -986,6 +1001,20 @@ func (ec *executionContext) field_Query_directiveNullableArg_args(ctx context.Co return args, nil } +func (ec *executionContext) field_Query_inputSlice_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 []string + if tmp, ok := rawArgs["arg"]; ok { + arg0, err = ec.unmarshalNString2ᚕstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["arg"] = arg0 + return args, nil +} + func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -2176,6 +2205,39 @@ func (ec *executionContext) _Query_directiveInput(ctx context.Context, field gra return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } +func (ec *executionContext) _Query_inputSlice(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_inputSlice_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().InputSlice(rctx, args["arg"].([]string)) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + func (ec *executionContext) _Query_keywordArgs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3957,6 +4019,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr res = ec._Query_directiveInput(ctx, field) return res }) + case "inputSlice": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_inputSlice(ctx, field) + if res == graphql.Null { + invalid = true + } + return res + }) case "keywordArgs": field := field out.Concurrently(i, func() (res graphql.Marshaler) { @@ -4364,6 +4435,35 @@ func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.S return graphql.MarshalString(v) } +func (ec *executionContext) unmarshalNString2ᚕstring(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshalNString2string(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalNString2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNString2string(ctx, sel, v[i]) + } + + return ret +} + func (ec *executionContext) unmarshalNString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil diff --git a/codegen/testserver/input_test.go b/codegen/testserver/input_test.go new file mode 100644 index 00000000000..7e8f1f3b779 --- /dev/null +++ b/codegen/testserver/input_test.go @@ -0,0 +1,34 @@ +package testserver + +import ( + "context" + "net/http/httptest" + "testing" + + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/handler" + "github.com/stretchr/testify/require" +) + +func TestInput(t *testing.T) { + resolvers := &Stub{} + + srv := httptest.NewServer(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolvers}))) + + c := client.New(srv.URL) + + t.Run("when function errors on directives", func(t *testing.T) { + resolvers.QueryResolver.InputSlice = func(ctx context.Context, arg []string) (b bool, e error) { + return true, nil + } + + var resp struct { + DirectiveArg *string + } + + err := c.Post(`query { inputSlice(arg: ["ok", 1, 2, "ok"]) }`, &resp) + + require.EqualError(t, err, `http 422: {"errors":[{"message":"Expected type String!, found 1.","locations":[{"line":1,"column":32}]},{"message":"Expected type String!, found 2.","locations":[{"line":1,"column":35}]}],"data":null}`) + require.Nil(t, resp.DirectiveArg) + }) +} diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index 3aecb553fa2..d58c00725fd 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -92,6 +92,9 @@ func (r *queryResolver) DirectiveInputNullable(ctx context.Context, arg *InputDi func (r *queryResolver) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) { panic("not implemented") } +func (r *queryResolver) InputSlice(ctx context.Context, arg []string) (bool, error) { + panic("not implemented") +} func (r *queryResolver) KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) { panic("not implemented") } diff --git a/codegen/testserver/schema.graphql b/codegen/testserver/schema.graphql index da8e967569b..956c6c4461d 100644 --- a/codegen/testserver/schema.graphql +++ b/codegen/testserver/schema.graphql @@ -16,6 +16,7 @@ type Query { directiveNullableArg(arg: Int @range(min:0), arg2: Int @range): String directiveInputNullable(arg: InputDirectives): String directiveInput(arg: InputDirectives!): String + inputSlice(arg: [String!]!): Boolean! } type Subscription { diff --git a/codegen/testserver/stub.go b/codegen/testserver/stub.go index 09712806267..dfef6457b35 100644 --- a/codegen/testserver/stub.go +++ b/codegen/testserver/stub.go @@ -34,6 +34,7 @@ type Stub struct { DirectiveNullableArg func(ctx context.Context, arg *int, arg2 *int) (*string, error) DirectiveInputNullable func(ctx context.Context, arg *InputDirectives) (*string, error) DirectiveInput func(ctx context.Context, arg InputDirectives) (*string, error) + InputSlice func(ctx context.Context, arg []string) (bool, error) KeywordArgs func(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) } SubscriptionResolver struct { @@ -126,6 +127,9 @@ func (r *stubQuery) DirectiveInputNullable(ctx context.Context, arg *InputDirect func (r *stubQuery) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) { return r.QueryResolver.DirectiveInput(ctx, arg) } +func (r *stubQuery) InputSlice(ctx context.Context, arg []string) (bool, error) { + return r.QueryResolver.InputSlice(ctx, arg) +} func (r *stubQuery) KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) { return r.QueryResolver.KeywordArgs(ctx, breakArg, defaultArg, funcArg, interfaceArg, selectArg, caseArg, deferArg, goArg, mapArg, structArg, chanArg, elseArg, gotoArg, packageArg, switchArg, constArg, fallthroughArg, ifArg, rangeArg, typeArg, continueArg, forArg, importArg, returnArg, varArg) } From de148d133667b3cf0574b2054b8d5579f5c5db1a Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Thu, 7 Feb 2019 21:11:28 +1100 Subject: [PATCH 077/147] Test for #484 --- codegen/testserver/interfaces_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 codegen/testserver/interfaces_test.go diff --git a/codegen/testserver/interfaces_test.go b/codegen/testserver/interfaces_test.go new file mode 100644 index 00000000000..d10f48b071c --- /dev/null +++ b/codegen/testserver/interfaces_test.go @@ -0,0 +1,16 @@ +package testserver + +import ( + "reflect" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestInterfaces(t *testing.T) { + t.Run("slices of interfaces are not pointers", func(t *testing.T) { + field, ok := reflect.TypeOf((*QueryResolver)(nil)).Elem().MethodByName("Shapes") + require.True(t, ok) + require.Equal(t, "[]testserver.Shape", field.Type.Out(0).String()) + }) +} From 306da15f43db5b796bf7a77e7897e5f8772a7fa9 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Thu, 7 Feb 2019 23:13:43 +1100 Subject: [PATCH 078/147] Automatically convert IsZero to null --- codegen/config/binder.go | 19 +++++ codegen/testserver/generated.go | 117 ++++++++++++++++++++++++++++++ codegen/testserver/models-gen.go | 7 +- codegen/testserver/schema.graphql | 4 + codegen/testserver/time_test.go | 70 ++++++++++++++++++ codegen/type.gotpl | 9 +++ example/chat/generated.go | 6 ++ example/dataloader/generated.go | 6 ++ example/scalars/generated.go | 3 + example/selection/generated.go | 6 ++ example/starwars/generated.go | 3 + 11 files changed, 248 insertions(+), 2 deletions(-) create mode 100644 codegen/testserver/time_test.go diff --git a/codegen/config/binder.go b/codegen/config/binder.go index 305bc23b6bb..21160017fb5 100644 --- a/codegen/config/binder.go +++ b/codegen/config/binder.go @@ -196,6 +196,25 @@ func (t *TypeReference) IsScalar() bool { return t.Definition.Kind == ast.Scalar } +func (t *TypeReference) HasIsZero() bool { + it := t.GO + if ptr, isPtr := it.(*types.Pointer); isPtr { + it = ptr.Elem() + } + namedType, ok := it.(*types.Named) + if !ok { + return false + } + + for i := 0; i < namedType.NumMethods(); i++ { + switch namedType.Method(i).Name() { + case "IsZero": + return true + } + } + return false +} + func (t *TypeReference) SelfMarshalling() bool { it := t.GO if ptr, isPtr := it.(*types.Pointer); isPtr { diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 44b59803780..a6d1a82fe36 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -10,6 +10,7 @@ import ( "io" "strconv" "sync" + "time" introspection1 "github.com/99designs/gqlgen/codegen/testserver/introspection" "github.com/99designs/gqlgen/codegen/testserver/invalid-packagename" @@ -130,6 +131,8 @@ type ComplexityRoot struct { User struct { Id func(childComplexity int) int Friends func(childComplexity int) int + Created func(childComplexity int) int + Updated func(childComplexity int) int } } @@ -537,6 +540,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.User.Friends(childComplexity), true + case "User.created": + if e.complexity.User.Created == nil { + break + } + + return e.complexity.User.Created(childComplexity), true + + case "User.updated": + if e.complexity.User.Updated == nil { + break + } + + return e.complexity.User.Updated(childComplexity), true + } return 0, false } @@ -690,6 +707,8 @@ type Subscription { type User { id: Int! friends: [User!]! + created: Time! + updated: Time } type Error { @@ -836,6 +855,8 @@ enum Status { OK ERROR } + +scalar Time `}, ) @@ -2501,6 +2522,55 @@ func (ec *executionContext) _User_friends(ctx context.Context, field graphql.Col return ec.marshalNUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx, field.Selections, res) } +func (ec *executionContext) _User_created(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "User", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Created, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(time.Time) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) _User_updated(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "User", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Updated, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*time.Time) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalOTime2ᚖtimeᚐTime(ctx, field.Selections, res) +} + func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -4127,6 +4197,13 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj } return res }) + case "created": + out.Values[i] = ec._User_created(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "updated": + out.Values[i] = ec._User_updated(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -4482,6 +4559,20 @@ func (ec *executionContext) marshalNString2ᚖstring(ctx context.Context, sel as return ec.marshalNString2string(ctx, sel, *v) } +func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v interface{}) (time.Time, error) { + return graphql.UnmarshalTime(v) +} + +func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { + if v.IsZero() { + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return graphql.MarshalTime(v) +} + func (ec *executionContext) marshalNUser2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler { return ec._User(ctx, sel, &v) } @@ -5071,6 +5162,32 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as return ec.marshalOString2string(ctx, sel, *v) } +func (ec *executionContext) unmarshalOTime2timeᚐTime(ctx context.Context, v interface{}) (time.Time, error) { + return graphql.UnmarshalTime(v) +} + +func (ec *executionContext) marshalOTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { + if v.IsZero() { + return graphql.Null + } + return graphql.MarshalTime(v) +} + +func (ec *executionContext) unmarshalOTime2ᚖtimeᚐTime(ctx context.Context, v interface{}) (*time.Time, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOTime2timeᚐTime(ctx, v) + return &res, err +} + +func (ec *executionContext) marshalOTime2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOTime2timeᚐTime(ctx, sel, *v) +} + func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup diff --git a/codegen/testserver/models-gen.go b/codegen/testserver/models-gen.go index b358d12a397..08034e49877 100644 --- a/codegen/testserver/models-gen.go +++ b/codegen/testserver/models-gen.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "strconv" + "time" ) type InnerDirectives struct { @@ -63,8 +64,10 @@ type OuterObject struct { } type User struct { - ID int `json:"id"` - Friends []User `json:"friends"` + ID int `json:"id"` + Friends []User `json:"friends"` + Created time.Time `json:"created"` + Updated *time.Time `json:"updated"` } type Status string diff --git a/codegen/testserver/schema.graphql b/codegen/testserver/schema.graphql index 956c6c4461d..b0d311f8357 100644 --- a/codegen/testserver/schema.graphql +++ b/codegen/testserver/schema.graphql @@ -27,6 +27,8 @@ type Subscription { type User { id: Int! friends: [User!]! + created: Time! + updated: Time } type Error { @@ -173,3 +175,5 @@ enum Status { OK ERROR } + +scalar Time diff --git a/codegen/testserver/time_test.go b/codegen/testserver/time_test.go new file mode 100644 index 00000000000..71918053454 --- /dev/null +++ b/codegen/testserver/time_test.go @@ -0,0 +1,70 @@ +package testserver + +import ( + "context" + "net/http/httptest" + "testing" + "time" + + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/handler" + "github.com/stretchr/testify/require" +) + +func TestTime(t *testing.T) { + resolvers := &Stub{} + + srv := httptest.NewServer(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolvers}))) + c := client.New(srv.URL) + + resolvers.QueryResolver.User = func(ctx context.Context, id int) (user User, e error) { + return User{}, nil + } + + t.Run("zero value in nullable field", func(t *testing.T) { + var resp struct { + User struct { + Updated *string + } + } + + err := c.Post(`query { user(id: 1) { updated } }`, &resp) + require.NoError(t, err) + + require.Nil(t, resp.User.Updated) + }) + + t.Run("zero value in non nullable field", func(t *testing.T) { + var resp struct { + User struct { + Created *string + } + } + + err := c.Post(`query { user(id: 1) { created } }`, &resp) + require.EqualError(t, err, `[{"message":"must not be null","path":["user","created"]}]`) + }) + + t.Run("with values", func(t *testing.T) { + resolvers.QueryResolver.User = func(ctx context.Context, id int) (user User, e error) { + updated := time.Date(2010, 1, 1, 0, 0, 20, 0, time.UTC) + return User{ + Created: time.Date(2010, 1, 1, 0, 0, 10, 0, time.UTC), + Updated: &updated, + }, nil + } + + var resp struct { + User struct { + Created string + Updated string + } + } + + err := c.Post(`query { user(id: 1) { created, updated } }`, &resp) + require.NoError(t, err) + + require.Equal(t, "2010-01-01T00:00:10Z", resp.User.Created) + require.Equal(t, "2010-01-01T00:00:20Z", resp.User.Updated) + }) +} diff --git a/codegen/type.gotpl b/codegen/type.gotpl index 2e343eb9906..6fadb4424f6 100644 --- a/codegen/type.gotpl +++ b/codegen/type.gotpl @@ -49,6 +49,15 @@ {{- end }} return graphql.Null } + {{- else if $type.HasIsZero }} + if v.IsZero() { + {{- if $type.GQL.NonNull }} + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + {{- end }} + return graphql.Null + } {{- end }} {{- if $type.SelfMarshalling }} diff --git a/example/chat/generated.go b/example/chat/generated.go index 740cd4b20e2..fa4c1334332 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -1997,6 +1997,12 @@ func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v in } func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { + if v.IsZero() { + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } return graphql.MarshalTime(v) } diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index 5f789a7e639..404af1956ef 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -2133,6 +2133,12 @@ func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v in } func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { + if v.IsZero() { + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } return graphql.MarshalTime(v) } diff --git a/example/scalars/generated.go b/example/scalars/generated.go index 60a3c8c091d..764500f7466 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -2322,6 +2322,9 @@ func (ec *executionContext) unmarshalOTimestamp2timeᚐTime(ctx context.Context, } func (ec *executionContext) marshalOTimestamp2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { + if v.IsZero() { + return graphql.Null + } return model.MarshalTimestamp(v) } diff --git a/example/selection/generated.go b/example/selection/generated.go index 16ef946384b..226225b96a3 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -1758,6 +1758,12 @@ func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v in } func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { + if v.IsZero() { + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } return graphql.MarshalTime(v) } diff --git a/example/starwars/generated.go b/example/starwars/generated.go index eadab3d5563..fc61c6e4025 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -4290,6 +4290,9 @@ func (ec *executionContext) unmarshalOTime2timeᚐTime(ctx context.Context, v in } func (ec *executionContext) marshalOTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { + if v.IsZero() { + return graphql.Null + } return graphql.MarshalTime(v) } From efe8b026d562b95b6cd95f3df3b64e4624ed2b01 Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Mon, 4 Feb 2019 11:57:17 +1100 Subject: [PATCH 079/147] Add reproducable test cases --- codegen/testserver/generated.go | 49 ++++++++++++++++++++++++++ codegen/testserver/generated_test.go | 51 ++++++++++++++++++++++++++++ codegen/testserver/resolver.go | 3 ++ codegen/testserver/schema.graphql | 1 + codegen/testserver/stub.go | 4 +++ 5 files changed, 108 insertions(+) diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 44b59803780..8351189ad9c 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -113,6 +113,7 @@ type ComplexityRoot struct { DirectiveInputNullable func(childComplexity int, arg *InputDirectives) int DirectiveInput func(childComplexity int, arg InputDirectives) int InputSlice func(childComplexity int, arg []string) int + ShapeUnion func(childComplexity int) int KeywordArgs func(childComplexity int, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) int } @@ -158,6 +159,7 @@ type QueryResolver interface { DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) InputSlice(ctx context.Context, arg []string) (bool, error) + ShapeUnion(ctx context.Context) (ShapeUnion, error) KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) } type SubscriptionResolver interface { @@ -476,6 +478,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.InputSlice(childComplexity, args["arg"].([]string)), true + case "Query.shapeUnion": + if e.complexity.Query.ShapeUnion == nil { + break + } + + return e.complexity.Query.ShapeUnion(childComplexity), true + case "Query.keywordArgs": if e.complexity.Query.KeywordArgs == nil { break @@ -680,6 +689,7 @@ var parsedSchema = gqlparser.MustLoadSchema( directiveInputNullable(arg: InputDirectives): String directiveInput(arg: InputDirectives!): String inputSlice(arg: [String!]!): Boolean! + shapeUnion: ShapeUnion! } type Subscription { @@ -2238,6 +2248,32 @@ func (ec *executionContext) _Query_inputSlice(ctx context.Context, field graphql return ec.marshalNBoolean2bool(ctx, field.Selections, res) } +func (ec *executionContext) _Query_shapeUnion(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().ShapeUnion(rctx) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(ShapeUnion) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNShapeUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShapeUnion(ctx, field.Selections, res) +} + func (ec *executionContext) _Query_keywordArgs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -4028,6 +4064,15 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } return res }) + case "shapeUnion": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + res = ec._Query_shapeUnion(ctx, field) + if res == graphql.Null { + invalid = true + } + return res + }) case "keywordArgs": field := field out.Concurrently(i, func() (res graphql.Marshaler) { @@ -4427,6 +4472,10 @@ func (ec *executionContext) unmarshalNRecursiveInputSlice2githubᚗcomᚋ99desig return ec.unmarshalInputRecursiveInputSlice(ctx, v) } +func (ec *executionContext) marshalNShapeUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShapeUnion(ctx context.Context, sel ast.SelectionSet, v ShapeUnion) graphql.Marshaler { + return ec._ShapeUnion(ctx, sel, &v) +} + func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } diff --git a/codegen/testserver/generated_test.go b/codegen/testserver/generated_test.go index 51547ae62c7..bcc00d21e56 100644 --- a/codegen/testserver/generated_test.go +++ b/codegen/testserver/generated_test.go @@ -4,10 +4,13 @@ package testserver import ( + "context" "net/http" + "net/http/httptest" "reflect" "testing" + "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/handler" "github.com/stretchr/testify/require" ) @@ -30,3 +33,51 @@ func TestEnums(t *testing.T) { require.Equal(t, StatusError, AllStatus[1]) }) } + +func TestUnionFragments(t *testing.T) { + resolvers := &Stub{} + resolvers.QueryResolver.ShapeUnion = func(ctx context.Context) (ShapeUnion, error) { + return &Circle{Radius: 32}, nil + } + + srv := httptest.NewServer(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolvers}))) + c := client.New(srv.URL) + + t.Run("inline fragment on union", func(t *testing.T) { + var resp struct { + ShapeUnion struct { + Radius float64 + } + } + c.MustPost(`query { + shapeUnion { + ... on Circle { + radius + } + } + } + `, &resp) + require.NotEmpty(t, resp.ShapeUnion.Radius) + }) + + t.Run("named fragment", func(t *testing.T) { + var resp struct { + ShapeUnion struct { + Radius float64 + } + } + c.MustPost(`query { + shapeUnion { + ...C + } + } + + fragment C on ShapeUnion { + ... on Circle { + radius + } + } + `, &resp) + require.NotEmpty(t, resp.ShapeUnion.Radius) + }) +} diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index d58c00725fd..20bcaa425fd 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -95,6 +95,9 @@ func (r *queryResolver) DirectiveInput(ctx context.Context, arg InputDirectives) func (r *queryResolver) InputSlice(ctx context.Context, arg []string) (bool, error) { panic("not implemented") } +func (r *queryResolver) ShapeUnion(ctx context.Context) (ShapeUnion, error) { + panic("not implemented") +} func (r *queryResolver) KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) { panic("not implemented") } diff --git a/codegen/testserver/schema.graphql b/codegen/testserver/schema.graphql index 956c6c4461d..293c18d1947 100644 --- a/codegen/testserver/schema.graphql +++ b/codegen/testserver/schema.graphql @@ -17,6 +17,7 @@ type Query { directiveInputNullable(arg: InputDirectives): String directiveInput(arg: InputDirectives!): String inputSlice(arg: [String!]!): Boolean! + shapeUnion: ShapeUnion! } type Subscription { diff --git a/codegen/testserver/stub.go b/codegen/testserver/stub.go index dfef6457b35..d88f0ddbb5a 100644 --- a/codegen/testserver/stub.go +++ b/codegen/testserver/stub.go @@ -35,6 +35,7 @@ type Stub struct { DirectiveInputNullable func(ctx context.Context, arg *InputDirectives) (*string, error) DirectiveInput func(ctx context.Context, arg InputDirectives) (*string, error) InputSlice func(ctx context.Context, arg []string) (bool, error) + ShapeUnion func(ctx context.Context) (ShapeUnion, error) KeywordArgs func(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) } SubscriptionResolver struct { @@ -130,6 +131,9 @@ func (r *stubQuery) DirectiveInput(ctx context.Context, arg InputDirectives) (*s func (r *stubQuery) InputSlice(ctx context.Context, arg []string) (bool, error) { return r.QueryResolver.InputSlice(ctx, arg) } +func (r *stubQuery) ShapeUnion(ctx context.Context) (ShapeUnion, error) { + return r.QueryResolver.ShapeUnion(ctx) +} func (r *stubQuery) KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) { return r.QueryResolver.KeywordArgs(ctx, breakArg, defaultArg, funcArg, interfaceArg, selectArg, caseArg, deferArg, goArg, mapArg, structArg, chanArg, elseArg, gotoArg, packageArg, switchArg, constArg, fallthroughArg, ifArg, rangeArg, typeArg, continueArg, forArg, importArg, returnArg, varArg) } From ccca823f7257048049df495b88e0c33818db5a4b Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Mon, 4 Feb 2019 13:05:49 +1100 Subject: [PATCH 080/147] Separate out conditionals in collect fields These conditions are not really related, and I missed the second conditional when reading through the first time. --- graphql/exec.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/graphql/exec.go b/graphql/exec.go index 9beb3149078..a76ec859b82 100644 --- a/graphql/exec.go +++ b/graphql/exec.go @@ -35,7 +35,10 @@ func collectFields(reqCtx *RequestContext, selSet ast.SelectionSet, satisfies [] f.Selections = append(f.Selections, sel.SelectionSet...) case *ast.InlineFragment: - if !shouldIncludeNode(sel.Directives, reqCtx.Variables) || !instanceOf(sel.TypeCondition, satisfies) { + if !shouldIncludeNode(sel.Directives, reqCtx.Variables) { + continue + } + if !instanceOf(sel.TypeCondition, satisfies) { continue } for _, childField := range collectFields(reqCtx, sel.SelectionSet, satisfies, visited) { From 99e9f41fd92a958226c960260de82cc0c0fd85f2 Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Thu, 7 Feb 2019 16:02:38 +1100 Subject: [PATCH 081/147] Use Implements for type Implementors in codegen --- codegen/object.go | 4 ++-- codegen/testserver/generated.go | 4 ++-- example/starwars/generated.go | 6 +++--- example/type-system-extension/generated.go | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/codegen/object.go b/codegen/object.go index 70429a21ca7..7b9e3d6f597 100644 --- a/codegen/object.go +++ b/codegen/object.go @@ -84,8 +84,8 @@ type Objects []*Object func (o *Object) Implementors() string { satisfiedBy := strconv.Quote(o.Name) - for _, s := range o.Definition.Interfaces { - satisfiedBy += ", " + strconv.Quote(s) + for _, s := range o.Implements { + satisfiedBy += ", " + strconv.Quote(s.Name) } return "[]string{" + satisfiedBy + "}" } diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 8351189ad9c..a58e8e26b41 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -3657,7 +3657,7 @@ func (ec *executionContext) _ShapeUnion(ctx context.Context, sel ast.SelectionSe // region **************************** object.gotpl **************************** -var circleImplementors = []string{"Circle", "Shape"} +var circleImplementors = []string{"Circle", "Shape", "ShapeUnion"} func (ec *executionContext) _Circle(ctx context.Context, sel ast.SelectionSet, obj *Circle) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, circleImplementors) @@ -4097,7 +4097,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr return out } -var rectangleImplementors = []string{"Rectangle", "Shape"} +var rectangleImplementors = []string{"Rectangle", "Shape", "ShapeUnion"} func (ec *executionContext) _Rectangle(ctx context.Context, sel ast.SelectionSet, obj *Rectangle) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, rectangleImplementors) diff --git a/example/starwars/generated.go b/example/starwars/generated.go index eadab3d5563..e69ac3f814b 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -2897,7 +2897,7 @@ func (ec *executionContext) _SearchResult(ctx context.Context, sel ast.Selection // region **************************** object.gotpl **************************** -var droidImplementors = []string{"Droid", "Character"} +var droidImplementors = []string{"Droid", "Character", "SearchResult"} func (ec *executionContext) _Droid(ctx context.Context, sel ast.SelectionSet, obj *Droid) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, droidImplementors) @@ -3024,7 +3024,7 @@ func (ec *executionContext) _FriendsEdge(ctx context.Context, sel ast.SelectionS return out } -var humanImplementors = []string{"Human", "Character"} +var humanImplementors = []string{"Human", "Character", "SearchResult"} func (ec *executionContext) _Human(ctx context.Context, sel ast.SelectionSet, obj *Human) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, humanImplementors) @@ -3263,7 +3263,7 @@ func (ec *executionContext) _Review(ctx context.Context, sel ast.SelectionSet, o return out } -var starshipImplementors = []string{"Starship"} +var starshipImplementors = []string{"Starship", "SearchResult"} func (ec *executionContext) _Starship(ctx context.Context, sel ast.SelectionSet, obj *Starship) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, starshipImplementors) diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index 79575cf6e9b..190b4c6ba87 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -1613,7 +1613,7 @@ func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) return out } -var todoImplementors = []string{"Todo", "Node"} +var todoImplementors = []string{"Todo", "Node", "Data"} func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, todoImplementors) From 1b8b1ea16cb53e976af44f7d126446b5eba52d97 Mon Sep 17 00:00:00 2001 From: Andreas Wiede Date: Wed, 6 Feb 2019 15:31:25 -0500 Subject: [PATCH 082/147] Fix typo in README Fix typo in README in selection example directory to point to the selection example, not the todo example. --- example/selection/readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/example/selection/readme.md b/example/selection/readme.md index e8dc2e8e183..f37be6eb6a9 100644 --- a/example/selection/readme.md +++ b/example/selection/readme.md @@ -1,10 +1,10 @@ -### todo app +### selection app This is the simplest example of a graphql server. to run this server ```bash -go run ./example/todo/server/server.go +go run ./example/selection/server/server.go ``` -and open http://localhost:8081 in your browser +and open http://localhost:8086 in your browser From 0b0e4a91a0827c66fd3d6f6b5a58177be96ce860 Mon Sep 17 00:00:00 2001 From: matthew clemens Date: Sat, 9 Feb 2019 14:36:34 -0800 Subject: [PATCH 083/147] Fix directives on fields with custom scalars --- codegen/input.gotpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen/input.gotpl b/codegen/input.gotpl index 7345bf4fe16..c8ac7ad3a5d 100644 --- a/codegen/input.gotpl +++ b/codegen/input.gotpl @@ -35,7 +35,7 @@ if err != nil { return it, err } - if data, ok := tmp.({{ $field.TypeReference.GO }}) ; ok { + if data, ok := tmp.({{ $field.TypeReference.GO | ref }}) ; ok { it.{{$field.GoFieldName}} = data } else { return it, fmt.Errorf(`unexpected type %T from directive, should be {{ $field.TypeReference.GO }}`, tmp) From a2e61b3d628bf5e0f5b12e961f82a68fba066448 Mon Sep 17 00:00:00 2001 From: matthew clemens Date: Sat, 9 Feb 2019 21:24:32 -0800 Subject: [PATCH 084/147] Added a model and used directive on an input field within the integration schema Added to the integration schema such that the build will catch the directive bug in question. --- codegen/testserver/generated.go | 46 +++++++++++++++++++++++++++++++ codegen/testserver/gqlgen.yml | 2 ++ codegen/testserver/models-gen.go | 1 + codegen/testserver/schema.graphql | 3 ++ codegen/testserver/thirdparty.go | 30 ++++++++++++++++++++ 5 files changed, 82 insertions(+) create mode 100644 codegen/testserver/thirdparty.go diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 7375bb8a83a..7bba322c1d7 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -759,10 +759,13 @@ input OuterInput { inner: InnerInput! } +scalar ThirdParty + input InputDirectives { text: String! @length(min: 0, max: 7, message: "not valid") inner: InnerDirectives! innerNullable: InnerDirectives + thirdParty: ThirdParty @length(min: 0, max: 7, message: "not valid") } input InnerDirectives { @@ -3489,6 +3492,26 @@ func (ec *executionContext) unmarshalInputInputDirectives(ctx context.Context, v if err != nil { return it, err } + case "thirdParty": + var err error + getField0 := func(ctx context.Context) (interface{}, error) { + return ec.unmarshalOThirdParty2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐThirdParty(ctx, v) + } + getField1 := func(ctx context.Context) (res interface{}, err error) { + max := 7 + n := getField0 + return ec.directives.Length(ctx, it, n, 0, &max) + } + + tmp, err := getField1(ctx) + if err != nil { + return it, err + } + if data, ok := tmp.(*ThirdParty); ok { + it.ThirdParty = data + } else { + return it, fmt.Errorf(`unexpected type %T from directive, should be *github.com/99designs/gqlgen/codegen/testserver.ThirdParty`, tmp) + } } } @@ -5211,6 +5234,29 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as return ec.marshalOString2string(ctx, sel, *v) } +func (ec *executionContext) unmarshalOThirdParty2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐThirdParty(ctx context.Context, v interface{}) (ThirdParty, error) { + return UnmarshalThirdParty(v) +} + +func (ec *executionContext) marshalOThirdParty2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐThirdParty(ctx context.Context, sel ast.SelectionSet, v ThirdParty) graphql.Marshaler { + return MarshalThirdParty(v) +} + +func (ec *executionContext) unmarshalOThirdParty2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐThirdParty(ctx context.Context, v interface{}) (*ThirdParty, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOThirdParty2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐThirdParty(ctx, v) + return &res, err +} + +func (ec *executionContext) marshalOThirdParty2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐThirdParty(ctx context.Context, sel ast.SelectionSet, v *ThirdParty) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalOThirdParty2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐThirdParty(ctx, sel, *v) +} + func (ec *executionContext) unmarshalOTime2timeᚐTime(ctx context.Context, v interface{}) (time.Time, error) { return graphql.UnmarshalTime(v) } diff --git a/codegen/testserver/gqlgen.yml b/codegen/testserver/gqlgen.yml index 7a6e8e5674e..f326e6d0556 100644 --- a/codegen/testserver/gqlgen.yml +++ b/codegen/testserver/gqlgen.yml @@ -38,3 +38,5 @@ models: model: "github.com/99designs/gqlgen/codegen/testserver.Error" EmbeddedPointer: model: "github.com/99designs/gqlgen/codegen/testserver.EmbeddedPointerModel" + ThirdParty: + model: "github.com/99designs/gqlgen/codegen/testserver.ThirdParty" diff --git a/codegen/testserver/models-gen.go b/codegen/testserver/models-gen.go index 08034e49877..716b09bedea 100644 --- a/codegen/testserver/models-gen.go +++ b/codegen/testserver/models-gen.go @@ -25,6 +25,7 @@ type InputDirectives struct { Text string `json:"text"` Inner InnerDirectives `json:"inner"` InnerNullable *InnerDirectives `json:"innerNullable"` + ThirdParty *ThirdParty `json:"thirdParty"` } type Keywords struct { diff --git a/codegen/testserver/schema.graphql b/codegen/testserver/schema.graphql index 1247187a109..21da0e9b219 100644 --- a/codegen/testserver/schema.graphql +++ b/codegen/testserver/schema.graphql @@ -70,10 +70,13 @@ input OuterInput { inner: InnerInput! } +scalar ThirdParty + input InputDirectives { text: String! @length(min: 0, max: 7, message: "not valid") inner: InnerDirectives! innerNullable: InnerDirectives + thirdParty: ThirdParty @length(min: 0, max: 7, message: "not valid") } input InnerDirectives { diff --git a/codegen/testserver/thirdparty.go b/codegen/testserver/thirdparty.go new file mode 100644 index 00000000000..104548ce714 --- /dev/null +++ b/codegen/testserver/thirdparty.go @@ -0,0 +1,30 @@ +package testserver + +import ( + "fmt" + "github.com/99designs/gqlgen/graphql" + "io" + "strconv" +) + +type ThirdParty struct { + str string +} + +func MarshalThirdParty(tp ThirdParty) graphql.Marshaler { + return graphql.WriterFunc(func(w io.Writer) { + _, err := io.WriteString(w, strconv.Quote(tp.str)) + if err != nil { + panic(err) + } + }) +} + +func UnmarshalThirdParty(input interface{}) (ThirdParty, error) { + switch input := input.(type) { + case string: + return ThirdParty{str: input}, nil + default: + return ThirdParty{}, fmt.Errorf("unknown type for input: %s", input) + } +} From dc6a7a36272c22a045dad6e8a7dd47d5f1a41a0c Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Mon, 11 Feb 2019 17:17:19 +1100 Subject: [PATCH 085/147] Add CollectAllFields helper method --- graphql/context.go | 18 ++++++++++++++++++ graphql/exec.go | 7 +++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/graphql/context.go b/graphql/context.go index e0f8d816477..8211c812be8 100644 --- a/graphql/context.go +++ b/graphql/context.go @@ -132,6 +132,24 @@ func CollectFieldsCtx(ctx context.Context, satisfies []string) []CollectedField return CollectFields(ctx, resctx.Field.Selections, satisfies) } +// CollectAllFields returns a slice of all GraphQL field names that were selected for the current resolver context. +// The slice will contain the unique set of all fields requested regardless of fragment type conditions. +func CollectAllFields(ctx context.Context) []string { + resctx := GetResolverContext(ctx) + collected := CollectFields(ctx, resctx.Field.Selections, nil) + uniq := make([]string, 0, len(collected)) +Next: + for _, f := range collected { + for _, name := range uniq { + if name == f.Name { + continue Next + } + } + uniq = append(uniq, f.Name) + } + return uniq +} + // Errorf sends an error string to the client, passing it through the formatter. func (c *RequestContext) Errorf(ctx context.Context, format string, args ...interface{}) { c.errorsMu.Lock() diff --git a/graphql/exec.go b/graphql/exec.go index a76ec859b82..17c57bf67a5 100644 --- a/graphql/exec.go +++ b/graphql/exec.go @@ -16,6 +16,9 @@ type ExecutableSchema interface { Subscription(ctx context.Context, op *ast.OperationDefinition) func() *Response } +// CollectFields returns the set of fields from an ast.SelectionSet where all collected fields satisfy at least one of the GraphQL types +// passed through satisfies. Providing an empty or nil slice for satisfies will return collect all fields regardless of fragment +// type conditions. func CollectFields(ctx context.Context, selSet ast.SelectionSet, satisfies []string) []CollectedField { return collectFields(GetRequestContext(ctx), selSet, satisfies, map[string]bool{}) } @@ -38,7 +41,7 @@ func collectFields(reqCtx *RequestContext, selSet ast.SelectionSet, satisfies [] if !shouldIncludeNode(sel.Directives, reqCtx.Variables) { continue } - if !instanceOf(sel.TypeCondition, satisfies) { + if len(satisfies) > 0 && !instanceOf(sel.TypeCondition, satisfies) { continue } for _, childField := range collectFields(reqCtx, sel.SelectionSet, satisfies, visited) { @@ -62,7 +65,7 @@ func collectFields(reqCtx *RequestContext, selSet ast.SelectionSet, satisfies [] panic(fmt.Errorf("missing fragment %s", fragmentName)) } - if !instanceOf(fragment.TypeCondition, satisfies) { + if len(satisfies) > 0 && !instanceOf(fragment.TypeCondition, satisfies) { continue } From 9ebe77175f676c267fb9091042ec3da209479659 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Mon, 18 Feb 2019 11:28:51 +1100 Subject: [PATCH 086/147] Fix unstable external marshaler funcs with same name as type --- codegen/config/binder.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/codegen/config/binder.go b/codegen/config/binder.go index 21160017fb5..4ecd505ff52 100644 --- a/codegen/config/binder.go +++ b/codegen/config/binder.go @@ -122,13 +122,26 @@ func (b *Binder) FindObject(pkgName string, typeName string) (types.Object, erro return nil, errors.Errorf("required package was not loaded: %s", fullName) } + // function based marshalers take precedence for astNode, def := range pkg.TypesInfo.Defs { // only look at defs in the top scope if def == nil || def.Parent() == nil || def.Parent() != pkg.Types.Scope() { continue } - if astNode.Name == typeName || astNode.Name == "Marshal"+typeName { + if astNode.Name == "Marshal"+typeName { + return def, nil + } + } + + // then look for types directly + for astNode, def := range pkg.TypesInfo.Defs { + // only look at defs in the top scope + if def == nil || def.Parent() == nil || def.Parent() != pkg.Types.Scope() { + continue + } + + if astNode.Name == typeName { return def, nil } } From 3a8bf33f05dbdaacf8a2bba0114977eeab1615b9 Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Mon, 18 Feb 2019 11:28:58 +1100 Subject: [PATCH 087/147] Add CollectAllFields test cases --- graphql/context.go | 2 +- graphql/context_test.go | 69 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/graphql/context.go b/graphql/context.go index 8211c812be8..cc8d659b116 100644 --- a/graphql/context.go +++ b/graphql/context.go @@ -133,7 +133,7 @@ func CollectFieldsCtx(ctx context.Context, satisfies []string) []CollectedField } // CollectAllFields returns a slice of all GraphQL field names that were selected for the current resolver context. -// The slice will contain the unique set of all fields requested regardless of fragment type conditions. +// The slice will contain the unique set of all field names requested regardless of fragment type conditions. func CollectAllFields(ctx context.Context) []string { resctx := GetResolverContext(ctx) collected := CollectFields(ctx, resctx.Field.Selections, nil) diff --git a/graphql/context_test.go b/graphql/context_test.go index 65bd6193f31..14304bcd3b3 100644 --- a/graphql/context_test.go +++ b/graphql/context_test.go @@ -78,3 +78,72 @@ func TestGetResolverContext(t *testing.T) { rc := &ResolverContext{} require.Equal(t, rc, GetResolverContext(WithResolverContext(context.Background(), rc))) } + +func testContext(sel ast.SelectionSet) context.Context { + + ctx := context.Background() + + rqCtx := &RequestContext{} + ctx = WithRequestContext(ctx, rqCtx) + + root := &ResolverContext{ + Field: CollectedField{ + Selections: sel, + }, + } + ctx = WithResolverContext(ctx, root) + + return ctx +} + +func TestCollectAllFields(t *testing.T) { + t.Run("collect fields", func(t *testing.T) { + ctx := testContext(ast.SelectionSet{ + &ast.Field{ + Name: "field", + }, + }) + s := CollectAllFields(ctx) + require.Equal(t, []string{"field"}, s) + }) + + t.Run("unique field names", func(t *testing.T) { + ctx := testContext(ast.SelectionSet{ + &ast.Field{ + Name: "field", + }, + &ast.Field{ + Name: "field", + Alias: "field alias", + }, + }) + s := CollectAllFields(ctx) + require.Equal(t, []string{"field"}, s) + }) + + t.Run("collect fragments", func(t *testing.T) { + ctx := testContext(ast.SelectionSet{ + &ast.Field{ + Name: "fieldA", + }, + &ast.InlineFragment{ + TypeCondition: "ExampleTypeA", + SelectionSet: ast.SelectionSet{ + &ast.Field{ + Name: "fieldA", + }, + }, + }, + &ast.InlineFragment{ + TypeCondition: "ExampleTypeB", + SelectionSet: ast.SelectionSet{ + &ast.Field{ + Name: "fieldB", + }, + }, + }, + }) + s := CollectAllFields(ctx) + require.Equal(t, []string{"fieldA", "fieldB"}, s) + }) +} From 8c2d15ee698737bc1c524ecc11a96deb1c7253fc Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Sat, 9 Feb 2019 14:06:52 +1100 Subject: [PATCH 088/147] Fix underscore only fields closes #473 --- codegen/field.go | 4 +- codegen/generated!.gotpl | 8 +- codegen/templates/templates.go | 4 + codegen/testserver/generated.go | 146 ++++++++++++--------- codegen/testserver/gqlgen.yml | 4 + codegen/testserver/models-gen.go | 1 + codegen/testserver/resolver.go | 2 +- codegen/testserver/schema.graphql | 2 + codegen/testserver/stub.go | 6 +- example/chat/generated.go | 24 ++-- example/config/generated.go | 46 +++---- example/config/resolver.go | 4 + example/dataloader/generated.go | 48 +++---- example/scalars/generated.go | 36 ++--- example/selection/generated.go | 18 +-- example/starwars/generated.go | 94 ++++++------- example/todo/generated.go | 22 ++-- example/type-system-extension/generated.go | 20 +-- integration/generated.go | 28 ++-- 19 files changed, 274 insertions(+), 243 deletions(-) diff --git a/codegen/field.go b/codegen/field.go index 1c9c129bf28..1e68ad8ba8f 100644 --- a/codegen/field.go +++ b/codegen/field.go @@ -98,10 +98,10 @@ func (b *builder) bindField(obj *Object, f *Field) error { case obj.Type == config.MapType: return nil case b.Config.Models[obj.Name].Fields[f.Name].FieldName != "": - f.Name = b.Config.Models[obj.Name].Fields[f.Name].FieldName + f.GoFieldName = b.Config.Models[obj.Name].Fields[f.Name].FieldName } - target, err := b.findBindTarget(obj.Type.(*types.Named), f.Name) + target, err := b.findBindTarget(obj.Type.(*types.Named), f.GoFieldName) if err != nil { return err } diff --git a/codegen/generated!.gotpl b/codegen/generated!.gotpl index 31486bd550e..ca9e754929e 100644 --- a/codegen/generated!.gotpl +++ b/codegen/generated!.gotpl @@ -48,7 +48,7 @@ type ComplexityRoot struct { {{ $object.Name|toCamel }} struct { {{ range $field := $object.Fields -}} {{ if not $field.IsReserved -}} - {{ $field.Name|toCamel }} {{ $field.ComplexitySignature }} + {{ $field.GoFieldName }} {{ $field.ComplexitySignature }} {{ end }} {{- end }} } @@ -86,8 +86,8 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in {{ if not $object.IsReserved }} {{ range $field := $object.Fields }} {{ if not $field.IsReserved }} - case "{{$object.Name}}.{{$field.Name}}": - if e.complexity.{{$object.Name|toCamel}}.{{$field.Name|toCamel}} == nil { + case "{{$object.Name}}.{{$field.GoFieldName}}": + if e.complexity.{{$object.Name|toCamel}}.{{$field.GoFieldName}} == nil { break } {{ if $field.Args }} @@ -96,7 +96,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } {{ end }} - return e.complexity.{{$object.Name|toCamel}}.{{$field.Name|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true + return e.complexity.{{$object.Name|toCamel}}.{{$field.GoFieldName}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true {{ end }} {{ end }} {{ end }} diff --git a/codegen/templates/templates.go b/codegen/templates/templates.go index 0282f32c0a2..8522824e5c9 100644 --- a/codegen/templates/templates.go +++ b/codegen/templates/templates.go @@ -229,6 +229,9 @@ func Call(p *types.Func) string { } func ToCamel(s string) string { + if s == "_" { + return "_" + } buffer := make([]rune, 0, len(s)) upper := true lastWasUpper := false @@ -288,6 +291,7 @@ var keywords = []string{ "import", "return", "var", + "_", } // sanitizeKeywords prevents collisions with go keywords for arguments to resolver functions diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 7bba322c1d7..3f1a3af81f9 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -58,12 +58,12 @@ type ComplexityRoot struct { } EmbeddedPointer struct { - Id func(childComplexity int) int + ID func(childComplexity int) int Title func(childComplexity int) int } Error struct { - Id func(childComplexity int) int + ID func(childComplexity int) int ErrorOnNonRequiredField func(childComplexity int) int ErrorOnRequiredField func(childComplexity int) int NilOnRequiredField func(childComplexity int) int @@ -74,15 +74,15 @@ type ComplexityRoot struct { } InnerObject struct { - Id func(childComplexity int) int + ID func(childComplexity int) int } InvalidIdentifier struct { - Id func(childComplexity int) int + ID func(childComplexity int) int } It struct { - Id func(childComplexity int) int + ID func(childComplexity int) int } ModelMethods struct { @@ -115,7 +115,7 @@ type ComplexityRoot struct { DirectiveInput func(childComplexity int, arg InputDirectives) int InputSlice func(childComplexity int, arg []string) int ShapeUnion func(childComplexity int) int - KeywordArgs func(childComplexity int, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) int + KeywordArgs func(childComplexity int, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string, _Arg string) int } Rectangle struct { @@ -130,7 +130,7 @@ type ComplexityRoot struct { } User struct { - Id func(childComplexity int) int + ID func(childComplexity int) int Friends func(childComplexity int) int Created func(childComplexity int) int Updated func(childComplexity int) int @@ -163,7 +163,7 @@ type QueryResolver interface { DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) InputSlice(ctx context.Context, arg []string) (bool, error) ShapeUnion(ctx context.Context) (ShapeUnion, error) - KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) + KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string, _Arg string) (bool, error) } type SubscriptionResolver interface { Updated(ctx context.Context) (<-chan string, error) @@ -188,14 +188,14 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { - case "Circle.radius": + case "Circle.Radius": if e.complexity.Circle.Radius == nil { break } return e.complexity.Circle.Radius(childComplexity), true - case "Circle.area": + case "Circle.Area": if e.complexity.Circle.Area == nil { break } @@ -203,11 +203,11 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Circle.Area(childComplexity), true case "EmbeddedPointer.ID": - if e.complexity.EmbeddedPointer.Id == nil { + if e.complexity.EmbeddedPointer.ID == nil { break } - return e.complexity.EmbeddedPointer.Id(childComplexity), true + return e.complexity.EmbeddedPointer.ID(childComplexity), true case "EmbeddedPointer.Title": if e.complexity.EmbeddedPointer.Title == nil { @@ -216,105 +216,105 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.EmbeddedPointer.Title(childComplexity), true - case "Error.id": - if e.complexity.Error.Id == nil { + case "Error.ID": + if e.complexity.Error.ID == nil { break } - return e.complexity.Error.Id(childComplexity), true + return e.complexity.Error.ID(childComplexity), true - case "Error.errorOnNonRequiredField": + case "Error.ErrorOnNonRequiredField": if e.complexity.Error.ErrorOnNonRequiredField == nil { break } return e.complexity.Error.ErrorOnNonRequiredField(childComplexity), true - case "Error.errorOnRequiredField": + case "Error.ErrorOnRequiredField": if e.complexity.Error.ErrorOnRequiredField == nil { break } return e.complexity.Error.ErrorOnRequiredField(childComplexity), true - case "Error.nilOnRequiredField": + case "Error.NilOnRequiredField": if e.complexity.Error.NilOnRequiredField == nil { break } return e.complexity.Error.NilOnRequiredField(childComplexity), true - case "ForcedResolver.field": + case "ForcedResolver.Field": if e.complexity.ForcedResolver.Field == nil { break } return e.complexity.ForcedResolver.Field(childComplexity), true - case "InnerObject.id": - if e.complexity.InnerObject.Id == nil { + case "InnerObject.ID": + if e.complexity.InnerObject.ID == nil { break } - return e.complexity.InnerObject.Id(childComplexity), true + return e.complexity.InnerObject.ID(childComplexity), true - case "InvalidIdentifier.id": - if e.complexity.InvalidIdentifier.Id == nil { + case "InvalidIdentifier.ID": + if e.complexity.InvalidIdentifier.ID == nil { break } - return e.complexity.InvalidIdentifier.Id(childComplexity), true + return e.complexity.InvalidIdentifier.ID(childComplexity), true - case "It.id": - if e.complexity.It.Id == nil { + case "It.ID": + if e.complexity.It.ID == nil { break } - return e.complexity.It.Id(childComplexity), true + return e.complexity.It.ID(childComplexity), true - case "ModelMethods.resolverField": + case "ModelMethods.ResolverField": if e.complexity.ModelMethods.ResolverField == nil { break } return e.complexity.ModelMethods.ResolverField(childComplexity), true - case "ModelMethods.noContext": + case "ModelMethods.NoContext": if e.complexity.ModelMethods.NoContext == nil { break } return e.complexity.ModelMethods.NoContext(childComplexity), true - case "ModelMethods.withContext": + case "ModelMethods.WithContext": if e.complexity.ModelMethods.WithContext == nil { break } return e.complexity.ModelMethods.WithContext(childComplexity), true - case "OuterObject.inner": + case "OuterObject.Inner": if e.complexity.OuterObject.Inner == nil { break } return e.complexity.OuterObject.Inner(childComplexity), true - case "Query.invalidIdentifier": + case "Query.InvalidIdentifier": if e.complexity.Query.InvalidIdentifier == nil { break } return e.complexity.Query.InvalidIdentifier(childComplexity), true - case "Query.collision": + case "Query.Collision": if e.complexity.Query.Collision == nil { break } return e.complexity.Query.Collision(childComplexity), true - case "Query.mapInput": + case "Query.MapInput": if e.complexity.Query.MapInput == nil { break } @@ -326,7 +326,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.MapInput(childComplexity, args["input"].(map[string]interface{})), true - case "Query.recursive": + case "Query.Recursive": if e.complexity.Query.Recursive == nil { break } @@ -338,7 +338,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Recursive(childComplexity, args["input"].(*RecursiveInputSlice)), true - case "Query.nestedInputs": + case "Query.NestedInputs": if e.complexity.Query.NestedInputs == nil { break } @@ -350,14 +350,14 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.NestedInputs(childComplexity, args["input"].([][]*OuterInput)), true - case "Query.nestedOutputs": + case "Query.NestedOutputs": if e.complexity.Query.NestedOutputs == nil { break } return e.complexity.Query.NestedOutputs(childComplexity), true - case "Query.keywords": + case "Query.Keywords": if e.complexity.Query.Keywords == nil { break } @@ -369,35 +369,35 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Keywords(childComplexity, args["input"].(*Keywords)), true - case "Query.shapes": + case "Query.Shapes": if e.complexity.Query.Shapes == nil { break } return e.complexity.Query.Shapes(childComplexity), true - case "Query.errorBubble": + case "Query.ErrorBubble": if e.complexity.Query.ErrorBubble == nil { break } return e.complexity.Query.ErrorBubble(childComplexity), true - case "Query.modelMethods": + case "Query.ModelMethods": if e.complexity.Query.ModelMethods == nil { break } return e.complexity.Query.ModelMethods(childComplexity), true - case "Query.valid": + case "Query.Valid": if e.complexity.Query.Valid == nil { break } return e.complexity.Query.Valid(childComplexity), true - case "Query.user": + case "Query.User": if e.complexity.Query.User == nil { break } @@ -409,7 +409,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.User(childComplexity, args["id"].(int)), true - case "Query.nullableArg": + case "Query.NullableArg": if e.complexity.Query.NullableArg == nil { break } @@ -421,7 +421,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.NullableArg(childComplexity, args["arg"].(*int)), true - case "Query.directiveArg": + case "Query.DirectiveArg": if e.complexity.Query.DirectiveArg == nil { break } @@ -433,7 +433,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.DirectiveArg(childComplexity, args["arg"].(string)), true - case "Query.directiveNullableArg": + case "Query.DirectiveNullableArg": if e.complexity.Query.DirectiveNullableArg == nil { break } @@ -445,7 +445,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.DirectiveNullableArg(childComplexity, args["arg"].(*int), args["arg2"].(*int)), true - case "Query.directiveInputNullable": + case "Query.DirectiveInputNullable": if e.complexity.Query.DirectiveInputNullable == nil { break } @@ -457,7 +457,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.DirectiveInputNullable(childComplexity, args["arg"].(*InputDirectives)), true - case "Query.directiveInput": + case "Query.DirectiveInput": if e.complexity.Query.DirectiveInput == nil { break } @@ -469,7 +469,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.DirectiveInput(childComplexity, args["arg"].(InputDirectives)), true - case "Query.inputSlice": + case "Query.InputSlice": if e.complexity.Query.InputSlice == nil { break } @@ -481,14 +481,14 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.InputSlice(childComplexity, args["arg"].([]string)), true - case "Query.shapeUnion": + case "Query.ShapeUnion": if e.complexity.Query.ShapeUnion == nil { break } return e.complexity.Query.ShapeUnion(childComplexity), true - case "Query.keywordArgs": + case "Query.KeywordArgs": if e.complexity.Query.KeywordArgs == nil { break } @@ -498,65 +498,65 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Query.KeywordArgs(childComplexity, 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)), true + return e.complexity.Query.KeywordArgs(childComplexity, 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), args["_"].(string)), true - case "Rectangle.length": + case "Rectangle.Length": if e.complexity.Rectangle.Length == nil { break } return e.complexity.Rectangle.Length(childComplexity), true - case "Rectangle.width": + case "Rectangle.Width": if e.complexity.Rectangle.Width == nil { break } return e.complexity.Rectangle.Width(childComplexity), true - case "Rectangle.area": + case "Rectangle.Area": if e.complexity.Rectangle.Area == nil { break } return e.complexity.Rectangle.Area(childComplexity), true - case "Subscription.updated": + case "Subscription.Updated": if e.complexity.Subscription.Updated == nil { break } return e.complexity.Subscription.Updated(childComplexity), true - case "Subscription.initPayload": + case "Subscription.InitPayload": if e.complexity.Subscription.InitPayload == nil { break } return e.complexity.Subscription.InitPayload(childComplexity), true - case "User.id": - if e.complexity.User.Id == nil { + case "User.ID": + if e.complexity.User.ID == nil { break } - return e.complexity.User.Id(childComplexity), true + return e.complexity.User.ID(childComplexity), true - case "User.friends": + case "User.Friends": if e.complexity.User.Friends == nil { break } return e.complexity.User.Friends(childComplexity), true - case "User.created": + case "User.Created": if e.complexity.User.Created == nil { break } return e.complexity.User.Created(childComplexity), true - case "User.updated": + case "User.Updated": if e.complexity.User.Updated == nil { break } @@ -806,6 +806,7 @@ input Keywords { import: String! return: String! var: String! + _: String! } extend type Query { @@ -835,6 +836,7 @@ extend type Query { import: String!, return: String!, var: String!, + _: String!, ): Boolean! } @@ -1252,6 +1254,14 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra } } args["var"] = arg24 + var arg25 string + if tmp, ok := rawArgs["_"]; ok { + arg25, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["_"] = arg25 return args, nil } @@ -2317,7 +2327,7 @@ func (ec *executionContext) _Query_keywordArgs(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().KeywordArgs(rctx, args["break"].(string), args["default"].(string), args["func"].(string), args["interface"].(string), args["select"].(string), args["case"].(string), args["defer"].(string), args["go"].(string), args["map"].(string), args["struct"].(string), args["chan"].(string), args["else"].(string), args["goto"].(string), args["package"].(string), args["switch"].(string), args["const"].(string), args["fallthrough"].(string), args["if"].(string), args["range"].(string), args["type"].(string), args["continue"].(string), args["for"].(string), args["import"].(string), args["return"].(string), args["var"].(string)) + return ec.resolvers.Query().KeywordArgs(rctx, args["break"].(string), args["default"].(string), args["func"].(string), args["interface"].(string), args["select"].(string), args["case"].(string), args["defer"].(string), args["go"].(string), args["map"].(string), args["struct"].(string), args["chan"].(string), args["else"].(string), args["goto"].(string), args["package"].(string), args["switch"].(string), args["const"].(string), args["fallthrough"].(string), args["if"].(string), args["range"].(string), args["type"].(string), args["continue"].(string), args["for"].(string), args["import"].(string), args["return"].(string), args["var"].(string), args["_"].(string)) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -3674,6 +3684,12 @@ func (ec *executionContext) unmarshalInputKeywords(ctx context.Context, v interf if err != nil { return it, err } + case "_": + var err error + it.Underscore, err = ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } } } diff --git a/codegen/testserver/gqlgen.yml b/codegen/testserver/gqlgen.yml index f326e6d0556..5cdf1bad5a8 100644 --- a/codegen/testserver/gqlgen.yml +++ b/codegen/testserver/gqlgen.yml @@ -40,3 +40,7 @@ models: model: "github.com/99designs/gqlgen/codegen/testserver.EmbeddedPointerModel" ThirdParty: model: "github.com/99designs/gqlgen/codegen/testserver.ThirdParty" + Keywords: + fields: + _: { fieldName: Underscore } + diff --git a/codegen/testserver/models-gen.go b/codegen/testserver/models-gen.go index 716b09bedea..37774af1ea7 100644 --- a/codegen/testserver/models-gen.go +++ b/codegen/testserver/models-gen.go @@ -54,6 +54,7 @@ type Keywords struct { Import string `json:"import"` Return string `json:"return"` Var string `json:"var"` + Underscore string `json:"_"` } type OuterInput struct { diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index 20bcaa425fd..f474d5e624d 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -98,7 +98,7 @@ func (r *queryResolver) InputSlice(ctx context.Context, arg []string) (bool, err func (r *queryResolver) ShapeUnion(ctx context.Context) (ShapeUnion, error) { panic("not implemented") } -func (r *queryResolver) KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) { +func (r *queryResolver) KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string, _Arg string) (bool, error) { panic("not implemented") } diff --git a/codegen/testserver/schema.graphql b/codegen/testserver/schema.graphql index 21da0e9b219..de4320ca065 100644 --- a/codegen/testserver/schema.graphql +++ b/codegen/testserver/schema.graphql @@ -117,6 +117,7 @@ input Keywords { import: String! return: String! var: String! + _: String! } extend type Query { @@ -146,6 +147,7 @@ extend type Query { import: String!, return: String!, var: String!, + _: String!, ): Boolean! } diff --git a/codegen/testserver/stub.go b/codegen/testserver/stub.go index d88f0ddbb5a..7086569a523 100644 --- a/codegen/testserver/stub.go +++ b/codegen/testserver/stub.go @@ -36,7 +36,7 @@ type Stub struct { DirectiveInput func(ctx context.Context, arg InputDirectives) (*string, error) InputSlice func(ctx context.Context, arg []string) (bool, error) ShapeUnion func(ctx context.Context) (ShapeUnion, error) - KeywordArgs func(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) + KeywordArgs func(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string, _Arg string) (bool, error) } SubscriptionResolver struct { Updated func(ctx context.Context) (<-chan string, error) @@ -134,8 +134,8 @@ func (r *stubQuery) InputSlice(ctx context.Context, arg []string) (bool, error) func (r *stubQuery) ShapeUnion(ctx context.Context) (ShapeUnion, error) { return r.QueryResolver.ShapeUnion(ctx) } -func (r *stubQuery) KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string) (bool, error) { - return r.QueryResolver.KeywordArgs(ctx, breakArg, defaultArg, funcArg, interfaceArg, selectArg, caseArg, deferArg, goArg, mapArg, structArg, chanArg, elseArg, gotoArg, packageArg, switchArg, constArg, fallthroughArg, ifArg, rangeArg, typeArg, continueArg, forArg, importArg, returnArg, varArg) +func (r *stubQuery) KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string, _Arg string) (bool, error) { + return r.QueryResolver.KeywordArgs(ctx, breakArg, defaultArg, funcArg, interfaceArg, selectArg, caseArg, deferArg, goArg, mapArg, structArg, chanArg, elseArg, gotoArg, packageArg, switchArg, constArg, fallthroughArg, ifArg, rangeArg, typeArg, continueArg, forArg, importArg, returnArg, varArg, _Arg) } type stubSubscription struct{ *Stub } diff --git a/example/chat/generated.go b/example/chat/generated.go index fa4c1334332..21c7d263de1 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -50,7 +50,7 @@ type ComplexityRoot struct { } Message struct { - Id func(childComplexity int) int + ID func(childComplexity int) int Text func(childComplexity int) int CreatedBy func(childComplexity int) int CreatedAt func(childComplexity int) int @@ -94,49 +94,49 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { - case "Chatroom.name": + case "Chatroom.Name": if e.complexity.Chatroom.Name == nil { break } return e.complexity.Chatroom.Name(childComplexity), true - case "Chatroom.messages": + case "Chatroom.Messages": if e.complexity.Chatroom.Messages == nil { break } return e.complexity.Chatroom.Messages(childComplexity), true - case "Message.id": - if e.complexity.Message.Id == nil { + case "Message.ID": + if e.complexity.Message.ID == nil { break } - return e.complexity.Message.Id(childComplexity), true + return e.complexity.Message.ID(childComplexity), true - case "Message.text": + case "Message.Text": if e.complexity.Message.Text == nil { break } return e.complexity.Message.Text(childComplexity), true - case "Message.createdBy": + case "Message.CreatedBy": if e.complexity.Message.CreatedBy == nil { break } return e.complexity.Message.CreatedBy(childComplexity), true - case "Message.createdAt": + case "Message.CreatedAt": if e.complexity.Message.CreatedAt == nil { break } return e.complexity.Message.CreatedAt(childComplexity), true - case "Mutation.post": + case "Mutation.Post": if e.complexity.Mutation.Post == nil { break } @@ -148,7 +148,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.Post(childComplexity, args["text"].(string), args["username"].(string), args["roomName"].(string)), true - case "Query.room": + case "Query.Room": if e.complexity.Query.Room == nil { break } @@ -160,7 +160,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Room(childComplexity, args["name"].(string)), true - case "Subscription.messageAdded": + case "Subscription.MessageAdded": if e.complexity.Subscription.MessageAdded == nil { break } diff --git a/example/config/generated.go b/example/config/generated.go index 17e04c5d0bc..b7337bb00e7 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -51,15 +51,15 @@ type ComplexityRoot struct { } Todo struct { - Id func(childComplexity int) int - DatabaseId func(childComplexity int) int + ID func(childComplexity int) int + DatabaseID func(childComplexity int) int Description func(childComplexity int) int Done func(childComplexity int) int User func(childComplexity int) int } User struct { - Id func(childComplexity int) int + ID func(childComplexity int) int FullName func(childComplexity int) int } } @@ -89,7 +89,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { - case "Mutation.createTodo": + case "Mutation.CreateTodo": if e.complexity.Mutation.CreateTodo == nil { break } @@ -101,26 +101,26 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.CreateTodo(childComplexity, args["input"].(NewTodo)), true - case "Query.todos": + case "Query.Todos": if e.complexity.Query.Todos == nil { break } return e.complexity.Query.Todos(childComplexity), true - case "Todo.id": - if e.complexity.Todo.Id == nil { + case "Todo.ID": + if e.complexity.Todo.ID == nil { break } - return e.complexity.Todo.Id(childComplexity), true + return e.complexity.Todo.ID(childComplexity), true - case "Todo.databaseId": - if e.complexity.Todo.DatabaseId == nil { + case "Todo.DatabaseID": + if e.complexity.Todo.DatabaseID == nil { break } - return e.complexity.Todo.DatabaseId(childComplexity), true + return e.complexity.Todo.DatabaseID(childComplexity), true case "Todo.Description": if e.complexity.Todo.Description == nil { @@ -129,26 +129,26 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Todo.Description(childComplexity), true - case "Todo.done": + case "Todo.Done": if e.complexity.Todo.Done == nil { break } return e.complexity.Todo.Done(childComplexity), true - case "Todo.user": + case "Todo.User": if e.complexity.Todo.User == nil { break } return e.complexity.Todo.User(childComplexity), true - case "User.id": - if e.complexity.User.Id == nil { + case "User.ID": + if e.complexity.User.ID == nil { break } - return e.complexity.User.Id(childComplexity), true + return e.complexity.User.ID(childComplexity), true case "User.FullName": if e.complexity.User.FullName == nil { @@ -491,7 +491,7 @@ func (ec *executionContext) _Todo_databaseId(ctx context.Context, field graphql. return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) _Todo_Description(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { +func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -595,7 +595,7 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte return ec.marshalNID2string(ctx, field.Selections, res) } -func (ec *executionContext) _User_FullName(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { +func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1432,7 +1432,7 @@ func (ec *executionContext) unmarshalInputNewTodo(ctx context.Context, v interfa if err != nil { return it, err } - case "UserID": + case "userId": var err error it.UserID, err = ec.unmarshalNString2string(ctx, v) if err != nil { @@ -1547,8 +1547,8 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj if out.Values[i] == graphql.Null { invalid = true } - case "Description": - out.Values[i] = ec._Todo_Description(ctx, field, obj) + case "text": + out.Values[i] = ec._Todo_text(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } @@ -1589,8 +1589,8 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj if out.Values[i] == graphql.Null { invalid = true } - case "FullName": - out.Values[i] = ec._User_FullName(ctx, field, obj) + case "name": + out.Values[i] = ec._User_name(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } diff --git a/example/config/resolver.go b/example/config/resolver.go index c089094fa33..02d59e09037 100644 --- a/example/config/resolver.go +++ b/example/config/resolver.go @@ -60,6 +60,10 @@ func (r *queryResolver) Todos(ctx context.Context) ([]Todo, error) { type todoResolver struct{ *Resolver } +func (r *todoResolver) Description(ctx context.Context, obj *Todo) (string, error) { + panic("implement me") +} + func (r *todoResolver) ID(ctx context.Context, obj *Todo) (string, error) { if obj.ID != "" { return obj.ID, nil diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index 404af1956ef..f09ad400dcd 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -44,13 +44,13 @@ type DirectiveRoot struct { type ComplexityRoot struct { Address struct { - Id func(childComplexity int) int + ID func(childComplexity int) int Street func(childComplexity int) int Country func(childComplexity int) int } Customer struct { - Id func(childComplexity int) int + ID func(childComplexity int) int Name func(childComplexity int) int Address func(childComplexity int) int Orders func(childComplexity int) int @@ -61,7 +61,7 @@ type ComplexityRoot struct { } Order struct { - Id func(childComplexity int) int + ID func(childComplexity int) int Date func(childComplexity int) int Amount func(childComplexity int) int Items func(childComplexity int) int @@ -102,98 +102,98 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { - case "Address.id": - if e.complexity.Address.Id == nil { + case "Address.ID": + if e.complexity.Address.ID == nil { break } - return e.complexity.Address.Id(childComplexity), true + return e.complexity.Address.ID(childComplexity), true - case "Address.street": + case "Address.Street": if e.complexity.Address.Street == nil { break } return e.complexity.Address.Street(childComplexity), true - case "Address.country": + case "Address.Country": if e.complexity.Address.Country == nil { break } return e.complexity.Address.Country(childComplexity), true - case "Customer.id": - if e.complexity.Customer.Id == nil { + case "Customer.ID": + if e.complexity.Customer.ID == nil { break } - return e.complexity.Customer.Id(childComplexity), true + return e.complexity.Customer.ID(childComplexity), true - case "Customer.name": + case "Customer.Name": if e.complexity.Customer.Name == nil { break } return e.complexity.Customer.Name(childComplexity), true - case "Customer.address": + case "Customer.Address": if e.complexity.Customer.Address == nil { break } return e.complexity.Customer.Address(childComplexity), true - case "Customer.orders": + case "Customer.Orders": if e.complexity.Customer.Orders == nil { break } return e.complexity.Customer.Orders(childComplexity), true - case "Item.name": + case "Item.Name": if e.complexity.Item.Name == nil { break } return e.complexity.Item.Name(childComplexity), true - case "Order.id": - if e.complexity.Order.Id == nil { + case "Order.ID": + if e.complexity.Order.ID == nil { break } - return e.complexity.Order.Id(childComplexity), true + return e.complexity.Order.ID(childComplexity), true - case "Order.date": + case "Order.Date": if e.complexity.Order.Date == nil { break } return e.complexity.Order.Date(childComplexity), true - case "Order.amount": + case "Order.Amount": if e.complexity.Order.Amount == nil { break } return e.complexity.Order.Amount(childComplexity), true - case "Order.items": + case "Order.Items": if e.complexity.Order.Items == nil { break } return e.complexity.Order.Items(childComplexity), true - case "Query.customers": + case "Query.Customers": if e.complexity.Query.Customers == nil { break } return e.complexity.Query.Customers(childComplexity), true - case "Query.torture1d": + case "Query.Torture1d": if e.complexity.Query.Torture1d == nil { break } @@ -205,7 +205,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Torture1d(childComplexity, args["customerIds"].([]int)), true - case "Query.torture2d": + case "Query.Torture2d": if e.complexity.Query.Torture2d == nil { break } diff --git a/example/scalars/generated.go b/example/scalars/generated.go index 764500f7466..914a491e015 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -45,7 +45,7 @@ type DirectiveRoot struct { type ComplexityRoot struct { Address struct { - Id func(childComplexity int) int + ID func(childComplexity int) int Location func(childComplexity int) int } @@ -55,7 +55,7 @@ type ComplexityRoot struct { } User struct { - Id func(childComplexity int) int + ID func(childComplexity int) int Name func(childComplexity int) int Created func(childComplexity int) int IsBanned func(childComplexity int) int @@ -90,21 +90,21 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { - case "Address.id": - if e.complexity.Address.Id == nil { + case "Address.ID": + if e.complexity.Address.ID == nil { break } - return e.complexity.Address.Id(childComplexity), true + return e.complexity.Address.ID(childComplexity), true - case "Address.location": + case "Address.Location": if e.complexity.Address.Location == nil { break } return e.complexity.Address.Location(childComplexity), true - case "Query.user": + case "Query.User": if e.complexity.Query.User == nil { break } @@ -116,7 +116,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.User(childComplexity, args["id"].(external.ObjectID)), true - case "Query.search": + case "Query.Search": if e.complexity.Query.Search == nil { break } @@ -128,56 +128,56 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Search(childComplexity, args["input"].(*model.SearchArgs)), true - case "User.id": - if e.complexity.User.Id == nil { + case "User.ID": + if e.complexity.User.ID == nil { break } - return e.complexity.User.Id(childComplexity), true + return e.complexity.User.ID(childComplexity), true - case "User.name": + case "User.Name": if e.complexity.User.Name == nil { break } return e.complexity.User.Name(childComplexity), true - case "User.created": + case "User.Created": if e.complexity.User.Created == nil { break } return e.complexity.User.Created(childComplexity), true - case "User.isBanned": + case "User.IsBanned": if e.complexity.User.IsBanned == nil { break } return e.complexity.User.IsBanned(childComplexity), true - case "User.primitiveResolver": + case "User.PrimitiveResolver": if e.complexity.User.PrimitiveResolver == nil { break } return e.complexity.User.PrimitiveResolver(childComplexity), true - case "User.customResolver": + case "User.CustomResolver": if e.complexity.User.CustomResolver == nil { break } return e.complexity.User.CustomResolver(childComplexity), true - case "User.address": + case "User.Address": if e.complexity.User.Address == nil { break } return e.complexity.User.Address(childComplexity), true - case "User.tier": + case "User.Tier": if e.complexity.User.Tier == nil { break } diff --git a/example/selection/generated.go b/example/selection/generated.go index 226225b96a3..3692f5a0e13 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -80,63 +80,63 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { - case "Like.reaction": + case "Like.Reaction": if e.complexity.Like.Reaction == nil { break } return e.complexity.Like.Reaction(childComplexity), true - case "Like.sent": + case "Like.Sent": if e.complexity.Like.Sent == nil { break } return e.complexity.Like.Sent(childComplexity), true - case "Like.selection": + case "Like.Selection": if e.complexity.Like.Selection == nil { break } return e.complexity.Like.Selection(childComplexity), true - case "Like.collected": + case "Like.Collected": if e.complexity.Like.Collected == nil { break } return e.complexity.Like.Collected(childComplexity), true - case "Post.message": + case "Post.Message": if e.complexity.Post.Message == nil { break } return e.complexity.Post.Message(childComplexity), true - case "Post.sent": + case "Post.Sent": if e.complexity.Post.Sent == nil { break } return e.complexity.Post.Sent(childComplexity), true - case "Post.selection": + case "Post.Selection": if e.complexity.Post.Selection == nil { break } return e.complexity.Post.Selection(childComplexity), true - case "Post.collected": + case "Post.Collected": if e.complexity.Post.Collected == nil { break } return e.complexity.Post.Collected(childComplexity), true - case "Query.events": + case "Query.Events": if e.complexity.Query.Events == nil { break } diff --git a/example/starwars/generated.go b/example/starwars/generated.go index 46cfa7f74bd..b460c01e686 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -48,7 +48,7 @@ type DirectiveRoot struct { type ComplexityRoot struct { Droid struct { - Id func(childComplexity int) int + ID func(childComplexity int) int Name func(childComplexity int) int Friends func(childComplexity int) int FriendsConnection func(childComplexity int, first *int, after *string) int @@ -69,7 +69,7 @@ type ComplexityRoot struct { } Human struct { - Id func(childComplexity int) int + ID func(childComplexity int) int Name func(childComplexity int) int Height func(childComplexity int, unit LengthUnit) int Mass func(childComplexity int) int @@ -106,7 +106,7 @@ type ComplexityRoot struct { } Starship struct { - Id func(childComplexity int) int + ID func(childComplexity int) int Name func(childComplexity int) int Length func(childComplexity int, unit *LengthUnit) int History func(childComplexity int) int @@ -158,28 +158,28 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { - case "Droid.id": - if e.complexity.Droid.Id == nil { + case "Droid.ID": + if e.complexity.Droid.ID == nil { break } - return e.complexity.Droid.Id(childComplexity), true + return e.complexity.Droid.ID(childComplexity), true - case "Droid.name": + case "Droid.Name": if e.complexity.Droid.Name == nil { break } return e.complexity.Droid.Name(childComplexity), true - case "Droid.friends": + case "Droid.Friends": if e.complexity.Droid.Friends == nil { break } return e.complexity.Droid.Friends(childComplexity), true - case "Droid.friendsConnection": + case "Droid.FriendsConnection": if e.complexity.Droid.FriendsConnection == nil { break } @@ -191,77 +191,77 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Droid.FriendsConnection(childComplexity, args["first"].(*int), args["after"].(*string)), true - case "Droid.appearsIn": + case "Droid.AppearsIn": if e.complexity.Droid.AppearsIn == nil { break } return e.complexity.Droid.AppearsIn(childComplexity), true - case "Droid.primaryFunction": + case "Droid.PrimaryFunction": if e.complexity.Droid.PrimaryFunction == nil { break } return e.complexity.Droid.PrimaryFunction(childComplexity), true - case "FriendsConnection.totalCount": + case "FriendsConnection.TotalCount": if e.complexity.FriendsConnection.TotalCount == nil { break } return e.complexity.FriendsConnection.TotalCount(childComplexity), true - case "FriendsConnection.edges": + case "FriendsConnection.Edges": if e.complexity.FriendsConnection.Edges == nil { break } return e.complexity.FriendsConnection.Edges(childComplexity), true - case "FriendsConnection.friends": + case "FriendsConnection.Friends": if e.complexity.FriendsConnection.Friends == nil { break } return e.complexity.FriendsConnection.Friends(childComplexity), true - case "FriendsConnection.pageInfo": + case "FriendsConnection.PageInfo": if e.complexity.FriendsConnection.PageInfo == nil { break } return e.complexity.FriendsConnection.PageInfo(childComplexity), true - case "FriendsEdge.cursor": + case "FriendsEdge.Cursor": if e.complexity.FriendsEdge.Cursor == nil { break } return e.complexity.FriendsEdge.Cursor(childComplexity), true - case "FriendsEdge.node": + case "FriendsEdge.Node": if e.complexity.FriendsEdge.Node == nil { break } return e.complexity.FriendsEdge.Node(childComplexity), true - case "Human.id": - if e.complexity.Human.Id == nil { + case "Human.ID": + if e.complexity.Human.ID == nil { break } - return e.complexity.Human.Id(childComplexity), true + return e.complexity.Human.ID(childComplexity), true - case "Human.name": + case "Human.Name": if e.complexity.Human.Name == nil { break } return e.complexity.Human.Name(childComplexity), true - case "Human.height": + case "Human.Height": if e.complexity.Human.Height == nil { break } @@ -273,21 +273,21 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Human.Height(childComplexity, args["unit"].(LengthUnit)), true - case "Human.mass": + case "Human.Mass": if e.complexity.Human.Mass == nil { break } return e.complexity.Human.Mass(childComplexity), true - case "Human.friends": + case "Human.Friends": if e.complexity.Human.Friends == nil { break } return e.complexity.Human.Friends(childComplexity), true - case "Human.friendsConnection": + case "Human.FriendsConnection": if e.complexity.Human.FriendsConnection == nil { break } @@ -299,21 +299,21 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Human.FriendsConnection(childComplexity, args["first"].(*int), args["after"].(*string)), true - case "Human.appearsIn": + case "Human.AppearsIn": if e.complexity.Human.AppearsIn == nil { break } return e.complexity.Human.AppearsIn(childComplexity), true - case "Human.starships": + case "Human.Starships": if e.complexity.Human.Starships == nil { break } return e.complexity.Human.Starships(childComplexity), true - case "Mutation.createReview": + case "Mutation.CreateReview": if e.complexity.Mutation.CreateReview == nil { break } @@ -325,28 +325,28 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.CreateReview(childComplexity, args["episode"].(Episode), args["review"].(Review)), true - case "PageInfo.startCursor": + case "PageInfo.StartCursor": if e.complexity.PageInfo.StartCursor == nil { break } return e.complexity.PageInfo.StartCursor(childComplexity), true - case "PageInfo.endCursor": + case "PageInfo.EndCursor": if e.complexity.PageInfo.EndCursor == nil { break } return e.complexity.PageInfo.EndCursor(childComplexity), true - case "PageInfo.hasNextPage": + case "PageInfo.HasNextPage": if e.complexity.PageInfo.HasNextPage == nil { break } return e.complexity.PageInfo.HasNextPage(childComplexity), true - case "Query.hero": + case "Query.Hero": if e.complexity.Query.Hero == nil { break } @@ -358,7 +358,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Hero(childComplexity, args["episode"].(*Episode)), true - case "Query.reviews": + case "Query.Reviews": if e.complexity.Query.Reviews == nil { break } @@ -370,7 +370,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Reviews(childComplexity, args["episode"].(Episode), args["since"].(*time.Time)), true - case "Query.search": + case "Query.Search": if e.complexity.Query.Search == nil { break } @@ -382,7 +382,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Search(childComplexity, args["text"].(string)), true - case "Query.character": + case "Query.Character": if e.complexity.Query.Character == nil { break } @@ -394,7 +394,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Character(childComplexity, args["id"].(string)), true - case "Query.droid": + case "Query.Droid": if e.complexity.Query.Droid == nil { break } @@ -406,7 +406,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Droid(childComplexity, args["id"].(string)), true - case "Query.human": + case "Query.Human": if e.complexity.Query.Human == nil { break } @@ -418,7 +418,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Human(childComplexity, args["id"].(string)), true - case "Query.starship": + case "Query.Starship": if e.complexity.Query.Starship == nil { break } @@ -430,42 +430,42 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Starship(childComplexity, args["id"].(string)), true - case "Review.stars": + case "Review.Stars": if e.complexity.Review.Stars == nil { break } return e.complexity.Review.Stars(childComplexity), true - case "Review.commentary": + case "Review.Commentary": if e.complexity.Review.Commentary == nil { break } return e.complexity.Review.Commentary(childComplexity), true - case "Review.time": + case "Review.Time": if e.complexity.Review.Time == nil { break } return e.complexity.Review.Time(childComplexity), true - case "Starship.id": - if e.complexity.Starship.Id == nil { + case "Starship.ID": + if e.complexity.Starship.ID == nil { break } - return e.complexity.Starship.Id(childComplexity), true + return e.complexity.Starship.ID(childComplexity), true - case "Starship.name": + case "Starship.Name": if e.complexity.Starship.Name == nil { break } return e.complexity.Starship.Name(childComplexity), true - case "Starship.length": + case "Starship.Length": if e.complexity.Starship.Length == nil { break } @@ -477,7 +477,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Starship.Length(childComplexity, args["unit"].(*LengthUnit)), true - case "Starship.history": + case "Starship.History": if e.complexity.Starship.History == nil { break } diff --git a/example/todo/generated.go b/example/todo/generated.go index 97c638394f3..b95f35ea97d 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -54,7 +54,7 @@ type ComplexityRoot struct { } Todo struct { - Id func(childComplexity int) int + ID func(childComplexity int) int Text func(childComplexity int) int Done func(childComplexity int) int } @@ -85,7 +85,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { - case "MyMutation.createTodo": + case "MyMutation.CreateTodo": if e.complexity.MyMutation.CreateTodo == nil { break } @@ -97,7 +97,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.MyMutation.CreateTodo(childComplexity, args["todo"].(TodoInput)), true - case "MyMutation.updateTodo": + case "MyMutation.UpdateTodo": if e.complexity.MyMutation.UpdateTodo == nil { break } @@ -109,7 +109,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.MyMutation.UpdateTodo(childComplexity, args["id"].(int), args["changes"].(map[string]interface{})), true - case "MyQuery.todo": + case "MyQuery.Todo": if e.complexity.MyQuery.Todo == nil { break } @@ -121,35 +121,35 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.MyQuery.Todo(childComplexity, args["id"].(int)), true - case "MyQuery.lastTodo": + case "MyQuery.LastTodo": if e.complexity.MyQuery.LastTodo == nil { break } return e.complexity.MyQuery.LastTodo(childComplexity), true - case "MyQuery.todos": + case "MyQuery.Todos": if e.complexity.MyQuery.Todos == nil { break } return e.complexity.MyQuery.Todos(childComplexity), true - case "Todo.id": - if e.complexity.Todo.Id == nil { + case "Todo.ID": + if e.complexity.Todo.ID == nil { break } - return e.complexity.Todo.Id(childComplexity), true + return e.complexity.Todo.ID(childComplexity), true - case "Todo.text": + case "Todo.Text": if e.complexity.Todo.Text == nil { break } return e.complexity.Todo.Text(childComplexity), true - case "Todo.done": + case "Todo.Done": if e.complexity.Todo.Done == nil { break } diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index 190b4c6ba87..d0cfc65866f 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -65,7 +65,7 @@ type ComplexityRoot struct { } Todo struct { - Id func(childComplexity int) int + ID func(childComplexity int) int Text func(childComplexity int) int State func(childComplexity int) int Verified func(childComplexity int) int @@ -95,7 +95,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { - case "MyMutation.createTodo": + case "MyMutation.CreateTodo": if e.complexity.MyMutation.CreateTodo == nil { break } @@ -107,14 +107,14 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.MyMutation.CreateTodo(childComplexity, args["todo"].(TodoInput)), true - case "MyQuery.todos": + case "MyQuery.Todos": if e.complexity.MyQuery.Todos == nil { break } return e.complexity.MyQuery.Todos(childComplexity), true - case "MyQuery.todo": + case "MyQuery.Todo": if e.complexity.MyQuery.Todo == nil { break } @@ -126,28 +126,28 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.MyQuery.Todo(childComplexity, args["id"].(string)), true - case "Todo.id": - if e.complexity.Todo.Id == nil { + case "Todo.ID": + if e.complexity.Todo.ID == nil { break } - return e.complexity.Todo.Id(childComplexity), true + return e.complexity.Todo.ID(childComplexity), true - case "Todo.text": + case "Todo.Text": if e.complexity.Todo.Text == nil { break } return e.complexity.Todo.Text(childComplexity), true - case "Todo.state": + case "Todo.State": if e.complexity.Todo.State == nil { break } return e.complexity.Todo.State(childComplexity), true - case "Todo.verified": + case "Todo.Verified": if e.complexity.Todo.Verified == nil { break } diff --git a/integration/generated.go b/integration/generated.go index 82a43f247e4..d875ecf8426 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -55,7 +55,7 @@ type ComplexityRoot struct { Path func(childComplexity int) int Date func(childComplexity int, filter models.DateFilter) int Viewer func(childComplexity int) int - JsonEncoding func(childComplexity int) int + JSONEncoding func(childComplexity int) int Error func(childComplexity int, typeArg *models.ErrorType) int } @@ -99,35 +99,35 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { - case "Element.child": + case "Element.Child": if e.complexity.Element.Child == nil { break } return e.complexity.Element.Child(childComplexity), true - case "Element.error": + case "Element.Error": if e.complexity.Element.Error == nil { break } return e.complexity.Element.Error(childComplexity), true - case "Element.mismatched": + case "Element.Mismatched": if e.complexity.Element.Mismatched == nil { break } return e.complexity.Element.Mismatched(childComplexity), true - case "Query.path": + case "Query.Path": if e.complexity.Query.Path == nil { break } return e.complexity.Query.Path(childComplexity), true - case "Query.date": + case "Query.Date": if e.complexity.Query.Date == nil { break } @@ -139,21 +139,21 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Date(childComplexity, args["filter"].(models.DateFilter)), true - case "Query.viewer": + case "Query.Viewer": if e.complexity.Query.Viewer == nil { break } return e.complexity.Query.Viewer(childComplexity), true - case "Query.jsonEncoding": - if e.complexity.Query.JsonEncoding == nil { + case "Query.JSONEncoding": + if e.complexity.Query.JSONEncoding == nil { break } - return e.complexity.Query.JsonEncoding(childComplexity), true + return e.complexity.Query.JSONEncoding(childComplexity), true - case "Query.error": + case "Query.Error": if e.complexity.Query.Error == nil { break } @@ -165,21 +165,21 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Error(childComplexity, args["type"].(*models.ErrorType)), true - case "User.name": + case "User.Name": if e.complexity.User.Name == nil { break } return e.complexity.User.Name(childComplexity), true - case "User.likes": + case "User.Likes": if e.complexity.User.Likes == nil { break } return e.complexity.User.Likes(childComplexity), true - case "Viewer.user": + case "Viewer.User": if e.complexity.Viewer.User == nil { break } From f6c52666a789164d9efcc22473a5911c56c34b00 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Sat, 9 Feb 2019 14:15:58 +1100 Subject: [PATCH 089/147] Add a test for aliasing different cases fixes #376 --- codegen/testserver/generated.go | 696 ++++++++++++++++---------- codegen/testserver/gqlgen.yml | 10 +- codegen/testserver/models-gen.go | 36 +- codegen/testserver/resolver.go | 5 +- codegen/testserver/schema.graphql | 61 --- codegen/testserver/stub.go | 10 +- codegen/testserver/validtypes.graphql | 68 +++ codegen/testserver/validtypes_test.go | 38 ++ 8 files changed, 563 insertions(+), 361 deletions(-) create mode 100644 codegen/testserver/validtypes.graphql create mode 100644 codegen/testserver/validtypes_test.go diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 3f1a3af81f9..4a79db8c945 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -102,7 +102,6 @@ type ComplexityRoot struct { Recursive func(childComplexity int, input *RecursiveInputSlice) int NestedInputs func(childComplexity int, input [][]*OuterInput) int NestedOutputs func(childComplexity int) int - Keywords func(childComplexity int, input *Keywords) int Shapes func(childComplexity int) int ErrorBubble func(childComplexity int) int ModelMethods func(childComplexity int) int @@ -115,7 +114,7 @@ type ComplexityRoot struct { DirectiveInput func(childComplexity int, arg InputDirectives) int InputSlice func(childComplexity int, arg []string) int ShapeUnion func(childComplexity int) int - KeywordArgs func(childComplexity int, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string, _Arg string) int + ValidType func(childComplexity int) int } Rectangle struct { @@ -135,6 +134,13 @@ type ComplexityRoot struct { Created func(childComplexity int) int Updated func(childComplexity int) int } + + ValidType struct { + DifferentCase func(childComplexity int) int + DifferentCaseOld func(childComplexity int) int + ValidInputKeywords func(childComplexity int, input *ValidInput) int + ValidArgs func(childComplexity int, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string, _Arg string) int + } } type ForcedResolverResolver interface { @@ -150,7 +156,6 @@ type QueryResolver interface { Recursive(ctx context.Context, input *RecursiveInputSlice) (*bool, error) NestedInputs(ctx context.Context, input [][]*OuterInput) (*bool, error) NestedOutputs(ctx context.Context) ([][]*OuterObject, error) - Keywords(ctx context.Context, input *Keywords) (bool, error) Shapes(ctx context.Context) ([]Shape, error) ErrorBubble(ctx context.Context) (*Error, error) ModelMethods(ctx context.Context) (*ModelMethods, error) @@ -163,7 +168,7 @@ type QueryResolver interface { DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) InputSlice(ctx context.Context, arg []string) (bool, error) ShapeUnion(ctx context.Context) (ShapeUnion, error) - KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string, _Arg string) (bool, error) + ValidType(ctx context.Context) (*ValidType, error) } type SubscriptionResolver interface { Updated(ctx context.Context) (<-chan string, error) @@ -357,18 +362,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.NestedOutputs(childComplexity), true - case "Query.Keywords": - if e.complexity.Query.Keywords == nil { - break - } - - args, err := ec.field_Query_keywords_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.Keywords(childComplexity, args["input"].(*Keywords)), true - case "Query.Shapes": if e.complexity.Query.Shapes == nil { break @@ -488,17 +481,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.ShapeUnion(childComplexity), true - case "Query.KeywordArgs": - if e.complexity.Query.KeywordArgs == nil { + case "Query.ValidType": + if e.complexity.Query.ValidType == nil { break } - args, err := ec.field_Query_keywordArgs_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.KeywordArgs(childComplexity, 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), args["_"].(string)), true + return e.complexity.Query.ValidType(childComplexity), true case "Rectangle.Length": if e.complexity.Rectangle.Length == nil { @@ -563,6 +551,44 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.User.Updated(childComplexity), true + case "ValidType.DifferentCase": + if e.complexity.ValidType.DifferentCase == nil { + break + } + + return e.complexity.ValidType.DifferentCase(childComplexity), true + + case "ValidType.DifferentCaseOld": + if e.complexity.ValidType.DifferentCaseOld == nil { + break + } + + return e.complexity.ValidType.DifferentCaseOld(childComplexity), true + + case "ValidType.ValidInputKeywords": + if e.complexity.ValidType.ValidInputKeywords == nil { + break + } + + args, err := ec.field_ValidType_validInputKeywords_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.ValidType.ValidInputKeywords(childComplexity, args["input"].(*ValidInput)), true + + case "ValidType.ValidArgs": + if e.complexity.ValidType.ValidArgs == nil { + break + } + + args, err := ec.field_ValidType_validArgs_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.ValidType.ValidArgs(childComplexity, 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), args["_"].(string)), true + } return 0, false } @@ -694,7 +720,6 @@ var parsedSchema = gqlparser.MustLoadSchema( recursive(input: RecursiveInputSlice): Boolean nestedInputs(input: [[OuterInput]] = [[{inner: {id: 1}}]]): Boolean nestedOutputs: [[OuterObject]] - keywords(input: Keywords): Boolean! shapes: [Shape] errorBubble: Error modelMethods: ModelMethods @@ -780,37 +805,49 @@ type InnerObject { id: Int! } -input Keywords { - break: String! - default: String! - func: String! - interface: String! - select: String! - case: String! - defer: String! - go: String! - map: String! - struct: String! - chan: String! - else: String! - goto: String! - package: String! - switch: String! - const: String! - fallthrough: String! - if: String! - range: String! - type: String! - continue: String! - for: String! - import: String! - return: String! - var: String! - _: String! +interface Shape { + area: Float +} +type Circle implements Shape { + radius: Float + area: Float +} +type Rectangle implements Shape { + length: Float + width: Float + area: Float +} +union ShapeUnion = Circle | Rectangle + +type ForcedResolver { + field: Circle } -extend type Query { - keywordArgs( +type EmbeddedPointer { + ID: String + Title: String +} + +directive @length(min: Int!, max: Int) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION +directive @range(min: Int = 0, max: Int) on ARGUMENT_DEFINITION + +enum Status { + OK + ERROR +} + +scalar Time +`}, + &ast.Source{Name: "validtypes.graphql", Input: `extend type Query { + validType: ValidType +} + +""" These things are all valid, but without care generate invalid go code """ +type ValidType { + differentCase: String! + different_case: String! + validInputKeywords(input: ValidInput): Boolean! + validArgs( break: String!, default: String!, func: String!, @@ -840,38 +877,35 @@ extend type Query { ): Boolean! } -interface Shape { - area: Float -} -type Circle implements Shape { - radius: Float - area: Float -} -type Rectangle implements Shape { - length: Float - width: Float - area: Float -} -union ShapeUnion = Circle | Rectangle - -type ForcedResolver { - field: Circle -} - -type EmbeddedPointer { - ID: String - Title: String -} - -directive @length(min: Int!, max: Int) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION -directive @range(min: Int = 0, max: Int) on ARGUMENT_DEFINITION - -enum Status { - OK - ERROR +input ValidInput { + break: String! + default: String! + func: String! + interface: String! + select: String! + case: String! + defer: String! + go: String! + map: String! + struct: String! + chan: String! + else: String! + goto: String! + package: String! + switch: String! + const: String! + fallthrough: String! + if: String! + range: String! + type: String! + continue: String! + for: String! + import: String! + return: String! + var: String! + _: String! } -scalar Time `}, ) @@ -1051,7 +1085,77 @@ func (ec *executionContext) field_Query_inputSlice_args(ctx context.Context, raw return args, nil } -func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_mapInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 map[string]interface{} + if tmp, ok := rawArgs["input"]; ok { + arg0, err = ec.unmarshalOChanges2map(ctx, tmp) + if err != nil { + return nil, err + } + } + args["input"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_nestedInputs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 [][]*OuterInput + if tmp, ok := rawArgs["input"]; ok { + arg0, err = ec.unmarshalOOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(ctx, tmp) + if err != nil { + return nil, err + } + } + args["input"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_nullableArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 *int + if tmp, ok := rawArgs["arg"]; ok { + arg0, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["arg"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_recursive_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 *RecursiveInputSlice + if tmp, ok := rawArgs["input"]; ok { + arg0, err = ec.unmarshalORecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(ctx, tmp) + if err != nil { + return nil, err + } + } + args["input"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 int + if tmp, ok := rawArgs["id"]; ok { + arg0, err = ec.unmarshalNInt2int(ctx, tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + return args, nil +} + +func (ec *executionContext) field_ValidType_validArgs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string @@ -1265,40 +1369,12 @@ func (ec *executionContext) field_Query_keywordArgs_args(ctx context.Context, ra return args, nil } -func (ec *executionContext) field_Query_keywords_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 *Keywords - if tmp, ok := rawArgs["input"]; ok { - arg0, err = ec.unmarshalOKeywords2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(ctx, tmp) - if err != nil { - return nil, err - } - } - args["input"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query_mapInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 map[string]interface{} - if tmp, ok := rawArgs["input"]; ok { - arg0, err = ec.unmarshalOChanges2map(ctx, tmp) - if err != nil { - return nil, err - } - } - args["input"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query_nestedInputs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_ValidType_validInputKeywords_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} - var arg0 [][]*OuterInput + var arg0 *ValidInput if tmp, ok := rawArgs["input"]; ok { - arg0, err = ec.unmarshalOOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(ctx, tmp) + arg0, err = ec.unmarshalOValidInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐValidInput(ctx, tmp) if err != nil { return nil, err } @@ -1307,48 +1383,6 @@ func (ec *executionContext) field_Query_nestedInputs_args(ctx context.Context, r return args, nil } -func (ec *executionContext) field_Query_nullableArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 *int - if tmp, ok := rawArgs["arg"]; ok { - arg0, err = ec.unmarshalOInt2ᚖint(ctx, tmp) - if err != nil { - return nil, err - } - } - args["arg"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query_recursive_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 *RecursiveInputSlice - if tmp, ok := rawArgs["input"]; ok { - arg0, err = ec.unmarshalORecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(ctx, tmp) - if err != nil { - return nil, err - } - } - args["input"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 int - if tmp, ok := rawArgs["id"]; ok { - arg0, err = ec.unmarshalNInt2int(ctx, tmp) - if err != nil { - return nil, err - } - } - args["id"] = arg0 - return args, nil -} - func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -1928,47 +1962,14 @@ func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field grap resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().NestedOutputs(rctx) - }) - if resTmp == nil { - return graphql.Null - } - res := resTmp.([][]*OuterObject) - rctx.Result = res - ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOOuterObject2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx, field.Selections, res) -} - -func (ec *executionContext) _Query_keywords(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { - ctx = ec.Tracer.StartFieldExecution(ctx, field) - defer func() { ec.Tracer.EndFieldExecution(ctx) }() - rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, - } - ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_keywords_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args - ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Keywords(rctx, args["input"].(*Keywords)) - }) - if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } + }) + if resTmp == nil { return graphql.Null } - res := resTmp.(bool) + res := resTmp.([][]*OuterObject) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalOOuterObject2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx, field.Selections, res) } func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -2308,7 +2309,7 @@ func (ec *executionContext) _Query_shapeUnion(ctx context.Context, field graphql return ec.marshalNShapeUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShapeUnion(ctx, field.Selections, res) } -func (ec *executionContext) _Query_keywordArgs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) _Query_validType(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -2317,28 +2318,18 @@ func (ec *executionContext) _Query_keywordArgs(ctx context.Context, field graphq Args: nil, } ctx = graphql.WithResolverContext(ctx, rctx) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_keywordArgs_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().KeywordArgs(rctx, args["break"].(string), args["default"].(string), args["func"].(string), args["interface"].(string), args["select"].(string), args["case"].(string), args["defer"].(string), args["go"].(string), args["map"].(string), args["struct"].(string), args["chan"].(string), args["else"].(string), args["goto"].(string), args["package"].(string), args["switch"].(string), args["const"].(string), args["fallthrough"].(string), args["if"].(string), args["range"].(string), args["type"].(string), args["continue"].(string), args["for"].(string), args["import"].(string), args["return"].(string), args["var"].(string), args["_"].(string)) + return ec.resolvers.Query().ValidType(rctx) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*ValidType) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalOValidType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐValidType(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -2620,6 +2611,124 @@ func (ec *executionContext) _User_updated(ctx context.Context, field graphql.Col return ec.marshalOTime2ᚖtimeᚐTime(ctx, field.Selections, res) } +func (ec *executionContext) _ValidType_differentCase(ctx context.Context, field graphql.CollectedField, obj *ValidType) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "ValidType", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DifferentCase, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) _ValidType_different_case(ctx context.Context, field graphql.CollectedField, obj *ValidType) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "ValidType", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DifferentCaseOld, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) _ValidType_validInputKeywords(ctx context.Context, field graphql.CollectedField, obj *ValidType) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "ValidType", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_ValidType_validInputKeywords_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ValidInputKeywords, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) _ValidType_validArgs(ctx context.Context, field graphql.CollectedField, obj *ValidType) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "ValidType", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_ValidType_validArgs_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ValidArgs, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3528,8 +3637,44 @@ func (ec *executionContext) unmarshalInputInputDirectives(ctx context.Context, v return it, nil } -func (ec *executionContext) unmarshalInputKeywords(ctx context.Context, v interface{}) (Keywords, error) { - var it Keywords +func (ec *executionContext) unmarshalInputOuterInput(ctx context.Context, v interface{}) (OuterInput, error) { + var it OuterInput + var asMap = v.(map[string]interface{}) + + for k, v := range asMap { + switch k { + case "inner": + var err error + it.Inner, err = ec.unmarshalNInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerInput(ctx, v) + if err != nil { + return it, err + } + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputRecursiveInputSlice(ctx context.Context, v interface{}) (RecursiveInputSlice, error) { + var it RecursiveInputSlice + var asMap = v.(map[string]interface{}) + + for k, v := range asMap { + switch k { + case "self": + var err error + it.Self, err = ec.unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(ctx, v) + if err != nil { + return it, err + } + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputValidInput(ctx context.Context, v interface{}) (ValidInput, error) { + var it ValidInput var asMap = v.(map[string]interface{}) for k, v := range asMap { @@ -3696,42 +3841,6 @@ func (ec *executionContext) unmarshalInputKeywords(ctx context.Context, v interf return it, nil } -func (ec *executionContext) unmarshalInputOuterInput(ctx context.Context, v interface{}) (OuterInput, error) { - var it OuterInput - var asMap = v.(map[string]interface{}) - - for k, v := range asMap { - switch k { - case "inner": - var err error - it.Inner, err = ec.unmarshalNInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerInput(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputRecursiveInputSlice(ctx context.Context, v interface{}) (RecursiveInputSlice, error) { - var it RecursiveInputSlice - var asMap = v.(map[string]interface{}) - - for k, v := range asMap { - switch k { - case "self": - var err error - it.Self, err = ec.unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** @@ -4089,15 +4198,6 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr res = ec._Query_nestedOutputs(ctx, field) return res }) - case "keywords": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_keywords(ctx, field) - if res == graphql.Null { - invalid = true - } - return res - }) case "shapes": field := field out.Concurrently(i, func() (res graphql.Marshaler) { @@ -4182,13 +4282,10 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } return res }) - case "keywordArgs": + case "validType": field := field out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Query_keywordArgs(ctx, field) - if res == graphql.Null { - invalid = true - } + res = ec._Query_validType(ctx, field) return res }) case "__type": @@ -4299,6 +4396,48 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj return out } +var validTypeImplementors = []string{"ValidType"} + +func (ec *executionContext) _ValidType(ctx context.Context, sel ast.SelectionSet, obj *ValidType) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, validTypeImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("ValidType") + case "differentCase": + out.Values[i] = ec._ValidType_differentCase(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "different_case": + out.Values[i] = ec._ValidType_different_case(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "validInputKeywords": + out.Values[i] = ec._ValidType_validInputKeywords(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "validArgs": + out.Values[i] = ec._ValidType_validArgs(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { @@ -5012,18 +5151,6 @@ func (ec *executionContext) marshalOIt2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋco return ec._It(ctx, sel, v) } -func (ec *executionContext) unmarshalOKeywords2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(ctx context.Context, v interface{}) (Keywords, error) { - return ec.unmarshalInputKeywords(ctx, v) -} - -func (ec *executionContext) unmarshalOKeywords2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(ctx context.Context, v interface{}) (*Keywords, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalOKeywords2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐKeywords(ctx, v) - return &res, err -} - func (ec *executionContext) marshalOModelMethods2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐModelMethods(ctx context.Context, sel ast.SelectionSet, v ModelMethods) graphql.Marshaler { return ec._ModelMethods(ctx, sel, &v) } @@ -5299,6 +5426,29 @@ func (ec *executionContext) marshalOTime2ᚖtimeᚐTime(ctx context.Context, sel return ec.marshalOTime2timeᚐTime(ctx, sel, *v) } +func (ec *executionContext) unmarshalOValidInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐValidInput(ctx context.Context, v interface{}) (ValidInput, error) { + return ec.unmarshalInputValidInput(ctx, v) +} + +func (ec *executionContext) unmarshalOValidInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐValidInput(ctx context.Context, v interface{}) (*ValidInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalOValidInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐValidInput(ctx, v) + return &res, err +} + +func (ec *executionContext) marshalOValidType2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐValidType(ctx context.Context, sel ast.SelectionSet, v ValidType) graphql.Marshaler { + return ec._ValidType(ctx, sel, &v) +} + +func (ec *executionContext) marshalOValidType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐValidType(ctx context.Context, sel ast.SelectionSet, v *ValidType) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._ValidType(ctx, sel, v) +} + func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup diff --git a/codegen/testserver/gqlgen.yml b/codegen/testserver/gqlgen.yml index 5cdf1bad5a8..c240e129ca9 100644 --- a/codegen/testserver/gqlgen.yml +++ b/codegen/testserver/gqlgen.yml @@ -1,4 +1,5 @@ -schema: schema.graphql +schema: + - "*.graphql" exec: filename: generated.go @@ -43,4 +44,9 @@ models: Keywords: fields: _: { fieldName: Underscore } - + ValidInput: + fields: + _: { fieldName: Underscore } + ValidType: + fields: + different_case: { fieldName: DifferentCaseOld } diff --git a/codegen/testserver/models-gen.go b/codegen/testserver/models-gen.go index 37774af1ea7..f0af1136297 100644 --- a/codegen/testserver/models-gen.go +++ b/codegen/testserver/models-gen.go @@ -28,7 +28,22 @@ type InputDirectives struct { ThirdParty *ThirdParty `json:"thirdParty"` } -type Keywords struct { +type OuterInput struct { + Inner InnerInput `json:"inner"` +} + +type OuterObject struct { + Inner InnerObject `json:"inner"` +} + +type User struct { + ID int `json:"id"` + Friends []User `json:"friends"` + Created time.Time `json:"created"` + Updated *time.Time `json:"updated"` +} + +type ValidInput struct { Break string `json:"break"` Default string `json:"default"` Func string `json:"func"` @@ -57,19 +72,12 @@ type Keywords struct { Underscore string `json:"_"` } -type OuterInput struct { - Inner InnerInput `json:"inner"` -} - -type OuterObject struct { - Inner InnerObject `json:"inner"` -} - -type User struct { - ID int `json:"id"` - Friends []User `json:"friends"` - Created time.Time `json:"created"` - Updated *time.Time `json:"updated"` +// These things are all valid, but without care generate invalid go code +type ValidType struct { + DifferentCase string `json:"differentCase"` + DifferentCaseOld string `json:"different_case"` + ValidInputKeywords bool `json:"validInputKeywords"` + ValidArgs bool `json:"validArgs"` } type Status string diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index f474d5e624d..190b6c84871 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -59,9 +59,6 @@ func (r *queryResolver) NestedInputs(ctx context.Context, input [][]*OuterInput) func (r *queryResolver) NestedOutputs(ctx context.Context) ([][]*OuterObject, error) { panic("not implemented") } -func (r *queryResolver) Keywords(ctx context.Context, input *Keywords) (bool, error) { - panic("not implemented") -} func (r *queryResolver) Shapes(ctx context.Context) ([]Shape, error) { panic("not implemented") } @@ -98,7 +95,7 @@ func (r *queryResolver) InputSlice(ctx context.Context, arg []string) (bool, err func (r *queryResolver) ShapeUnion(ctx context.Context) (ShapeUnion, error) { panic("not implemented") } -func (r *queryResolver) KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string, _Arg string) (bool, error) { +func (r *queryResolver) ValidType(ctx context.Context) (*ValidType, error) { panic("not implemented") } diff --git a/codegen/testserver/schema.graphql b/codegen/testserver/schema.graphql index de4320ca065..c400847ad97 100644 --- a/codegen/testserver/schema.graphql +++ b/codegen/testserver/schema.graphql @@ -5,7 +5,6 @@ type Query { recursive(input: RecursiveInputSlice): Boolean nestedInputs(input: [[OuterInput]] = [[{inner: {id: 1}}]]): Boolean nestedOutputs: [[OuterObject]] - keywords(input: Keywords): Boolean! shapes: [Shape] errorBubble: Error modelMethods: ModelMethods @@ -91,66 +90,6 @@ type InnerObject { id: Int! } -input Keywords { - break: String! - default: String! - func: String! - interface: String! - select: String! - case: String! - defer: String! - go: String! - map: String! - struct: String! - chan: String! - else: String! - goto: String! - package: String! - switch: String! - const: String! - fallthrough: String! - if: String! - range: String! - type: String! - continue: String! - for: String! - import: String! - return: String! - var: String! - _: String! -} - -extend type Query { - keywordArgs( - break: String!, - default: String!, - func: String!, - interface: String!, - select: String!, - case: String!, - defer: String!, - go: String!, - map: String!, - struct: String!, - chan: String!, - else: String!, - goto: String!, - package: String!, - switch: String!, - const: String!, - fallthrough: String!, - if: String!, - range: String!, - type: String!, - continue: String!, - for: String!, - import: String!, - return: String!, - var: String!, - _: String!, - ): Boolean! -} - interface Shape { area: Float } diff --git a/codegen/testserver/stub.go b/codegen/testserver/stub.go index 7086569a523..0a80f2e6844 100644 --- a/codegen/testserver/stub.go +++ b/codegen/testserver/stub.go @@ -23,7 +23,6 @@ type Stub struct { Recursive func(ctx context.Context, input *RecursiveInputSlice) (*bool, error) NestedInputs func(ctx context.Context, input [][]*OuterInput) (*bool, error) NestedOutputs func(ctx context.Context) ([][]*OuterObject, error) - Keywords func(ctx context.Context, input *Keywords) (bool, error) Shapes func(ctx context.Context) ([]Shape, error) ErrorBubble func(ctx context.Context) (*Error, error) ModelMethods func(ctx context.Context) (*ModelMethods, error) @@ -36,7 +35,7 @@ type Stub struct { DirectiveInput func(ctx context.Context, arg InputDirectives) (*string, error) InputSlice func(ctx context.Context, arg []string) (bool, error) ShapeUnion func(ctx context.Context) (ShapeUnion, error) - KeywordArgs func(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string, _Arg string) (bool, error) + ValidType func(ctx context.Context) (*ValidType, error) } SubscriptionResolver struct { Updated func(ctx context.Context) (<-chan string, error) @@ -95,9 +94,6 @@ func (r *stubQuery) NestedInputs(ctx context.Context, input [][]*OuterInput) (*b func (r *stubQuery) NestedOutputs(ctx context.Context) ([][]*OuterObject, error) { return r.QueryResolver.NestedOutputs(ctx) } -func (r *stubQuery) Keywords(ctx context.Context, input *Keywords) (bool, error) { - return r.QueryResolver.Keywords(ctx, input) -} func (r *stubQuery) Shapes(ctx context.Context) ([]Shape, error) { return r.QueryResolver.Shapes(ctx) } @@ -134,8 +130,8 @@ func (r *stubQuery) InputSlice(ctx context.Context, arg []string) (bool, error) func (r *stubQuery) ShapeUnion(ctx context.Context) (ShapeUnion, error) { return r.QueryResolver.ShapeUnion(ctx) } -func (r *stubQuery) KeywordArgs(ctx context.Context, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string, _Arg string) (bool, error) { - return r.QueryResolver.KeywordArgs(ctx, breakArg, defaultArg, funcArg, interfaceArg, selectArg, caseArg, deferArg, goArg, mapArg, structArg, chanArg, elseArg, gotoArg, packageArg, switchArg, constArg, fallthroughArg, ifArg, rangeArg, typeArg, continueArg, forArg, importArg, returnArg, varArg, _Arg) +func (r *stubQuery) ValidType(ctx context.Context) (*ValidType, error) { + return r.QueryResolver.ValidType(ctx) } type stubSubscription struct{ *Stub } diff --git a/codegen/testserver/validtypes.graphql b/codegen/testserver/validtypes.graphql new file mode 100644 index 00000000000..f344a9f2de5 --- /dev/null +++ b/codegen/testserver/validtypes.graphql @@ -0,0 +1,68 @@ +extend type Query { + validType: ValidType +} + +""" These things are all valid, but without care generate invalid go code """ +type ValidType { + differentCase: String! + different_case: String! + validInputKeywords(input: ValidInput): Boolean! + validArgs( + break: String!, + default: String!, + func: String!, + interface: String!, + select: String!, + case: String!, + defer: String!, + go: String!, + map: String!, + struct: String!, + chan: String!, + else: String!, + goto: String!, + package: String!, + switch: String!, + const: String!, + fallthrough: String!, + if: String!, + range: String!, + type: String!, + continue: String!, + for: String!, + import: String!, + return: String!, + var: String!, + _: String!, + ): Boolean! +} + +input ValidInput { + break: String! + default: String! + func: String! + interface: String! + select: String! + case: String! + defer: String! + go: String! + map: String! + struct: String! + chan: String! + else: String! + goto: String! + package: String! + switch: String! + const: String! + fallthrough: String! + if: String! + range: String! + type: String! + continue: String! + for: String! + import: String! + return: String! + var: String! + _: String! +} + diff --git a/codegen/testserver/validtypes_test.go b/codegen/testserver/validtypes_test.go new file mode 100644 index 00000000000..7c6df2fafec --- /dev/null +++ b/codegen/testserver/validtypes_test.go @@ -0,0 +1,38 @@ +package testserver + +import ( + "context" + "net/http/httptest" + "testing" + + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/handler" + "github.com/stretchr/testify/require" +) + +func TestValidType(t *testing.T) { + resolvers := &Stub{} + resolvers.QueryResolver.ValidType = func(ctx context.Context) (validType *ValidType, e error) { + return &ValidType{ + DifferentCase: "new", + DifferentCaseOld: "old", + }, nil + } + + srv := httptest.NewServer(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolvers}))) + c := client.New(srv.URL) + + t.Run("fields with differing cases can be distinguished", func(t *testing.T) { + var resp struct { + ValidType struct { + New string `json:"differentCase"` + Old string `json:"different_case"` + } + } + err := c.Post(`query { validType { differentCase, different_case } }`, &resp) + require.NoError(t, err) + + require.Equal(t, "new", resp.ValidType.New) + require.Equal(t, "old", resp.ValidType.Old) + }) +} From 58b2c74f6d7dd5ecf4503d1adab5bcd3838aef73 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Mon, 18 Feb 2019 12:06:44 +1100 Subject: [PATCH 090/147] drive by config fix --- codegen/config/config_test.go | 2 +- codegen/{ => config}/testdata/cfg/conflictedPackages.yml | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename codegen/{ => config}/testdata/cfg/conflictedPackages.yml (100%) diff --git a/codegen/config/config_test.go b/codegen/config/config_test.go index d4f94f9c973..6ac5257cfdd 100644 --- a/codegen/config/config_test.go +++ b/codegen/config/config_test.go @@ -87,7 +87,7 @@ func TestConfigCheck(t *testing.T) { err = config.normalize() require.NoError(t, err) - err = config.check() + err = config.Check() require.EqualError(t, err, "filenames exec.go and models.go are in the same directory but have different package definitions") }) } diff --git a/codegen/testdata/cfg/conflictedPackages.yml b/codegen/config/testdata/cfg/conflictedPackages.yml similarity index 100% rename from codegen/testdata/cfg/conflictedPackages.yml rename to codegen/config/testdata/cfg/conflictedPackages.yml From e61b3e0be1fc52d94f0bbc80f7c486bb9eeb4f40 Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Mon, 18 Feb 2019 12:22:03 +1100 Subject: [PATCH 091/147] Add Field Collection docs --- docs/content/reference/field-collection.md | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 docs/content/reference/field-collection.md diff --git a/docs/content/reference/field-collection.md b/docs/content/reference/field-collection.md new file mode 100644 index 00000000000..f79bc4b0b61 --- /dev/null +++ b/docs/content/reference/field-collection.md @@ -0,0 +1,57 @@ +--- +title: 'Determining which fields were requested by a query' +description: How to determine which fields a query requested in a resolver. +linkTitle: Field Collection +menu: { main: { parent: 'reference' } } +--- + +Often it is useful to know which fields were queried for in a resolver. Having this information can allow a resolver to only fetch the set of fields required from a data source, rather than over-fetching everything and allowing gqlgen to do the rest. + +This process is known as [Field Collection](https://facebook.github.io/graphql/draft/#sec-Field-Collection) — gqlgen automatically does this in order to know which fields should be a part of the response payload. The set of collected fields does however depend on the type being resolved. Queries can contain fragments, and resolvers can return interfaces and unions, therefore the set of collected fields cannot be fully determined until the type of the resolved object is known. + +Within a resolver, there are several API methods available to query the selected fields. + +## CollectAllFields + +`CollectAllFields` is the simplest way to get the set of queried fields. It will return a slice of strings of the field names from the query. This will be a unique set of fields, and will return all fragment fields, ignoring fragment Type Conditions. + +Given the following example query: + +```graphql +query { + foo { + fieldA + ... on Bar { + fieldB + } + ... on Baz { + fieldC + } + } +} +``` + +Calling `CollectAllFields` from a resolver will yield a string slice containing `fieldA`, `fieldB`, and `fieldC`. + +## CollectFieldsCtx + +`CollectFieldsCtx` is useful in cases where more information on matches is required, or the set of collected fields should match fragment type conditions for a resolved type. `CollectFieldsCtx` takes a `satisfies` parameter, which should be a slice of strings of types that the resolved type will satisfy. + +For example, given the following schema: + +```graphql +interface Shape { + area: Float +} +type Circle implements Shape { + radius: Float + area: Float +} +union Shapes = Circle +``` + +The type `Circle` would satisfy `Circle`, `Shape`, and `Shapes` — these values should be passed to `CollectFieldsCtx` to get the set of collected fields for a resolved `Circle` object. + +> Note +> +> `CollectFieldsCtx` is just a convenience wrapper around `CollectFields` that calls the later with the selection set automatically passed through from the resolver context. From 318639bbbb71985778ca2ee796bfe22fe231808e Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Mon, 18 Feb 2019 13:29:43 +1100 Subject: [PATCH 092/147] Always return *Thing from resolvers for structs --- codegen/config/binder.go | 18 ++++++++++++++++ codegen/field.go | 5 +++++ codegen/testserver/generated.go | 16 ++++++++++++--- codegen/testserver/middleware_test.go | 4 ++-- codegen/testserver/resolver.go | 2 +- codegen/testserver/stub.go | 4 ++-- codegen/testserver/time_test.go | 8 ++++---- codegen/testserver/tracer_test.go | 4 ++-- example/chat/generated.go | 20 +++++++++++++----- example/chat/resolvers.go | 18 ++++++++-------- example/config/generated.go | 16 ++++++++++++--- example/config/resolver.go | 4 ++-- example/scalars/generated.go | 24 +++++++++++++++++++--- example/scalars/resolvers.go | 4 ++-- example/starwars/generated.go | 22 ++++++++++++++------ example/starwars/model.go | 8 ++++---- example/starwars/resolvers.go | 4 ++-- example/todo/generated.go | 16 ++++++++++++--- example/todo/todo.go | 4 ++-- example/type-system-extension/generated.go | 16 ++++++++++++--- example/type-system-extension/resolver.go | 4 ++-- integration/generated.go | 16 ++++++++++++--- integration/resolver.go | 4 ++-- 23 files changed, 176 insertions(+), 65 deletions(-) diff --git a/codegen/config/binder.go b/codegen/config/binder.go index 4ecd505ff52..873ff371c9a 100644 --- a/codegen/config/binder.go +++ b/codegen/config/binder.go @@ -149,6 +149,19 @@ func (b *Binder) FindObject(pkgName string, typeName string) (types.Object, erro return nil, errors.Errorf("unable to find type %s\n", fullName) } +func (b *Binder) PointerTo(ref *TypeReference) *TypeReference { + newRef := &TypeReference{ + GO: types.NewPointer(ref.GO), + GQL: ref.GQL, + Definition: ref.Definition, + Unmarshaler: ref.Unmarshaler, + Marshaler: ref.Marshaler, + } + + b.References = append(b.References, newRef) + return newRef +} + var modsRegex = regexp.MustCompile(`^(\*|\[\])*`) func normalizeVendor(pkg string) string { @@ -205,6 +218,11 @@ func (t *TypeReference) IsNamed() bool { return isSlice } +func (t *TypeReference) IsStruct() bool { + _, isStruct := t.GO.Underlying().(*types.Struct) + return isStruct +} + func (t *TypeReference) IsScalar() bool { return t.Definition.Kind == ast.Scalar } diff --git a/codegen/field.go b/codegen/field.go index 1e68ad8ba8f..bab170c9e93 100644 --- a/codegen/field.go +++ b/codegen/field.go @@ -77,7 +77,12 @@ func (b *builder) bindField(obj *Object, f *Field) error { } f.TypeReference = tr } + + if f.IsResolver && !f.TypeReference.IsPtr() && f.TypeReference.IsStruct() { + f.TypeReference = b.Binder.PointerTo(f.TypeReference) + } }() + switch { case f.Name == "__schema": f.GoFieldType = GoFieldMethod diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 4a79db8c945..62ccbb2d220 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -160,7 +160,7 @@ type QueryResolver interface { ErrorBubble(ctx context.Context) (*Error, error) ModelMethods(ctx context.Context) (*ModelMethods, error) Valid(ctx context.Context) (string, error) - User(ctx context.Context, id int) (User, error) + User(ctx context.Context, id int) (*User, error) NullableArg(ctx context.Context, arg *int) (*string, error) DirectiveArg(ctx context.Context, arg string) (*string, error) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int) (*string, error) @@ -2094,10 +2094,10 @@ func (ec *executionContext) _Query_user(ctx context.Context, field graphql.Colle } return graphql.Null } - res := resTmp.(User) + res := resTmp.(*User) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNUser2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx, field.Selections, res) + return ec.marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx, field.Selections, res) } func (ec *executionContext) _Query_nullableArg(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -4835,6 +4835,16 @@ func (ec *executionContext) marshalNUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ return ret } +func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx context.Context, sel ast.SelectionSet, v *User) graphql.Marshaler { + if v == nil { + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec._User(ctx, sel, v) +} + func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { return ec.___Directive(ctx, sel, &v) } diff --git a/codegen/testserver/middleware_test.go b/codegen/testserver/middleware_test.go index 231b839cfea..05ae43c3e8c 100644 --- a/codegen/testserver/middleware_test.go +++ b/codegen/testserver/middleware_test.go @@ -19,8 +19,8 @@ func TestMiddleware(t *testing.T) { return &Error{ID: "E1234"}, nil } - resolvers.QueryResolver.User = func(ctx context.Context, id int) (user User, e error) { - return User{ID: 1}, nil + resolvers.QueryResolver.User = func(ctx context.Context, id int) (user *User, e error) { + return &User{ID: 1}, nil } resolvers.UserResolver.Friends = func(ctx context.Context, obj *User) (users []User, e error) { diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index 190b6c84871..d2b55ca2fca 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -71,7 +71,7 @@ func (r *queryResolver) ModelMethods(ctx context.Context) (*ModelMethods, error) func (r *queryResolver) Valid(ctx context.Context) (string, error) { panic("not implemented") } -func (r *queryResolver) User(ctx context.Context, id int) (User, error) { +func (r *queryResolver) User(ctx context.Context, id int) (*User, error) { panic("not implemented") } func (r *queryResolver) NullableArg(ctx context.Context, arg *int) (*string, error) { diff --git a/codegen/testserver/stub.go b/codegen/testserver/stub.go index 0a80f2e6844..57e31cc2086 100644 --- a/codegen/testserver/stub.go +++ b/codegen/testserver/stub.go @@ -27,7 +27,7 @@ type Stub struct { ErrorBubble func(ctx context.Context) (*Error, error) ModelMethods func(ctx context.Context) (*ModelMethods, error) Valid func(ctx context.Context) (string, error) - User func(ctx context.Context, id int) (User, error) + User func(ctx context.Context, id int) (*User, error) NullableArg func(ctx context.Context, arg *int) (*string, error) DirectiveArg func(ctx context.Context, arg string) (*string, error) DirectiveNullableArg func(ctx context.Context, arg *int, arg2 *int) (*string, error) @@ -106,7 +106,7 @@ func (r *stubQuery) ModelMethods(ctx context.Context) (*ModelMethods, error) { func (r *stubQuery) Valid(ctx context.Context) (string, error) { return r.QueryResolver.Valid(ctx) } -func (r *stubQuery) User(ctx context.Context, id int) (User, error) { +func (r *stubQuery) User(ctx context.Context, id int) (*User, error) { return r.QueryResolver.User(ctx, id) } func (r *stubQuery) NullableArg(ctx context.Context, arg *int) (*string, error) { diff --git a/codegen/testserver/time_test.go b/codegen/testserver/time_test.go index 71918053454..fc293563e77 100644 --- a/codegen/testserver/time_test.go +++ b/codegen/testserver/time_test.go @@ -17,8 +17,8 @@ func TestTime(t *testing.T) { srv := httptest.NewServer(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolvers}))) c := client.New(srv.URL) - resolvers.QueryResolver.User = func(ctx context.Context, id int) (user User, e error) { - return User{}, nil + resolvers.QueryResolver.User = func(ctx context.Context, id int) (user *User, e error) { + return &User{}, nil } t.Run("zero value in nullable field", func(t *testing.T) { @@ -46,9 +46,9 @@ func TestTime(t *testing.T) { }) t.Run("with values", func(t *testing.T) { - resolvers.QueryResolver.User = func(ctx context.Context, id int) (user User, e error) { + resolvers.QueryResolver.User = func(ctx context.Context, id int) (user *User, e error) { updated := time.Date(2010, 1, 1, 0, 0, 20, 0, time.UTC) - return User{ + return &User{ Created: time.Date(2010, 1, 1, 0, 0, 10, 0, time.UTC), Updated: &updated, }, nil diff --git a/codegen/testserver/tracer_test.go b/codegen/testserver/tracer_test.go index d0fad686b0e..e2ccc5f95fd 100644 --- a/codegen/testserver/tracer_test.go +++ b/codegen/testserver/tracer_test.go @@ -16,8 +16,8 @@ import ( func TestTracer(t *testing.T) { resolvers := &Stub{} - resolvers.QueryResolver.User = func(ctx context.Context, id int) (user User, e error) { - return User{ID: 1}, nil + resolvers.QueryResolver.User = func(ctx context.Context, id int) (user *User, e error) { + return &User{ID: 1}, nil } t.Run("called in the correct order", func(t *testing.T) { var tracerLog []string diff --git a/example/chat/generated.go b/example/chat/generated.go index 21c7d263de1..5827c738d48 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -70,13 +70,13 @@ type ComplexityRoot struct { } type MutationResolver interface { - Post(ctx context.Context, text string, username string, roomName string) (Message, error) + Post(ctx context.Context, text string, username string, roomName string) (*Message, error) } type QueryResolver interface { Room(ctx context.Context, name string) (*Chatroom, error) } type SubscriptionResolver interface { - MessageAdded(ctx context.Context, roomName string) (<-chan Message, error) + MessageAdded(ctx context.Context, roomName string) (<-chan *Message, error) } type executableSchema struct { @@ -597,10 +597,10 @@ func (ec *executionContext) _Mutation_post(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.(Message) + res := resTmp.(*Message) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNMessage2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx, field.Selections, res) + return ec.marshalNMessage2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx, field.Selections, res) } func (ec *executionContext) _Query_room(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -714,7 +714,7 @@ func (ec *executionContext) _Subscription_messageAdded(ctx context.Context, fiel w.Write([]byte{'{'}) graphql.MarshalString(field.Alias).MarshalGQL(w) w.Write([]byte{':'}) - ec.marshalNMessage2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx, field.Selections, res).MarshalGQL(w) + ec.marshalNMessage2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx, field.Selections, res).MarshalGQL(w) w.Write([]byte{'}'}) }) } @@ -1984,6 +1984,16 @@ func (ec *executionContext) marshalNMessage2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } +func (ec *executionContext) marshalNMessage2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx context.Context, sel ast.SelectionSet, v *Message) graphql.Marshaler { + if v == nil { + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec._Message(ctx, sel, v) +} + func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } diff --git a/example/chat/resolvers.go b/example/chat/resolvers.go index 735a1d4eeb4..5c0de7b0602 100644 --- a/example/chat/resolvers.go +++ b/example/chat/resolvers.go @@ -37,16 +37,16 @@ func New() Config { type Chatroom struct { Name string Messages []Message - Observers map[string]chan Message + Observers map[string]chan *Message } type mutationResolver struct{ *resolver } -func (r *mutationResolver) Post(ctx context.Context, text string, username string, roomName string) (Message, error) { +func (r *mutationResolver) Post(ctx context.Context, text string, username string, roomName string) (*Message, error) { r.mu.Lock() room := r.Rooms[roomName] if room == nil { - room = &Chatroom{Name: roomName, Observers: map[string]chan Message{}} + room = &Chatroom{Name: roomName, Observers: map[string]chan *Message{}} r.Rooms[roomName] = room } r.mu.Unlock() @@ -61,10 +61,10 @@ func (r *mutationResolver) Post(ctx context.Context, text string, username strin room.Messages = append(room.Messages, message) r.mu.Lock() for _, observer := range room.Observers { - observer <- message + observer <- &message } r.mu.Unlock() - return message, nil + return &message, nil } type queryResolver struct{ *resolver } @@ -73,7 +73,7 @@ func (r *queryResolver) Room(ctx context.Context, name string) (*Chatroom, error r.mu.Lock() room := r.Rooms[name] if room == nil { - room = &Chatroom{Name: name, Observers: map[string]chan Message{}} + room = &Chatroom{Name: name, Observers: map[string]chan *Message{}} r.Rooms[name] = room } r.mu.Unlock() @@ -83,17 +83,17 @@ func (r *queryResolver) Room(ctx context.Context, name string) (*Chatroom, error type subscriptionResolver struct{ *resolver } -func (r *subscriptionResolver) MessageAdded(ctx context.Context, roomName string) (<-chan Message, error) { +func (r *subscriptionResolver) MessageAdded(ctx context.Context, roomName string) (<-chan *Message, error) { r.mu.Lock() room := r.Rooms[roomName] if room == nil { - room = &Chatroom{Name: roomName, Observers: map[string]chan Message{}} + room = &Chatroom{Name: roomName, Observers: map[string]chan *Message{}} r.Rooms[roomName] = room } r.mu.Unlock() id := randString(8) - events := make(chan Message, 1) + events := make(chan *Message, 1) go func() { <-ctx.Done() diff --git a/example/config/generated.go b/example/config/generated.go index b7337bb00e7..b78e835eca6 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -65,7 +65,7 @@ type ComplexityRoot struct { } type MutationResolver interface { - CreateTodo(ctx context.Context, input NewTodo) (Todo, error) + CreateTodo(ctx context.Context, input NewTodo) (*Todo, error) } type QueryResolver interface { Todos(ctx context.Context) ([]Todo, error) @@ -354,10 +354,10 @@ func (ec *executionContext) _Mutation_createTodo(ctx context.Context, field grap } return graphql.Null } - res := resTmp.(Todo) + res := resTmp.(*Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐTodo(ctx, field.Selections, res) + return ec.marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐTodo(ctx, field.Selections, res) } func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1921,6 +1921,16 @@ func (ec *executionContext) marshalNTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ return ret } +func (ec *executionContext) marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { + if v == nil { + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec._Todo(ctx, sel, v) +} + func (ec *executionContext) marshalNUser2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler { return ec._User(ctx, sel, &v) } diff --git a/example/config/resolver.go b/example/config/resolver.go index 02d59e09037..85b5eae5bcb 100644 --- a/example/config/resolver.go +++ b/example/config/resolver.go @@ -38,7 +38,7 @@ func (r *Resolver) Todo() TodoResolver { type mutationResolver struct{ *Resolver } -func (r *mutationResolver) CreateTodo(ctx context.Context, input NewTodo) (Todo, error) { +func (r *mutationResolver) CreateTodo(ctx context.Context, input NewTodo) (*Todo, error) { newID := r.nextID r.nextID++ @@ -49,7 +49,7 @@ func (r *mutationResolver) CreateTodo(ctx context.Context, input NewTodo) (Todo, r.todos = append(r.todos, newTodo) - return newTodo, nil + return &newTodo, nil } type queryResolver struct{ *Resolver } diff --git a/example/scalars/generated.go b/example/scalars/generated.go index 914a491e015..34e955ca8ee 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -72,7 +72,7 @@ type QueryResolver interface { } type UserResolver interface { PrimitiveResolver(ctx context.Context, obj *model.User) (string, error) - CustomResolver(ctx context.Context, obj *model.User) (model.Point, error) + CustomResolver(ctx context.Context, obj *model.User) (*model.Point, error) } type executableSchema struct { @@ -677,10 +677,10 @@ func (ec *executionContext) _User_customResolver(ctx context.Context, field grap } return graphql.Null } - res := resTmp.(model.Point) + res := resTmp.(*model.Point) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx, field.Selections, res) + return ec.marshalNPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx, field.Selections, res) } func (ec *executionContext) _User_address(ctx context.Context, field graphql.CollectedField, obj *model.User) graphql.Marshaler { @@ -1980,6 +1980,24 @@ func (ec *executionContext) marshalNPoint2githubᚗcomᚋ99designsᚋgqlgenᚋex return v } +func (ec *executionContext) unmarshalNPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, v interface{}) (*model.Point, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalNPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx, v) + return &res, err +} + +func (ec *executionContext) marshalNPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, sel ast.SelectionSet, v *model.Point) graphql.Marshaler { + if v == nil { + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return v +} + func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } diff --git a/example/scalars/resolvers.go b/example/scalars/resolvers.go index b2661121f83..c723b0d5446 100644 --- a/example/scalars/resolvers.go +++ b/example/scalars/resolvers.go @@ -69,6 +69,6 @@ func (r *userResolver) PrimitiveResolver(ctx context.Context, obj *model.User) ( return "test", nil } -func (r *userResolver) CustomResolver(ctx context.Context, obj *model.User) (model.Point, error) { - return model.Point{X: 5, Y: 1}, nil +func (r *userResolver) CustomResolver(ctx context.Context, obj *model.User) (*model.Point, error) { + return &model.Point{X: 5, Y: 1}, nil } diff --git a/example/starwars/generated.go b/example/starwars/generated.go index b460c01e686..5a2a083ce45 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -115,7 +115,7 @@ type ComplexityRoot struct { type DroidResolver interface { Friends(ctx context.Context, obj *Droid) ([]Character, error) - FriendsConnection(ctx context.Context, obj *Droid, first *int, after *string) (FriendsConnection, error) + FriendsConnection(ctx context.Context, obj *Droid, first *int, after *string) (*FriendsConnection, error) } type FriendsConnectionResolver interface { Edges(ctx context.Context, obj *FriendsConnection) ([]FriendsEdge, error) @@ -123,7 +123,7 @@ type FriendsConnectionResolver interface { } type HumanResolver interface { Friends(ctx context.Context, obj *Human) ([]Character, error) - FriendsConnection(ctx context.Context, obj *Human, first *int, after *string) (FriendsConnection, error) + FriendsConnection(ctx context.Context, obj *Human, first *int, after *string) (*FriendsConnection, error) Starships(ctx context.Context, obj *Human) ([]Starship, error) } @@ -1047,10 +1047,10 @@ func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field } return graphql.Null } - res := resTmp.(FriendsConnection) + res := resTmp.(*FriendsConnection) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNFriendsConnection2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsConnection(ctx, field.Selections, res) + return ec.marshalNFriendsConnection2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsConnection(ctx, field.Selections, res) } func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { @@ -1407,10 +1407,10 @@ func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field } return graphql.Null } - res := resTmp.(FriendsConnection) + res := resTmp.(*FriendsConnection) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNFriendsConnection2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsConnection(ctx, field.Selections, res) + return ec.marshalNFriendsConnection2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsConnection(ctx, field.Selections, res) } func (ec *executionContext) _Human_appearsIn(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { @@ -3638,6 +3638,16 @@ func (ec *executionContext) marshalNFriendsConnection2githubᚗcomᚋ99designs return ec._FriendsConnection(ctx, sel, &v) } +func (ec *executionContext) marshalNFriendsConnection2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsConnection(ctx context.Context, sel ast.SelectionSet, v *FriendsConnection) graphql.Marshaler { + if v == nil { + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec._FriendsConnection(ctx, sel, v) +} + func (ec *executionContext) marshalNFriendsEdge2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsEdge(ctx context.Context, sel ast.SelectionSet, v FriendsEdge) graphql.Marshaler { return ec._FriendsEdge(ctx, sel, &v) } diff --git a/example/starwars/model.go b/example/starwars/model.go index 4ff05e0bfd9..fd9e274894f 100644 --- a/example/starwars/model.go +++ b/example/starwars/model.go @@ -51,16 +51,16 @@ type Droid struct { func (Droid) IsCharacter() {} func (Droid) IsSearchResult() {} -func (r *Resolver) resolveFriendConnection(ctx context.Context, ids []string, first *int, after *string) (FriendsConnection, error) { +func (r *Resolver) resolveFriendConnection(ctx context.Context, ids []string, first *int, after *string) (*FriendsConnection, error) { from := 0 if after != nil { b, err := base64.StdEncoding.DecodeString(*after) if err != nil { - return FriendsConnection{}, err + return nil, err } i, err := strconv.Atoi(strings.TrimPrefix(string(b), "cursor")) if err != nil { - return FriendsConnection{}, err + return nil, err } from = i } @@ -73,7 +73,7 @@ func (r *Resolver) resolveFriendConnection(ctx context.Context, ids []string, fi } } - return FriendsConnection{ + return &FriendsConnection{ ids: ids, from: from, to: to, diff --git a/example/starwars/resolvers.go b/example/starwars/resolvers.go index a472ac22fa4..1e000584728 100644 --- a/example/starwars/resolvers.go +++ b/example/starwars/resolvers.go @@ -58,7 +58,7 @@ func (r *droidResolver) Friends(ctx context.Context, obj *Droid) ([]Character, e return r.resolveCharacters(ctx, obj.FriendIds) } -func (r *droidResolver) FriendsConnection(ctx context.Context, obj *Droid, first *int, after *string) (FriendsConnection, error) { +func (r *droidResolver) FriendsConnection(ctx context.Context, obj *Droid, first *int, after *string) (*FriendsConnection, error) { return r.resolveFriendConnection(ctx, obj.FriendIds, first, after) } @@ -90,7 +90,7 @@ func (r *humanResolver) Friends(ctx context.Context, obj *Human) ([]Character, e return r.resolveCharacters(ctx, obj.FriendIds) } -func (r *humanResolver) FriendsConnection(ctx context.Context, obj *Human, first *int, after *string) (FriendsConnection, error) { +func (r *humanResolver) FriendsConnection(ctx context.Context, obj *Human, first *int, after *string) (*FriendsConnection, error) { return r.resolveFriendConnection(ctx, obj.FriendIds, first, after) } diff --git a/example/todo/generated.go b/example/todo/generated.go index b95f35ea97d..cd535e1e49e 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -61,7 +61,7 @@ type ComplexityRoot struct { } type MyMutationResolver interface { - CreateTodo(ctx context.Context, todo TodoInput) (Todo, error) + CreateTodo(ctx context.Context, todo TodoInput) (*Todo, error) UpdateTodo(ctx context.Context, id int, changes map[string]interface{}) (*Todo, error) } type MyQueryResolver interface { @@ -434,10 +434,10 @@ func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field gr } return graphql.Null } - res := resTmp.(Todo) + res := resTmp.(*Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx, field.Selections, res) + return ec.marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx, field.Selections, res) } func (ec *executionContext) _MyMutation_updateTodo(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1953,6 +1953,16 @@ func (ec *executionContext) marshalNTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ return ret } +func (ec *executionContext) marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { + if v == nil { + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec._Todo(ctx, sel, v) +} + func (ec *executionContext) unmarshalNTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodoInput(ctx context.Context, v interface{}) (TodoInput, error) { return ec.unmarshalInputTodoInput(ctx, v) } diff --git a/example/todo/todo.go b/example/todo/todo.go index 40e0402bf9a..86efdabfed9 100644 --- a/example/todo/todo.go +++ b/example/todo/todo.go @@ -91,7 +91,7 @@ func (r *QueryResolver) Todos(ctx context.Context) ([]Todo, error) { type MutationResolver resolvers -func (r *MutationResolver) CreateTodo(ctx context.Context, todo TodoInput) (Todo, error) { +func (r *MutationResolver) CreateTodo(ctx context.Context, todo TodoInput) (*Todo, error) { newID := r.id() newTodo := Todo{ @@ -106,7 +106,7 @@ func (r *MutationResolver) CreateTodo(ctx context.Context, todo TodoInput) (Todo r.todos = append(r.todos, newTodo) - return newTodo, nil + return &newTodo, nil } func (r *MutationResolver) UpdateTodo(ctx context.Context, id int, changes map[string]interface{}) (*Todo, error) { diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index d0cfc65866f..5633266ab3b 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -73,7 +73,7 @@ type ComplexityRoot struct { } type MyMutationResolver interface { - CreateTodo(ctx context.Context, todo TodoInput) (Todo, error) + CreateTodo(ctx context.Context, todo TodoInput) (*Todo, error) } type MyQueryResolver interface { Todos(ctx context.Context) ([]Todo, error) @@ -467,10 +467,10 @@ func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field gr } return graphql.Null } - res := resTmp.(Todo) + res := resTmp.(*Todo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx, field.Selections, res) + return ec.marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx, field.Selections, res) } func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1968,6 +1968,16 @@ func (ec *executionContext) marshalNTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ return ret } +func (ec *executionContext) marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { + if v == nil { + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec._Todo(ctx, sel, v) +} + func (ec *executionContext) unmarshalNTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodoInput(ctx context.Context, v interface{}) (TodoInput, error) { return ec.unmarshalInputTodoInput(ctx, v) } diff --git a/example/type-system-extension/resolver.go b/example/type-system-extension/resolver.go index 5a8d590cd0e..5158534b83f 100644 --- a/example/type-system-extension/resolver.go +++ b/example/type-system-extension/resolver.go @@ -65,7 +65,7 @@ func (r *queryResolver) Todo(ctx context.Context, id string) (*Todo, error) { type mutationResolver struct{ *resolver } -func (r *mutationResolver) CreateTodo(ctx context.Context, todoInput TodoInput) (Todo, error) { +func (r *mutationResolver) CreateTodo(ctx context.Context, todoInput TodoInput) (*Todo, error) { newID := fmt.Sprintf("Todo:%d", len(r.todos)+1) newTodo := &Todo{ ID: newID, @@ -74,5 +74,5 @@ func (r *mutationResolver) CreateTodo(ctx context.Context, todoInput TodoInput) } r.todos = append(r.todos, newTodo) - return *newTodo, nil + return newTodo, nil } diff --git a/integration/generated.go b/integration/generated.go index d875ecf8426..40cab9ab1f5 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -70,7 +70,7 @@ type ComplexityRoot struct { } type ElementResolver interface { - Child(ctx context.Context, obj *models.Element) (models.Element, error) + Child(ctx context.Context, obj *models.Element) (*models.Element, error) Error(ctx context.Context, obj *models.Element) (bool, error) } type QueryResolver interface { @@ -433,10 +433,10 @@ func (ec *executionContext) _Element_child(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.(models.Element) + res := resTmp.(*models.Element) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNElement2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx, field.Selections, res) + return ec.marshalNElement2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx, field.Selections, res) } func (ec *executionContext) _Element_error(ctx context.Context, field graphql.CollectedField, obj *models.Element) graphql.Marshaler { @@ -2030,6 +2030,16 @@ func (ec *executionContext) marshalNElement2githubᚗcomᚋ99designsᚋgqlgenᚋ return ec._Element(ctx, sel, &v) } +func (ec *executionContext) marshalNElement2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx context.Context, sel ast.SelectionSet, v *models.Element) graphql.Marshaler { + if v == nil { + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec._Element(ctx, sel, v) +} + func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } diff --git a/integration/resolver.go b/integration/resolver.go index 2edb9941f6e..5e685ceb196 100644 --- a/integration/resolver.go +++ b/integration/resolver.go @@ -47,8 +47,8 @@ func (r *elementResolver) Mismatched(ctx context.Context, obj *models.Element) ( return []bool{true}, nil } -func (r *elementResolver) Child(ctx context.Context, obj *models.Element) (models.Element, error) { - return models.Element{ID: obj.ID * 10}, nil +func (r *elementResolver) Child(ctx context.Context, obj *models.Element) (*models.Element, error) { + return &models.Element{ID: obj.ID * 10}, nil } type queryResolver struct{ *Resolver } From d261b3fbb107b328ef6ffcfdbbc0e0903b1c5767 Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Mon, 18 Feb 2019 14:10:33 +1100 Subject: [PATCH 093/147] Fix navigation font weights --- docs/layouts/_default/baseof.html | 2 +- docs/static/main.css | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/docs/layouts/_default/baseof.html b/docs/layouts/_default/baseof.html index 4fb29e68095..70eea20aba6 100644 --- a/docs/layouts/_default/baseof.html +++ b/docs/layouts/_default/baseof.html @@ -9,7 +9,7 @@ {{ if not .IsHome }}{{ .Title }} —{{ end }} {{ .Site.Title }} - + diff --git a/docs/static/main.css b/docs/static/main.css index 2178cbac662..563955595f5 100644 --- a/docs/static/main.css +++ b/docs/static/main.css @@ -221,10 +221,6 @@ ul.submenu span { padding: 5px 10px; } -ul.menu li { - font-weight: 400; -} - ul.menu li.active, ul.menu a:hover { background-color: var(--color-nav-active); @@ -389,7 +385,6 @@ em { color: var(--color-heading-text); background-color: var(--color-heading-background); font-family: var(--font-heading); - font-weight: 500; list-style-type: none; -webkit-font-smoothing: antialiased; From 378510e5cd93d65003b605a7451021e0d7d3b533 Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Mon, 18 Feb 2019 14:20:35 +1100 Subject: [PATCH 094/147] Move Getting Started above Configuration --- docs/content/config.md | 2 +- docs/content/getting-started.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/content/config.md b/docs/content/config.md index 93118c4f682..98cb7127e8b 100644 --- a/docs/content/config.md +++ b/docs/content/config.md @@ -3,7 +3,7 @@ linkTitle: Configuration title: How to configure gqlgen using gqlgen.yml description: How to configure gqlgen using gqlgen.yml menu: main -weight: -7 +weight: -5 --- gqlgen can be configured using a `gqlgen.yml` file, by default it will be loaded from the current directory, or any parent directory. diff --git a/docs/content/getting-started.md b/docs/content/getting-started.md index 9ea218afc26..154db185e65 100644 --- a/docs/content/getting-started.md +++ b/docs/content/getting-started.md @@ -3,7 +3,7 @@ linkTitle: Getting Started title: Building GraphQL servers in golang description: Get started building type-safe GraphQL servers in Golang using gqlgen menu: main -weight: -5 +weight: -7 --- This tutorial will take you through the process of building a GraphQL server with gqlgen that can: From cdc575a23d5a8191e51176214a4aad0cbea5feb2 Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Mon, 18 Feb 2019 15:18:17 +1100 Subject: [PATCH 095/147] Update getting started with Go Modules support --- docs/content/getting-started-dep.md | 292 ++++++++++++++++++++++++++++ docs/content/getting-started.md | 54 ++--- 2 files changed, 303 insertions(+), 43 deletions(-) create mode 100644 docs/content/getting-started-dep.md diff --git a/docs/content/getting-started-dep.md b/docs/content/getting-started-dep.md new file mode 100644 index 00000000000..204741adfe4 --- /dev/null +++ b/docs/content/getting-started-dep.md @@ -0,0 +1,292 @@ +--- +linkTitle: Getting Started Using dep +title: Building GraphQL servers in golang +description: Get started building type-safe GraphQL servers in Golang using gqlgen +weight: -7 +hidden: true +--- + +> Deprecated +> +> This tutorial uses the `dep` tool to manage dependencies instead of Go Modules and should be considered a deprecated way to use gqlgen. Read out new [Getting Started]({{< ref "getting-started.md" >}}) guide for instructions for using Go Modules. + +This tutorial will take you through the process of building a GraphQL server with gqlgen that can: + + - Return a list of todos + - Create new todos + - Mark off todos as they are completed + +You can find the finished code for this tutorial [here](https://github.com/vektah/gqlgen-tutorials/tree/master/gettingstarted) + +## Install gqlgen + +This article uses [`dep`](https://github.com/golang/dep) to install gqlgen. [Follow the instructions for your environment](https://github.com/golang/dep) to install. + +Assuming you already have a working [Go environment](https://golang.org/doc/install), create a directory for the project in your `$GOPATH`: + +```sh +$ mkdir -p $GOPATH/src/github.com/[username]/gqlgen-todos +``` + +Add the following file to your project under `scripts/gqlgen.go`: + +```go +// +build ignore + +package main + +import "github.com/99designs/gqlgen/cmd" + +func main() { + cmd.Execute() +} +``` + +Lastly, initialise dep. This will inspect any imports you have in your project, and pull down the latest tagged release. + +```sh +$ dep init +``` + +## Building the server + +### Define the schema + +gqlgen is a schema-first library — before writing code, you describe your API using the GraphQL +[Schema Definition Language](http://graphql.org/learn/schema/). This usually goes into a file called `schema.graphql`: + +```graphql +type Todo { + id: ID! + text: String! + done: Boolean! + user: User! +} + +type User { + id: ID! + name: String! +} + +type Query { + todos: [Todo!]! +} + +input NewTodo { + text: String! + userId: String! +} + +type Mutation { + createTodo(input: NewTodo!): Todo! +} +``` + +### Create the project skeleton + +```bash +$ go run scripts/gqlgen.go init +``` + +This has created an empty skeleton with all files you need: + + - `gqlgen.yml` — The gqlgen config file, knobs for controlling the generated code. + - `generated.go` — The GraphQL execution runtime, the bulk of the generated code. + - `models_gen.go` — Generated models required to build the graph. Often you will override these with your own models. Still very useful for input types. + - `resolver.go` — This is where your application code lives. `generated.go` will call into this to get the data the user has requested. + - `server/server.go` — This is a minimal entry point that sets up an `http.Handler` to the generated GraphQL server. + + Now run dep ensure, so that we can ensure that the newly generated code's dependencies are all present: + + ```sh + $ dep ensure + ``` + +### Create the database models + +The generated model for Todo isn't right, it has a user embeded in it but we only want to fetch it if the user actually requested it. So instead lets make a new model in `todo.go`: + +```go +package gettingstarted + +type Todo struct { + ID string + Text string + Done bool + UserID string +} +``` + +Next tell gqlgen to use this new struct by adding it to `gqlgen.yml`: + +```yaml +models: + Todo: + model: github.com/[username]/gqlgen-todos/gettingstarted.Todo +``` + +Regenerate by running: + +```bash +$ go run scripts/gqlgen.go -v +Unable to bind Todo.user to github.com/[username]/gqlgen-todos/gettingstarted.Todo + no method named user + no field named user + Adding resolver method +``` + +> Note +> +> The verbose flag `-v` is here to show what gqlgen is doing. It has looked at all the fields on the model and found matching methods for all of them, except user. For user it has added a resolver to the interface you need to implement. *This is the magic that makes gqlgen work so well!* + +### Implement the resolvers + +The generated runtime has defined an interface for all the missing resolvers that we need to provide. Lets take a look in `generated.go` + +```go +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + resolvers: cfg.Resolvers, + directives: cfg.Directives, + } +} + +type Config struct { + Resolvers ResolverRoot + Directives DirectiveRoot +} + +type ResolverRoot interface { + Mutation() MutationResolver + Query() QueryResolver + Todo() TodoResolver +} + +type DirectiveRoot struct { +} +type MutationResolver interface { + CreateTodo(ctx context.Context, input NewTodo) (Todo, error) +} +type QueryResolver interface { + Todos(ctx context.Context) ([]Todo, error) +} +type TodoResolver interface { + User(ctx context.Context, obj *Todo) (User, error) +} +``` + +Notice the `TodoResolver.User` method? Thats gqlgen saying "I dont know how to get a User from a Todo, you tell me.". +Its worked out how to build everything else for us. + +For any missing models (like NewTodo) gqlgen will generate a go struct. This is usually only used for input types and +one-off return values. Most of the time your types will be coming from the database, or an API client so binding is +better than generating. + +### Write the resolvers + +This is a work in progress, we have a way to generate resolver stubs, but it cannot currently update existing code. We can force it to run again by deleting `resolver.go` and re-running gqlgen: + +```bash +$ rm resolver.go +$ go run scripts/gqlgen.go +``` + +Now we just need to fill in the `not implemented` parts. Update `resolver.go` + +```go +//go:generate go run ./scripts/gqlgen.go + +package gettingstarted + +import ( + context "context" + "fmt" + "math/rand" +) + +type Resolver struct{ + todos []Todo +} + +func (r *Resolver) Mutation() MutationResolver { + return &mutationResolver{r} +} +func (r *Resolver) Query() QueryResolver { + return &queryResolver{r} +} +func (r *Resolver) Todo() TodoResolver { + return &todoResolver{r} +} + +type mutationResolver struct{ *Resolver } + +func (r *mutationResolver) CreateTodo(ctx context.Context, input NewTodo) (Todo, error) { + todo := Todo{ + Text: input.Text, + ID: fmt.Sprintf("T%d", rand.Int()), + UserID: input.UserID, + } + r.todos = append(r.todos, todo) + return todo, nil +} + +type queryResolver struct{ *Resolver } + +func (r *queryResolver) Todos(ctx context.Context) ([]Todo, error) { + return r.todos, nil +} + +type todoResolver struct{ *Resolver } + +func (r *todoResolver) User(ctx context.Context, obj *Todo) (User, error) { + return User{ID: obj.UserID, Name: "user " + obj.UserID}, nil +} + +``` + +We now have a working server, to start it: +```bash +go run server/server.go +``` + +then open http://localhost:8080 in a browser. here are some queries to try: +```graphql +mutation createTodo { + createTodo(input:{text:"todo", userId:"1"}) { + user { + id + } + text + done + } +} + +query findTodos { + todos { + text + done + user { + name + } + } +} +``` + +## Finishing touches + +At the top of our `resolver.go` add the following line: + +```go +//go:generate go run scripts/gqlgen.go -v +``` + +This magic comment tells `go generate` what command to run when we want to regenerate our code. To run go generate recursively over your entire project, use this command: + +```go +go generate ./... +``` + +> Note +> +> Ensure that the path to your `gqlgen` binary is relative to the file the generate command is added to. diff --git a/docs/content/getting-started.md b/docs/content/getting-started.md index 154db185e65..fd3b647ec8f 100644 --- a/docs/content/getting-started.md +++ b/docs/content/getting-started.md @@ -14,38 +14,18 @@ This tutorial will take you through the process of building a GraphQL server wit You can find the finished code for this tutorial [here](https://github.com/vektah/gqlgen-tutorials/tree/master/gettingstarted) -## Install gqlgen - -This article uses [`dep`](https://github.com/golang/dep) to install gqlgen. [Follow the instructions for your environment](https://github.com/golang/dep) to install. - -Assuming you already have a working [Go environment](https://golang.org/doc/install), create a directory for the project in your `$GOPATH`: - -```sh -$ mkdir -p $GOPATH/src/github.com/[username]/gqlgen-todos -``` - -> Go Modules +> Note > -> Currently `gqlgen` does not support Go Modules. This is due to the [`loader`](https://godoc.org/golang.org/x/tools/go/loader) package, that also does not yet support Go Modules. We are looking at solutions to this and the issue is tracked in Github. - -Add the following file to your project under `scripts/gqlgen.go`: - -```go -// +build ignore +> This tutorial uses Go Modules and requires Go 1.11+. If you want to use this tutorial without Go Modules, take a look at our [Getting Started Using dep]({{< ref "getting-started-dep.md" >}}) guide instead. -package main +## Setup Project -import "github.com/99designs/gqlgen/cmd" - -func main() { - cmd.Execute() -} -``` - -Lastly, initialise dep. This will inspect any imports you have in your project, and pull down the latest tagged release. +Create a directory for your project, and initialise it as a Go Module: ```sh -$ dep init +mkdir gqlgen-todos +cd gqlgen-todos +go mod init gqlgen-todos ``` ## Building the server @@ -85,7 +65,7 @@ type Mutation { ### Create the project skeleton ```bash -$ go run scripts/gqlgen.go init +$ go run github.com/99designs/gqlgen init ``` This has created an empty skeleton with all files you need: @@ -95,12 +75,6 @@ This has created an empty skeleton with all files you need: - `models_gen.go` — Generated models required to build the graph. Often you will override these with your own models. Still very useful for input types. - `resolver.go` — This is where your application code lives. `generated.go` will call into this to get the data the user has requested. - `server/server.go` — This is a minimal entry point that sets up an `http.Handler` to the generated GraphQL server. - - Now run dep ensure, so that we can ensure that the newly generated code's dependencies are all present: - - ```sh - $ dep ensure - ``` ### Create the database models @@ -128,7 +102,7 @@ models: Regenerate by running: ```bash -$ go run scripts/gqlgen.go -v +$ go run github.com/99designs/gqlgen -v Unable to bind Todo.user to github.com/[username]/gqlgen-todos/gettingstarted.Todo no method named user no field named user @@ -189,14 +163,12 @@ This is a work in progress, we have a way to generate resolver stubs, but it can ```bash $ rm resolver.go -$ go run scripts/gqlgen.go +$ go run github.com/99designs/gqlgen ``` Now we just need to fill in the `not implemented` parts. Update `resolver.go` ```go -//go:generate go run ./scripts/gqlgen.go - package gettingstarted import ( @@ -278,7 +250,7 @@ query findTodos { At the top of our `resolver.go` add the following line: ```go -//go:generate go run scripts/gqlgen.go -v +//go:generate go run github.com/99designs/gqlgen ``` This magic comment tells `go generate` what command to run when we want to regenerate our code. To run go generate recursively over your entire project, use this command: @@ -286,7 +258,3 @@ This magic comment tells `go generate` what command to run when we want to regen ```go go generate ./... ``` - -> Note -> -> Ensure that the path to your `gqlgen` binary is relative to the file the generate command is added to. From ba761dcf38224e9a3da08bc678fe2e2415d0df28 Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Mon, 18 Feb 2019 15:42:37 +1100 Subject: [PATCH 096/147] Reintroduce main package in root --- ambient.go | 2 +- generate.go => api/generate.go | 2 +- option.go => api/option.go | 2 +- cmd/gen.go | 4 ++-- cmd/init.go | 5 ++--- internal/code/imports_test.go | 4 ++-- main.go | 9 +++++++++ testdata/gqlgen.go | 8 ++++---- 8 files changed, 22 insertions(+), 14 deletions(-) rename generate.go => api/generate.go (99%) rename option.go => api/option.go (96%) create mode 100644 main.go diff --git a/ambient.go b/ambient.go index 3ec2601cc91..350bc75cc6a 100644 --- a/ambient.go +++ b/ambient.go @@ -1,4 +1,4 @@ -package gqlgen +package main import ( // Import and ignore the ambient imports listed below so dependency managers diff --git a/generate.go b/api/generate.go similarity index 99% rename from generate.go rename to api/generate.go index 86c64b7a12b..3dd083f52f6 100644 --- a/generate.go +++ b/api/generate.go @@ -1,4 +1,4 @@ -package gqlgen +package api import ( "syscall" diff --git a/option.go b/api/option.go similarity index 96% rename from option.go rename to api/option.go index 0c173c7264e..f7ba6774bd0 100644 --- a/option.go +++ b/api/option.go @@ -1,4 +1,4 @@ -package gqlgen +package api import ( "github.com/99designs/gqlgen/codegen/config" diff --git a/cmd/gen.go b/cmd/gen.go index 6a077ec97e4..5613ee31ee9 100644 --- a/cmd/gen.go +++ b/cmd/gen.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - "github.com/99designs/gqlgen" + "github.com/99designs/gqlgen/api" "github.com/99designs/gqlgen/codegen/config" "github.com/pkg/errors" "github.com/urfave/cli" @@ -36,7 +36,7 @@ var genCmd = cli.Command{ } } - if err = gqlgen.Generate(cfg); err != nil { + if err = api.Generate(cfg); err != nil { fmt.Fprintln(os.Stderr, err.Error()) os.Exit(3) } diff --git a/cmd/init.go b/cmd/init.go index 076d7d20a11..664c523b780 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -7,10 +7,9 @@ import ( "os" "strings" + "github.com/99designs/gqlgen/api" "github.com/99designs/gqlgen/plugin/servergen" - "github.com/99designs/gqlgen" - "github.com/99designs/gqlgen/codegen/config" "github.com/pkg/errors" "github.com/urfave/cli" @@ -73,7 +72,7 @@ var initCmd = cli.Command{ } func GenerateGraphServer(cfg *config.Config, serverFilename string) { - err := gqlgen.Generate(cfg, gqlgen.AddPlugin(servergen.New(serverFilename))) + err := api.Generate(cfg, api.AddPlugin(servergen.New(serverFilename))) if err != nil { fmt.Fprintln(os.Stderr, err.Error()) } diff --git a/internal/code/imports_test.go b/internal/code/imports_test.go index 2612ffce5fb..b1825749259 100644 --- a/internal/code/imports_test.go +++ b/internal/code/imports_test.go @@ -14,7 +14,7 @@ func TestImportPathForDir(t *testing.T) { require.NoError(t, err) assert.Equal(t, "github.com/99designs/gqlgen/internal/code", ImportPathForDir(wd)) - assert.Equal(t, "github.com/99designs/gqlgen", ImportPathForDir(filepath.Join(wd, "..", ".."))) + assert.Equal(t, "github.com/99designs/gqlgen/api", ImportPathForDir(filepath.Join(wd, "..", "..", "api"))) // doesnt contain go code, but should still give a valid import path assert.Equal(t, "github.com/99designs/gqlgen/docs", ImportPathForDir(filepath.Join(wd, "..", "..", "docs"))) @@ -24,7 +24,7 @@ func TestImportPathForDir(t *testing.T) { } func TestNameForPackage(t *testing.T) { - assert.Equal(t, "gqlgen", NameForPackage("github.com/99designs/gqlgen")) + assert.Equal(t, "api", NameForPackage("github.com/99designs/gqlgen/api")) // does not contain go code, should still give a valid name assert.Equal(t, "docs", NameForPackage("github.com/99designs/gqlgen/docs")) diff --git a/main.go b/main.go new file mode 100644 index 00000000000..dbc24135388 --- /dev/null +++ b/main.go @@ -0,0 +1,9 @@ +package main + +import ( + "github.com/99designs/gqlgen/cmd" +) + +func main() { + cmd.Execute() +} diff --git a/testdata/gqlgen.go b/testdata/gqlgen.go index d69313e9e8e..f4bbe75507d 100644 --- a/testdata/gqlgen.go +++ b/testdata/gqlgen.go @@ -8,7 +8,7 @@ import ( "os" "time" - "github.com/99designs/gqlgen" + "github.com/99designs/gqlgen/api" "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/plugin/stubgen" ) @@ -27,12 +27,12 @@ func main() { os.Exit(2) } - var options []gqlgen.Option + var options []api.Option if *stub != "" { - options = append(options, gqlgen.AddPlugin(stubgen.New(*stub, "Stub"))) + options = append(options, api.AddPlugin(stubgen.New(*stub, "Stub"))) } - err = gqlgen.Generate(cfg, options...) + err = api.Generate(cfg, options...) if err != nil { fmt.Fprintln(os.Stderr, err.Error()) os.Exit(3) From 6c5760320cc3834d46cd190fa906bdf7c033a5da Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Mon, 18 Feb 2019 16:16:47 +1100 Subject: [PATCH 097/147] Update getting started with 0.8 generated code --- docs/content/getting-started.md | 50 +++++++++++++-------------------- 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/docs/content/getting-started.md b/docs/content/getting-started.md index fd3b647ec8f..37d0913e13d 100644 --- a/docs/content/getting-started.md +++ b/docs/content/getting-started.md @@ -23,9 +23,9 @@ You can find the finished code for this tutorial [here](https://github.com/vekta Create a directory for your project, and initialise it as a Go Module: ```sh -mkdir gqlgen-todos -cd gqlgen-todos -go mod init gqlgen-todos +$ mkdir gqlgen-todos +$ cd gqlgen-todos +$ go mod init github.com/[username]/gqlgen-todos ``` ## Building the server @@ -81,7 +81,7 @@ This has created an empty skeleton with all files you need: The generated model for Todo isn't right, it has a user embeded in it but we only want to fetch it if the user actually requested it. So instead lets make a new model in `todo.go`: ```go -package gettingstarted +package gqlgen_todos type Todo struct { ID string @@ -96,17 +96,13 @@ Next tell gqlgen to use this new struct by adding it to `gqlgen.yml`: ```yaml models: Todo: - model: github.com/[username]/gqlgen-todos/gettingstarted.Todo + model: github.com/[username]/gqlgen-todos.Todo ``` Regenerate by running: ```bash -$ go run github.com/99designs/gqlgen -v -Unable to bind Todo.user to github.com/[username]/gqlgen-todos/gettingstarted.Todo - no method named user - no field named user - Adding resolver method +$ go run github.com/99designs/gqlgen ``` > Note @@ -115,20 +111,16 @@ Unable to bind Todo.user to github.com/[username]/gqlgen-todos/gettingstarted.To ### Implement the resolvers -The generated runtime has defined an interface for all the missing resolvers that we need to provide. Lets take a look in `generated.go` +The generated runtime has defined an interface for all the missing resolvers that we need to provide. Lets take a look in `generated.go`: ```go -// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. -func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { - return &executableSchema{ - resolvers: cfg.Resolvers, - directives: cfg.Directives, - } +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema {} + // ... } type Config struct { Resolvers ResolverRoot - Directives DirectiveRoot + // ... } type ResolverRoot interface { @@ -137,23 +129,21 @@ type ResolverRoot interface { Todo() TodoResolver } -type DirectiveRoot struct { -} type MutationResolver interface { - CreateTodo(ctx context.Context, input NewTodo) (Todo, error) + CreateTodo(ctx context.Context, input NewTodo) (*Todo, error) } type QueryResolver interface { Todos(ctx context.Context) ([]Todo, error) } type TodoResolver interface { - User(ctx context.Context, obj *Todo) (User, error) + User(ctx context.Context, obj *Todo) (*User, error) } ``` Notice the `TodoResolver.User` method? Thats gqlgen saying "I dont know how to get a User from a Todo, you tell me.". Its worked out how to build everything else for us. -For any missing models (like NewTodo) gqlgen will generate a go struct. This is usually only used for input types and +For any missing models (like `NewTodo`) gqlgen will generate a go struct. This is usually only used for input types and one-off return values. Most of the time your types will be coming from the database, or an API client so binding is better than generating. @@ -169,7 +159,7 @@ $ go run github.com/99designs/gqlgen Now we just need to fill in the `not implemented` parts. Update `resolver.go` ```go -package gettingstarted +package gqlgen_todos import ( context "context" @@ -177,7 +167,7 @@ import ( "math/rand" ) -type Resolver struct{ +type Resolver struct { todos []Todo } @@ -193,13 +183,13 @@ func (r *Resolver) Todo() TodoResolver { type mutationResolver struct{ *Resolver } -func (r *mutationResolver) CreateTodo(ctx context.Context, input NewTodo) (Todo, error) { - todo := Todo{ +func (r *mutationResolver) CreateTodo(ctx context.Context, input NewTodo) (*Todo, error) { + todo := &Todo{ Text: input.Text, ID: fmt.Sprintf("T%d", rand.Int()), UserID: input.UserID, } - r.todos = append(r.todos, todo) + r.todos = append(r.todos, *todo) return todo, nil } @@ -211,8 +201,8 @@ func (r *queryResolver) Todos(ctx context.Context) ([]Todo, error) { type todoResolver struct{ *Resolver } -func (r *todoResolver) User(ctx context.Context, obj *Todo) (User, error) { - return User{ID: obj.UserID, Name: "user " + obj.UserID}, nil +func (r *todoResolver) User(ctx context.Context, obj *Todo) (*User, error) { + return &User{ID: obj.UserID, Name: "user " + obj.UserID}, nil } ``` From 0bd120b5c27fa81fc3f60f662496bc3328f3ad86 Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Mon, 18 Feb 2019 16:19:11 +1100 Subject: [PATCH 098/147] Update dep code as well --- docs/content/getting-started-dep.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/docs/content/getting-started-dep.md b/docs/content/getting-started-dep.md index 204741adfe4..93c8410c370 100644 --- a/docs/content/getting-started-dep.md +++ b/docs/content/getting-started-dep.md @@ -195,8 +195,6 @@ $ go run scripts/gqlgen.go Now we just need to fill in the `not implemented` parts. Update `resolver.go` ```go -//go:generate go run ./scripts/gqlgen.go - package gettingstarted import ( @@ -205,7 +203,7 @@ import ( "math/rand" ) -type Resolver struct{ +type Resolver struct { todos []Todo } @@ -221,13 +219,13 @@ func (r *Resolver) Todo() TodoResolver { type mutationResolver struct{ *Resolver } -func (r *mutationResolver) CreateTodo(ctx context.Context, input NewTodo) (Todo, error) { - todo := Todo{ +func (r *mutationResolver) CreateTodo(ctx context.Context, input NewTodo) (*Todo, error) { + todo := &Todo{ Text: input.Text, ID: fmt.Sprintf("T%d", rand.Int()), UserID: input.UserID, } - r.todos = append(r.todos, todo) + r.todos = append(r.todos, *todo) return todo, nil } @@ -239,8 +237,8 @@ func (r *queryResolver) Todos(ctx context.Context) ([]Todo, error) { type todoResolver struct{ *Resolver } -func (r *todoResolver) User(ctx context.Context, obj *Todo) (User, error) { - return User{ID: obj.UserID, Name: "user " + obj.UserID}, nil +func (r *todoResolver) User(ctx context.Context, obj *Todo) (*User, error) { + return &User{ID: obj.UserID, Name: "user " + obj.UserID}, nil } ``` From 67795c95b21a60fda303b35e509a447653bc8351 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Mon, 18 Feb 2019 16:34:56 +1100 Subject: [PATCH 099/147] Recover from panics in unlikly places --- codegen/args.go | 2 +- codegen/config/binder.go | 8 +- codegen/field.go | 12 +- codegen/object.gotpl | 5 + codegen/testserver/generated.go | 519 +++++++++++++++++++++ codegen/testserver/gqlgen.yml | 4 + codegen/testserver/models.go | 20 +- codegen/testserver/panics.graphql | 12 + codegen/testserver/panics_test.go | 56 +++ codegen/testserver/resolver.go | 15 + codegen/testserver/stub.go | 20 + codegen/type.gotpl | 6 + example/chat/generated.go | 59 +++ example/config/generated.go | 64 +++ example/dataloader/generated.go | 102 ++++ example/scalars/generated.go | 74 +++ example/selection/generated.go | 59 +++ example/starwars/generated.go | 159 +++++++ example/todo/generated.go | 69 +++ example/type-system-extension/generated.go | 64 +++ integration/generated.go | 108 ++++- 21 files changed, 1425 insertions(+), 12 deletions(-) create mode 100644 codegen/testserver/panics.graphql create mode 100644 codegen/testserver/panics_test.go diff --git a/codegen/args.go b/codegen/args.go index b5690e7d78b..d1498bddb10 100644 --- a/codegen/args.go +++ b/codegen/args.go @@ -78,7 +78,7 @@ nextArg: } // no matching arg found, abort - return fmt.Errorf("%s is not in schema", param.Name()) + return fmt.Errorf("arg %s not in schema", param.Name()) } field.Args = newArgs diff --git a/codegen/config/binder.go b/codegen/config/binder.go index 873ff371c9a..15e456c52e1 100644 --- a/codegen/config/binder.go +++ b/codegen/config/binder.go @@ -84,7 +84,7 @@ var InterfaceType = types.NewInterfaceType(nil, nil) func (b *Binder) DefaultUserObject(name string) (types.Type, error) { models := b.cfg.Models[name].Model if len(models) == 0 { - return nil, fmt.Errorf(name + " not found") + return nil, fmt.Errorf(name + " not found in typemap") } if models[0] == "map[string]interface{}" { @@ -346,6 +346,10 @@ func (b *Binder) TypeReference(schemaType *ast.Type, bindTarget types.Type) (ret } }() + if len(b.cfg.Models[schemaType.Name()].Model) == 0 { + return nil, fmt.Errorf("%s was not found", schemaType.Name()) + } + for _, model := range b.cfg.Models[schemaType.Name()].Model { if model == "map[string]interface{}" { if !isMap(bindTarget) { @@ -404,7 +408,7 @@ func (b *Binder) TypeReference(schemaType *ast.Type, bindTarget types.Type) (ret return ref, nil } - return nil, fmt.Errorf("not found") + return nil, fmt.Errorf("%s has type compatible with %s", schemaType.Name(), bindTarget.String()) } func (b *Binder) CopyModifiersFromAst(t *ast.Type, usePtr bool, base types.Type) types.Type { diff --git a/codegen/field.go b/codegen/field.go index bab170c9e93..e54e9fdad1f 100644 --- a/codegen/field.go +++ b/codegen/field.go @@ -62,9 +62,14 @@ func (b *builder) buildField(obj *Object, field *ast.FieldDefinition) (*Field, e } if err = b.bindField(obj, &f); err != nil { + f.IsResolver = true log.Println(err.Error()) } + if f.IsResolver && !f.TypeReference.IsPtr() && f.TypeReference.IsStruct() { + f.TypeReference = b.Binder.PointerTo(f.TypeReference) + } + return &f, nil } @@ -77,10 +82,6 @@ func (b *builder) bindField(obj *Object, f *Field) error { } f.TypeReference = tr } - - if f.IsResolver && !f.TypeReference.IsPtr() && f.TypeReference.IsStruct() { - f.TypeReference = b.Binder.PointerTo(f.TypeReference) - } }() switch { @@ -115,8 +116,6 @@ func (b *builder) bindField(obj *Object, f *Field) error { switch target := target.(type) { case nil: - f.IsResolver = true - objPos := b.Binder.TypePosition(obj.Type) return fmt.Errorf( "%s:%d adding resolver method for %s.%s, nothing matched", @@ -125,6 +124,7 @@ func (b *builder) bindField(obj *Object, f *Field) error { obj.Name, f.Name, ) + case *types.Func: sig := target.Type().(*types.Signature) if sig.Results().Len() == 1 { diff --git a/codegen/object.gotpl b/codegen/object.gotpl index 8966ff77a05..13224ed0233 100644 --- a/codegen/object.gotpl +++ b/codegen/object.gotpl @@ -42,6 +42,11 @@ func (ec *executionContext) _{{$object.Name}}(ctx context.Context, sel ast.Selec {{- if $field.IsConcurrent }} field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._{{$object.Name}}_{{$field.Name}}(ctx, field{{if not $object.Root}}, obj{{end}}) {{- if $field.TypeReference.GQL.NonNull }} if res == graphql.Null { diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 62ccbb2d220..5be09523697 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -40,6 +40,7 @@ type Config struct { type ResolverRoot interface { ForcedResolver() ForcedResolverResolver ModelMethods() ModelMethodsResolver + Panics() PanicsResolver Query() QueryResolver Subscription() SubscriptionResolver User() UserResolver @@ -95,6 +96,12 @@ type ComplexityRoot struct { Inner func(childComplexity int) int } + Panics struct { + FieldScalarMarshal func(childComplexity int) int + FieldFuncMarshal func(childComplexity int, u []MarshalPanic) int + ArgUnmarshal func(childComplexity int, u []MarshalPanic) int + } + Query struct { InvalidIdentifier func(childComplexity int) int Collision func(childComplexity int) int @@ -114,6 +121,7 @@ type ComplexityRoot struct { DirectiveInput func(childComplexity int, arg InputDirectives) int InputSlice func(childComplexity int, arg []string) int ShapeUnion func(childComplexity int) int + Panics func(childComplexity int) int ValidType func(childComplexity int) int } @@ -149,6 +157,11 @@ type ForcedResolverResolver interface { type ModelMethodsResolver interface { ResolverField(ctx context.Context, obj *ModelMethods) (bool, error) } +type PanicsResolver interface { + FieldScalarMarshal(ctx context.Context, obj *Panics) ([]MarshalPanic, error) + + ArgUnmarshal(ctx context.Context, obj *Panics, u []MarshalPanic) (bool, error) +} type QueryResolver interface { InvalidIdentifier(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) Collision(ctx context.Context) (*introspection1.It, error) @@ -168,6 +181,7 @@ type QueryResolver interface { DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) InputSlice(ctx context.Context, arg []string) (bool, error) ShapeUnion(ctx context.Context) (ShapeUnion, error) + Panics(ctx context.Context) (*Panics, error) ValidType(ctx context.Context) (*ValidType, error) } type SubscriptionResolver interface { @@ -305,6 +319,37 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.OuterObject.Inner(childComplexity), true + case "Panics.FieldScalarMarshal": + if e.complexity.Panics.FieldScalarMarshal == nil { + break + } + + return e.complexity.Panics.FieldScalarMarshal(childComplexity), true + + case "Panics.FieldFuncMarshal": + if e.complexity.Panics.FieldFuncMarshal == nil { + break + } + + args, err := ec.field_Panics_fieldFuncMarshal_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Panics.FieldFuncMarshal(childComplexity, args["u"].([]MarshalPanic)), true + + case "Panics.ArgUnmarshal": + if e.complexity.Panics.ArgUnmarshal == nil { + break + } + + args, err := ec.field_Panics_argUnmarshal_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Panics.ArgUnmarshal(childComplexity, args["u"].([]MarshalPanic)), true + case "Query.InvalidIdentifier": if e.complexity.Query.InvalidIdentifier == nil { break @@ -481,6 +526,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.ShapeUnion(childComplexity), true + case "Query.Panics": + if e.complexity.Query.Panics == nil { + break + } + + return e.complexity.Query.Panics(childComplexity), true + case "Query.ValidType": if e.complexity.Query.ValidType == nil { break @@ -713,6 +765,19 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er } var parsedSchema = gqlparser.MustLoadSchema( + &ast.Source{Name: "panics.graphql", Input: `extend type Query { + panics: Panics +} + +type Panics { + fieldScalarMarshal: [MarshalPanic!]! + fieldFuncMarshal(u: [MarshalPanic!]!): [MarshalPanic!]! + argUnmarshal(u: [MarshalPanic!]!): Boolean! + +} + +scalar MarshalPanic +`}, &ast.Source{Name: "schema.graphql", Input: `type Query { invalidIdentifier: InvalidIdentifier collision: It @@ -957,6 +1022,34 @@ func (ec *executionContext) dir_range_args(ctx context.Context, rawArgs map[stri return args, nil } +func (ec *executionContext) field_Panics_argUnmarshal_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 []MarshalPanic + if tmp, ok := rawArgs["u"]; ok { + arg0, err = ec.unmarshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanic(ctx, tmp) + if err != nil { + return nil, err + } + } + args["u"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Panics_fieldFuncMarshal_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 []MarshalPanic + if tmp, ok := rawArgs["u"]; ok { + arg0, err = ec.unmarshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanic(ctx, tmp) + if err != nil { + return nil, err + } + } + args["u"] = arg0 + return args, nil +} + func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -1813,6 +1906,98 @@ func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphq return ec.marshalNInnerObject2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerObject(ctx, field.Selections, res) } +func (ec *executionContext) _Panics_fieldScalarMarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Panics", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Panics().FieldScalarMarshal(rctx, obj) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]MarshalPanic) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanic(ctx, field.Selections, res) +} + +func (ec *executionContext) _Panics_fieldFuncMarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Panics", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Panics_fieldFuncMarshal_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.FieldFuncMarshal(ctx, args["u"].([]MarshalPanic)), nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]MarshalPanic) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanic(ctx, field.Selections, res) +} + +func (ec *executionContext) _Panics_argUnmarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Panics", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Panics_argUnmarshal_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Panics().ArgUnmarshal(rctx, obj, args["u"].([]MarshalPanic)) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2309,6 +2494,29 @@ func (ec *executionContext) _Query_shapeUnion(ctx context.Context, field graphql return ec.marshalNShapeUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShapeUnion(ctx, field.Selections, res) } +func (ec *executionContext) _Query_panics(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Panics(rctx) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Panics) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalOPanics2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPanics(ctx, field.Selections, res) +} + func (ec *executionContext) _Query_validType(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3980,6 +4188,11 @@ func (ec *executionContext) _ForcedResolver(ctx context.Context, sel ast.Selecti case "field": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._ForcedResolver_field(ctx, field, obj) return res }) @@ -4089,6 +4302,11 @@ func (ec *executionContext) _ModelMethods(ctx context.Context, sel ast.Selection case "resolverField": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._ModelMethods_resolverField(ctx, field, obj) if res == graphql.Null { invalid = true @@ -4103,6 +4321,11 @@ func (ec *executionContext) _ModelMethods(ctx context.Context, sel ast.Selection case "withContext": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._ModelMethods_withContext(ctx, field, obj) if res == graphql.Null { invalid = true @@ -4147,6 +4370,70 @@ func (ec *executionContext) _OuterObject(ctx context.Context, sel ast.SelectionS return out } +var panicsImplementors = []string{"Panics"} + +func (ec *executionContext) _Panics(ctx context.Context, sel ast.SelectionSet, obj *Panics) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, panicsImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Panics") + case "fieldScalarMarshal": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Panics_fieldScalarMarshal(ctx, field, obj) + if res == graphql.Null { + invalid = true + } + return res + }) + case "fieldFuncMarshal": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Panics_fieldFuncMarshal(ctx, field, obj) + if res == graphql.Null { + invalid = true + } + return res + }) + case "argUnmarshal": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Panics_argUnmarshal(ctx, field, obj) + if res == graphql.Null { + invalid = true + } + return res + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { @@ -4165,60 +4452,110 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "invalidIdentifier": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_invalidIdentifier(ctx, field) return res }) case "collision": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_collision(ctx, field) return res }) case "mapInput": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_mapInput(ctx, field) return res }) case "recursive": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_recursive(ctx, field) return res }) case "nestedInputs": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_nestedInputs(ctx, field) return res }) case "nestedOutputs": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_nestedOutputs(ctx, field) return res }) case "shapes": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_shapes(ctx, field) return res }) case "errorBubble": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_errorBubble(ctx, field) return res }) case "modelMethods": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_modelMethods(ctx, field) return res }) case "valid": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_valid(ctx, field) if res == graphql.Null { invalid = true @@ -4228,6 +4565,11 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "user": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_user(ctx, field) if res == graphql.Null { invalid = true @@ -4237,36 +4579,66 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "nullableArg": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_nullableArg(ctx, field) return res }) case "directiveArg": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_directiveArg(ctx, field) return res }) case "directiveNullableArg": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_directiveNullableArg(ctx, field) return res }) case "directiveInputNullable": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_directiveInputNullable(ctx, field) return res }) case "directiveInput": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_directiveInput(ctx, field) return res }) case "inputSlice": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_inputSlice(ctx, field) if res == graphql.Null { invalid = true @@ -4276,15 +4648,36 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "shapeUnion": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_shapeUnion(ctx, field) if res == graphql.Null { invalid = true } return res }) + case "panics": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_panics(ctx, field) + return res + }) case "validType": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_validType(ctx, field) return res }) @@ -4372,6 +4765,11 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj case "friends": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._User_friends(ctx, field, obj) if res == graphql.Null { invalid = true @@ -4723,6 +5121,44 @@ func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.Selecti return graphql.MarshalInt(v) } +func (ec *executionContext) unmarshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanic(ctx context.Context, v interface{}) (MarshalPanic, error) { + var res MarshalPanic + return res, res.UnmarshalGQL(v) +} + +func (ec *executionContext) marshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanic(ctx context.Context, sel ast.SelectionSet, v MarshalPanic) graphql.Marshaler { + return v +} + +func (ec *executionContext) unmarshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanic(ctx context.Context, v interface{}) ([]MarshalPanic, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]MarshalPanic, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanic(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanic(ctx context.Context, sel ast.SelectionSet, v []MarshalPanic) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanic(ctx, sel, v[i]) + } + + return ret +} + func (ec *executionContext) unmarshalNRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(ctx context.Context, v interface{}) (RecursiveInputSlice, error) { return ec.unmarshalInputRecursiveInputSlice(ctx, v) } @@ -4819,6 +5255,12 @@ func (ec *executionContext) marshalNUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -4864,6 +5306,12 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -4923,6 +5371,12 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstring(ctx context.Co } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -4966,6 +5420,12 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -5001,6 +5461,12 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -5243,6 +5709,12 @@ func (ec *executionContext) marshalOOuterObject2ᚕᚕᚖgithubᚗcomᚋ99design } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -5274,6 +5746,12 @@ func (ec *executionContext) marshalOOuterObject2ᚕᚖgithubᚗcomᚋ99designs } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -5297,6 +5775,17 @@ func (ec *executionContext) marshalOOuterObject2ᚖgithubᚗcomᚋ99designsᚋgq return ec._OuterObject(ctx, sel, v) } +func (ec *executionContext) marshalOPanics2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPanics(ctx context.Context, sel ast.SelectionSet, v Panics) graphql.Marshaler { + return ec._Panics(ctx, sel, &v) +} + +func (ec *executionContext) marshalOPanics2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPanics(ctx context.Context, sel ast.SelectionSet, v *Panics) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Panics(ctx, sel, v) +} + func (ec *executionContext) unmarshalORecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(ctx context.Context, v interface{}) (RecursiveInputSlice, error) { return ec.unmarshalInputRecursiveInputSlice(ctx, v) } @@ -5348,6 +5837,12 @@ func (ec *executionContext) marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -5474,6 +5969,12 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -5505,6 +6006,12 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -5536,6 +6043,12 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -5582,6 +6095,12 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } diff --git a/codegen/testserver/gqlgen.yml b/codegen/testserver/gqlgen.yml index c240e129ca9..26a1572c51e 100644 --- a/codegen/testserver/gqlgen.yml +++ b/codegen/testserver/gqlgen.yml @@ -50,3 +50,7 @@ models: ValidType: fields: different_case: { fieldName: DifferentCaseOld } + Panics: + model: "github.com/99designs/gqlgen/codegen/testserver.Panics" + MarshalPanic: + model: "github.com/99designs/gqlgen/codegen/testserver.MarshalPanic" diff --git a/codegen/testserver/models.go b/codegen/testserver/models.go index 8647046a607..bedcb790114 100644 --- a/codegen/testserver/models.go +++ b/codegen/testserver/models.go @@ -1,8 +1,9 @@ package testserver import ( - context "context" + "context" "fmt" + "io" ) type ForcedResolver struct { @@ -44,3 +45,20 @@ type EmbeddedPointerModel struct { type EmbeddedPointer struct { Title string } + +type MarshalPanic string + +func (m *MarshalPanic) UnmarshalGQL(v interface{}) error { + panic("BOOM") +} + +func (m MarshalPanic) MarshalGQL(w io.Writer) { + panic("BOOM") +} + +type Panics struct { +} + +func (p *Panics) FieldFuncMarshal(ctx context.Context, u []MarshalPanic) []MarshalPanic { + return []MarshalPanic{MarshalPanic("aa"), MarshalPanic("bb")} +} diff --git a/codegen/testserver/panics.graphql b/codegen/testserver/panics.graphql new file mode 100644 index 00000000000..8895fca82c8 --- /dev/null +++ b/codegen/testserver/panics.graphql @@ -0,0 +1,12 @@ +extend type Query { + panics: Panics +} + +type Panics { + fieldScalarMarshal: [MarshalPanic!]! + fieldFuncMarshal(u: [MarshalPanic!]!): [MarshalPanic!]! + argUnmarshal(u: [MarshalPanic!]!): Boolean! + +} + +scalar MarshalPanic diff --git a/codegen/testserver/panics_test.go b/codegen/testserver/panics_test.go new file mode 100644 index 00000000000..ed7ce713cbb --- /dev/null +++ b/codegen/testserver/panics_test.go @@ -0,0 +1,56 @@ +package testserver + +import ( + "context" + "net/http/httptest" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/handler" +) + +func TestPanics(t *testing.T) { + resolvers := &Stub{} + resolvers.QueryResolver.Panics = func(ctx context.Context) (panics *Panics, e error) { + return &Panics{}, nil + } + resolvers.PanicsResolver.ArgUnmarshal = func(ctx context.Context, obj *Panics, u []MarshalPanic) (b bool, e error) { + return true, nil + } + resolvers.PanicsResolver.FieldScalarMarshal = func(ctx context.Context, obj *Panics) (marshalPanic []MarshalPanic, e error) { + return []MarshalPanic{MarshalPanic("aa"), MarshalPanic("bb")}, nil + } + + srv := httptest.NewServer(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolvers}))) + c := client.New(srv.URL) + + t.Run("panics in marshallers will not kill server", func(t *testing.T) { + var resp interface{} + err := c.Post(`query { panics { fieldScalarMarshal } }`, &resp) + + require.EqualError(t, err, "http 422: {\"errors\":[{\"message\":\"internal system error\"}],\"data\":null}") + }) + + t.Run("panics in unmarshalers will not kill server", func(t *testing.T) { + var resp interface{} + err := c.Post(`query { panics { argUnmarshal(u: ["aa", "bb"]) } }`, &resp) + + require.EqualError(t, err, "http 422: {\"errors\":[{\"message\":\"internal system error\"}],\"data\":null}") + }) + + t.Run("panics in funcs unmarshal return errors", func(t *testing.T) { + var resp interface{} + err := c.Post(`query { panics { fieldFuncMarshal(u: ["aa", "bb"]) } }`, &resp) + + require.EqualError(t, err, "http 422: {\"errors\":[{\"message\":\"internal system error\"}],\"data\":null}") + }) + + t.Run("panics in funcs marshal return errors", func(t *testing.T) { + var resp interface{} + err := c.Post(`query { panics { fieldFuncMarshal(u: []) } }`, &resp) + + require.EqualError(t, err, "http 422: {\"errors\":[{\"message\":\"internal system error\"}],\"data\":null}") + }) +} diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index d2b55ca2fca..565a4c6a4eb 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -17,6 +17,9 @@ func (r *Resolver) ForcedResolver() ForcedResolverResolver { func (r *Resolver) ModelMethods() ModelMethodsResolver { return &modelMethodsResolver{r} } +func (r *Resolver) Panics() PanicsResolver { + return &panicsResolver{r} +} func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } @@ -39,6 +42,15 @@ func (r *modelMethodsResolver) ResolverField(ctx context.Context, obj *ModelMeth panic("not implemented") } +type panicsResolver struct{ *Resolver } + +func (r *panicsResolver) FieldScalarMarshal(ctx context.Context, obj *Panics) ([]MarshalPanic, error) { + panic("not implemented") +} +func (r *panicsResolver) ArgUnmarshal(ctx context.Context, obj *Panics, u []MarshalPanic) (bool, error) { + panic("not implemented") +} + type queryResolver struct{ *Resolver } func (r *queryResolver) InvalidIdentifier(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) { @@ -95,6 +107,9 @@ func (r *queryResolver) InputSlice(ctx context.Context, arg []string) (bool, err func (r *queryResolver) ShapeUnion(ctx context.Context) (ShapeUnion, error) { panic("not implemented") } +func (r *queryResolver) Panics(ctx context.Context) (*Panics, error) { + panic("not implemented") +} func (r *queryResolver) ValidType(ctx context.Context) (*ValidType, error) { panic("not implemented") } diff --git a/codegen/testserver/stub.go b/codegen/testserver/stub.go index 57e31cc2086..1e732362073 100644 --- a/codegen/testserver/stub.go +++ b/codegen/testserver/stub.go @@ -16,6 +16,10 @@ type Stub struct { ModelMethodsResolver struct { ResolverField func(ctx context.Context, obj *ModelMethods) (bool, error) } + PanicsResolver struct { + FieldScalarMarshal func(ctx context.Context, obj *Panics) ([]MarshalPanic, error) + ArgUnmarshal func(ctx context.Context, obj *Panics, u []MarshalPanic) (bool, error) + } QueryResolver struct { InvalidIdentifier func(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) Collision func(ctx context.Context) (*introspection1.It, error) @@ -35,6 +39,7 @@ type Stub struct { DirectiveInput func(ctx context.Context, arg InputDirectives) (*string, error) InputSlice func(ctx context.Context, arg []string) (bool, error) ShapeUnion func(ctx context.Context) (ShapeUnion, error) + Panics func(ctx context.Context) (*Panics, error) ValidType func(ctx context.Context) (*ValidType, error) } SubscriptionResolver struct { @@ -52,6 +57,9 @@ func (r *Stub) ForcedResolver() ForcedResolverResolver { func (r *Stub) ModelMethods() ModelMethodsResolver { return &stubModelMethods{r} } +func (r *Stub) Panics() PanicsResolver { + return &stubPanics{r} +} func (r *Stub) Query() QueryResolver { return &stubQuery{r} } @@ -74,6 +82,15 @@ func (r *stubModelMethods) ResolverField(ctx context.Context, obj *ModelMethods) return r.ModelMethodsResolver.ResolverField(ctx, obj) } +type stubPanics struct{ *Stub } + +func (r *stubPanics) FieldScalarMarshal(ctx context.Context, obj *Panics) ([]MarshalPanic, error) { + return r.PanicsResolver.FieldScalarMarshal(ctx, obj) +} +func (r *stubPanics) ArgUnmarshal(ctx context.Context, obj *Panics, u []MarshalPanic) (bool, error) { + return r.PanicsResolver.ArgUnmarshal(ctx, obj, u) +} + type stubQuery struct{ *Stub } func (r *stubQuery) InvalidIdentifier(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) { @@ -130,6 +147,9 @@ func (r *stubQuery) InputSlice(ctx context.Context, arg []string) (bool, error) func (r *stubQuery) ShapeUnion(ctx context.Context) (ShapeUnion, error) { return r.QueryResolver.ShapeUnion(ctx) } +func (r *stubQuery) Panics(ctx context.Context) (*Panics, error) { + return r.QueryResolver.Panics(ctx) +} func (r *stubQuery) ValidType(ctx context.Context) (*ValidType, error) { return r.QueryResolver.ValidType(ctx) } diff --git a/codegen/type.gotpl b/codegen/type.gotpl index 6fadb4424f6..ce766d3c5f8 100644 --- a/codegen/type.gotpl +++ b/codegen/type.gotpl @@ -80,6 +80,12 @@ } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } diff --git a/example/chat/generated.go b/example/chat/generated.go index 5827c738d48..845ab1658ec 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -1650,6 +1650,11 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "room": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_room(ctx, field) return res }) @@ -1968,6 +1973,12 @@ func (ec *executionContext) marshalNMessage2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2035,6 +2046,12 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2094,6 +2111,12 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstring(ctx context.Co } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2137,6 +2160,12 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2172,6 +2201,12 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2278,6 +2313,12 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2309,6 +2350,12 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2340,6 +2387,12 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2386,6 +2439,12 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } diff --git a/example/config/generated.go b/example/config/generated.go index b78e835eca6..97a7dd2c8af 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -1501,6 +1501,11 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "todos": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_todos(ctx, field) if res == graphql.Null { invalid = true @@ -1536,6 +1541,11 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj case "id": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Todo_id(ctx, field, obj) if res == graphql.Null { invalid = true @@ -1905,6 +1915,12 @@ func (ec *executionContext) marshalNTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -1954,6 +1970,12 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2013,6 +2035,12 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstring(ctx context.Co } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2056,6 +2084,12 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2091,6 +2125,12 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2186,6 +2226,12 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2217,6 +2263,12 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2248,6 +2300,12 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2294,6 +2352,12 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index f09ad400dcd..f2d965d06e4 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -1701,12 +1701,22 @@ func (ec *executionContext) _Customer(ctx context.Context, sel ast.SelectionSet, case "address": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Customer_address(ctx, field, obj) return res }) case "orders": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Customer_orders(ctx, field, obj) return res }) @@ -1777,6 +1787,11 @@ func (ec *executionContext) _Order(ctx context.Context, sel ast.SelectionSet, ob case "items": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Order_items(ctx, field, obj) return res }) @@ -1809,18 +1824,33 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "customers": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_customers(ctx, field) return res }) case "torture1d": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_torture1d(ctx, field) return res }) case "torture2d": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_torture2d(ctx, field) return res }) @@ -2161,6 +2191,12 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2220,6 +2256,12 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstring(ctx context.Co } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2263,6 +2305,12 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2298,6 +2346,12 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2381,6 +2435,12 @@ func (ec *executionContext) marshalOCustomer2ᚕgithubᚗcomᚋ99designsᚋgqlge } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2412,6 +2472,12 @@ func (ec *executionContext) marshalOCustomer2ᚕᚕgithubᚗcomᚋ99designsᚋgq } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2501,6 +2567,12 @@ func (ec *executionContext) marshalOItem2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2532,6 +2604,12 @@ func (ec *executionContext) marshalOOrder2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2586,6 +2664,12 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2617,6 +2701,12 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2648,6 +2738,12 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2694,6 +2790,12 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } diff --git a/example/scalars/generated.go b/example/scalars/generated.go index 34e955ca8ee..08bcab5f8a6 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -1613,12 +1613,22 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "user": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_user(ctx, field) return res }) case "search": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_search(ctx, field) if res == graphql.Null { invalid = true @@ -1671,6 +1681,11 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj case "primitiveResolver": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._User_primitiveResolver(ctx, field, obj) if res == graphql.Null { invalid = true @@ -1680,6 +1695,11 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj case "customResolver": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._User_customResolver(ctx, field, obj) if res == graphql.Null { invalid = true @@ -2025,6 +2045,12 @@ func (ec *executionContext) marshalNUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2060,6 +2086,12 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2119,6 +2151,12 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstring(ctx context.Co } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2162,6 +2200,12 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2197,6 +2241,12 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2387,6 +2437,12 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2418,6 +2474,12 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2449,6 +2511,12 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2495,6 +2563,12 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } diff --git a/example/selection/generated.go b/example/selection/generated.go index 3692f5a0e13..a15fc7fcaaf 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -1470,6 +1470,11 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "events": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_events(ctx, field) return res }) @@ -1786,6 +1791,12 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -1845,6 +1856,12 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstring(ctx context.Co } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -1888,6 +1905,12 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -1923,6 +1946,12 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -1995,6 +2024,12 @@ func (ec *executionContext) marshalOEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2078,6 +2113,12 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2109,6 +2150,12 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2140,6 +2187,12 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2186,6 +2239,12 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } diff --git a/example/starwars/generated.go b/example/starwars/generated.go index 5a2a083ce45..99116eac698 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -2921,12 +2921,22 @@ func (ec *executionContext) _Droid(ctx context.Context, sel ast.SelectionSet, ob case "friends": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Droid_friends(ctx, field, obj) return res }) case "friendsConnection": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Droid_friendsConnection(ctx, field, obj) if res == graphql.Null { invalid = true @@ -2970,12 +2980,22 @@ func (ec *executionContext) _FriendsConnection(ctx context.Context, sel ast.Sele case "edges": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._FriendsConnection_edges(ctx, field, obj) return res }) case "friends": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._FriendsConnection_friends(ctx, field, obj) return res }) @@ -3055,12 +3075,22 @@ func (ec *executionContext) _Human(ctx context.Context, sel ast.SelectionSet, ob case "friends": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Human_friends(ctx, field, obj) return res }) case "friendsConnection": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Human_friendsConnection(ctx, field, obj) if res == graphql.Null { invalid = true @@ -3075,6 +3105,11 @@ func (ec *executionContext) _Human(ctx context.Context, sel ast.SelectionSet, ob case "starships": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Human_starships(ctx, field, obj) return res }) @@ -3172,12 +3207,22 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "hero": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_hero(ctx, field) return res }) case "reviews": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_reviews(ctx, field) if res == graphql.Null { invalid = true @@ -3187,6 +3232,11 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "search": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_search(ctx, field) if res == graphql.Null { invalid = true @@ -3196,24 +3246,44 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "character": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_character(ctx, field) return res }) case "droid": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_droid(ctx, field) return res }) case "human": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_human(ctx, field) return res }) case "starship": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_starship(ctx, field) return res }) @@ -3287,6 +3357,11 @@ func (ec *executionContext) _Starship(ctx context.Context, sel ast.SelectionSet, case "length": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Starship_length(ctx, field, obj) if res == graphql.Null { invalid = true @@ -3610,6 +3685,12 @@ func (ec *executionContext) marshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -3749,6 +3830,12 @@ func (ec *executionContext) marshalNReview2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -3788,6 +3875,12 @@ func (ec *executionContext) marshalNSearchResult2ᚕgithubᚗcomᚋ99designsᚋg } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -3835,6 +3928,12 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -3894,6 +3993,12 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstring(ctx context.Co } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -3937,6 +4042,12 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -3972,6 +4083,12 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -4048,6 +4165,12 @@ func (ec *executionContext) marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlg } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -4122,6 +4245,12 @@ func (ec *executionContext) marshalOFriendsEdge2ᚕgithubᚗcomᚋ99designsᚋgq } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -4249,6 +4378,12 @@ func (ec *executionContext) marshalOStarship2ᚕgithubᚗcomᚋ99designsᚋgqlge } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -4336,6 +4471,12 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -4367,6 +4508,12 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -4398,6 +4545,12 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -4444,6 +4597,12 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } diff --git a/example/todo/generated.go b/example/todo/generated.go index cd535e1e49e..1db0bd6ebf8 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -1562,18 +1562,33 @@ func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) case "todo": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._MyQuery_todo(ctx, field) return res }) case "lastTodo": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._MyQuery_lastTodo(ctx, field) return res }) case "todos": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._MyQuery_todos(ctx, field) if res == graphql.Null { invalid = true @@ -1937,6 +1952,12 @@ func (ec *executionContext) marshalNTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -1986,6 +2007,12 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2045,6 +2072,12 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstring(ctx context.Co } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2088,6 +2121,12 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2123,6 +2162,12 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2229,6 +2274,12 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2260,6 +2311,12 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2291,6 +2348,12 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2337,6 +2400,12 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index 5633266ab3b..e21dae94c46 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -1586,6 +1586,11 @@ func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) case "todos": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._MyQuery_todos(ctx, field) if res == graphql.Null { invalid = true @@ -1595,6 +1600,11 @@ func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) case "todo": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._MyQuery_todo(ctx, field) return res }) @@ -1952,6 +1962,12 @@ func (ec *executionContext) marshalNTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2001,6 +2017,12 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2060,6 +2082,12 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstring(ctx context.Co } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2103,6 +2131,12 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2138,6 +2172,12 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2244,6 +2284,12 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2275,6 +2321,12 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2306,6 +2358,12 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2352,6 +2410,12 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } diff --git a/integration/generated.go b/integration/generated.go index 40cab9ab1f5..a9044e3f509 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -72,6 +72,7 @@ type ComplexityRoot struct { type ElementResolver interface { Child(ctx context.Context, obj *models.Element) (*models.Element, error) Error(ctx context.Context, obj *models.Element) (bool, error) + Mismatched(ctx context.Context, obj *models.Element) ([]bool, error) } type QueryResolver interface { Path(ctx context.Context) ([]*models.Element, error) @@ -477,7 +478,7 @@ func (ec *executionContext) _Element_mismatched(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Mismatched, nil + return ec.resolvers.Element().Mismatched(rctx, obj) }) if resTmp == nil { return graphql.Null @@ -1612,6 +1613,11 @@ func (ec *executionContext) _Element(ctx context.Context, sel ast.SelectionSet, case "child": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Element_child(ctx, field, obj) if res == graphql.Null { invalid = true @@ -1621,6 +1627,11 @@ func (ec *executionContext) _Element(ctx context.Context, sel ast.SelectionSet, case "error": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Element_error(ctx, field, obj) if res == graphql.Null { invalid = true @@ -1628,7 +1639,16 @@ func (ec *executionContext) _Element(ctx context.Context, sel ast.SelectionSet, return res }) case "mismatched": - out.Values[i] = ec._Element_mismatched(ctx, field, obj) + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Element_mismatched(ctx, field, obj) + return res + }) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -1658,12 +1678,22 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "path": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_path(ctx, field) return res }) case "date": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_date(ctx, field) if res == graphql.Null { invalid = true @@ -1673,12 +1703,22 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "viewer": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_viewer(ctx, field) return res }) case "jsonEncoding": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_jsonEncoding(ctx, field) if res == graphql.Null { invalid = true @@ -1688,6 +1728,11 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr case "error": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._Query_error(ctx, field) if res == graphql.Null { invalid = true @@ -1728,6 +1773,11 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj case "likes": field := field out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() res = ec._User_likes(ctx, field, obj) if res == graphql.Null { invalid = true @@ -2096,6 +2146,12 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2155,6 +2211,12 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstring(ctx context.Co } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2198,6 +2260,12 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2233,6 +2301,12 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2362,6 +2436,12 @@ func (ec *executionContext) marshalOElement2ᚕᚖgithubᚗcomᚋ99designsᚋgql } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2492,6 +2572,12 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2523,6 +2609,12 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2554,6 +2646,12 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } @@ -2600,6 +2698,12 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() if !isLen1 { defer wg.Done() } From da12fd11020c4d2449f5abb2545ce28d4dde75dd Mon Sep 17 00:00:00 2001 From: Luca Steeb Date: Fri, 1 Mar 2019 14:28:08 +0100 Subject: [PATCH 100/147] Fix cli config getters --- cmd/gen.go | 2 +- cmd/init.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/gen.go b/cmd/gen.go index 5613ee31ee9..c69858b44b0 100644 --- a/cmd/gen.go +++ b/cmd/gen.go @@ -20,7 +20,7 @@ var genCmd = cli.Command{ Action: func(ctx *cli.Context) { var cfg *config.Config var err error - if configFilename := ctx.String("gen"); configFilename != "" { + if configFilename := ctx.String("config"); configFilename != "" { cfg, err = config.LoadConfig(configFilename) if err != nil { fmt.Fprintln(os.Stderr, err.Error()) diff --git a/cmd/init.go b/cmd/init.go index 664c523b780..e07bed97086 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -83,7 +83,7 @@ func GenerateGraphServer(cfg *config.Config, serverFilename string) { func initConfig(ctx *cli.Context) *config.Config { var cfg *config.Config var err error - configFilename := ctx.String("cfg") + configFilename := ctx.String("config") if configFilename != "" { cfg, err = config.LoadConfig(configFilename) } else { From 37cbbd6de2268ca9b0930abc3e39abc72e685e58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Sun, 3 Mar 2019 17:18:06 +0100 Subject: [PATCH 101/147] playground: secure CDN resources with Subresource Integrity --- handler/playground.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/handler/playground.go b/handler/playground.go index f1687defb76..49258368dcf 100644 --- a/handler/playground.go +++ b/handler/playground.go @@ -11,9 +11,12 @@ var page = template.Must(template.New("graphiql").Parse(` - - - + + + {{.title}} @@ -43,9 +46,12 @@ var page = template.Must(template.New("graphiql").Parse(` func Playground(title string, endpoint string) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { err := page.Execute(w, map[string]string{ - "title": title, - "endpoint": endpoint, - "version": "1.7.8", + "title": title, + "endpoint": endpoint, + "version": "1.7.8", + "cssSRI": "sha256-cS9Vc2OBt9eUf4sykRWukeFYaInL29+myBmFDSa7F/U=", + "faviconSRI": "sha256-GhTyE+McTU79R4+pRO6ih+4TfsTOrpPwD8ReKFzb3PM=", + "jsSRI": "sha256-ucQsC5k+XYnUlQia6tMKdAOGBbfbDAquMa+oqIooB5A=", }) if err != nil { panic(err) From 6ad1d97e52a5c003f8014dc0ed00663caf4a1118 Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Mon, 4 Mar 2019 10:07:26 +1100 Subject: [PATCH 102/147] Move feature comparison --- docs/content/feature-comparison.md | 29 +++++++++++++++++++++++++++++ docs/static/main.css | 18 +++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 docs/content/feature-comparison.md diff --git a/docs/content/feature-comparison.md b/docs/content/feature-comparison.md new file mode 100644 index 00000000000..9c1bec69d07 --- /dev/null +++ b/docs/content/feature-comparison.md @@ -0,0 +1,29 @@ +--- +linkTitle: Feature Comparison +title: Comparing Features of Other Go GraphQL Implementations +description: Comparing Features of Other Go GraphQL Implementations +menu: main +weight: -1 +--- + +| | [gqlgen](https://github.com/99designs/gqlgen) | [gophers](https://github.com/graph-gophers/graphql-go) | [graphql-go](https://github.com/graphql-go/graphql) | [thunder](https://github.com/samsarahq/thunder) | +| --------: | :-------- | :-------- | :-------- | :-------- | +| Kind | schema first | schema first | run time types | struct first | +| Boilerplate | less | more | more | some | +| Docs | [docs](https://gqlgen.com) & [examples](https://github.com/99designs/gqlgen/tree/master/example) | [examples](https://github.com/graph-gophers/graphql-go/tree/master/example/starwars) | [examples](https://github.com/graphql-go/graphql/tree/master/examples) | [examples](https://github.com/samsarahq/thunder/tree/master/example)| +| Query | 👍 | 👍 | 👍 | 👍 | +| Mutation | 👍 | 🚧 [pr](https://github.com/graph-gophers/graphql-go/pull/182) | 👍 | 👍 | +| Subscription | 👍 | 🚧 [pr](https://github.com/graph-gophers/graphql-go/pull/182) | 👍 | 👍 | +| Type Safety | 👍 | 👍 | ⛔️ | 👍 | +| Type Binding | 👍 | 🚧 [pr](https://github.com/graph-gophers/graphql-go/pull/194) | ⛔️ | 👍 | +| Embedding | 👍 | ⛔️ | 🚧 [pr](https://github.com/graphql-go/graphql/pull/371) | ⛔️ | +| Interfaces | 👍 | 👍 | 👍 | ⛔️ [is](https://github.com/samsarahq/thunder/issues/78) | +| Generated Enums | 👍 | ⛔️ | ⛔️ | ⛔️ | +| Generated Inputs | 👍 | ⛔️ | ⛔️ | ⛔️ | +| Stitching gql | 🕐 [is](https://github.com/99designs/gqlgen/issues/5) | ⛔️ | ⛔️ | ⛔️ | +| Opentracing | 👍 | 👍 | ⛔️ | ✂️[pr](https://github.com/samsarahq/thunder/pull/77) | +| Hooks for error logging | 👍 | ⛔️ | ⛔️ | ⛔️ | +| Dataloading | 👍 | 👍 | 👍 | ⚠️ | +| Concurrency | 👍 | 👍 | 👍 | 👍 | +| Custom errors & error.path | 👍 | ⛔️ [is](https://github.com/graphql-go/graphql/issues/259) | ⛔️ | ⛔️ | +| Query complexity | 👍 | ⛔️ [is](https://github.com/graphql-go/graphql/issues/231) | ⛔️ | ⛔️ | diff --git a/docs/static/main.css b/docs/static/main.css index 563955595f5..0e26e83a766 100644 --- a/docs/static/main.css +++ b/docs/static/main.css @@ -430,4 +430,20 @@ blockquote p:first-of-type { blockquote code { background-color: var(--color-blockquote-highlight); -} \ No newline at end of file +} + +table { + width: 100%; +} + +td, th { + padding: 0.2em 1em; +} + +tr { + border-bottom: 1px solid var(--color-heading-background); +} + +tr td:first-child, th { + font-weight: bold; +} From d9a9a532178aff2def9992c39db37fcd79092fa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Sun, 3 Mar 2019 17:18:06 +0100 Subject: [PATCH 103/147] playground: secure CDN resources with Subresource Integrity --- handler/playground.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/handler/playground.go b/handler/playground.go index b3297f44ab3..09db11de152 100644 --- a/handler/playground.go +++ b/handler/playground.go @@ -11,9 +11,12 @@ var page = template.Must(template.New("graphiql").Parse(` - - - + + + {{.title}} @@ -44,9 +47,12 @@ func Playground(title string, endpoint string) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { w.Header().Add("Content-Type", "text/html") err := page.Execute(w, map[string]string{ - "title": title, - "endpoint": endpoint, - "version": "1.7.8", + "title": title, + "endpoint": endpoint, + "version": "1.7.8", + "cssSRI": "sha256-cS9Vc2OBt9eUf4sykRWukeFYaInL29+myBmFDSa7F/U=", + "faviconSRI": "sha256-GhTyE+McTU79R4+pRO6ih+4TfsTOrpPwD8ReKFzb3PM=", + "jsSRI": "sha256-ucQsC5k+XYnUlQia6tMKdAOGBbfbDAquMa+oqIooB5A=", }) if err != nil { panic(err) From d81670d8bf568c4d5ed5b8db1274c3cf496db416 Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Mon, 4 Mar 2019 11:34:10 +1100 Subject: [PATCH 104/147] Add initial contributing guidelines --- CONTRIBUTING.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000000..8981109add0 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,27 @@ +# Contributing + +Want to contribute to gqlgen? Here are some guidelines for how we accept help. + +## Getting in Touch + +Our [gitter](https://gitter.im/gqlgen/Lobby) channel is the best place to ask questions or get advice on using gqlgen. + +## Reporting Bugs and Issues + + We use [GitHub Issues](https://github.com/99designs/gqlgen/issues) to track bugs, so please do a search before submitting to ensure your problem isn't already tracked. + +### New Issues + +Please provide the expected and observed behaviours in your issue. A minimal GraphQL schema or configuration file should be provided where appropriate. + +## Proposing a Change + +If you intend to implement a feature for gqlgen, or make a non-trivial change to the current implementation, we recommend [first filing an issue](https://github.com/99designs/gqlgen/issues/new) marked with the `proposal` tag, so that the engineering team can provide guidance and feedback on the direction of an implementation. This also help ensure that other people aren't also working on the same thing. + +Bug fixes are welcome and should come with appropriate test coverage. + +New features should be made against the `next` branch. + +### License + +By contributing to gqlgen, you agree that your contributions will be licensed under its MIT license. From 25bdf3d6bff9790ffb0eb8ef7b4422e4008386f7 Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Mon, 4 Mar 2019 11:41:15 +1100 Subject: [PATCH 105/147] Consolidate Introduction documents --- CONTRIBUTING.md | 2 +- README.md | 60 +++++++++++++++++------------------- docs/content/introduction.md | 28 +++++++++-------- 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8981109add0..461709ecf8e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ -# Contributing +# Contribution Guidelines Want to contribute to gqlgen? Here are some guidelines for how we accept help. diff --git a/README.md b/README.md index 708f66127d1..162983667af 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,30 @@ # gqlgen [![CircleCI](https://badgen.net/circleci/github/99designs/gqlgen/master)](https://circleci.com/gh/99designs/gqlgen) [![Read the Docs](https://badgen.net/badge/docs/available/green)](http://gqlgen.com/) -This is a library for quickly creating strictly typed graphql servers in golang. - -See the [docs](https://gqlgen.com/) for a getting started guide. - -### Feature comparison - -| | [gqlgen](https://github.com/99designs/gqlgen) | [gophers](https://github.com/graph-gophers/graphql-go) | [graphql-go](https://github.com/graphql-go/graphql) | [thunder](https://github.com/samsarahq/thunder) | -| --------: | :-------- | :-------- | :-------- | :-------- | -| Kind | schema first | schema first | run time types | struct first | -| Boilerplate | less | more | more | some | -| Docs | [docs](https://gqlgen.com) & [examples](https://github.com/99designs/gqlgen/tree/master/example) | [examples](https://github.com/graph-gophers/graphql-go/tree/master/example/starwars) | [examples](https://github.com/graphql-go/graphql/tree/master/examples) | [examples](https://github.com/samsarahq/thunder/tree/master/example)| -| Query | :+1: | :+1: | :+1: | :+1: | -| Mutation | :+1: | :construction: [pr](https://github.com/graph-gophers/graphql-go/pull/182) | :+1: | :+1: | -| Subscription | :+1: | :construction: [pr](https://github.com/graph-gophers/graphql-go/pull/182) | :+1: | :+1: | -| Type Safety | :+1: | :+1: | :no_entry: | :+1: | -| Type Binding | :+1: | :construction: [pr](https://github.com/graph-gophers/graphql-go/pull/194) | :no_entry: | :+1: | -| Embedding | :+1: | :no_entry: | :construction: [pr](https://github.com/graphql-go/graphql/pull/371) | :no_entry: | -| Interfaces | :+1: | :+1: | :+1: | :no_entry: [is](https://github.com/samsarahq/thunder/issues/78) | -| Generated Enums | :+1: | :no_entry: | :no_entry: | :no_entry: | -| Generated Inputs | :+1: | :no_entry: | :no_entry: | :no_entry: | -| Stitching gql | :clock1: [is](https://github.com/99designs/gqlgen/issues/5) | :no_entry: | :no_entry: | :no_entry: | -| Opentracing | :+1: | :+1: | :no_entry: | :scissors:[pr](https://github.com/samsarahq/thunder/pull/77) | -| Hooks for error logging | :+1: | :no_entry: | :no_entry: | :no_entry: | -| Dataloading | :+1: | :+1: | :+1: | :warning: | -| Concurrency | :+1: | :+1: | :+1: | :+1: | -| Custom errors & error.path | :+1: | :no_entry: [is](https://github.com/graphql-go/graphql/issues/259) | :no_entry: | :no_entry: | -| Query complexity | :+1: | :no_entry: [is](https://github.com/graphql-go/graphql/issues/231) | :no_entry: | :no_entry: | - - -### Help - -Create an issue or join the conversation on [gitter](https://gitter.im/gqlgen) +## What is gqlgen? + +[gqlgen](https://github.com/99designs/gqlgen) is a Go library for building GraphQL servers without any fuss. gqlgen is: + + - **Schema first** — Define your API using the GraphQL [Schema Definition Language](http://graphql.org/learn/schema/). + - **Type safe** — You should never see `map[string]interface{}` here. + - **Codegen** — Let us generate the boring bits, so you can build your app quickly. + +[Feature Comparison](https://gqlgen.com/feature-comparison/) + +## Getting Started + +First work your way through the [Getting Started](ttps://gqlgen.com/getting-started/) tutorial. + +If you can't find what your looking for, look at our [examples](https://github.com/99designs/gqlgen/tree/master/example) for example usage of gqlgen. + +## Reporting Issues + +If you think you've found a bug, or something isn't behaving the way you think it should, please raise an [issue](https://github.com/99designs/gqlgen/issues) on GitHub. + +## Contributing + +Read our [Contribution Guidelines](https://github.com/99designs/gqlgen/blob/master/CONTRIBUTING.md) for information on how you can help out gqlgen. + +## Talks & Blog Posts + + - [Christopher Biscardi @ Gophercon UK 2018](https://youtu.be/FdURVezcdcw) + - [Introducing gqlgen: a GraphQL Server Generator for Go](https://99designs.com.au/blog/engineering/gqlgen-a-graphql-server-generator-for-go/) diff --git a/docs/content/introduction.md b/docs/content/introduction.md index 1d98c9b1e1f..ce43ff7ea8a 100644 --- a/docs/content/introduction.md +++ b/docs/content/introduction.md @@ -1,31 +1,35 @@ --- linkTitle: Introduction -title: Type-safe graphql for golang +title: Type-safe GraphQL for Go type: homepage date: 2018-03-17T13:06:47+11:00 --- ## What is gqlgen? -[gqlgen](https://github.com/99designs/gqlgen) is a golang library for building graphql servers without any fuss. gqlgen is: +[gqlgen](https://github.com/99designs/gqlgen) is a Go library for building GraphQL servers without any fuss. gqlgen is: - - Schema first: You define your API using the graphql [Schema Definition Language](http://graphql.org/learn/schema/) - - Type safe: You should never see `map[string]interface{}` here. - - Codegen: Let us generate the boring bits, so you can build your app quickly. + - **Schema first** — Define your API using the GraphQL [Schema Definition Language](http://graphql.org/learn/schema/). + - **Type safe** — You should never see `map[string]interface{}` here. + - **Codegen** — Let us generate the boring bits, so you can build your app quickly. +[Feature Comparison]({{< ref "feature-comparison.md" >}}) -## Getting started +## Getting Started -First take a look at the [Getting Started]({{< ref "getting-started.md" >}}) tutorial. +First work your way through the [Getting Started]({{< ref "getting-started.md" >}}) tutorial. -If you cant find what your looking for, maybe the [examples](https://github.com/99designs/gqlgen/tree/master/example) will help. +If you can't find what your looking for, look at our [examples](https://github.com/99designs/gqlgen/tree/master/example) for example usage of gqlgen. +## Reporting Issues -## Getting help +If you think you've found a bug, or something isn't behaving the way you think it should, please raise an [issue](https://github.com/99designs/gqlgen/issues) on GitHub. -If you think you've found a bug, or something isn't behaving the way you think it should please raise an [issue](https://github.com/99designs/gqlgen/issues) on github. +## Contributing +Read our [Contribution Guidelines](https://github.com/99designs/gqlgen/blob/master/CONTRIBUTING.md) for information on how you can help out gqlgen. -## Talks +## Talks & Blog Posts - - [Christopher Biscardi @ Gophercon UK 2018](https://youtu.be/FdURVezcdcw) + - [Christopher Biscardi @ Gophercon UK 2018](https://youtu.be/FdURVezcdcw) + - [Introducing gqlgen: a GraphQL Server Generator for Go](https://99designs.com.au/blog/engineering/gqlgen-a-graphql-server-generator-for-go/) From 5c692e294e71aa6846192ce71e90c983d760d114 Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Mon, 4 Mar 2019 12:38:04 +1100 Subject: [PATCH 106/147] User README as canonical introduction --- docs/content/_introduction.md | 1 + docs/content/introduction.md | 29 ----------------------------- docs/layouts/index.html | 5 +++++ 3 files changed, 6 insertions(+), 29 deletions(-) create mode 120000 docs/content/_introduction.md diff --git a/docs/content/_introduction.md b/docs/content/_introduction.md new file mode 120000 index 00000000000..fe840054137 --- /dev/null +++ b/docs/content/_introduction.md @@ -0,0 +1 @@ +../../README.md \ No newline at end of file diff --git a/docs/content/introduction.md b/docs/content/introduction.md index ce43ff7ea8a..6ee0d144fa9 100644 --- a/docs/content/introduction.md +++ b/docs/content/introduction.md @@ -4,32 +4,3 @@ title: Type-safe GraphQL for Go type: homepage date: 2018-03-17T13:06:47+11:00 --- - -## What is gqlgen? - -[gqlgen](https://github.com/99designs/gqlgen) is a Go library for building GraphQL servers without any fuss. gqlgen is: - - - **Schema first** — Define your API using the GraphQL [Schema Definition Language](http://graphql.org/learn/schema/). - - **Type safe** — You should never see `map[string]interface{}` here. - - **Codegen** — Let us generate the boring bits, so you can build your app quickly. - -[Feature Comparison]({{< ref "feature-comparison.md" >}}) - -## Getting Started - -First work your way through the [Getting Started]({{< ref "getting-started.md" >}}) tutorial. - -If you can't find what your looking for, look at our [examples](https://github.com/99designs/gqlgen/tree/master/example) for example usage of gqlgen. - -## Reporting Issues - -If you think you've found a bug, or something isn't behaving the way you think it should, please raise an [issue](https://github.com/99designs/gqlgen/issues) on GitHub. - -## Contributing - -Read our [Contribution Guidelines](https://github.com/99designs/gqlgen/blob/master/CONTRIBUTING.md) for information on how you can help out gqlgen. - -## Talks & Blog Posts - - - [Christopher Biscardi @ Gophercon UK 2018](https://youtu.be/FdURVezcdcw) - - [Introducing gqlgen: a GraphQL Server Generator for Go](https://99designs.com.au/blog/engineering/gqlgen-a-graphql-server-generator-for-go/) diff --git a/docs/layouts/index.html b/docs/layouts/index.html index 9e5776800d9..f3e8fa58eb2 100644 --- a/docs/layouts/index.html +++ b/docs/layouts/index.html @@ -11,6 +11,11 @@

{{ .LinkTitle }}

{{ .Content }} + {{.Scratch.Set "intro" (readFile "content/_introduction.md")}} + {{.Scratch.Set "intro" (split (.Scratch.Get "intro") "\n")}} + {{.Scratch.Set "intro" (after 2 (.Scratch.Get "intro"))}} + {{.Scratch.Set "intro" (delimit (.Scratch.Get "intro") "\n")}} + {{.Scratch.Get "intro"|markdownify}}
{{ end }} From 1e7aab63fc134090a47d1f3634bab4d8f3d35291 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Mon, 4 Mar 2019 11:12:04 +1100 Subject: [PATCH 107/147] Workaround for using packages with vendored code --- codegen/config/binder.go | 22 +++++++++------------- codegen/config/config.go | 2 +- internal/code/imports.go | 1 + internal/code/util.go | 26 +++++++++++++++++++++++++- 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/codegen/config/binder.go b/codegen/config/binder.go index 15e456c52e1..0c8c7d614c2 100644 --- a/codegen/config/binder.go +++ b/codegen/config/binder.go @@ -4,11 +4,8 @@ import ( "fmt" "go/token" "go/types" - "regexp" - "strings" "github.com/99designs/gqlgen/codegen/templates" - "github.com/99designs/gqlgen/internal/code" "github.com/pkg/errors" "github.com/vektah/gqlparser/ast" @@ -29,6 +26,14 @@ func (c *Config) NewBinder(s *ast.Schema) (*Binder, error) { return nil, err } + for _, p := range pkgs { + for _, e := range p.Errors { + if e.Kind == packages.ListError { + return nil, p.Errors[0] + } + } + } + return &Binder{ pkgs: pkgs, schema: s, @@ -71,7 +76,7 @@ func (b *Binder) FindType(pkgName string, typeName string) (types.Type, error) { func (b *Binder) getPkg(find string) *packages.Package { for _, p := range b.pkgs { - if normalizeVendor(find) == normalizeVendor(p.PkgPath) { + if code.NormalizeVendor(find) == code.NormalizeVendor(p.PkgPath) { return p } } @@ -162,15 +167,6 @@ func (b *Binder) PointerTo(ref *TypeReference) *TypeReference { return newRef } -var modsRegex = regexp.MustCompile(`^(\*|\[\])*`) - -func normalizeVendor(pkg string) string { - modifiers := modsRegex.FindAllString(pkg, 1)[0] - pkg = strings.TrimPrefix(pkg, modifiers) - parts := strings.Split(pkg, "/vendor/") - return modifiers + parts[len(parts)-1] -} - // TypeReference is used by args and field types. The Definition can refer to both input and output types. type TypeReference struct { Definition *ast.Definition diff --git a/codegen/config/config.go b/codegen/config/config.go index 1638239d003..5bdc5063d55 100644 --- a/codegen/config/config.go +++ b/codegen/config/config.go @@ -249,7 +249,7 @@ func (tm TypeMap) ReferencedPackages() []string { if pkg == "" || inStrSlice(pkgs, pkg) { continue } - pkgs = append(pkgs, pkg) + pkgs = append(pkgs, code.QualifyPackagePath(pkg)) } } diff --git a/internal/code/imports.go b/internal/code/imports.go index 27343212799..ecfe9dbc9f4 100644 --- a/internal/code/imports.go +++ b/internal/code/imports.go @@ -33,6 +33,7 @@ func NameForPackage(importPath string) string { if v, ok := nameForPackageCache.Load(importPath); ok { return v.(string) } + importPath = QualifyPackagePath(importPath) p, _ := packages.Load(nil, importPath) if len(p) != 1 || p[0].Name == "" { diff --git a/internal/code/util.go b/internal/code/util.go index 6e06e4cc187..2be83a23cea 100644 --- a/internal/code/util.go +++ b/internal/code/util.go @@ -1,6 +1,8 @@ package code import ( + "go/build" + "os" "path/filepath" "regexp" "strings" @@ -13,11 +15,15 @@ func PkgAndType(name string) (string, string) { return "", name } - return NormalizeVendor(strings.Join(parts[:len(parts)-1], ".")), parts[len(parts)-1] + return strings.Join(parts[:len(parts)-1], "."), parts[len(parts)-1] } var modsRegex = regexp.MustCompile(`^(\*|\[\])*`) +// NormalizeVendor takes a qualified package path and turns it into normal one. +// eg . +// github.com/foo/vendor/github.com/99designs/gqlgen/graphql becomes +// github.com/99designs/gqlgen/graphql func NormalizeVendor(pkg string) string { modifiers := modsRegex.FindAllString(pkg, 1)[0] pkg = strings.TrimPrefix(pkg, modifiers) @@ -25,6 +31,24 @@ func NormalizeVendor(pkg string) string { return modifiers + parts[len(parts)-1] } +// QualifyPackagePath takes an import and fully qualifies it with a vendor dir, if one is required. +// eg . +// github.com/99designs/gqlgen/graphql becomes +// github.com/foo/vendor/github.com/99designs/gqlgen/graphql +// +// x/tools/packages only supports 'qualified package paths' so this will need to be done prior to calling it +// See https://github.com/golang/go/issues/30289 +func QualifyPackagePath(importPath string) string { + wd, _ := os.Getwd() + + pkg, err := build.Import(importPath, wd, 0) + if err != nil { + return importPath + } + + return pkg.ImportPath +} + var invalidPackageNameChar = regexp.MustCompile(`[^\w]`) func SanitizePackageName(pkg string) string { From fb87dc3942e4179aa1eb8007f8f3d384fd4b9fca Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Mon, 4 Mar 2019 13:49:52 +1100 Subject: [PATCH 108/147] Automatically bind to int32 and int64 --- codegen/config/config.go | 6 +- codegen/testserver/generated.go | 308 ++++++++++++++++++++++++++++++ codegen/testserver/gqlgen.yml | 2 + codegen/testserver/models.go | 9 + codegen/testserver/resolver.go | 3 + codegen/testserver/schema.graphql | 10 + codegen/testserver/stub.go | 4 + graphql/int.go | 50 +++++ graphql/int_test.go | 71 +++++++ 9 files changed, 462 insertions(+), 1 deletion(-) create mode 100644 graphql/int_test.go diff --git a/codegen/config/config.go b/codegen/config/config.go index 1638239d003..cf54e8fb6a6 100644 --- a/codegen/config/config.go +++ b/codegen/config/config.go @@ -339,12 +339,16 @@ func (c *Config) InjectBuiltins(s *ast.Schema) { "__EnumValue": {Model: StringList{"github.com/99designs/gqlgen/graphql/introspection.EnumValue"}}, "__InputValue": {Model: StringList{"github.com/99designs/gqlgen/graphql/introspection.InputValue"}}, "__Schema": {Model: StringList{"github.com/99designs/gqlgen/graphql/introspection.Schema"}}, - "Int": {Model: StringList{"github.com/99designs/gqlgen/graphql.Int"}}, "Float": {Model: StringList{"github.com/99designs/gqlgen/graphql.Float"}}, "String": {Model: StringList{"github.com/99designs/gqlgen/graphql.String"}}, "Boolean": {Model: StringList{"github.com/99designs/gqlgen/graphql.Boolean"}}, "Time": {Model: StringList{"github.com/99designs/gqlgen/graphql.Time"}}, "Map": {Model: StringList{"github.com/99designs/gqlgen/graphql.Map"}}, + "Int": {Model: StringList{ + "github.com/99designs/gqlgen/graphql.Int", + "github.com/99designs/gqlgen/graphql.Int32", + "github.com/99designs/gqlgen/graphql.Int64", + }}, "ID": { Model: StringList{ "github.com/99designs/gqlgen/graphql.ID", diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 5be09523697..6932d23fd05 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -53,6 +53,14 @@ type DirectiveRoot struct { } type ComplexityRoot struct { + Autobind struct { + Int func(childComplexity int) int + Int32 func(childComplexity int) int + Int64 func(childComplexity int) int + IdStr func(childComplexity int) int + IdInt func(childComplexity int) int + } + Circle struct { Radius func(childComplexity int) int Area func(childComplexity int) int @@ -121,6 +129,7 @@ type ComplexityRoot struct { DirectiveInput func(childComplexity int, arg InputDirectives) int InputSlice func(childComplexity int, arg []string) int ShapeUnion func(childComplexity int) int + Autobind func(childComplexity int) int Panics func(childComplexity int) int ValidType func(childComplexity int) int } @@ -181,6 +190,7 @@ type QueryResolver interface { DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) InputSlice(ctx context.Context, arg []string) (bool, error) ShapeUnion(ctx context.Context) (ShapeUnion, error) + Autobind(ctx context.Context) (*Autobind, error) Panics(ctx context.Context) (*Panics, error) ValidType(ctx context.Context) (*ValidType, error) } @@ -207,6 +217,41 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { + case "Autobind.Int": + if e.complexity.Autobind.Int == nil { + break + } + + return e.complexity.Autobind.Int(childComplexity), true + + case "Autobind.Int32": + if e.complexity.Autobind.Int32 == nil { + break + } + + return e.complexity.Autobind.Int32(childComplexity), true + + case "Autobind.Int64": + if e.complexity.Autobind.Int64 == nil { + break + } + + return e.complexity.Autobind.Int64(childComplexity), true + + case "Autobind.IdStr": + if e.complexity.Autobind.IdStr == nil { + break + } + + return e.complexity.Autobind.IdStr(childComplexity), true + + case "Autobind.IdInt": + if e.complexity.Autobind.IdInt == nil { + break + } + + return e.complexity.Autobind.IdInt(childComplexity), true + case "Circle.Radius": if e.complexity.Circle.Radius == nil { break @@ -526,6 +571,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.ShapeUnion(childComplexity), true + case "Query.Autobind": + if e.complexity.Query.Autobind == nil { + break + } + + return e.complexity.Query.Autobind(childComplexity), true + case "Query.Panics": if e.complexity.Query.Panics == nil { break @@ -797,6 +849,7 @@ scalar MarshalPanic directiveInput(arg: InputDirectives!): String inputSlice(arg: [String!]!): Boolean! shapeUnion: ShapeUnion! + autobind: Autobind } type Subscription { @@ -811,6 +864,15 @@ type User { updated: Time } +type Autobind { + int: Int! + int32: Int! + int64: Int! + + idStr: ID! + idInt: ID! +} + type Error { id: ID! errorOnNonRequiredField: String @@ -1508,6 +1570,136 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg // region **************************** field.gotpl ***************************** +func (ec *executionContext) _Autobind_int(ctx context.Context, field graphql.CollectedField, obj *Autobind) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Autobind", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Int, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) _Autobind_int32(ctx context.Context, field graphql.CollectedField, obj *Autobind) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Autobind", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Int32, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int32) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNInt2int32(ctx, field.Selections, res) +} + +func (ec *executionContext) _Autobind_int64(ctx context.Context, field graphql.CollectedField, obj *Autobind) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Autobind", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Int64, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int64) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNInt2int64(ctx, field.Selections, res) +} + +func (ec *executionContext) _Autobind_idStr(ctx context.Context, field graphql.CollectedField, obj *Autobind) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Autobind", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IdStr, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) _Autobind_idInt(ctx context.Context, field graphql.CollectedField, obj *Autobind) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Autobind", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IdInt, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNID2int(ctx, field.Selections, res) +} + func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.CollectedField, obj *Circle) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2494,6 +2686,29 @@ func (ec *executionContext) _Query_shapeUnion(ctx context.Context, field graphql return ec.marshalNShapeUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShapeUnion(ctx, field.Selections, res) } +func (ec *executionContext) _Query_autobind(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Autobind(rctx) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Autobind) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalOAutobind2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐAutobind(ctx, field.Selections, res) +} + func (ec *executionContext) _Query_panics(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -4083,6 +4298,53 @@ func (ec *executionContext) _ShapeUnion(ctx context.Context, sel ast.SelectionSe // region **************************** object.gotpl **************************** +var autobindImplementors = []string{"Autobind"} + +func (ec *executionContext) _Autobind(ctx context.Context, sel ast.SelectionSet, obj *Autobind) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, autobindImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Autobind") + case "int": + out.Values[i] = ec._Autobind_int(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "int32": + out.Values[i] = ec._Autobind_int32(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "int64": + out.Values[i] = ec._Autobind_int64(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "idStr": + out.Values[i] = ec._Autobind_idStr(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "idInt": + out.Values[i] = ec._Autobind_idInt(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + var circleImplementors = []string{"Circle", "Shape", "ShapeUnion"} func (ec *executionContext) _Circle(ctx context.Context, sel ast.SelectionSet, obj *Circle) graphql.Marshaler { @@ -4659,6 +4921,17 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } return res }) + case "autobind": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_autobind(ctx, field) + return res + }) case "panics": field := field out.Concurrently(i, func() (res graphql.Marshaler) { @@ -5089,6 +5362,14 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se return graphql.MarshalBoolean(v) } +func (ec *executionContext) unmarshalNID2int(ctx context.Context, v interface{}) (int, error) { + return graphql.UnmarshalIntID(v) +} + +func (ec *executionContext) marshalNID2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { + return graphql.MarshalIntID(v) +} + func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalID(v) } @@ -5121,6 +5402,22 @@ func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.Selecti return graphql.MarshalInt(v) } +func (ec *executionContext) unmarshalNInt2int32(ctx context.Context, v interface{}) (int32, error) { + return graphql.UnmarshalInt32(v) +} + +func (ec *executionContext) marshalNInt2int32(ctx context.Context, sel ast.SelectionSet, v int32) graphql.Marshaler { + return graphql.MarshalInt32(v) +} + +func (ec *executionContext) unmarshalNInt2int64(ctx context.Context, v interface{}) (int64, error) { + return graphql.UnmarshalInt64(v) +} + +func (ec *executionContext) marshalNInt2int64(ctx context.Context, sel ast.SelectionSet, v int64) graphql.Marshaler { + return graphql.MarshalInt64(v) +} + func (ec *executionContext) unmarshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanic(ctx context.Context, v interface{}) (MarshalPanic, error) { var res MarshalPanic return res, res.UnmarshalGQL(v) @@ -5501,6 +5798,17 @@ func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel a return graphql.MarshalString(v) } +func (ec *executionContext) marshalOAutobind2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐAutobind(ctx context.Context, sel ast.SelectionSet, v Autobind) graphql.Marshaler { + return ec._Autobind(ctx, sel, &v) +} + +func (ec *executionContext) marshalOAutobind2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐAutobind(ctx context.Context, sel ast.SelectionSet, v *Autobind) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Autobind(ctx, sel, v) +} + func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } diff --git a/codegen/testserver/gqlgen.yml b/codegen/testserver/gqlgen.yml index 26a1572c51e..dff1dd02a47 100644 --- a/codegen/testserver/gqlgen.yml +++ b/codegen/testserver/gqlgen.yml @@ -54,3 +54,5 @@ models: model: "github.com/99designs/gqlgen/codegen/testserver.Panics" MarshalPanic: model: "github.com/99designs/gqlgen/codegen/testserver.MarshalPanic" + Autobind: + model: "github.com/99designs/gqlgen/codegen/testserver.Autobind" diff --git a/codegen/testserver/models.go b/codegen/testserver/models.go index bedcb790114..690b4d31d82 100644 --- a/codegen/testserver/models.go +++ b/codegen/testserver/models.go @@ -62,3 +62,12 @@ type Panics struct { func (p *Panics) FieldFuncMarshal(ctx context.Context, u []MarshalPanic) []MarshalPanic { return []MarshalPanic{MarshalPanic("aa"), MarshalPanic("bb")} } + +type Autobind struct { + Int int + Int32 int32 + Int64 int64 + + IdStr string + IdInt int +} diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index 565a4c6a4eb..91c494ab1a8 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -107,6 +107,9 @@ func (r *queryResolver) InputSlice(ctx context.Context, arg []string) (bool, err func (r *queryResolver) ShapeUnion(ctx context.Context) (ShapeUnion, error) { panic("not implemented") } +func (r *queryResolver) Autobind(ctx context.Context) (*Autobind, error) { + panic("not implemented") +} func (r *queryResolver) Panics(ctx context.Context) (*Panics, error) { panic("not implemented") } diff --git a/codegen/testserver/schema.graphql b/codegen/testserver/schema.graphql index c400847ad97..d6a7fb51274 100644 --- a/codegen/testserver/schema.graphql +++ b/codegen/testserver/schema.graphql @@ -17,6 +17,7 @@ type Query { directiveInput(arg: InputDirectives!): String inputSlice(arg: [String!]!): Boolean! shapeUnion: ShapeUnion! + autobind: Autobind } type Subscription { @@ -31,6 +32,15 @@ type User { updated: Time } +type Autobind { + int: Int! + int32: Int! + int64: Int! + + idStr: ID! + idInt: ID! +} + type Error { id: ID! errorOnNonRequiredField: String diff --git a/codegen/testserver/stub.go b/codegen/testserver/stub.go index 1e732362073..a99c44461fc 100644 --- a/codegen/testserver/stub.go +++ b/codegen/testserver/stub.go @@ -39,6 +39,7 @@ type Stub struct { DirectiveInput func(ctx context.Context, arg InputDirectives) (*string, error) InputSlice func(ctx context.Context, arg []string) (bool, error) ShapeUnion func(ctx context.Context) (ShapeUnion, error) + Autobind func(ctx context.Context) (*Autobind, error) Panics func(ctx context.Context) (*Panics, error) ValidType func(ctx context.Context) (*ValidType, error) } @@ -147,6 +148,9 @@ func (r *stubQuery) InputSlice(ctx context.Context, arg []string) (bool, error) func (r *stubQuery) ShapeUnion(ctx context.Context) (ShapeUnion, error) { return r.QueryResolver.ShapeUnion(ctx) } +func (r *stubQuery) Autobind(ctx context.Context) (*Autobind, error) { + return r.QueryResolver.Autobind(ctx) +} func (r *stubQuery) Panics(ctx context.Context) (*Panics, error) { return r.QueryResolver.Panics(ctx) } diff --git a/graphql/int.go b/graphql/int.go index ff87574cab7..57d0d589bae 100644 --- a/graphql/int.go +++ b/graphql/int.go @@ -27,3 +27,53 @@ func UnmarshalInt(v interface{}) (int, error) { return 0, fmt.Errorf("%T is not an int", v) } } + +func MarshalInt64(i int64) Marshaler { + return WriterFunc(func(w io.Writer) { + io.WriteString(w, strconv.FormatInt(i, 10)) + }) +} + +func UnmarshalInt64(v interface{}) (int64, error) { + switch v := v.(type) { + case string: + return strconv.ParseInt(v, 10, 64) + case int: + return int64(v), nil + case int64: + return v, nil + case json.Number: + return strconv.ParseInt(string(v), 10, 64) + default: + return 0, fmt.Errorf("%T is not an int", v) + } +} + +func MarshalInt32(i int32) Marshaler { + return WriterFunc(func(w io.Writer) { + io.WriteString(w, strconv.FormatInt(int64(i), 10)) + }) +} + +func UnmarshalInt32(v interface{}) (int32, error) { + switch v := v.(type) { + case string: + iv, err := strconv.ParseInt(v, 10, 32) + if err != nil { + return 0, err + } + return int32(iv), nil + case int: + return int32(v), nil + case int64: + return int32(v), nil + case json.Number: + iv, err := strconv.ParseInt(string(v), 10, 32) + if err != nil { + return 0, err + } + return int32(iv), nil + default: + return 0, fmt.Errorf("%T is not an int", v) + } +} diff --git a/graphql/int_test.go b/graphql/int_test.go new file mode 100644 index 00000000000..ada9ca5d8bc --- /dev/null +++ b/graphql/int_test.go @@ -0,0 +1,71 @@ +package graphql + +import ( + "encoding/json" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestInt(t *testing.T) { + t.Run("marshal", func(t *testing.T) { + assert.Equal(t, "123", m2s(MarshalInt(123))) + }) + + t.Run("unmarshal", func(t *testing.T) { + assert.Equal(t, 123, mustUnmarshalInt(123)) + assert.Equal(t, 123, mustUnmarshalInt(int64(123))) + assert.Equal(t, 123, mustUnmarshalInt(json.Number("123"))) + assert.Equal(t, 123, mustUnmarshalInt("123")) + }) +} + +func mustUnmarshalInt(v interface{}) int { + res, err := UnmarshalInt(v) + if err != nil { + panic(err) + } + return res +} + +func TestInt32(t *testing.T) { + t.Run("marshal", func(t *testing.T) { + assert.Equal(t, "123", m2s(MarshalInt32(123))) + }) + + t.Run("unmarshal", func(t *testing.T) { + assert.Equal(t, int32(123), mustUnmarshalInt32(123)) + assert.Equal(t, int32(123), mustUnmarshalInt32(int64(123))) + assert.Equal(t, int32(123), mustUnmarshalInt32(json.Number("123"))) + assert.Equal(t, int32(123), mustUnmarshalInt32("123")) + }) +} + +func mustUnmarshalInt32(v interface{}) int32 { + res, err := UnmarshalInt32(v) + if err != nil { + panic(err) + } + return res +} + +func TestInt64(t *testing.T) { + t.Run("marshal", func(t *testing.T) { + assert.Equal(t, "123", m2s(MarshalInt32(123))) + }) + + t.Run("unmarshal", func(t *testing.T) { + assert.Equal(t, int64(123), mustUnmarshalInt64(123)) + assert.Equal(t, int64(123), mustUnmarshalInt64(int64(123))) + assert.Equal(t, int64(123), mustUnmarshalInt64(json.Number("123"))) + assert.Equal(t, int64(123), mustUnmarshalInt64("123")) + }) +} + +func mustUnmarshalInt64(v interface{}) int64 { + res, err := UnmarshalInt64(v) + if err != nil { + panic(err) + } + return res +} From 08923334725c963ffcff948efe030881d658c38a Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Mon, 4 Mar 2019 15:11:34 +1100 Subject: [PATCH 109/147] Handle non-existant directories when generating default package names --- example/starwars/.gqlgen.yml | 15 +- example/starwars/benchmarks_test.go | 3 +- .../{generated.go => generated/exec.go} | 363 +++++++++--------- .../{models_gen.go => models/generated.go} | 2 +- example/starwars/{ => models}/model.go | 56 +-- example/starwars/resolvers.go | 166 ++++---- example/starwars/server/server.go | 3 +- example/starwars/starwars_test.go | 3 +- internal/code/imports.go | 16 +- internal/code/imports_test.go | 2 +- plugin/stubgen/stubs.go | 8 +- 11 files changed, 335 insertions(+), 302 deletions(-) rename example/starwars/{generated.go => generated/exec.go} (90%) rename example/starwars/{models_gen.go => models/generated.go} (99%) rename example/starwars/{ => models}/model.go (50%) diff --git a/example/starwars/.gqlgen.yml b/example/starwars/.gqlgen.yml index 49f10ad9700..42d07800ed9 100644 --- a/example/starwars/.gqlgen.yml +++ b/example/starwars/.gqlgen.yml @@ -1,14 +1,19 @@ +exec: + filename: generated/exec.go +model: + filename: models/generated.go + models: Droid: - model: github.com/99designs/gqlgen/example/starwars.Droid + model: github.com/99designs/gqlgen/example/starwars/models.Droid FriendsConnection: - model: github.com/99designs/gqlgen/example/starwars.FriendsConnection + model: github.com/99designs/gqlgen/example/starwars/models.FriendsConnection Human: - model: github.com/99designs/gqlgen/example/starwars.Human + model: github.com/99designs/gqlgen/example/starwars/models.Human Review: - model: github.com/99designs/gqlgen/example/starwars.Review + model: github.com/99designs/gqlgen/example/starwars/models.Review ReviewInput: - model: github.com/99designs/gqlgen/example/starwars.Review + model: github.com/99designs/gqlgen/example/starwars/models.Review Starship: fields: length: diff --git a/example/starwars/benchmarks_test.go b/example/starwars/benchmarks_test.go index 8386b7963f0..f0d9e1f0438 100644 --- a/example/starwars/benchmarks_test.go +++ b/example/starwars/benchmarks_test.go @@ -5,11 +5,12 @@ import ( "strings" "testing" + "github.com/99designs/gqlgen/example/starwars/generated" "github.com/99designs/gqlgen/handler" ) func BenchmarkSimpleQueryNoArgs(b *testing.B) { - server := handler.GraphQL(NewExecutableSchema(NewResolver())) + server := handler.GraphQL(generated.NewExecutableSchema(NewResolver())) q := `{"query":"{ search(text:\"Luke\") { ... on Human { starships { name } } } }"}` diff --git a/example/starwars/generated.go b/example/starwars/generated/exec.go similarity index 90% rename from example/starwars/generated.go rename to example/starwars/generated/exec.go index 99116eac698..65c84b4aa76 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated/exec.go @@ -1,6 +1,6 @@ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. -package starwars +package generated import ( "bytes" @@ -11,6 +11,7 @@ import ( "sync" "time" + "github.com/99designs/gqlgen/example/starwars/models" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" "github.com/vektah/gqlparser" @@ -71,7 +72,7 @@ type ComplexityRoot struct { Human struct { ID func(childComplexity int) int Name func(childComplexity int) int - Height func(childComplexity int, unit LengthUnit) int + Height func(childComplexity int, unit models.LengthUnit) int Mass func(childComplexity int) int Friends func(childComplexity int) int FriendsConnection func(childComplexity int, first *int, after *string) int @@ -80,7 +81,7 @@ type ComplexityRoot struct { } Mutation struct { - CreateReview func(childComplexity int, episode Episode, review Review) int + CreateReview func(childComplexity int, episode models.Episode, review models.Review) int } PageInfo struct { @@ -90,8 +91,8 @@ type ComplexityRoot struct { } Query struct { - Hero func(childComplexity int, episode *Episode) int - Reviews func(childComplexity int, episode Episode, since *time.Time) int + Hero func(childComplexity int, episode *models.Episode) int + Reviews func(childComplexity int, episode models.Episode, since *time.Time) int Search func(childComplexity int, text string) int Character func(childComplexity int, id string) int Droid func(childComplexity int, id string) int @@ -108,39 +109,39 @@ type ComplexityRoot struct { Starship struct { ID func(childComplexity int) int Name func(childComplexity int) int - Length func(childComplexity int, unit *LengthUnit) int + Length func(childComplexity int, unit *models.LengthUnit) int History func(childComplexity int) int } } type DroidResolver interface { - Friends(ctx context.Context, obj *Droid) ([]Character, error) - FriendsConnection(ctx context.Context, obj *Droid, first *int, after *string) (*FriendsConnection, error) + Friends(ctx context.Context, obj *models.Droid) ([]models.Character, error) + FriendsConnection(ctx context.Context, obj *models.Droid, first *int, after *string) (*models.FriendsConnection, error) } type FriendsConnectionResolver interface { - Edges(ctx context.Context, obj *FriendsConnection) ([]FriendsEdge, error) - Friends(ctx context.Context, obj *FriendsConnection) ([]Character, error) + Edges(ctx context.Context, obj *models.FriendsConnection) ([]models.FriendsEdge, error) + Friends(ctx context.Context, obj *models.FriendsConnection) ([]models.Character, error) } type HumanResolver interface { - Friends(ctx context.Context, obj *Human) ([]Character, error) - FriendsConnection(ctx context.Context, obj *Human, first *int, after *string) (*FriendsConnection, error) + Friends(ctx context.Context, obj *models.Human) ([]models.Character, error) + FriendsConnection(ctx context.Context, obj *models.Human, first *int, after *string) (*models.FriendsConnection, error) - Starships(ctx context.Context, obj *Human) ([]Starship, error) + Starships(ctx context.Context, obj *models.Human) ([]models.Starship, error) } type MutationResolver interface { - CreateReview(ctx context.Context, episode Episode, review Review) (*Review, error) + CreateReview(ctx context.Context, episode models.Episode, review models.Review) (*models.Review, error) } type QueryResolver interface { - Hero(ctx context.Context, episode *Episode) (Character, error) - Reviews(ctx context.Context, episode Episode, since *time.Time) ([]Review, error) - Search(ctx context.Context, text string) ([]SearchResult, error) - Character(ctx context.Context, id string) (Character, error) - Droid(ctx context.Context, id string) (*Droid, error) - Human(ctx context.Context, id string) (*Human, error) - Starship(ctx context.Context, id string) (*Starship, error) + Hero(ctx context.Context, episode *models.Episode) (models.Character, error) + Reviews(ctx context.Context, episode models.Episode, since *time.Time) ([]models.Review, error) + Search(ctx context.Context, text string) ([]models.SearchResult, error) + Character(ctx context.Context, id string) (models.Character, error) + Droid(ctx context.Context, id string) (*models.Droid, error) + Human(ctx context.Context, id string) (*models.Human, error) + Starship(ctx context.Context, id string) (*models.Starship, error) } type StarshipResolver interface { - Length(ctx context.Context, obj *Starship, unit *LengthUnit) (float64, error) + Length(ctx context.Context, obj *models.Starship, unit *models.LengthUnit) (float64, error) } type executableSchema struct { @@ -271,7 +272,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Human.Height(childComplexity, args["unit"].(LengthUnit)), true + return e.complexity.Human.Height(childComplexity, args["unit"].(models.LengthUnit)), true case "Human.Mass": if e.complexity.Human.Mass == nil { @@ -323,7 +324,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Mutation.CreateReview(childComplexity, args["episode"].(Episode), args["review"].(Review)), true + return e.complexity.Mutation.CreateReview(childComplexity, args["episode"].(models.Episode), args["review"].(models.Review)), true case "PageInfo.StartCursor": if e.complexity.PageInfo.StartCursor == nil { @@ -356,7 +357,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Query.Hero(childComplexity, args["episode"].(*Episode)), true + return e.complexity.Query.Hero(childComplexity, args["episode"].(*models.Episode)), true case "Query.Reviews": if e.complexity.Query.Reviews == nil { @@ -368,7 +369,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Query.Reviews(childComplexity, args["episode"].(Episode), args["since"].(*time.Time)), true + return e.complexity.Query.Reviews(childComplexity, args["episode"].(models.Episode), args["since"].(*time.Time)), true case "Query.Search": if e.complexity.Query.Search == nil { @@ -475,7 +476,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Starship.Length(childComplexity, args["unit"].(*LengthUnit)), true + return e.complexity.Starship.Length(childComplexity, args["unit"].(*models.LengthUnit)), true case "Starship.History": if e.complexity.Starship.History == nil { @@ -746,9 +747,9 @@ func (ec *executionContext) field_Human_friendsConnection_args(ctx context.Conte func (ec *executionContext) field_Human_height_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} - var arg0 LengthUnit + var arg0 models.LengthUnit if tmp, ok := rawArgs["unit"]; ok { - arg0, err = ec.unmarshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(ctx, tmp) + arg0, err = ec.unmarshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐLengthUnit(ctx, tmp) if err != nil { return nil, err } @@ -760,17 +761,17 @@ func (ec *executionContext) field_Human_height_args(ctx context.Context, rawArgs func (ec *executionContext) field_Mutation_createReview_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} - var arg0 Episode + var arg0 models.Episode if tmp, ok := rawArgs["episode"]; ok { - arg0, err = ec.unmarshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx, tmp) + arg0, err = ec.unmarshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐEpisode(ctx, tmp) if err != nil { return nil, err } } args["episode"] = arg0 - var arg1 Review + var arg1 models.Review if tmp, ok := rawArgs["review"]; ok { - arg1, err = ec.unmarshalNReviewInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx, tmp) + arg1, err = ec.unmarshalNReviewInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐReview(ctx, tmp) if err != nil { return nil, err } @@ -824,9 +825,9 @@ func (ec *executionContext) field_Query_droid_args(ctx context.Context, rawArgs func (ec *executionContext) field_Query_hero_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} - var arg0 *Episode + var arg0 *models.Episode if tmp, ok := rawArgs["episode"]; ok { - arg0, err = ec.unmarshalOEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx, tmp) + arg0, err = ec.unmarshalOEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐEpisode(ctx, tmp) if err != nil { return nil, err } @@ -852,9 +853,9 @@ func (ec *executionContext) field_Query_human_args(ctx context.Context, rawArgs func (ec *executionContext) field_Query_reviews_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} - var arg0 Episode + var arg0 models.Episode if tmp, ok := rawArgs["episode"]; ok { - arg0, err = ec.unmarshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx, tmp) + arg0, err = ec.unmarshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐEpisode(ctx, tmp) if err != nil { return nil, err } @@ -902,9 +903,9 @@ func (ec *executionContext) field_Query_starship_args(ctx context.Context, rawAr func (ec *executionContext) field_Starship_length_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} - var arg0 *LengthUnit + var arg0 *models.LengthUnit if tmp, ok := rawArgs["unit"]; ok { - arg0, err = ec.unmarshalOLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(ctx, tmp) + arg0, err = ec.unmarshalOLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐLengthUnit(ctx, tmp) if err != nil { return nil, err } @@ -945,7 +946,7 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg // region **************************** field.gotpl ***************************** -func (ec *executionContext) _Droid_id(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { +func (ec *executionContext) _Droid_id(ctx context.Context, field graphql.CollectedField, obj *models.Droid) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -971,7 +972,7 @@ func (ec *executionContext) _Droid_id(ctx context.Context, field graphql.Collect return ec.marshalNID2string(ctx, field.Selections, res) } -func (ec *executionContext) _Droid_name(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { +func (ec *executionContext) _Droid_name(ctx context.Context, field graphql.CollectedField, obj *models.Droid) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -997,7 +998,7 @@ func (ec *executionContext) _Droid_name(ctx context.Context, field graphql.Colle return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Droid_friends(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { +func (ec *executionContext) _Droid_friends(ctx context.Context, field graphql.CollectedField, obj *models.Droid) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1014,13 +1015,13 @@ func (ec *executionContext) _Droid_friends(ctx context.Context, field graphql.Co if resTmp == nil { return graphql.Null } - res := resTmp.([]Character) + res := resTmp.([]models.Character) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, field.Selections, res) + return ec.marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐCharacter(ctx, field.Selections, res) } -func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { +func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *models.Droid) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1047,13 +1048,13 @@ func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field } return graphql.Null } - res := resTmp.(*FriendsConnection) + res := resTmp.(*models.FriendsConnection) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNFriendsConnection2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsConnection(ctx, field.Selections, res) + return ec.marshalNFriendsConnection2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐFriendsConnection(ctx, field.Selections, res) } -func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { +func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql.CollectedField, obj *models.Droid) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1073,13 +1074,13 @@ func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql. } return graphql.Null } - res := resTmp.([]Episode) + res := resTmp.([]models.Episode) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx, field.Selections, res) + return ec.marshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐEpisode(ctx, field.Selections, res) } -func (ec *executionContext) _Droid_primaryFunction(ctx context.Context, field graphql.CollectedField, obj *Droid) graphql.Marshaler { +func (ec *executionContext) _Droid_primaryFunction(ctx context.Context, field graphql.CollectedField, obj *models.Droid) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1102,7 +1103,7 @@ func (ec *executionContext) _Droid_primaryFunction(ctx context.Context, field gr return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) _FriendsConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { +func (ec *executionContext) _FriendsConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *models.FriendsConnection) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1128,7 +1129,7 @@ func (ec *executionContext) _FriendsConnection_totalCount(ctx context.Context, f return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) _FriendsConnection_edges(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { +func (ec *executionContext) _FriendsConnection_edges(ctx context.Context, field graphql.CollectedField, obj *models.FriendsConnection) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1145,13 +1146,13 @@ func (ec *executionContext) _FriendsConnection_edges(ctx context.Context, field if resTmp == nil { return graphql.Null } - res := resTmp.([]FriendsEdge) + res := resTmp.([]models.FriendsEdge) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOFriendsEdge2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsEdge(ctx, field.Selections, res) + return ec.marshalOFriendsEdge2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐFriendsEdge(ctx, field.Selections, res) } -func (ec *executionContext) _FriendsConnection_friends(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { +func (ec *executionContext) _FriendsConnection_friends(ctx context.Context, field graphql.CollectedField, obj *models.FriendsConnection) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1168,13 +1169,13 @@ func (ec *executionContext) _FriendsConnection_friends(ctx context.Context, fiel if resTmp == nil { return graphql.Null } - res := resTmp.([]Character) + res := resTmp.([]models.Character) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, field.Selections, res) + return ec.marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐCharacter(ctx, field.Selections, res) } -func (ec *executionContext) _FriendsConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *FriendsConnection) graphql.Marshaler { +func (ec *executionContext) _FriendsConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *models.FriendsConnection) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1194,13 +1195,13 @@ func (ec *executionContext) _FriendsConnection_pageInfo(ctx context.Context, fie } return graphql.Null } - res := resTmp.(PageInfo) + res := resTmp.(models.PageInfo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNPageInfo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐPageInfo(ctx, field.Selections, res) + return ec.marshalNPageInfo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐPageInfo(ctx, field.Selections, res) } -func (ec *executionContext) _FriendsEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *FriendsEdge) graphql.Marshaler { +func (ec *executionContext) _FriendsEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *models.FriendsEdge) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1226,7 +1227,7 @@ func (ec *executionContext) _FriendsEdge_cursor(ctx context.Context, field graph return ec.marshalNID2string(ctx, field.Selections, res) } -func (ec *executionContext) _FriendsEdge_node(ctx context.Context, field graphql.CollectedField, obj *FriendsEdge) graphql.Marshaler { +func (ec *executionContext) _FriendsEdge_node(ctx context.Context, field graphql.CollectedField, obj *models.FriendsEdge) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1243,13 +1244,13 @@ func (ec *executionContext) _FriendsEdge_node(ctx context.Context, field graphql if resTmp == nil { return graphql.Null } - res := resTmp.(Character) + res := resTmp.(models.Character) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, field.Selections, res) + return ec.marshalOCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐCharacter(ctx, field.Selections, res) } -func (ec *executionContext) _Human_id(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { +func (ec *executionContext) _Human_id(ctx context.Context, field graphql.CollectedField, obj *models.Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1275,7 +1276,7 @@ func (ec *executionContext) _Human_id(ctx context.Context, field graphql.Collect return ec.marshalNID2string(ctx, field.Selections, res) } -func (ec *executionContext) _Human_name(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { +func (ec *executionContext) _Human_name(ctx context.Context, field graphql.CollectedField, obj *models.Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1301,7 +1302,7 @@ func (ec *executionContext) _Human_name(ctx context.Context, field graphql.Colle return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Human_height(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { +func (ec *executionContext) _Human_height(ctx context.Context, field graphql.CollectedField, obj *models.Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1320,7 +1321,7 @@ func (ec *executionContext) _Human_height(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Height(args["unit"].(LengthUnit)), nil + return obj.Height(args["unit"].(models.LengthUnit)), nil }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1334,7 +1335,7 @@ func (ec *executionContext) _Human_height(ctx context.Context, field graphql.Col return ec.marshalNFloat2float64(ctx, field.Selections, res) } -func (ec *executionContext) _Human_mass(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { +func (ec *executionContext) _Human_mass(ctx context.Context, field graphql.CollectedField, obj *models.Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1357,7 +1358,7 @@ func (ec *executionContext) _Human_mass(ctx context.Context, field graphql.Colle return ec.marshalOFloat2float64(ctx, field.Selections, res) } -func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { +func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.CollectedField, obj *models.Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1374,13 +1375,13 @@ func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.Co if resTmp == nil { return graphql.Null } - res := resTmp.([]Character) + res := resTmp.([]models.Character) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, field.Selections, res) + return ec.marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐCharacter(ctx, field.Selections, res) } -func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { +func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *models.Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1407,13 +1408,13 @@ func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field } return graphql.Null } - res := resTmp.(*FriendsConnection) + res := resTmp.(*models.FriendsConnection) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNFriendsConnection2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsConnection(ctx, field.Selections, res) + return ec.marshalNFriendsConnection2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐFriendsConnection(ctx, field.Selections, res) } -func (ec *executionContext) _Human_appearsIn(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { +func (ec *executionContext) _Human_appearsIn(ctx context.Context, field graphql.CollectedField, obj *models.Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1433,13 +1434,13 @@ func (ec *executionContext) _Human_appearsIn(ctx context.Context, field graphql. } return graphql.Null } - res := resTmp.([]Episode) + res := resTmp.([]models.Episode) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx, field.Selections, res) + return ec.marshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐEpisode(ctx, field.Selections, res) } -func (ec *executionContext) _Human_starships(ctx context.Context, field graphql.CollectedField, obj *Human) graphql.Marshaler { +func (ec *executionContext) _Human_starships(ctx context.Context, field graphql.CollectedField, obj *models.Human) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1456,10 +1457,10 @@ func (ec *executionContext) _Human_starships(ctx context.Context, field graphql. if resTmp == nil { return graphql.Null } - res := resTmp.([]Starship) + res := resTmp.([]models.Starship) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOStarship2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx, field.Selections, res) + return ec.marshalOStarship2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐStarship(ctx, field.Selections, res) } func (ec *executionContext) _Mutation_createReview(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1481,18 +1482,18 @@ func (ec *executionContext) _Mutation_createReview(ctx context.Context, field gr ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().CreateReview(rctx, args["episode"].(Episode), args["review"].(Review)) + return ec.resolvers.Mutation().CreateReview(rctx, args["episode"].(models.Episode), args["review"].(models.Review)) }) if resTmp == nil { return graphql.Null } - res := resTmp.(*Review) + res := resTmp.(*models.Review) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOReview2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx, field.Selections, res) + return ec.marshalOReview2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐReview(ctx, field.Selections, res) } -func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *PageInfo) graphql.Marshaler { +func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *models.PageInfo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1518,7 +1519,7 @@ func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field gra return ec.marshalNID2string(ctx, field.Selections, res) } -func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *PageInfo) graphql.Marshaler { +func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *models.PageInfo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1544,7 +1545,7 @@ func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graph return ec.marshalNID2string(ctx, field.Selections, res) } -func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *PageInfo) graphql.Marshaler { +func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *models.PageInfo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1589,15 +1590,15 @@ func (ec *executionContext) _Query_hero(ctx context.Context, field graphql.Colle ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Hero(rctx, args["episode"].(*Episode)) + return ec.resolvers.Query().Hero(rctx, args["episode"].(*models.Episode)) }) if resTmp == nil { return graphql.Null } - res := resTmp.(Character) + res := resTmp.(models.Character) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, field.Selections, res) + return ec.marshalOCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐCharacter(ctx, field.Selections, res) } func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1619,7 +1620,7 @@ func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Reviews(rctx, args["episode"].(Episode), args["since"].(*time.Time)) + return ec.resolvers.Query().Reviews(rctx, args["episode"].(models.Episode), args["since"].(*time.Time)) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1627,10 +1628,10 @@ func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.([]Review) + res := resTmp.([]models.Review) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNReview2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx, field.Selections, res) + return ec.marshalNReview2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐReview(ctx, field.Selections, res) } func (ec *executionContext) _Query_search(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1660,10 +1661,10 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.([]SearchResult) + res := resTmp.([]models.SearchResult) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNSearchResult2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐSearchResult(ctx, field.Selections, res) + return ec.marshalNSearchResult2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐSearchResult(ctx, field.Selections, res) } func (ec *executionContext) _Query_character(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1690,10 +1691,10 @@ func (ec *executionContext) _Query_character(ctx context.Context, field graphql. if resTmp == nil { return graphql.Null } - res := resTmp.(Character) + res := resTmp.(models.Character) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, field.Selections, res) + return ec.marshalOCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐCharacter(ctx, field.Selections, res) } func (ec *executionContext) _Query_droid(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1720,10 +1721,10 @@ func (ec *executionContext) _Query_droid(ctx context.Context, field graphql.Coll if resTmp == nil { return graphql.Null } - res := resTmp.(*Droid) + res := resTmp.(*models.Droid) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalODroid2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐDroid(ctx, field.Selections, res) + return ec.marshalODroid2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐDroid(ctx, field.Selections, res) } func (ec *executionContext) _Query_human(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1750,10 +1751,10 @@ func (ec *executionContext) _Query_human(ctx context.Context, field graphql.Coll if resTmp == nil { return graphql.Null } - res := resTmp.(*Human) + res := resTmp.(*models.Human) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOHuman2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐHuman(ctx, field.Selections, res) + return ec.marshalOHuman2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐHuman(ctx, field.Selections, res) } func (ec *executionContext) _Query_starship(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1780,10 +1781,10 @@ func (ec *executionContext) _Query_starship(ctx context.Context, field graphql.C if resTmp == nil { return graphql.Null } - res := resTmp.(*Starship) + res := resTmp.(*models.Starship) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOStarship2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx, field.Selections, res) + return ec.marshalOStarship2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐStarship(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { @@ -1839,7 +1840,7 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } -func (ec *executionContext) _Review_stars(ctx context.Context, field graphql.CollectedField, obj *Review) graphql.Marshaler { +func (ec *executionContext) _Review_stars(ctx context.Context, field graphql.CollectedField, obj *models.Review) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1865,7 +1866,7 @@ func (ec *executionContext) _Review_stars(ctx context.Context, field graphql.Col return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) _Review_commentary(ctx context.Context, field graphql.CollectedField, obj *Review) graphql.Marshaler { +func (ec *executionContext) _Review_commentary(ctx context.Context, field graphql.CollectedField, obj *models.Review) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1888,7 +1889,7 @@ func (ec *executionContext) _Review_commentary(ctx context.Context, field graphq return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _Review_time(ctx context.Context, field graphql.CollectedField, obj *Review) graphql.Marshaler { +func (ec *executionContext) _Review_time(ctx context.Context, field graphql.CollectedField, obj *models.Review) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1911,7 +1912,7 @@ func (ec *executionContext) _Review_time(ctx context.Context, field graphql.Coll return ec.marshalOTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) _Starship_id(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { +func (ec *executionContext) _Starship_id(ctx context.Context, field graphql.CollectedField, obj *models.Starship) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1937,7 +1938,7 @@ func (ec *executionContext) _Starship_id(ctx context.Context, field graphql.Coll return ec.marshalNID2string(ctx, field.Selections, res) } -func (ec *executionContext) _Starship_name(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { +func (ec *executionContext) _Starship_name(ctx context.Context, field graphql.CollectedField, obj *models.Starship) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1963,7 +1964,7 @@ func (ec *executionContext) _Starship_name(ctx context.Context, field graphql.Co return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Starship_length(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { +func (ec *executionContext) _Starship_length(ctx context.Context, field graphql.CollectedField, obj *models.Starship) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1982,7 +1983,7 @@ func (ec *executionContext) _Starship_length(ctx context.Context, field graphql. ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Starship().Length(rctx, obj, args["unit"].(*LengthUnit)) + return ec.resolvers.Starship().Length(rctx, obj, args["unit"].(*models.LengthUnit)) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1996,7 +1997,7 @@ func (ec *executionContext) _Starship_length(ctx context.Context, field graphql. return ec.marshalNFloat2float64(ctx, field.Selections, res) } -func (ec *executionContext) _Starship_history(ctx context.Context, field graphql.CollectedField, obj *Starship) graphql.Marshaler { +func (ec *executionContext) _Starship_history(ctx context.Context, field graphql.CollectedField, obj *models.Starship) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -2821,8 +2822,8 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co // region **************************** input.gotpl ***************************** -func (ec *executionContext) unmarshalInputReviewInput(ctx context.Context, v interface{}) (Review, error) { - var it Review +func (ec *executionContext) unmarshalInputReviewInput(ctx context.Context, v interface{}) (models.Review, error) { + var it models.Review var asMap = v.(map[string]interface{}) for k, v := range asMap { @@ -2855,38 +2856,38 @@ func (ec *executionContext) unmarshalInputReviewInput(ctx context.Context, v int // region ************************** interface.gotpl *************************** -func (ec *executionContext) _Character(ctx context.Context, sel ast.SelectionSet, obj *Character) graphql.Marshaler { +func (ec *executionContext) _Character(ctx context.Context, sel ast.SelectionSet, obj *models.Character) graphql.Marshaler { switch obj := (*obj).(type) { case nil: return graphql.Null - case Human: + case models.Human: return ec._Human(ctx, sel, &obj) - case *Human: + case *models.Human: return ec._Human(ctx, sel, obj) - case Droid: + case models.Droid: return ec._Droid(ctx, sel, &obj) - case *Droid: + case *models.Droid: return ec._Droid(ctx, sel, obj) default: panic(fmt.Errorf("unexpected type %T", obj)) } } -func (ec *executionContext) _SearchResult(ctx context.Context, sel ast.SelectionSet, obj *SearchResult) graphql.Marshaler { +func (ec *executionContext) _SearchResult(ctx context.Context, sel ast.SelectionSet, obj *models.SearchResult) graphql.Marshaler { switch obj := (*obj).(type) { case nil: return graphql.Null - case Human: + case models.Human: return ec._Human(ctx, sel, &obj) - case *Human: + case *models.Human: return ec._Human(ctx, sel, obj) - case Droid: + case models.Droid: return ec._Droid(ctx, sel, &obj) - case *Droid: + case *models.Droid: return ec._Droid(ctx, sel, obj) - case Starship: + case models.Starship: return ec._Starship(ctx, sel, &obj) - case *Starship: + case *models.Starship: return ec._Starship(ctx, sel, obj) default: panic(fmt.Errorf("unexpected type %T", obj)) @@ -2899,7 +2900,7 @@ func (ec *executionContext) _SearchResult(ctx context.Context, sel ast.Selection var droidImplementors = []string{"Droid", "Character", "SearchResult"} -func (ec *executionContext) _Droid(ctx context.Context, sel ast.SelectionSet, obj *Droid) graphql.Marshaler { +func (ec *executionContext) _Droid(ctx context.Context, sel ast.SelectionSet, obj *models.Droid) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, droidImplementors) out := graphql.NewFieldSet(fields) @@ -2963,7 +2964,7 @@ func (ec *executionContext) _Droid(ctx context.Context, sel ast.SelectionSet, ob var friendsConnectionImplementors = []string{"FriendsConnection"} -func (ec *executionContext) _FriendsConnection(ctx context.Context, sel ast.SelectionSet, obj *FriendsConnection) graphql.Marshaler { +func (ec *executionContext) _FriendsConnection(ctx context.Context, sel ast.SelectionSet, obj *models.FriendsConnection) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, friendsConnectionImplementors) out := graphql.NewFieldSet(fields) @@ -3017,7 +3018,7 @@ func (ec *executionContext) _FriendsConnection(ctx context.Context, sel ast.Sele var friendsEdgeImplementors = []string{"FriendsEdge"} -func (ec *executionContext) _FriendsEdge(ctx context.Context, sel ast.SelectionSet, obj *FriendsEdge) graphql.Marshaler { +func (ec *executionContext) _FriendsEdge(ctx context.Context, sel ast.SelectionSet, obj *models.FriendsEdge) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, friendsEdgeImplementors) out := graphql.NewFieldSet(fields) @@ -3046,7 +3047,7 @@ func (ec *executionContext) _FriendsEdge(ctx context.Context, sel ast.SelectionS var humanImplementors = []string{"Human", "Character", "SearchResult"} -func (ec *executionContext) _Human(ctx context.Context, sel ast.SelectionSet, obj *Human) graphql.Marshaler { +func (ec *executionContext) _Human(ctx context.Context, sel ast.SelectionSet, obj *models.Human) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, humanImplementors) out := graphql.NewFieldSet(fields) @@ -3154,7 +3155,7 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) var pageInfoImplementors = []string{"PageInfo"} -func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *PageInfo) graphql.Marshaler { +func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *models.PageInfo) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, pageInfoImplementors) out := graphql.NewFieldSet(fields) @@ -3304,7 +3305,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr var reviewImplementors = []string{"Review"} -func (ec *executionContext) _Review(ctx context.Context, sel ast.SelectionSet, obj *Review) graphql.Marshaler { +func (ec *executionContext) _Review(ctx context.Context, sel ast.SelectionSet, obj *models.Review) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, reviewImplementors) out := graphql.NewFieldSet(fields) @@ -3335,7 +3336,7 @@ func (ec *executionContext) _Review(ctx context.Context, sel ast.SelectionSet, o var starshipImplementors = []string{"Starship", "SearchResult"} -func (ec *executionContext) _Starship(ctx context.Context, sel ast.SelectionSet, obj *Starship) graphql.Marshaler { +func (ec *executionContext) _Starship(ctx context.Context, sel ast.SelectionSet, obj *models.Starship) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, starshipImplementors) out := graphql.NewFieldSet(fields) @@ -3637,20 +3638,20 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se return graphql.MarshalBoolean(v) } -func (ec *executionContext) marshalNCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v Character) graphql.Marshaler { +func (ec *executionContext) marshalNCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v models.Character) graphql.Marshaler { return ec._Character(ctx, sel, &v) } -func (ec *executionContext) unmarshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, v interface{}) (Episode, error) { - var res Episode +func (ec *executionContext) unmarshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐEpisode(ctx context.Context, v interface{}) (models.Episode, error) { + var res models.Episode return res, res.UnmarshalGQL(v) } -func (ec *executionContext) marshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v Episode) graphql.Marshaler { +func (ec *executionContext) marshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v models.Episode) graphql.Marshaler { return v } -func (ec *executionContext) unmarshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, v interface{}) ([]Episode, error) { +func (ec *executionContext) unmarshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐEpisode(ctx context.Context, v interface{}) ([]models.Episode, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -3660,9 +3661,9 @@ func (ec *executionContext) unmarshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlg } } var err error - res := make([]Episode, len(vSlice)) + res := make([]models.Episode, len(vSlice)) for i := range vSlice { - res[i], err = ec.unmarshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx, vSlice[i]) + res[i], err = ec.unmarshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐEpisode(ctx, vSlice[i]) if err != nil { return nil, err } @@ -3670,7 +3671,7 @@ func (ec *executionContext) unmarshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlg return res, nil } -func (ec *executionContext) marshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v []Episode) graphql.Marshaler { +func (ec *executionContext) marshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v []models.Episode) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -3694,7 +3695,7 @@ func (ec *executionContext) marshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx, sel, v[i]) + ret[i] = ec.marshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐEpisode(ctx, sel, v[i]) } if isLen1 { f(i) @@ -3715,11 +3716,11 @@ func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.S return graphql.MarshalFloat(v) } -func (ec *executionContext) marshalNFriendsConnection2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsConnection(ctx context.Context, sel ast.SelectionSet, v FriendsConnection) graphql.Marshaler { +func (ec *executionContext) marshalNFriendsConnection2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐFriendsConnection(ctx context.Context, sel ast.SelectionSet, v models.FriendsConnection) graphql.Marshaler { return ec._FriendsConnection(ctx, sel, &v) } -func (ec *executionContext) marshalNFriendsConnection2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsConnection(ctx context.Context, sel ast.SelectionSet, v *FriendsConnection) graphql.Marshaler { +func (ec *executionContext) marshalNFriendsConnection2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐFriendsConnection(ctx context.Context, sel ast.SelectionSet, v *models.FriendsConnection) graphql.Marshaler { if v == nil { if !ec.HasError(graphql.GetResolverContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -3729,7 +3730,7 @@ func (ec *executionContext) marshalNFriendsConnection2ᚖgithubᚗcomᚋ99design return ec._FriendsConnection(ctx, sel, v) } -func (ec *executionContext) marshalNFriendsEdge2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsEdge(ctx context.Context, sel ast.SelectionSet, v FriendsEdge) graphql.Marshaler { +func (ec *executionContext) marshalNFriendsEdge2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐFriendsEdge(ctx context.Context, sel ast.SelectionSet, v models.FriendsEdge) graphql.Marshaler { return ec._FriendsEdge(ctx, sel, &v) } @@ -3807,15 +3808,15 @@ func (ec *executionContext) marshalNInt2ᚕᚕint(ctx context.Context, sel ast.S return ret } -func (ec *executionContext) marshalNPageInfo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐPageInfo(ctx context.Context, sel ast.SelectionSet, v PageInfo) graphql.Marshaler { +func (ec *executionContext) marshalNPageInfo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐPageInfo(ctx context.Context, sel ast.SelectionSet, v models.PageInfo) graphql.Marshaler { return ec._PageInfo(ctx, sel, &v) } -func (ec *executionContext) marshalNReview2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx context.Context, sel ast.SelectionSet, v Review) graphql.Marshaler { +func (ec *executionContext) marshalNReview2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐReview(ctx context.Context, sel ast.SelectionSet, v models.Review) graphql.Marshaler { return ec._Review(ctx, sel, &v) } -func (ec *executionContext) marshalNReview2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx context.Context, sel ast.SelectionSet, v []Review) graphql.Marshaler { +func (ec *executionContext) marshalNReview2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐReview(ctx context.Context, sel ast.SelectionSet, v []models.Review) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -3839,7 +3840,7 @@ func (ec *executionContext) marshalNReview2ᚕgithubᚗcomᚋ99designsᚋgqlgen if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNReview2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx, sel, v[i]) + ret[i] = ec.marshalNReview2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐReview(ctx, sel, v[i]) } if isLen1 { f(i) @@ -3852,15 +3853,15 @@ func (ec *executionContext) marshalNReview2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) unmarshalNReviewInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx context.Context, v interface{}) (Review, error) { +func (ec *executionContext) unmarshalNReviewInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐReview(ctx context.Context, v interface{}) (models.Review, error) { return ec.unmarshalInputReviewInput(ctx, v) } -func (ec *executionContext) marshalNSearchResult2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐSearchResult(ctx context.Context, sel ast.SelectionSet, v SearchResult) graphql.Marshaler { +func (ec *executionContext) marshalNSearchResult2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐSearchResult(ctx context.Context, sel ast.SelectionSet, v models.SearchResult) graphql.Marshaler { return ec._SearchResult(ctx, sel, &v) } -func (ec *executionContext) marshalNSearchResult2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐSearchResult(ctx context.Context, sel ast.SelectionSet, v []SearchResult) graphql.Marshaler { +func (ec *executionContext) marshalNSearchResult2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐSearchResult(ctx context.Context, sel ast.SelectionSet, v []models.SearchResult) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -3884,7 +3885,7 @@ func (ec *executionContext) marshalNSearchResult2ᚕgithubᚗcomᚋ99designsᚋg if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNSearchResult2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐSearchResult(ctx, sel, v[i]) + ret[i] = ec.marshalNSearchResult2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐSearchResult(ctx, sel, v[i]) } if isLen1 { f(i) @@ -3897,7 +3898,7 @@ func (ec *executionContext) marshalNSearchResult2ᚕgithubᚗcomᚋ99designsᚋg return ret } -func (ec *executionContext) marshalNStarship2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx context.Context, sel ast.SelectionSet, v Starship) graphql.Marshaler { +func (ec *executionContext) marshalNStarship2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐStarship(ctx context.Context, sel ast.SelectionSet, v models.Starship) graphql.Marshaler { return ec._Starship(ctx, sel, &v) } @@ -4146,11 +4147,11 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast return ec.marshalOBoolean2bool(ctx, sel, *v) } -func (ec *executionContext) marshalOCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v Character) graphql.Marshaler { +func (ec *executionContext) marshalOCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v models.Character) graphql.Marshaler { return ec._Character(ctx, sel, &v) } -func (ec *executionContext) marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v []Character) graphql.Marshaler { +func (ec *executionContext) marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v []models.Character) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4174,7 +4175,7 @@ func (ec *executionContext) marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlg if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx, sel, v[i]) + ret[i] = ec.marshalNCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐCharacter(ctx, sel, v[i]) } if isLen1 { f(i) @@ -4187,35 +4188,35 @@ func (ec *executionContext) marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlg return ret } -func (ec *executionContext) marshalODroid2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐDroid(ctx context.Context, sel ast.SelectionSet, v Droid) graphql.Marshaler { +func (ec *executionContext) marshalODroid2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐDroid(ctx context.Context, sel ast.SelectionSet, v models.Droid) graphql.Marshaler { return ec._Droid(ctx, sel, &v) } -func (ec *executionContext) marshalODroid2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐDroid(ctx context.Context, sel ast.SelectionSet, v *Droid) graphql.Marshaler { +func (ec *executionContext) marshalODroid2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐDroid(ctx context.Context, sel ast.SelectionSet, v *models.Droid) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Droid(ctx, sel, v) } -func (ec *executionContext) unmarshalOEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, v interface{}) (Episode, error) { - var res Episode +func (ec *executionContext) unmarshalOEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐEpisode(ctx context.Context, v interface{}) (models.Episode, error) { + var res models.Episode return res, res.UnmarshalGQL(v) } -func (ec *executionContext) marshalOEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v Episode) graphql.Marshaler { +func (ec *executionContext) marshalOEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v models.Episode) graphql.Marshaler { return v } -func (ec *executionContext) unmarshalOEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, v interface{}) (*Episode, error) { +func (ec *executionContext) unmarshalOEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐEpisode(ctx context.Context, v interface{}) (*models.Episode, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx, v) + res, err := ec.unmarshalOEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐEpisode(ctx, v) return &res, err } -func (ec *executionContext) marshalOEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v *Episode) graphql.Marshaler { +func (ec *executionContext) marshalOEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v *models.Episode) graphql.Marshaler { if v == nil { return graphql.Null } @@ -4230,7 +4231,7 @@ func (ec *executionContext) marshalOFloat2float64(ctx context.Context, sel ast.S return graphql.MarshalFloat(v) } -func (ec *executionContext) marshalOFriendsEdge2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsEdge(ctx context.Context, sel ast.SelectionSet, v []FriendsEdge) graphql.Marshaler { +func (ec *executionContext) marshalOFriendsEdge2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐFriendsEdge(ctx context.Context, sel ast.SelectionSet, v []models.FriendsEdge) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4254,7 +4255,7 @@ func (ec *executionContext) marshalOFriendsEdge2ᚕgithubᚗcomᚋ99designsᚋgq if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNFriendsEdge2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsEdge(ctx, sel, v[i]) + ret[i] = ec.marshalNFriendsEdge2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐFriendsEdge(ctx, sel, v[i]) } if isLen1 { f(i) @@ -4267,11 +4268,11 @@ func (ec *executionContext) marshalOFriendsEdge2ᚕgithubᚗcomᚋ99designsᚋgq return ret } -func (ec *executionContext) marshalOHuman2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐHuman(ctx context.Context, sel ast.SelectionSet, v Human) graphql.Marshaler { +func (ec *executionContext) marshalOHuman2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐHuman(ctx context.Context, sel ast.SelectionSet, v models.Human) graphql.Marshaler { return ec._Human(ctx, sel, &v) } -func (ec *executionContext) marshalOHuman2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐHuman(ctx context.Context, sel ast.SelectionSet, v *Human) graphql.Marshaler { +func (ec *executionContext) marshalOHuman2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐHuman(ctx context.Context, sel ast.SelectionSet, v *models.Human) graphql.Marshaler { if v == nil { return graphql.Null } @@ -4324,46 +4325,46 @@ func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.Sele return ec.marshalOInt2int(ctx, sel, *v) } -func (ec *executionContext) unmarshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(ctx context.Context, v interface{}) (LengthUnit, error) { - var res LengthUnit +func (ec *executionContext) unmarshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐLengthUnit(ctx context.Context, v interface{}) (models.LengthUnit, error) { + var res models.LengthUnit return res, res.UnmarshalGQL(v) } -func (ec *executionContext) marshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(ctx context.Context, sel ast.SelectionSet, v LengthUnit) graphql.Marshaler { +func (ec *executionContext) marshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐLengthUnit(ctx context.Context, sel ast.SelectionSet, v models.LengthUnit) graphql.Marshaler { return v } -func (ec *executionContext) unmarshalOLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(ctx context.Context, v interface{}) (*LengthUnit, error) { +func (ec *executionContext) unmarshalOLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐLengthUnit(ctx context.Context, v interface{}) (*models.LengthUnit, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(ctx, v) + res, err := ec.unmarshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐLengthUnit(ctx, v) return &res, err } -func (ec *executionContext) marshalOLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(ctx context.Context, sel ast.SelectionSet, v *LengthUnit) graphql.Marshaler { +func (ec *executionContext) marshalOLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐLengthUnit(ctx context.Context, sel ast.SelectionSet, v *models.LengthUnit) graphql.Marshaler { if v == nil { return graphql.Null } return v } -func (ec *executionContext) marshalOReview2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx context.Context, sel ast.SelectionSet, v Review) graphql.Marshaler { +func (ec *executionContext) marshalOReview2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐReview(ctx context.Context, sel ast.SelectionSet, v models.Review) graphql.Marshaler { return ec._Review(ctx, sel, &v) } -func (ec *executionContext) marshalOReview2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx context.Context, sel ast.SelectionSet, v *Review) graphql.Marshaler { +func (ec *executionContext) marshalOReview2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐReview(ctx context.Context, sel ast.SelectionSet, v *models.Review) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Review(ctx, sel, v) } -func (ec *executionContext) marshalOStarship2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx context.Context, sel ast.SelectionSet, v Starship) graphql.Marshaler { +func (ec *executionContext) marshalOStarship2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐStarship(ctx context.Context, sel ast.SelectionSet, v models.Starship) graphql.Marshaler { return ec._Starship(ctx, sel, &v) } -func (ec *executionContext) marshalOStarship2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx context.Context, sel ast.SelectionSet, v []Starship) graphql.Marshaler { +func (ec *executionContext) marshalOStarship2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐStarship(ctx context.Context, sel ast.SelectionSet, v []models.Starship) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4387,7 +4388,7 @@ func (ec *executionContext) marshalOStarship2ᚕgithubᚗcomᚋ99designsᚋgqlge if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNStarship2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx, sel, v[i]) + ret[i] = ec.marshalNStarship2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐStarship(ctx, sel, v[i]) } if isLen1 { f(i) @@ -4400,7 +4401,7 @@ func (ec *executionContext) marshalOStarship2ᚕgithubᚗcomᚋ99designsᚋgqlge return ret } -func (ec *executionContext) marshalOStarship2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx context.Context, sel ast.SelectionSet, v *Starship) graphql.Marshaler { +func (ec *executionContext) marshalOStarship2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐStarship(ctx context.Context, sel ast.SelectionSet, v *models.Starship) graphql.Marshaler { if v == nil { return graphql.Null } diff --git a/example/starwars/models_gen.go b/example/starwars/models/generated.go similarity index 99% rename from example/starwars/models_gen.go rename to example/starwars/models/generated.go index e418cd89e42..2f02272c20e 100644 --- a/example/starwars/models_gen.go +++ b/example/starwars/models/generated.go @@ -1,6 +1,6 @@ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. -package starwars +package models import ( "fmt" diff --git a/example/starwars/model.go b/example/starwars/models/model.go similarity index 50% rename from example/starwars/model.go rename to example/starwars/models/model.go index fd9e274894f..e3225b743ae 100644 --- a/example/starwars/model.go +++ b/example/starwars/models/model.go @@ -1,11 +1,8 @@ -package starwars +package models import ( - "context" "encoding/base64" "fmt" - "strconv" - "strings" "time" ) @@ -19,16 +16,16 @@ type CharacterFields struct { type Human struct { CharacterFields StarshipIds []string - heightMeters float64 + HeightMeters float64 Mass float64 } func (h *Human) Height(unit LengthUnit) float64 { switch unit { case "METER", "": - return h.heightMeters + return h.HeightMeters case "FOOT": - return h.heightMeters * 3.28084 + return h.HeightMeters * 3.28084 default: panic("invalid unit") } @@ -51,53 +48,24 @@ type Droid struct { func (Droid) IsCharacter() {} func (Droid) IsSearchResult() {} -func (r *Resolver) resolveFriendConnection(ctx context.Context, ids []string, first *int, after *string) (*FriendsConnection, error) { - from := 0 - if after != nil { - b, err := base64.StdEncoding.DecodeString(*after) - if err != nil { - return nil, err - } - i, err := strconv.Atoi(strings.TrimPrefix(string(b), "cursor")) - if err != nil { - return nil, err - } - from = i - } - - to := len(ids) - if first != nil { - to = from + *first - if to > len(ids) { - to = len(ids) - } - } - - return &FriendsConnection{ - ids: ids, - from: from, - to: to, - }, nil -} - type FriendsConnection struct { - ids []string - from int - to int + Ids []string + From int + To int } func (f *FriendsConnection) TotalCount() int { - return len(f.ids) + return len(f.Ids) } func (f *FriendsConnection) PageInfo() PageInfo { return PageInfo{ - StartCursor: encodeCursor(f.from), - EndCursor: encodeCursor(f.to - 1), - HasNextPage: f.to < len(f.ids), + StartCursor: EncodeCursor(f.From), + EndCursor: EncodeCursor(f.To - 1), + HasNextPage: f.To < len(f.Ids), } } -func encodeCursor(i int) string { +func EncodeCursor(i int) string { return base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("cursor%d", i+1))) } diff --git a/example/starwars/resolvers.go b/example/starwars/resolvers.go index 1e000584728..7b1f3f4b5f4 100644 --- a/example/starwars/resolvers.go +++ b/example/starwars/resolvers.go @@ -1,47 +1,54 @@ +//go:generate rm -rf generated //go:generate go run ../../testdata/gqlgen.go package starwars import ( "context" + "encoding/base64" "errors" + "strconv" "strings" "time" + + "github.com/99designs/gqlgen/example/starwars/generated" + + "github.com/99designs/gqlgen/example/starwars/models" ) type Resolver struct { - humans map[string]Human - droid map[string]Droid - starships map[string]Starship - reviews map[Episode][]Review + humans map[string]models.Human + droid map[string]models.Droid + starships map[string]models.Starship + reviews map[models.Episode][]models.Review } -func (r *Resolver) Droid() DroidResolver { +func (r *Resolver) Droid() generated.DroidResolver { return &droidResolver{r} } -func (r *Resolver) FriendsConnection() FriendsConnectionResolver { +func (r *Resolver) FriendsConnection() generated.FriendsConnectionResolver { return &friendsConnectionResolver{r} } -func (r *Resolver) Human() HumanResolver { +func (r *Resolver) Human() generated.HumanResolver { return &humanResolver{r} } -func (r *Resolver) Mutation() MutationResolver { +func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} } -func (r *Resolver) Query() QueryResolver { +func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } -func (r *Resolver) Starship() StarshipResolver { +func (r *Resolver) Starship() generated.StarshipResolver { return &starshipResolver{r} } -func (r *Resolver) resolveCharacters(ctx context.Context, ids []string) ([]Character, error) { - var result []Character +func (r *Resolver) resolveCharacters(ctx context.Context, ids []string) ([]models.Character, error) { + var result []models.Character for _, id := range ids { char, err := r.Query().Character(ctx, id) if err != nil { @@ -54,48 +61,77 @@ func (r *Resolver) resolveCharacters(ctx context.Context, ids []string) ([]Chara type droidResolver struct{ *Resolver } -func (r *droidResolver) Friends(ctx context.Context, obj *Droid) ([]Character, error) { +func (r *droidResolver) Friends(ctx context.Context, obj *models.Droid) ([]models.Character, error) { return r.resolveCharacters(ctx, obj.FriendIds) } -func (r *droidResolver) FriendsConnection(ctx context.Context, obj *Droid, first *int, after *string) (*FriendsConnection, error) { +func (r *droidResolver) FriendsConnection(ctx context.Context, obj *models.Droid, first *int, after *string) (*models.FriendsConnection, error) { return r.resolveFriendConnection(ctx, obj.FriendIds, first, after) } type friendsConnectionResolver struct{ *Resolver } -func (r *friendsConnectionResolver) Edges(ctx context.Context, obj *FriendsConnection) ([]FriendsEdge, error) { - friends, err := r.resolveCharacters(ctx, obj.ids) +func (r *Resolver) resolveFriendConnection(ctx context.Context, ids []string, first *int, after *string) (*models.FriendsConnection, error) { + from := 0 + if after != nil { + b, err := base64.StdEncoding.DecodeString(*after) + if err != nil { + return nil, err + } + i, err := strconv.Atoi(strings.TrimPrefix(string(b), "cursor")) + if err != nil { + return nil, err + } + from = i + } + + to := len(ids) + if first != nil { + to = from + *first + if to > len(ids) { + to = len(ids) + } + } + + return &models.FriendsConnection{ + Ids: ids, + From: from, + To: to, + }, nil +} + +func (r *friendsConnectionResolver) Edges(ctx context.Context, obj *models.FriendsConnection) ([]models.FriendsEdge, error) { + friends, err := r.resolveCharacters(ctx, obj.Ids) if err != nil { return nil, err } - edges := make([]FriendsEdge, obj.to-obj.from) + edges := make([]models.FriendsEdge, obj.To-obj.From) for i := range edges { - edges[i] = FriendsEdge{ - Cursor: encodeCursor(obj.from + i), - Node: friends[obj.from+i], + edges[i] = models.FriendsEdge{ + Cursor: models.EncodeCursor(obj.From + i), + Node: friends[obj.From+i], } } return edges, nil } -func (r *friendsConnectionResolver) Friends(ctx context.Context, obj *FriendsConnection) ([]Character, error) { - return r.resolveCharacters(ctx, obj.ids) +func (r *friendsConnectionResolver) Friends(ctx context.Context, obj *models.FriendsConnection) ([]models.Character, error) { + return r.resolveCharacters(ctx, obj.Ids) } type humanResolver struct{ *Resolver } -func (r *humanResolver) Friends(ctx context.Context, obj *Human) ([]Character, error) { +func (r *humanResolver) Friends(ctx context.Context, obj *models.Human) ([]models.Character, error) { return r.resolveCharacters(ctx, obj.FriendIds) } -func (r *humanResolver) FriendsConnection(ctx context.Context, obj *Human, first *int, after *string) (*FriendsConnection, error) { +func (r *humanResolver) FriendsConnection(ctx context.Context, obj *models.Human, first *int, after *string) (*models.FriendsConnection, error) { return r.resolveFriendConnection(ctx, obj.FriendIds, first, after) } -func (r *humanResolver) Starships(ctx context.Context, obj *Human) ([]Starship, error) { - var result []Starship +func (r *humanResolver) Starships(ctx context.Context, obj *models.Human) ([]models.Starship, error) { + var result []models.Starship for _, id := range obj.StarshipIds { char, err := r.Query().Starship(ctx, id) if err != nil { @@ -110,7 +146,7 @@ func (r *humanResolver) Starships(ctx context.Context, obj *Human) ([]Starship, type mutationResolver struct{ *Resolver } -func (r *mutationResolver) CreateReview(ctx context.Context, episode Episode, review Review) (*Review, error) { +func (r *mutationResolver) CreateReview(ctx context.Context, episode models.Episode, review models.Review) (*models.Review, error) { review.Time = time.Now() time.Sleep(1 * time.Second) r.reviews[episode] = append(r.reviews[episode], review) @@ -119,19 +155,19 @@ func (r *mutationResolver) CreateReview(ctx context.Context, episode Episode, re type queryResolver struct{ *Resolver } -func (r *queryResolver) Hero(ctx context.Context, episode *Episode) (Character, error) { - if *episode == EpisodeEmpire { +func (r *queryResolver) Hero(ctx context.Context, episode *models.Episode) (models.Character, error) { + if *episode == models.EpisodeEmpire { return r.humans["1000"], nil } return r.droid["2001"], nil } -func (r *queryResolver) Reviews(ctx context.Context, episode Episode, since *time.Time) ([]Review, error) { +func (r *queryResolver) Reviews(ctx context.Context, episode models.Episode, since *time.Time) ([]models.Review, error) { if since == nil { return r.reviews[episode], nil } - var filtered []Review + var filtered []models.Review for _, rev := range r.reviews[episode] { if rev.Time.After(*since) { filtered = append(filtered, rev) @@ -140,8 +176,8 @@ func (r *queryResolver) Reviews(ctx context.Context, episode Episode, since *tim return filtered, nil } -func (r *queryResolver) Search(ctx context.Context, text string) ([]SearchResult, error) { - var l []SearchResult +func (r *queryResolver) Search(ctx context.Context, text string) ([]models.SearchResult, error) { + var l []models.SearchResult for _, h := range r.humans { if strings.Contains(h.Name, text) { l = append(l, h) @@ -160,7 +196,7 @@ func (r *queryResolver) Search(ctx context.Context, text string) ([]SearchResult return l, nil } -func (r *queryResolver) Character(ctx context.Context, id string) (Character, error) { +func (r *queryResolver) Character(ctx context.Context, id string) (models.Character, error) { if h, ok := r.humans[id]; ok { return &h, nil } @@ -170,21 +206,21 @@ func (r *queryResolver) Character(ctx context.Context, id string) (Character, er return nil, nil } -func (r *queryResolver) Droid(ctx context.Context, id string) (*Droid, error) { +func (r *queryResolver) Droid(ctx context.Context, id string) (*models.Droid, error) { if d, ok := r.droid[id]; ok { return &d, nil } return nil, nil } -func (r *queryResolver) Human(ctx context.Context, id string) (*Human, error) { +func (r *queryResolver) Human(ctx context.Context, id string) (*models.Human, error) { if h, ok := r.humans[id]; ok { return &h, nil } return nil, nil } -func (r *queryResolver) Starship(ctx context.Context, id string) (*Starship, error) { +func (r *queryResolver) Starship(ctx context.Context, id string) (*models.Starship, error) { if s, ok := r.starships[id]; ok { return &s, nil } @@ -193,97 +229,97 @@ func (r *queryResolver) Starship(ctx context.Context, id string) (*Starship, err type starshipResolver struct{ *Resolver } -func (r *starshipResolver) Length(ctx context.Context, obj *Starship, unit *LengthUnit) (float64, error) { +func (r *starshipResolver) Length(ctx context.Context, obj *models.Starship, unit *models.LengthUnit) (float64, error) { switch *unit { - case LengthUnitMeter, "": + case models.LengthUnitMeter, "": return obj.Length, nil - case LengthUnitFoot: + case models.LengthUnitFoot: return obj.Length * 3.28084, nil default: return 0, errors.New("invalid unit") } } -func NewResolver() Config { +func NewResolver() generated.Config { r := Resolver{} - r.humans = map[string]Human{ + r.humans = map[string]models.Human{ "1000": { - CharacterFields: CharacterFields{ + CharacterFields: models.CharacterFields{ ID: "1000", Name: "Luke Skywalker", FriendIds: []string{"1002", "1003", "2000", "2001"}, - AppearsIn: []Episode{EpisodeNewhope, EpisodeEmpire, EpisodeJedi}, + AppearsIn: []models.Episode{models.EpisodeNewhope, models.EpisodeEmpire, models.EpisodeJedi}, }, - heightMeters: 1.72, + HeightMeters: 1.72, Mass: 77, StarshipIds: []string{"3001", "3003"}, }, "1001": { - CharacterFields: CharacterFields{ + CharacterFields: models.CharacterFields{ ID: "1001", Name: "Darth Vader", FriendIds: []string{"1004"}, - AppearsIn: []Episode{EpisodeNewhope, EpisodeEmpire, EpisodeJedi}, + AppearsIn: []models.Episode{models.EpisodeNewhope, models.EpisodeEmpire, models.EpisodeJedi}, }, - heightMeters: 2.02, + HeightMeters: 2.02, Mass: 136, StarshipIds: []string{"3002"}, }, "1002": { - CharacterFields: CharacterFields{ + CharacterFields: models.CharacterFields{ ID: "1002", Name: "Han Solo", FriendIds: []string{"1000", "1003", "2001"}, - AppearsIn: []Episode{EpisodeNewhope, EpisodeEmpire, EpisodeJedi}, + AppearsIn: []models.Episode{models.EpisodeNewhope, models.EpisodeEmpire, models.EpisodeJedi}, }, - heightMeters: 1.8, + HeightMeters: 1.8, Mass: 80, StarshipIds: []string{"3000", "3003"}, }, "1003": { - CharacterFields: CharacterFields{ + CharacterFields: models.CharacterFields{ ID: "1003", Name: "Leia Organa", FriendIds: []string{"1000", "1002", "2000", "2001"}, - AppearsIn: []Episode{EpisodeNewhope, EpisodeEmpire, EpisodeJedi}, + AppearsIn: []models.Episode{models.EpisodeNewhope, models.EpisodeEmpire, models.EpisodeJedi}, }, - heightMeters: 1.5, + HeightMeters: 1.5, Mass: 49, }, "1004": { - CharacterFields: CharacterFields{ + CharacterFields: models.CharacterFields{ ID: "1004", Name: "Wilhuff Tarkin", FriendIds: []string{"1001"}, - AppearsIn: []Episode{EpisodeNewhope}, + AppearsIn: []models.Episode{models.EpisodeNewhope}, }, - heightMeters: 1.8, + HeightMeters: 1.8, Mass: 0, }, } - r.droid = map[string]Droid{ + r.droid = map[string]models.Droid{ "2000": { - CharacterFields: CharacterFields{ + CharacterFields: models.CharacterFields{ ID: "2000", Name: "C-3PO", FriendIds: []string{"1000", "1002", "1003", "2001"}, - AppearsIn: []Episode{EpisodeNewhope, EpisodeEmpire, EpisodeJedi}, + AppearsIn: []models.Episode{models.EpisodeNewhope, models.EpisodeEmpire, models.EpisodeJedi}, }, PrimaryFunction: "Protocol", }, "2001": { - CharacterFields: CharacterFields{ + CharacterFields: models.CharacterFields{ ID: "2001", Name: "R2-D2", FriendIds: []string{"1000", "1002", "1003"}, - AppearsIn: []Episode{EpisodeNewhope, EpisodeEmpire, EpisodeJedi}, + AppearsIn: []models.Episode{models.EpisodeNewhope, models.EpisodeEmpire, models.EpisodeJedi}, }, PrimaryFunction: "Astromech", }, } - r.starships = map[string]Starship{ + r.starships = map[string]models.Starship{ "3000": { ID: "3000", Name: "Millennium Falcon", @@ -330,9 +366,9 @@ func NewResolver() Config { }, } - r.reviews = map[Episode][]Review{} + r.reviews = map[models.Episode][]models.Review{} - return Config{ + return generated.Config{ Resolvers: &r, } } diff --git a/example/starwars/server/server.go b/example/starwars/server/server.go index 20d23cfaf0c..d082d3d92e9 100644 --- a/example/starwars/server/server.go +++ b/example/starwars/server/server.go @@ -7,13 +7,14 @@ import ( "net/http" "github.com/99designs/gqlgen/example/starwars" + "github.com/99designs/gqlgen/example/starwars/generated" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/handler" ) func main() { http.Handle("/", handler.Playground("Starwars", "/query")) - http.Handle("/query", handler.GraphQL(starwars.NewExecutableSchema(starwars.NewResolver()), + http.Handle("/query", handler.GraphQL(generated.NewExecutableSchema(starwars.NewResolver()), handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { rc := graphql.GetResolverContext(ctx) fmt.Println("Entered", rc.Object, rc.Field.Name) diff --git a/example/starwars/starwars_test.go b/example/starwars/starwars_test.go index 8468c82254a..53f33d34f53 100644 --- a/example/starwars/starwars_test.go +++ b/example/starwars/starwars_test.go @@ -5,13 +5,14 @@ import ( "testing" "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/example/starwars/generated" "github.com/99designs/gqlgen/graphql/introspection" "github.com/99designs/gqlgen/handler" "github.com/stretchr/testify/require" ) func TestStarwars(t *testing.T) { - srv := httptest.NewServer(handler.GraphQL(NewExecutableSchema(NewResolver()))) + srv := httptest.NewServer(handler.GraphQL(generated.NewExecutableSchema(NewResolver()))) c := client.New(srv.URL) t.Run("Lukes starships", func(t *testing.T) { diff --git a/internal/code/imports.go b/internal/code/imports.go index ecfe9dbc9f4..2384e87da95 100644 --- a/internal/code/imports.go +++ b/internal/code/imports.go @@ -1,6 +1,7 @@ package code import ( + "errors" "path/filepath" "sync" @@ -14,12 +15,22 @@ func ImportPathForDir(dir string) string { if v, ok := pathForDirCache.Load(dir); ok { return v.(string) } + p, _ := packages.Load(&packages.Config{ Dir: dir, }, ".") + // If the dir dosent exist yet, keep walking up the directory tree trying to find a match if len(p) != 1 { - return "" + parent, err := filepath.Abs(filepath.Join(dir, "..")) + if err != nil { + panic(err) + } + // Walked all the way to the root and didnt find anything :'( + if parent == dir { + return "" + } + return ImportPathForDir(parent) + "/" + filepath.Base(dir) } pathForDirCache.Store(dir, p[0].PkgPath) @@ -30,6 +41,9 @@ func ImportPathForDir(dir string) string { var nameForPackageCache = sync.Map{} func NameForPackage(importPath string) string { + if importPath == "" { + panic(errors.New("import path can not be empty")) + } if v, ok := nameForPackageCache.Load(importPath); ok { return v.(string) } diff --git a/internal/code/imports_test.go b/internal/code/imports_test.go index b1825749259..b1493375ca1 100644 --- a/internal/code/imports_test.go +++ b/internal/code/imports_test.go @@ -20,7 +20,7 @@ func TestImportPathForDir(t *testing.T) { assert.Equal(t, "github.com/99designs/gqlgen/docs", ImportPathForDir(filepath.Join(wd, "..", "..", "docs"))) // directory does not exist - assert.Equal(t, "", ImportPathForDir(filepath.Join(wd, "..", "..", "dos"))) + assert.Equal(t, "github.com/99designs/gqlgen/dos", ImportPathForDir(filepath.Join(wd, "..", "..", "dos"))) } func TestNameForPackage(t *testing.T) { diff --git a/plugin/stubgen/stubs.go b/plugin/stubgen/stubs.go index 44982b79e59..1dc29ee7da0 100644 --- a/plugin/stubgen/stubs.go +++ b/plugin/stubgen/stubs.go @@ -1,8 +1,11 @@ package stubgen import ( + "path/filepath" "syscall" + "github.com/99designs/gqlgen/internal/code" + "github.com/99designs/gqlgen/codegen" "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/codegen/templates" @@ -31,8 +34,11 @@ func (m *Plugin) MutateConfig(cfg *config.Config) error { } func (m *Plugin) GenerateCode(data *codegen.Data) error { + pkgPath := code.ImportPathForDir(filepath.Dir(m.filename)) + pkgName := code.NameForPackage(pkgPath) + return templates.Render(templates.Options{ - PackageName: data.Config.Exec.Package, + PackageName: pkgName, Filename: m.filename, Data: &ResolverBuild{ Data: data, From 8f91cf56cf39de4f3845395f3564224452d9b95b Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Mon, 4 Mar 2019 15:36:27 +1100 Subject: [PATCH 110/147] Very rough first pass at plugin docs --- docs/content/reference/plugins.md | 62 +++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 docs/content/reference/plugins.md diff --git a/docs/content/reference/plugins.md b/docs/content/reference/plugins.md new file mode 100644 index 00000000000..7f8cfce0b0b --- /dev/null +++ b/docs/content/reference/plugins.md @@ -0,0 +1,62 @@ +--- +linkTitle: Plugins +title: How to write plugins for gqlgen +description: Use plugins to customize code generation and integrate with other libraries +menu: { main: { parent: 'reference' } } +--- + +Plugins provide a way to hook into the gqlgen code generation lifecycle. In order to use anything other than the +default plugins you will need to create your own entrypoint: + + +## Using a plugin +```go +// +build ignore + +package main + +import ( + "flag" + "fmt" + "io/ioutil" + "log" + "os" + "time" + + "github.com/99designs/gqlgen/api" + "github.com/99designs/gqlgen/codegen/config" + "github.com/99designs/gqlgen/plugin/stubgen" +) + +func main() { + cfg, err := config.LoadConfigFromDefaultLocations() + if err != nil { + fmt.Fprintln(os.Stderr, "failed to load config", err.Error()) + os.Exit(2) + } + + + err = api.Generate(cfg, + api.AddPlugin(yourplugin.New()), // This is the magic line + ) + if err != nil { + fmt.Fprintln(os.Stderr, err.Error()) + os.Exit(3) + } +} + +``` + +## Writing a plugin + +There are currently only two hooks: + - MutateConfig: Allows a plugin to mutate the config before codegen starts. This allows plugins to add + custom directives, define types, and implement resolvers. see + [modelgen](https://github.com/99designs/gqlgen/tree/master/plugin/modelgen) for an example + - GenerateCode: Allows a plugin to generate a new output file, see + [stubgen](https://github.com/99designs/gqlgen/tree/master/plugin/stubgen) for an example + +Take a look at [plugin.go](https://github.com/99designs/gqlgen/blob/master/plugin/plugin.go) for the full list of +available hooks. These are likely to change with each release. + + From 44becbbe3afc314ba19778a18b0e7733645eaf24 Mon Sep 17 00:00:00 2001 From: John Lam Date: Mon, 4 Mar 2019 09:16:49 -0800 Subject: [PATCH 111/147] Update README.md Fixed typo in MD link ttps -> https --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 162983667af..66f68c69e35 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ ## Getting Started -First work your way through the [Getting Started](ttps://gqlgen.com/getting-started/) tutorial. +First work your way through the [Getting Started](https://gqlgen.com/getting-started/) tutorial. If you can't find what your looking for, look at our [examples](https://github.com/99designs/gqlgen/tree/master/example) for example usage of gqlgen. From 6ea48ff69aa370cc8fe7f498149f55859c3c11dd Mon Sep 17 00:00:00 2001 From: vvakame Date: Tue, 5 Mar 2019 18:42:06 +0900 Subject: [PATCH 112/147] Take care about commonInitialisms in ToCamel --- codegen/templates/templates.go | 33 ++++++++++++++++++++++++----- codegen/templates/templates_test.go | 15 ++++++++++++- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/codegen/templates/templates.go b/codegen/templates/templates.go index 8522824e5c9..74085e0fd3f 100644 --- a/codegen/templates/templates.go +++ b/codegen/templates/templates.go @@ -232,29 +232,52 @@ func ToCamel(s string) string { if s == "_" { return "_" } - buffer := make([]rune, 0, len(s)) + buf := bytes.NewBuffer(make([]byte, 0, len(s))) upper := true lastWasUpper := false + var maxCommonInitialismsLen int + for word := range commonInitialisms { + if l := len(word); maxCommonInitialismsLen < l { + maxCommonInitialismsLen = l + } + } - for _, c := range s { +outer: + for i, rs := 0, []rune(s); i < len(rs); i++ { + c := rs[i] if isDelimiter(c) { upper = true continue } if !lastWasUpper && unicode.IsUpper(c) { + tail := len(rs) - i + if maxCommonInitialismsLen < tail { + tail = maxCommonInitialismsLen + } + for j := tail; j != 0; j-- { + word := string(rs[i : i+j]) + if commonInitialisms[word] { + buf.WriteString(word) + i += j - 1 + upper = false + lastWasUpper = false // IDFoo will be IDFoo, not IDfoo + continue outer + } + } + upper = true } if upper { - buffer = append(buffer, unicode.ToUpper(c)) + buf.WriteRune(unicode.ToUpper(c)) } else { - buffer = append(buffer, unicode.ToLower(c)) + buf.WriteRune(unicode.ToLower(c)) } upper = false lastWasUpper = unicode.IsUpper(c) } - return string(buffer) + return buf.String() } func ToGo(name string) string { diff --git a/codegen/templates/templates_test.go b/codegen/templates/templates_test.go index 31f518b4bcc..5debc545ab2 100644 --- a/codegen/templates/templates_test.go +++ b/codegen/templates/templates_test.go @@ -6,12 +6,25 @@ import ( "github.com/stretchr/testify/require" ) -func TestToUpper(t *testing.T) { +func TestToCamel(t *testing.T) { require.Equal(t, "ToCamel", ToCamel("TO_CAMEL")) require.Equal(t, "ToCamel", ToCamel("to_camel")) require.Equal(t, "ToCamel", ToCamel("toCamel")) require.Equal(t, "ToCamel", ToCamel("ToCamel")) require.Equal(t, "ToCamel", ToCamel("to-camel")) + + require.Equal(t, "RelatedURLs", ToCamel("RelatedURLs")) + require.Equal(t, "ImageIDs", ToCamel("ImageIDs")) + require.Equal(t, "FooID", ToCamel("FooID")) + require.Equal(t, "IDFoo", ToCamel("IDFoo")) + require.Equal(t, "FooASCII", ToCamel("FooASCII")) + require.Equal(t, "ASCIIFoo", ToCamel("ASCIIFoo")) + require.Equal(t, "FooUTF8", ToCamel("FooUTF8")) + require.Equal(t, "UTF8Foo", ToCamel("UTF8Foo")) + + require.Equal(t, "A", ToCamel("A")) + require.Equal(t, "ID", ToCamel("ID")) + require.Equal(t, "", ToCamel("")) } func TestCenter(t *testing.T) { From b8526698d46f6a3e7726bfdd6c33163e06cb2ea1 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 5 Mar 2019 17:29:15 +0200 Subject: [PATCH 113/147] Load the playground sources from HTTPS by default For some browsers on non-secure domains resources from CDN doesn't loads, so I made all cdn.jsdelivr.net resources of the playground by HTTPS by default --- handler/playground.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/handler/playground.go b/handler/playground.go index 09db11de152..d0038b296d1 100644 --- a/handler/playground.go +++ b/handler/playground.go @@ -11,11 +11,11 @@ var page = template.Must(template.New("graphiql").Parse(` - - - {{.title}} From 5ba8c8ead3ca891601215263b5969e4942c52a6b Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Wed, 6 Mar 2019 11:32:47 +1100 Subject: [PATCH 114/147] Add builtin flag for build directives These have an internal implementation and should be excluded from the DirectiveRoot. In the future this may be a func that plugins could use to add custom implementations. --- codegen/data.go | 9 +++++- codegen/directive.go | 14 +++++---- codegen/testserver/generated.go | 50 +++++++++++++++++++++++++++++++ codegen/testserver/resolver.go | 3 ++ codegen/testserver/schema.graphql | 1 + codegen/testserver/stub.go | 4 +++ 6 files changed, 75 insertions(+), 6 deletions(-) diff --git a/codegen/data.go b/codegen/data.go index df1188b75a4..e7b5a92ef5e 100644 --- a/codegen/data.go +++ b/codegen/data.go @@ -62,9 +62,16 @@ func BuildData(cfg *config.Config) (*Data, error) { return nil, err } + dataDirectives := make(map[string]*Directive) + for name, d := range b.Directives { + if !d.Builtin { + dataDirectives[name] = d + } + } + s := Data{ Config: cfg, - Directives: b.Directives, + Directives: dataDirectives, Schema: b.Schema, SchemaStr: b.SchemaStr, Interfaces: map[string]*Interface{}, diff --git a/codegen/directive.go b/codegen/directive.go index 52f3cbae7b5..5a27e8ace71 100644 --- a/codegen/directive.go +++ b/codegen/directive.go @@ -11,8 +11,9 @@ import ( ) type Directive struct { - Name string - Args []*FieldArgument + Name string + Args []*FieldArgument + Builtin bool } func (b *builder) buildDirectives() (map[string]*Directive, error) { @@ -22,8 +23,10 @@ func (b *builder) buildDirectives() (map[string]*Directive, error) { if _, ok := directives[name]; ok { return nil, errors.Errorf("directive with name %s already exists", name) } + + var builtin bool if name == "skip" || name == "include" || name == "deprecated" { - continue + builtin = true } var args []*FieldArgument @@ -50,8 +53,9 @@ func (b *builder) buildDirectives() (map[string]*Directive, error) { } directives[name] = &Directive{ - Name: name, - Args: args, + Name: name, + Args: args, + Builtin: builtin, } } diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 6932d23fd05..3eb743e9b26 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -130,6 +130,7 @@ type ComplexityRoot struct { InputSlice func(childComplexity int, arg []string) int ShapeUnion func(childComplexity int) int Autobind func(childComplexity int) int + DeprecatedField func(childComplexity int) int Panics func(childComplexity int) int ValidType func(childComplexity int) int } @@ -191,6 +192,7 @@ type QueryResolver interface { InputSlice(ctx context.Context, arg []string) (bool, error) ShapeUnion(ctx context.Context) (ShapeUnion, error) Autobind(ctx context.Context) (*Autobind, error) + DeprecatedField(ctx context.Context) (string, error) Panics(ctx context.Context) (*Panics, error) ValidType(ctx context.Context) (*ValidType, error) } @@ -578,6 +580,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Autobind(childComplexity), true + case "Query.DeprecatedField": + if e.complexity.Query.DeprecatedField == nil { + break + } + + return e.complexity.Query.DeprecatedField(childComplexity), true + case "Query.Panics": if e.complexity.Query.Panics == nil { break @@ -850,6 +859,7 @@ scalar MarshalPanic inputSlice(arg: [String!]!): Boolean! shapeUnion: ShapeUnion! autobind: Autobind + deprecatedField: String! @deprecated(reason: "test deprecated directive") } type Subscription { @@ -2709,6 +2719,32 @@ func (ec *executionContext) _Query_autobind(ctx context.Context, field graphql.C return ec.marshalOAutobind2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐAutobind(ctx, field.Selections, res) } +func (ec *executionContext) _Query_deprecatedField(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().DeprecatedField(rctx) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNString2string(ctx, field.Selections, res) +} + func (ec *executionContext) _Query_panics(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -4932,6 +4968,20 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr res = ec._Query_autobind(ctx, field) return res }) + case "deprecatedField": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_deprecatedField(ctx, field) + if res == graphql.Null { + invalid = true + } + return res + }) case "panics": field := field out.Concurrently(i, func() (res graphql.Marshaler) { diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index 91c494ab1a8..fc062c5f01f 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -110,6 +110,9 @@ func (r *queryResolver) ShapeUnion(ctx context.Context) (ShapeUnion, error) { func (r *queryResolver) Autobind(ctx context.Context) (*Autobind, error) { panic("not implemented") } +func (r *queryResolver) DeprecatedField(ctx context.Context) (string, error) { + panic("not implemented") +} func (r *queryResolver) Panics(ctx context.Context) (*Panics, error) { panic("not implemented") } diff --git a/codegen/testserver/schema.graphql b/codegen/testserver/schema.graphql index d6a7fb51274..5ec9de8d065 100644 --- a/codegen/testserver/schema.graphql +++ b/codegen/testserver/schema.graphql @@ -18,6 +18,7 @@ type Query { inputSlice(arg: [String!]!): Boolean! shapeUnion: ShapeUnion! autobind: Autobind + deprecatedField: String! @deprecated(reason: "test deprecated directive") } type Subscription { diff --git a/codegen/testserver/stub.go b/codegen/testserver/stub.go index a99c44461fc..783f8aff58a 100644 --- a/codegen/testserver/stub.go +++ b/codegen/testserver/stub.go @@ -40,6 +40,7 @@ type Stub struct { InputSlice func(ctx context.Context, arg []string) (bool, error) ShapeUnion func(ctx context.Context) (ShapeUnion, error) Autobind func(ctx context.Context) (*Autobind, error) + DeprecatedField func(ctx context.Context) (string, error) Panics func(ctx context.Context) (*Panics, error) ValidType func(ctx context.Context) (*ValidType, error) } @@ -151,6 +152,9 @@ func (r *stubQuery) ShapeUnion(ctx context.Context) (ShapeUnion, error) { func (r *stubQuery) Autobind(ctx context.Context) (*Autobind, error) { return r.QueryResolver.Autobind(ctx) } +func (r *stubQuery) DeprecatedField(ctx context.Context) (string, error) { + return r.QueryResolver.DeprecatedField(ctx) +} func (r *stubQuery) Panics(ctx context.Context) (*Panics, error) { return r.QueryResolver.Panics(ctx) } From eb4536743c4dc507df32da1fe7a581052f7c438c Mon Sep 17 00:00:00 2001 From: vvakame Date: Wed, 6 Mar 2019 18:56:42 +0900 Subject: [PATCH 115/147] address comment --- codegen/generated!.gotpl | 6 +- codegen/templates/templates.go | 128 +++++++++++++++++----------- codegen/templates/templates_test.go | 102 +++++++++++++++++----- 3 files changed, 166 insertions(+), 70 deletions(-) diff --git a/codegen/generated!.gotpl b/codegen/generated!.gotpl index ca9e754929e..7c8afe436ea 100644 --- a/codegen/generated!.gotpl +++ b/codegen/generated!.gotpl @@ -45,7 +45,7 @@ type DirectiveRoot struct { type ComplexityRoot struct { {{ range $object := .Objects }} {{ if not $object.IsReserved -}} - {{ $object.Name|toCamel }} struct { + {{ $object.Name|go }} struct { {{ range $field := $object.Fields -}} {{ if not $field.IsReserved -}} {{ $field.GoFieldName }} {{ $field.ComplexitySignature }} @@ -87,7 +87,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in {{ range $field := $object.Fields }} {{ if not $field.IsReserved }} case "{{$object.Name}}.{{$field.GoFieldName}}": - if e.complexity.{{$object.Name|toCamel}}.{{$field.GoFieldName}} == nil { + if e.complexity.{{$object.Name|go}}.{{$field.GoFieldName}} == nil { break } {{ if $field.Args }} @@ -96,7 +96,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } {{ end }} - return e.complexity.{{$object.Name|toCamel}}.{{$field.GoFieldName}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true + return e.complexity.{{$object.Name|go}}.{{$field.GoFieldName}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true {{ end }} {{ end }} {{ end }} diff --git a/codegen/templates/templates.go b/codegen/templates/templates.go index 74085e0fd3f..fe51caaf5a4 100644 --- a/codegen/templates/templates.go +++ b/codegen/templates/templates.go @@ -129,7 +129,6 @@ func Funcs() template.FuncMap { "lcFirst": lcFirst, "quote": strconv.Quote, "rawQuote": rawQuote, - "toCamel": ToCamel, "dump": Dump, "ref": ref, "ts": TypeIdentifier, @@ -228,64 +227,97 @@ func Call(p *types.Func) string { return pkg + p.Name() } -func ToCamel(s string) string { - if s == "_" { - return "_" - } - buf := bytes.NewBuffer(make([]byte, 0, len(s))) - upper := true - lastWasUpper := false - var maxCommonInitialismsLen int - for word := range commonInitialisms { - if l := len(word); maxCommonInitialismsLen < l { - maxCommonInitialismsLen = l +func ToGo(name string) string { + runes := make([]rune, 0, len(name)) + + wordWalker(name, func(word string, hasCommonInitial bool) { + if !hasCommonInitial { + word = ucFirst(strings.ToLower(word)) } - } + runes = append(runes, []rune(word)...) + }) -outer: - for i, rs := 0, []rune(s); i < len(rs); i++ { - c := rs[i] - if isDelimiter(c) { - upper = true - continue + return string(runes) +} + +func ToGoPrivate(name string) string { + runes := make([]rune, 0, len(name)) + + first := true + wordWalker(name, func(word string, hasCommonInitial bool) { + if first { + word = strings.ToLower(word) + first = false + } else if !hasCommonInitial { + word = ucFirst(strings.ToLower(word)) } - if !lastWasUpper && unicode.IsUpper(c) { - tail := len(rs) - i - if maxCommonInitialismsLen < tail { - tail = maxCommonInitialismsLen + runes = append(runes, []rune(word)...) + }) + + return sanitizeKeywords(string(runes)) +} + +func wordWalker(str string, f func(word string, hasCommonInitial bool)) { + + skipRune := func(r rune) bool { + switch r { + case '-', '_': + return true + default: + return false + } + } + + runes := []rune(str) + w, i := 0, 0 // index of start of word, scan + hasCommonInitial := false + for i+1 <= len(runes) { + eow := false // whether we hit the end of a word + if i+1 == len(runes) { + eow = true + } else if skipRune(runes[i+1]) { + // underscore; shift the remainder forward over any run of underscores + eow = true + n := 1 + for i+n+1 < len(runes) && skipRune(runes[i+n+1]) { + n++ } - for j := tail; j != 0; j-- { - word := string(rs[i : i+j]) - if commonInitialisms[word] { - buf.WriteString(word) - i += j - 1 - upper = false - lastWasUpper = false // IDFoo will be IDFoo, not IDfoo - continue outer - } + + // Leave at most one underscore if the underscore is between two digits + if i+n+1 < len(runes) && unicode.IsDigit(runes[i]) && unicode.IsDigit(runes[i+n+1]) { + n-- } - upper = true + copy(runes[i+1:], runes[i+n+1:]) + runes = runes[:len(runes)-n] + } else if unicode.IsLower(runes[i]) && !unicode.IsLower(runes[i+1]) { + // lower->non-lower + eow = true } + i++ - if upper { - buf.WriteRune(unicode.ToUpper(c)) - } else { - buf.WriteRune(unicode.ToLower(c)) + // [w,i) is a word. + word := string(runes[w:i]) + if !eow && commonInitialisms[word] && !unicode.IsLower(runes[i]) { + // through + // split IDFoo → ID, Foo + // but URLs → URLs + } else if !eow { + if commonInitialisms[word] { + hasCommonInitial = true + } + continue } - upper = false - lastWasUpper = unicode.IsUpper(c) - } - return buf.String() -} - -func ToGo(name string) string { - return lintName(ToCamel(name)) -} + if u := strings.ToUpper(word); commonInitialisms[u] { + hasCommonInitial = true + word = u + } -func ToGoPrivate(name string) string { - return lintName(sanitizeKeywords(lcFirst(ToCamel(name)))) + f(word, hasCommonInitial) + hasCommonInitial = false + w = i + } } var keywords = []string{ diff --git a/codegen/templates/templates_test.go b/codegen/templates/templates_test.go index 5debc545ab2..47700b4ef5c 100644 --- a/codegen/templates/templates_test.go +++ b/codegen/templates/templates_test.go @@ -6,25 +6,89 @@ import ( "github.com/stretchr/testify/require" ) -func TestToCamel(t *testing.T) { - require.Equal(t, "ToCamel", ToCamel("TO_CAMEL")) - require.Equal(t, "ToCamel", ToCamel("to_camel")) - require.Equal(t, "ToCamel", ToCamel("toCamel")) - require.Equal(t, "ToCamel", ToCamel("ToCamel")) - require.Equal(t, "ToCamel", ToCamel("to-camel")) - - require.Equal(t, "RelatedURLs", ToCamel("RelatedURLs")) - require.Equal(t, "ImageIDs", ToCamel("ImageIDs")) - require.Equal(t, "FooID", ToCamel("FooID")) - require.Equal(t, "IDFoo", ToCamel("IDFoo")) - require.Equal(t, "FooASCII", ToCamel("FooASCII")) - require.Equal(t, "ASCIIFoo", ToCamel("ASCIIFoo")) - require.Equal(t, "FooUTF8", ToCamel("FooUTF8")) - require.Equal(t, "UTF8Foo", ToCamel("UTF8Foo")) - - require.Equal(t, "A", ToCamel("A")) - require.Equal(t, "ID", ToCamel("ID")) - require.Equal(t, "", ToCamel("")) +func TestToGo(t *testing.T) { + require.Equal(t, "ToCamel", ToGo("TO_CAMEL")) + require.Equal(t, "ToCamel", ToGo("to_camel")) + require.Equal(t, "ToCamel", ToGo("toCamel")) + require.Equal(t, "ToCamel", ToGo("ToCamel")) + require.Equal(t, "ToCamel", ToGo("to-camel")) + + require.Equal(t, "RelatedURLs", ToGo("RelatedURLs")) + require.Equal(t, "ImageIDs", ToGo("ImageIDs")) + require.Equal(t, "FooID", ToGo("FooID")) + require.Equal(t, "IDFoo", ToGo("IDFoo")) + require.Equal(t, "FooASCII", ToGo("FooASCII")) + require.Equal(t, "ASCIIFoo", ToGo("ASCIIFoo")) + require.Equal(t, "FooUTF8", ToGo("FooUTF8")) + require.Equal(t, "UTF8Foo", ToGo("UTF8Foo")) + require.Equal(t, "JSONEncoding", ToGo("JSONEncoding")) + + require.Equal(t, "A", ToGo("A")) + require.Equal(t, "ID", ToGo("ID")) + require.Equal(t, "", ToGo("")) + + require.Equal(t, "RelatedUrls", ToGo("RelatedUrls")) +} + +func TestToGoPrivate(t *testing.T) { + require.Equal(t, "toCamel", ToGoPrivate("TO_CAMEL")) + require.Equal(t, "toCamel", ToGoPrivate("to_camel")) + require.Equal(t, "toCamel", ToGoPrivate("toCamel")) + require.Equal(t, "toCamel", ToGoPrivate("ToCamel")) + require.Equal(t, "toCamel", ToGoPrivate("to-camel")) + + require.Equal(t, "relatedURLs", ToGoPrivate("RelatedURLs")) + require.Equal(t, "imageIDs", ToGoPrivate("ImageIDs")) + require.Equal(t, "fooID", ToGoPrivate("FooID")) + require.Equal(t, "idFoo", ToGoPrivate("IDFoo")) + require.Equal(t, "fooASCII", ToGoPrivate("FooASCII")) + require.Equal(t, "asciiFoo", ToGoPrivate("ASCIIFoo")) + require.Equal(t, "fooUTF8", ToGoPrivate("FooUTF8")) + require.Equal(t, "utf8Foo", ToGoPrivate("UTF8Foo")) + require.Equal(t, "jsonEncoding", ToGoPrivate("JSONEncoding")) + + require.Equal(t, "rangeArg", ToGoPrivate("Range")) + + require.Equal(t, "a", ToGoPrivate("A")) + require.Equal(t, "id", ToGoPrivate("ID")) + require.Equal(t, "", ToGoPrivate("")) +} + +func Test_wordWalker(t *testing.T) { + + type Result struct { + Value string + HasCommonInitial bool + } + helper := func(str string) []*Result { + resultList := []*Result{} + wordWalker(str, func(word string, hasCommonInitial bool) { + resultList = append(resultList, &Result{word, hasCommonInitial}) + }) + return resultList + } + + require.Equal(t, []*Result{{Value: "TO"}, {Value: "CAMEL"}}, helper("TO_CAMEL")) + require.Equal(t, []*Result{{Value: "to"}, {Value: "camel"}}, helper("to_camel")) + require.Equal(t, []*Result{{Value: "to"}, {Value: "Camel"}}, helper("toCamel")) + require.Equal(t, []*Result{{Value: "To"}, {Value: "Camel"}}, helper("ToCamel")) + require.Equal(t, []*Result{{Value: "to"}, {Value: "camel"}}, helper("to-camel")) + + require.Equal(t, []*Result{{Value: "Related"}, {Value: "URLs", HasCommonInitial: true}}, helper("RelatedURLs")) + require.Equal(t, []*Result{{Value: "Image"}, {Value: "IDs", HasCommonInitial: true}}, helper("ImageIDs")) + require.Equal(t, []*Result{{Value: "Foo"}, {Value: "ID", HasCommonInitial: true}}, helper("FooID")) + require.Equal(t, []*Result{{Value: "ID", HasCommonInitial: true}, {Value: "Foo"}}, helper("IDFoo")) + require.Equal(t, []*Result{{Value: "Foo"}, {Value: "ASCII", HasCommonInitial: true}}, helper("FooASCII")) + require.Equal(t, []*Result{{Value: "ASCII", HasCommonInitial: true}, {Value: "Foo"}}, helper("ASCIIFoo")) + require.Equal(t, []*Result{{Value: "Foo"}, {Value: "UTF8", HasCommonInitial: true}}, helper("FooUTF8")) + require.Equal(t, []*Result{{Value: "UTF8", HasCommonInitial: true}, {Value: "Foo"}}, helper("UTF8Foo")) + + require.Equal(t, []*Result{{Value: "A"}}, helper("A")) + require.Equal(t, []*Result{{Value: "ID", HasCommonInitial: true}}, helper("ID")) + require.Equal(t, []*Result{{Value: "ID", HasCommonInitial: true}}, helper("id")) + require.Equal(t, []*Result{}, helper("")) + + require.Equal(t, []*Result{{Value: "Related"}, {Value: "Urls"}}, helper("RelatedUrls")) } func TestCenter(t *testing.T) { From 2c3783f18f3b679ece4fffed18fa839977e8359d Mon Sep 17 00:00:00 2001 From: vvakame Date: Wed, 6 Mar 2019 19:13:32 +0900 Subject: [PATCH 116/147] some refactoring --- codegen/templates/templates.go | 35 +++++++++++++----- codegen/templates/templates_test.go | 56 ++++++++++++++--------------- 2 files changed, 53 insertions(+), 38 deletions(-) diff --git a/codegen/templates/templates.go b/codegen/templates/templates.go index fe51caaf5a4..a919a829ecc 100644 --- a/codegen/templates/templates.go +++ b/codegen/templates/templates.go @@ -230,8 +230,11 @@ func Call(p *types.Func) string { func ToGo(name string) string { runes := make([]rune, 0, len(name)) - wordWalker(name, func(word string, hasCommonInitial bool) { - if !hasCommonInitial { + wordWalker(name, func(info *wordInfo) { + word := info.Word + if info.MatchCommonInitial { + word = strings.ToUpper(word) + } else if !info.HasCommonInitial { word = ucFirst(strings.ToLower(word)) } runes = append(runes, []rune(word)...) @@ -244,11 +247,14 @@ func ToGoPrivate(name string) string { runes := make([]rune, 0, len(name)) first := true - wordWalker(name, func(word string, hasCommonInitial bool) { + wordWalker(name, func(info *wordInfo) { + word := info.Word if first { - word = strings.ToLower(word) + word = strings.ToLower(info.Word) first = false - } else if !hasCommonInitial { + } else if info.MatchCommonInitial { + word = strings.ToUpper(word) + } else if !info.HasCommonInitial { word = ucFirst(strings.ToLower(word)) } runes = append(runes, []rune(word)...) @@ -257,7 +263,13 @@ func ToGoPrivate(name string) string { return sanitizeKeywords(string(runes)) } -func wordWalker(str string, f func(word string, hasCommonInitial bool)) { +type wordInfo struct { + Word string + MatchCommonInitial bool + HasCommonInitial bool +} + +func wordWalker(str string, f func(*wordInfo)) { skipRune := func(r rune) bool { switch r { @@ -309,12 +321,17 @@ func wordWalker(str string, f func(word string, hasCommonInitial bool)) { continue } - if u := strings.ToUpper(word); commonInitialisms[u] { + matchCommonInitial := false + if commonInitialisms[strings.ToUpper(word)] { hasCommonInitial = true - word = u + matchCommonInitial = true } - f(word, hasCommonInitial) + f(&wordInfo{ + Word: word, + MatchCommonInitial: matchCommonInitial, + HasCommonInitial: hasCommonInitial, + }) hasCommonInitial = false w = i } diff --git a/codegen/templates/templates_test.go b/codegen/templates/templates_test.go index 47700b4ef5c..cea36a3018f 100644 --- a/codegen/templates/templates_test.go +++ b/codegen/templates/templates_test.go @@ -25,6 +25,7 @@ func TestToGo(t *testing.T) { require.Equal(t, "A", ToGo("A")) require.Equal(t, "ID", ToGo("ID")) + require.Equal(t, "ID", ToGo("id")) require.Equal(t, "", ToGo("")) require.Equal(t, "RelatedUrls", ToGo("RelatedUrls")) @@ -51,44 +52,41 @@ func TestToGoPrivate(t *testing.T) { require.Equal(t, "a", ToGoPrivate("A")) require.Equal(t, "id", ToGoPrivate("ID")) + require.Equal(t, "id", ToGoPrivate("id")) require.Equal(t, "", ToGoPrivate("")) } func Test_wordWalker(t *testing.T) { - type Result struct { - Value string - HasCommonInitial bool - } - helper := func(str string) []*Result { - resultList := []*Result{} - wordWalker(str, func(word string, hasCommonInitial bool) { - resultList = append(resultList, &Result{word, hasCommonInitial}) + helper := func(str string) []*wordInfo { + resultList := []*wordInfo{} + wordWalker(str, func(info *wordInfo) { + resultList = append(resultList, info) }) return resultList } - require.Equal(t, []*Result{{Value: "TO"}, {Value: "CAMEL"}}, helper("TO_CAMEL")) - require.Equal(t, []*Result{{Value: "to"}, {Value: "camel"}}, helper("to_camel")) - require.Equal(t, []*Result{{Value: "to"}, {Value: "Camel"}}, helper("toCamel")) - require.Equal(t, []*Result{{Value: "To"}, {Value: "Camel"}}, helper("ToCamel")) - require.Equal(t, []*Result{{Value: "to"}, {Value: "camel"}}, helper("to-camel")) - - require.Equal(t, []*Result{{Value: "Related"}, {Value: "URLs", HasCommonInitial: true}}, helper("RelatedURLs")) - require.Equal(t, []*Result{{Value: "Image"}, {Value: "IDs", HasCommonInitial: true}}, helper("ImageIDs")) - require.Equal(t, []*Result{{Value: "Foo"}, {Value: "ID", HasCommonInitial: true}}, helper("FooID")) - require.Equal(t, []*Result{{Value: "ID", HasCommonInitial: true}, {Value: "Foo"}}, helper("IDFoo")) - require.Equal(t, []*Result{{Value: "Foo"}, {Value: "ASCII", HasCommonInitial: true}}, helper("FooASCII")) - require.Equal(t, []*Result{{Value: "ASCII", HasCommonInitial: true}, {Value: "Foo"}}, helper("ASCIIFoo")) - require.Equal(t, []*Result{{Value: "Foo"}, {Value: "UTF8", HasCommonInitial: true}}, helper("FooUTF8")) - require.Equal(t, []*Result{{Value: "UTF8", HasCommonInitial: true}, {Value: "Foo"}}, helper("UTF8Foo")) - - require.Equal(t, []*Result{{Value: "A"}}, helper("A")) - require.Equal(t, []*Result{{Value: "ID", HasCommonInitial: true}}, helper("ID")) - require.Equal(t, []*Result{{Value: "ID", HasCommonInitial: true}}, helper("id")) - require.Equal(t, []*Result{}, helper("")) - - require.Equal(t, []*Result{{Value: "Related"}, {Value: "Urls"}}, helper("RelatedUrls")) + require.Equal(t, []*wordInfo{{Word: "TO"}, {Word: "CAMEL"}}, helper("TO_CAMEL")) + require.Equal(t, []*wordInfo{{Word: "to"}, {Word: "camel"}}, helper("to_camel")) + require.Equal(t, []*wordInfo{{Word: "to"}, {Word: "Camel"}}, helper("toCamel")) + require.Equal(t, []*wordInfo{{Word: "To"}, {Word: "Camel"}}, helper("ToCamel")) + require.Equal(t, []*wordInfo{{Word: "to"}, {Word: "camel"}}, helper("to-camel")) + + require.Equal(t, []*wordInfo{{Word: "Related"}, {Word: "URLs", HasCommonInitial: true}}, helper("RelatedURLs")) + require.Equal(t, []*wordInfo{{Word: "Image"}, {Word: "IDs", HasCommonInitial: true}}, helper("ImageIDs")) + require.Equal(t, []*wordInfo{{Word: "Foo"}, {Word: "ID", HasCommonInitial: true, MatchCommonInitial: true}}, helper("FooID")) + require.Equal(t, []*wordInfo{{Word: "ID", HasCommonInitial: true, MatchCommonInitial: true}, {Word: "Foo"}}, helper("IDFoo")) + require.Equal(t, []*wordInfo{{Word: "Foo"}, {Word: "ASCII", HasCommonInitial: true, MatchCommonInitial: true}}, helper("FooASCII")) + require.Equal(t, []*wordInfo{{Word: "ASCII", HasCommonInitial: true, MatchCommonInitial: true}, {Word: "Foo"}}, helper("ASCIIFoo")) + require.Equal(t, []*wordInfo{{Word: "Foo"}, {Word: "UTF8", HasCommonInitial: true, MatchCommonInitial: true}}, helper("FooUTF8")) + require.Equal(t, []*wordInfo{{Word: "UTF8", HasCommonInitial: true, MatchCommonInitial: true}, {Word: "Foo"}}, helper("UTF8Foo")) + + require.Equal(t, []*wordInfo{{Word: "A"}}, helper("A")) + require.Equal(t, []*wordInfo{{Word: "ID", HasCommonInitial: true, MatchCommonInitial: true}}, helper("ID")) + require.Equal(t, []*wordInfo{{Word: "id", HasCommonInitial: true, MatchCommonInitial: true}}, helper("id")) + require.Equal(t, []*wordInfo{}, helper("")) + + require.Equal(t, []*wordInfo{{Word: "Related"}, {Word: "Urls"}}, helper("RelatedUrls")) } func TestCenter(t *testing.T) { From 52838cca91034b6e26733eaa896e3c426be50eed Mon Sep 17 00:00:00 2001 From: vvakame Date: Wed, 6 Mar 2019 19:19:16 +0900 Subject: [PATCH 117/147] fix ci --- codegen/templates/templates.go | 84 ++-------------------------------- 1 file changed, 4 insertions(+), 80 deletions(-) diff --git a/codegen/templates/templates.go b/codegen/templates/templates.go index a919a829ecc..5f0fda9d646 100644 --- a/codegen/templates/templates.go +++ b/codegen/templates/templates.go @@ -269,17 +269,9 @@ type wordInfo struct { HasCommonInitial bool } +// This function is based on the following code. +// https://github.com/golang/lint/blob/06c8688daad7faa9da5a0c2f163a3d14aac986ca/lint.go#L679 func wordWalker(str string, f func(*wordInfo)) { - - skipRune := func(r rune) bool { - switch r { - case '-', '_': - return true - default: - return false - } - } - runes := []rune(str) w, i := 0, 0 // index of start of word, scan hasCommonInitial := false @@ -287,11 +279,11 @@ func wordWalker(str string, f func(*wordInfo)) { eow := false // whether we hit the end of a word if i+1 == len(runes) { eow = true - } else if skipRune(runes[i+1]) { + } else if isDelimiter(runes[i+1]) { // underscore; shift the remainder forward over any run of underscores eow = true n := 1 - for i+n+1 < len(runes) && skipRune(runes[i+n+1]) { + for i+n+1 < len(runes) && isDelimiter(runes[i+n+1]) { n++ } @@ -376,74 +368,6 @@ func sanitizeKeywords(name string) string { return name } -// copy from https://github.com/golang/lint/blob/06c8688daad7faa9da5a0c2f163a3d14aac986ca/lint.go#L679 -func lintName(name string) string { - // Fast path for simple cases: "_" and all lowercase. - if name == "_" { - return name - } - allLower := true - for _, r := range name { - if !unicode.IsLower(r) { - allLower = false - break - } - } - if allLower { - return name - } - - // Split camelCase at any lower->upper transition, and split on underscores. - // Check each word for common initialisms. - runes := []rune(name) - w, i := 0, 0 // index of start of word, scan - for i+1 <= len(runes) { - eow := false // whether we hit the end of a word - if i+1 == len(runes) { - eow = true - } else if runes[i+1] == '_' { - // underscore; shift the remainder forward over any run of underscores - eow = true - n := 1 - for i+n+1 < len(runes) && runes[i+n+1] == '_' { - n++ - } - - // Leave at most one underscore if the underscore is between two digits - if i+n+1 < len(runes) && unicode.IsDigit(runes[i]) && unicode.IsDigit(runes[i+n+1]) { - n-- - } - - copy(runes[i+1:], runes[i+n+1:]) - runes = runes[:len(runes)-n] - } else if unicode.IsLower(runes[i]) && !unicode.IsLower(runes[i+1]) { - // lower->non-lower - eow = true - } - i++ - if !eow { - continue - } - - // [w,i) is a word. - word := string(runes[w:i]) - if u := strings.ToUpper(word); commonInitialisms[u] { - // Keep consistent case, which is lowercase only at the start. - if w == 0 && unicode.IsLower(runes[w]) { - u = strings.ToLower(u) - } - // All the common initialisms are ASCII, - // so we can replace the bytes exactly. - copy(runes[w:], []rune(u)) - } else if w > 0 && strings.ToLower(word) == word { - // already all lowercase, and not the first word, so uppercase the first character. - runes[w] = unicode.ToUpper(runes[w]) - } - w = i - } - return string(runes) -} - // commonInitialisms is a set of common initialisms. // Only add entries that are highly unlikely to be non-initialisms. // For instance, "ID" is fine (Freudian code is rare), but "AND" is not. From b27139ed5c290214d979e374a23689fc36eed78a Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Wed, 6 Mar 2019 22:29:14 +1100 Subject: [PATCH 118/147] Fix default scalar implementation regression --- codegen/testserver/generated.go | 90 +++++++++++++++++++++++ codegen/testserver/resolver.go | 3 + codegen/testserver/scalar_default.graphql | 6 ++ codegen/testserver/scalar_default_test.go | 34 +++++++++ codegen/testserver/stub.go | 4 + plugin/modelgen/models.go | 9 ++- 6 files changed, 144 insertions(+), 2 deletions(-) create mode 100644 codegen/testserver/scalar_default.graphql create mode 100644 codegen/testserver/scalar_default_test.go diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 3eb743e9b26..7d941db3a31 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -132,6 +132,7 @@ type ComplexityRoot struct { Autobind func(childComplexity int) int DeprecatedField func(childComplexity int) int Panics func(childComplexity int) int + DefaultScalar func(childComplexity int, arg string) int ValidType func(childComplexity int) int } @@ -194,6 +195,7 @@ type QueryResolver interface { Autobind(ctx context.Context) (*Autobind, error) DeprecatedField(ctx context.Context) (string, error) Panics(ctx context.Context) (*Panics, error) + DefaultScalar(ctx context.Context, arg string) (string, error) ValidType(ctx context.Context) (*ValidType, error) } type SubscriptionResolver interface { @@ -594,6 +596,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Panics(childComplexity), true + case "Query.DefaultScalar": + if e.complexity.Query.DefaultScalar == nil { + break + } + + args, err := ec.field_Query_defaultScalar_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.DefaultScalar(childComplexity, args["arg"].(string)), true + case "Query.ValidType": if e.complexity.Query.ValidType == nil { break @@ -838,6 +852,13 @@ type Panics { } scalar MarshalPanic +`}, + &ast.Source{Name: "scalar_default.graphql", Input: `extend type Query { + defaultScalar(arg: DefaultScalarImplementation! = "default"): DefaultScalarImplementation! +} + +""" This doesnt have an implementation in the typemap, so it should act like a string """ +scalar DefaultScalarImplementation `}, &ast.Source{Name: "schema.graphql", Input: `type Query { invalidIdentifier: InvalidIdentifier @@ -1136,6 +1157,20 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs return args, nil } +func (ec *executionContext) field_Query_defaultScalar_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["arg"]; ok { + arg0, err = ec.unmarshalNDefaultScalarImplementation2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["arg"] = arg0 + return args, nil +} + func (ec *executionContext) field_Query_directiveArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -2768,6 +2803,39 @@ func (ec *executionContext) _Query_panics(ctx context.Context, field graphql.Col return ec.marshalOPanics2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPanics(ctx, field.Selections, res) } +func (ec *executionContext) _Query_defaultScalar(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_defaultScalar_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().DefaultScalar(rctx, args["arg"].(string)) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNDefaultScalarImplementation2string(ctx, field.Selections, res) +} + func (ec *executionContext) _Query_validType(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -4993,6 +5061,20 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr res = ec._Query_panics(ctx, field) return res }) + case "defaultScalar": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_defaultScalar(ctx, field) + if res == graphql.Null { + invalid = true + } + return res + }) case "validType": field := field out.Concurrently(i, func() (res graphql.Marshaler) { @@ -5412,6 +5494,14 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se return graphql.MarshalBoolean(v) } +func (ec *executionContext) unmarshalNDefaultScalarImplementation2string(ctx context.Context, v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalNDefaultScalarImplementation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + func (ec *executionContext) unmarshalNID2int(ctx context.Context, v interface{}) (int, error) { return graphql.UnmarshalIntID(v) } diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index fc062c5f01f..4c1e2294063 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -116,6 +116,9 @@ func (r *queryResolver) DeprecatedField(ctx context.Context) (string, error) { func (r *queryResolver) Panics(ctx context.Context) (*Panics, error) { panic("not implemented") } +func (r *queryResolver) DefaultScalar(ctx context.Context, arg string) (string, error) { + panic("not implemented") +} func (r *queryResolver) ValidType(ctx context.Context) (*ValidType, error) { panic("not implemented") } diff --git a/codegen/testserver/scalar_default.graphql b/codegen/testserver/scalar_default.graphql new file mode 100644 index 00000000000..56495bad727 --- /dev/null +++ b/codegen/testserver/scalar_default.graphql @@ -0,0 +1,6 @@ +extend type Query { + defaultScalar(arg: DefaultScalarImplementation! = "default"): DefaultScalarImplementation! +} + +""" This doesnt have an implementation in the typemap, so it should act like a string """ +scalar DefaultScalarImplementation diff --git a/codegen/testserver/scalar_default_test.go b/codegen/testserver/scalar_default_test.go new file mode 100644 index 00000000000..4b438560ceb --- /dev/null +++ b/codegen/testserver/scalar_default_test.go @@ -0,0 +1,34 @@ +package testserver + +import ( + "context" + "net/http/httptest" + "testing" + + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/handler" + "github.com/stretchr/testify/require" +) + +func TestDefaultScalarImplementation(t *testing.T) { + resolvers := &Stub{} + + srv := httptest.NewServer(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolvers}))) + c := client.New(srv.URL) + + resolvers.QueryResolver.DefaultScalar = func(ctx context.Context, arg string) (i string, e error) { + return arg, nil + } + + t.Run("with arg value", func(t *testing.T) { + var resp struct{ DefaultScalar string } + c.MustPost(`query { defaultScalar(arg: "fff") }`, &resp) + require.Equal(t, "fff", resp.DefaultScalar) + }) + + t.Run("with default value", func(t *testing.T) { + var resp struct{ DefaultScalar string } + c.MustPost(`query { defaultScalar }`, &resp) + require.Equal(t, "default", resp.DefaultScalar) + }) +} diff --git a/codegen/testserver/stub.go b/codegen/testserver/stub.go index 783f8aff58a..4388ad0dd69 100644 --- a/codegen/testserver/stub.go +++ b/codegen/testserver/stub.go @@ -42,6 +42,7 @@ type Stub struct { Autobind func(ctx context.Context) (*Autobind, error) DeprecatedField func(ctx context.Context) (string, error) Panics func(ctx context.Context) (*Panics, error) + DefaultScalar func(ctx context.Context, arg string) (string, error) ValidType func(ctx context.Context) (*ValidType, error) } SubscriptionResolver struct { @@ -158,6 +159,9 @@ func (r *stubQuery) DeprecatedField(ctx context.Context) (string, error) { func (r *stubQuery) Panics(ctx context.Context) (*Panics, error) { return r.QueryResolver.Panics(ctx) } +func (r *stubQuery) DefaultScalar(ctx context.Context, arg string) (string, error) { + return r.QueryResolver.DefaultScalar(ctx, arg) +} func (r *stubQuery) ValidType(ctx context.Context) (*ValidType, error) { return r.QueryResolver.ValidType(ctx) } diff --git a/plugin/modelgen/models.go b/plugin/modelgen/models.go index 2be7dfb2cfa..2c9a6fb3c49 100644 --- a/plugin/modelgen/models.go +++ b/plugin/modelgen/models.go @@ -4,10 +4,9 @@ import ( "go/types" "sort" - "github.com/99designs/gqlgen/internal/code" - "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/codegen/templates" + "github.com/99designs/gqlgen/internal/code" "github.com/99designs/gqlgen/plugin" "github.com/vektah/gqlparser/ast" ) @@ -17,6 +16,7 @@ type ModelBuild struct { Interfaces []*Interface Models []*Object Enums []*Enum + Scalars []string } type Interface struct { @@ -159,6 +159,8 @@ func (m *Plugin) MutateConfig(cfg *config.Config) error { } b.Enums = append(b.Enums, it) + case ast.Scalar: + b.Scalars = append(b.Scalars, schemaType.Name) } } @@ -175,6 +177,9 @@ func (m *Plugin) MutateConfig(cfg *config.Config) error { for _, it := range b.Interfaces { cfg.Models.Add(it.Name, cfg.Model.ImportPath()+"."+it.Name) } + for _, it := range b.Scalars { + cfg.Models.Add(it, "github.com/99designs/gqlgen/graphql.String") + } if len(b.Models) == 0 && len(b.Enums) == 0 { return nil From de3b7cb825c9676c720826472c7c54b0c0301ce0 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Wed, 6 Mar 2019 23:04:49 +1100 Subject: [PATCH 119/147] Fix autocasing modelgen bugs --- codegen/testserver/generated.go | 393 ++++++++++++++++++++ codegen/testserver/models-gen.go | 24 ++ codegen/testserver/weird_type_cases.graphql | 8 + plugin/modelgen/models.go | 22 +- plugin/modelgen/models.gotpl | 34 +- 5 files changed, 451 insertions(+), 30 deletions(-) create mode 100644 codegen/testserver/weird_type_cases.graphql diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 7d941db3a31..eb87e3f064f 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -53,6 +53,14 @@ type DirectiveRoot struct { } type ComplexityRoot struct { + Ait struct { + ID func(childComplexity int) int + } + + AbIt struct { + ID func(childComplexity int) int + } + Autobind struct { Int func(childComplexity int) int Int32 func(childComplexity int) int @@ -160,6 +168,22 @@ type ComplexityRoot struct { ValidInputKeywords func(childComplexity int, input *ValidInput) int ValidArgs func(childComplexity int, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string, _Arg string) int } + + Xxit struct { + ID func(childComplexity int) int + } + + XxIt struct { + ID func(childComplexity int) int + } + + AsdfIt struct { + ID func(childComplexity int) int + } + + IIt struct { + ID func(childComplexity int) int + } } type ForcedResolverResolver interface { @@ -221,6 +245,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { + case "AIt.ID": + if e.complexity.Ait.ID == nil { + break + } + + return e.complexity.Ait.ID(childComplexity), true + + case "AbIt.ID": + if e.complexity.AbIt.ID == nil { + break + } + + return e.complexity.AbIt.ID(childComplexity), true + case "Autobind.Int": if e.complexity.Autobind.Int == nil { break @@ -716,6 +754,34 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.ValidType.ValidArgs(childComplexity, 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), args["_"].(string)), true + case "XXIt.ID": + if e.complexity.Xxit.ID == nil { + break + } + + return e.complexity.Xxit.ID(childComplexity), true + + case "XxIt.ID": + if e.complexity.XxIt.ID == nil { + break + } + + return e.complexity.XxIt.ID(childComplexity), true + + case "asdfIt.ID": + if e.complexity.AsdfIt.ID == nil { + break + } + + return e.complexity.AsdfIt.ID(childComplexity), true + + case "iIt.ID": + if e.complexity.IIt.ID == nil { + break + } + + return e.complexity.IIt.ID(childComplexity), true + } return 0, false } @@ -1064,6 +1130,15 @@ input ValidInput { _: String! } +`}, + &ast.Source{Name: "weird_type_cases.graphql", Input: `# regression test for https://github.com/99designs/gqlgen/issues/583 + +type asdfIt { id: ID! } +type iIt { id: ID! } +type AIt { id: ID! } +type XXIt { id: ID! } +type AbIt { id: ID! } +type XxIt { id: ID! } `}, ) @@ -1615,6 +1690,58 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg // region **************************** field.gotpl ***************************** +func (ec *executionContext) _AIt_id(ctx context.Context, field graphql.CollectedField, obj *Ait) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "AIt", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) _AbIt_id(ctx context.Context, field graphql.CollectedField, obj *AbIt) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "AbIt", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNID2string(ctx, field.Selections, res) +} + func (ec *executionContext) _Autobind_int(ctx context.Context, field graphql.CollectedField, obj *Autobind) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3256,6 +3383,58 @@ func (ec *executionContext) _ValidType_validArgs(ctx context.Context, field grap return ec.marshalNBoolean2bool(ctx, field.Selections, res) } +func (ec *executionContext) _XXIt_id(ctx context.Context, field graphql.CollectedField, obj *Xxit) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "XXIt", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) _XxIt_id(ctx context.Context, field graphql.CollectedField, obj *XxIt) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "XxIt", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNID2string(ctx, field.Selections, res) +} + func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -4051,6 +4230,58 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } +func (ec *executionContext) _asdfIt_id(ctx context.Context, field graphql.CollectedField, obj *AsdfIt) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "asdfIt", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) _iIt_id(ctx context.Context, field graphql.CollectedField, obj *IIt) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "iIt", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNID2string(ctx, field.Selections, res) +} + // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** @@ -4402,6 +4633,60 @@ func (ec *executionContext) _ShapeUnion(ctx context.Context, sel ast.SelectionSe // region **************************** object.gotpl **************************** +var aItImplementors = []string{"AIt"} + +func (ec *executionContext) _AIt(ctx context.Context, sel ast.SelectionSet, obj *Ait) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, aItImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("AIt") + case "id": + out.Values[i] = ec._AIt_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var abItImplementors = []string{"AbIt"} + +func (ec *executionContext) _AbIt(ctx context.Context, sel ast.SelectionSet, obj *AbIt) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, abItImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("AbIt") + case "id": + out.Values[i] = ec._AbIt_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + var autobindImplementors = []string{"Autobind"} func (ec *executionContext) _Autobind(ctx context.Context, sel ast.SelectionSet, obj *Autobind) graphql.Marshaler { @@ -5241,6 +5526,60 @@ func (ec *executionContext) _ValidType(ctx context.Context, sel ast.SelectionSet return out } +var xXItImplementors = []string{"XXIt"} + +func (ec *executionContext) _XXIt(ctx context.Context, sel ast.SelectionSet, obj *Xxit) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, xXItImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("XXIt") + case "id": + out.Values[i] = ec._XXIt_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var xxItImplementors = []string{"XxIt"} + +func (ec *executionContext) _XxIt(ctx context.Context, sel ast.SelectionSet, obj *XxIt) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, xxItImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("XxIt") + case "id": + out.Values[i] = ec._XxIt_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { @@ -5482,6 +5821,60 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o return out } +var asdfItImplementors = []string{"asdfIt"} + +func (ec *executionContext) _asdfIt(ctx context.Context, sel ast.SelectionSet, obj *AsdfIt) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, asdfItImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("asdfIt") + case "id": + out.Values[i] = ec._asdfIt_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + +var iItImplementors = []string{"iIt"} + +func (ec *executionContext) _iIt(ctx context.Context, sel ast.SelectionSet, obj *IIt) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, iItImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("iIt") + case "id": + out.Values[i] = ec._iIt_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** diff --git a/codegen/testserver/models-gen.go b/codegen/testserver/models-gen.go index f0af1136297..b03f379f332 100644 --- a/codegen/testserver/models-gen.go +++ b/codegen/testserver/models-gen.go @@ -9,6 +9,14 @@ import ( "time" ) +type Ait struct { + ID string `json:"id"` +} + +type AbIt struct { + ID string `json:"id"` +} + type InnerDirectives struct { Message string `json:"message"` } @@ -80,6 +88,22 @@ type ValidType struct { ValidArgs bool `json:"validArgs"` } +type Xxit struct { + ID string `json:"id"` +} + +type XxIt struct { + ID string `json:"id"` +} + +type AsdfIt struct { + ID string `json:"id"` +} + +type IIt struct { + ID string `json:"id"` +} + type Status string const ( diff --git a/codegen/testserver/weird_type_cases.graphql b/codegen/testserver/weird_type_cases.graphql new file mode 100644 index 00000000000..afd440f1d12 --- /dev/null +++ b/codegen/testserver/weird_type_cases.graphql @@ -0,0 +1,8 @@ +# regression test for https://github.com/99designs/gqlgen/issues/583 + +type asdfIt { id: ID! } +type iIt { id: ID! } +type AIt { id: ID! } +type XXIt { id: ID! } +type AbIt { id: ID! } +type XxIt { id: ID! } diff --git a/plugin/modelgen/models.go b/plugin/modelgen/models.go index 2c9a6fb3c49..b4e089e994f 100644 --- a/plugin/modelgen/models.go +++ b/plugin/modelgen/models.go @@ -41,14 +41,12 @@ type Field struct { type Enum struct { Description string Name string - Raw string Values []*EnumValue } type EnumValue struct { Description string Name string - Value string } func New() plugin.Plugin { @@ -93,7 +91,7 @@ func (m *Plugin) MutateConfig(cfg *config.Config) error { case ast.Interface, ast.Union: it := &Interface{ Description: schemaType.Description, - Name: templates.ToGo(schemaType.Name), + Name: schemaType.Name, } b.Interfaces = append(b.Interfaces, it) @@ -103,11 +101,11 @@ func (m *Plugin) MutateConfig(cfg *config.Config) error { } it := &Object{ Description: schemaType.Description, - Name: templates.ToGo(schemaType.Name), + Name: schemaType.Name, } for _, implementor := range schema.GetImplements(schemaType) { - it.Implements = append(it.Implements, templates.ToGo(implementor.Name)) + it.Implements = append(it.Implements, implementor.Name) } for _, field := range schemaType.Fields { @@ -135,7 +133,7 @@ func (m *Plugin) MutateConfig(cfg *config.Config) error { fd := schema.Types[field.Type.Name()] it.Fields = append(it.Fields, &Field{ - Name: templates.ToGo(name), + Name: name, Type: binder.CopyModifiersFromAst(field.Type, fd.Kind != ast.Interface, typ), Description: field.Description, Tag: `json:"` + field.Name + `"`, @@ -145,15 +143,13 @@ func (m *Plugin) MutateConfig(cfg *config.Config) error { b.Models = append(b.Models, it) case ast.Enum: it := &Enum{ - Name: templates.ToGo(schemaType.Name), - Raw: schemaType.Name, + Name: schemaType.Name, Description: schemaType.Description, } for _, v := range schemaType.EnumValues { it.Values = append(it.Values, &EnumValue{ - Name: templates.ToGo(v.Name), - Value: v.Name, + Name: v.Name, Description: v.Description, }) } @@ -169,13 +165,13 @@ func (m *Plugin) MutateConfig(cfg *config.Config) error { sort.Slice(b.Interfaces, func(i, j int) bool { return b.Interfaces[i].Name < b.Interfaces[j].Name }) for _, it := range b.Enums { - cfg.Models.Add(it.Raw, cfg.Model.ImportPath()+"."+it.Name) + cfg.Models.Add(it.Name, cfg.Model.ImportPath()+"."+templates.ToGo(it.Name)) } for _, it := range b.Models { - cfg.Models.Add(it.Name, cfg.Model.ImportPath()+"."+it.Name) + cfg.Models.Add(it.Name, cfg.Model.ImportPath()+"."+templates.ToGo(it.Name)) } for _, it := range b.Interfaces { - cfg.Models.Add(it.Name, cfg.Model.ImportPath()+"."+it.Name) + cfg.Models.Add(it.Name, cfg.Model.ImportPath()+"."+templates.ToGo(it.Name)) } for _, it := range b.Scalars { cfg.Models.Add(it, "github.com/99designs/gqlgen/graphql.String") diff --git a/plugin/modelgen/models.gotpl b/plugin/modelgen/models.gotpl index 8c406194bdc..d06cf050f7d 100644 --- a/plugin/modelgen/models.gotpl +++ b/plugin/modelgen/models.gotpl @@ -14,71 +14,71 @@ {{- range $model := .Interfaces }} {{ with .Description }} {{.|prefixLines "// "}} {{ end }} - type {{.Name }} interface { - Is{{.Name }}() + type {{.Name|go }} interface { + Is{{.Name|go }}() } {{- end }} {{ range $model := .Models }} {{with .Description }} {{.|prefixLines "// "}} {{end}} - type {{ .Name }} struct { + type {{ .Name|go }} struct { {{- range $field := .Fields }} {{- with .Description }} {{.|prefixLines "// "}} {{- end}} - {{ $field.Name }} {{$field.Type | ref}} `{{$field.Tag}}` + {{ $field.Name|go }} {{$field.Type | ref}} `{{$field.Tag}}` {{- end }} } {{- range $iface := .Implements }} - func ({{ $model.Name }}) Is{{ $iface }}() {} + func ({{ $model.Name|go }}) Is{{ $iface }}() {} {{- end }} {{- end}} {{ range $enum := .Enums }} - {{ with .Description }} {{.|prefixLines "// "}} {{end}} - type {{.Name }} string + {{ with .Description|go }} {{.|prefixLines "// "}} {{end}} + type {{.Name|go }} string const ( {{- range $value := .Values}} {{- with .Description}} {{.|prefixLines "// "}} {{- end}} - {{ $enum.Name }}{{ .Name }} {{$enum.Name }} = {{.Value|quote}} + {{ $enum.Name|go }}{{ .Name|go }} {{$enum.Name|go }} = {{.Name|quote}} {{- end }} ) - var All{{.Name }} = []{{ .Name }}{ + var All{{.Name|go }} = []{{ .Name|go }}{ {{- range $value := .Values}} - {{$enum.Name }}{{ .Name }}, + {{$enum.Name|go }}{{ .Name|go }}, {{- end }} } - func (e {{.Name }}) IsValid() bool { + func (e {{.Name|go }}) IsValid() bool { switch e { - case {{ range $index, $element := .Values}}{{if $index}},{{end}}{{ $enum.Name }}{{ $element.Name }}{{end}}: + case {{ range $index, $element := .Values}}{{if $index}},{{end}}{{ $enum.Name|go }}{{ $element.Name|go }}{{end}}: return true } return false } - func (e {{.Name }}) String() string { + func (e {{.Name|go }}) String() string { return string(e) } - func (e *{{.Name }}) UnmarshalGQL(v interface{}) error { + func (e *{{.Name|go }}) UnmarshalGQL(v interface{}) error { str, ok := v.(string) if !ok { return fmt.Errorf("enums must be strings") } - *e = {{ .Name }}(str) + *e = {{ .Name|go }}(str) if !e.IsValid() { - return fmt.Errorf("%s is not a valid {{ .Raw }}", str) + return fmt.Errorf("%s is not a valid {{ .Name }}", str) } return nil } - func (e {{.Name }}) MarshalGQL(w io.Writer) { + func (e {{.Name|go }}) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } From bc386d79c8cee441951f71814be1a61bbd4b9a5b Mon Sep 17 00:00:00 2001 From: vvakame Date: Thu, 7 Mar 2019 11:59:43 +0900 Subject: [PATCH 120/147] Fix mixed case name handling in ToGo, ToGoPrivate --- codegen/templates/templates.go | 14 ++++++++++++-- codegen/templates/templates_test.go | 6 ++++++ codegen/testserver/generated.go | 20 ++++++++++---------- codegen/testserver/models-gen.go | 4 ++-- 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/codegen/templates/templates.go b/codegen/templates/templates.go index 5f0fda9d646..9d45b6718ef 100644 --- a/codegen/templates/templates.go +++ b/codegen/templates/templates.go @@ -235,7 +235,11 @@ func ToGo(name string) string { if info.MatchCommonInitial { word = strings.ToUpper(word) } else if !info.HasCommonInitial { - word = ucFirst(strings.ToLower(word)) + if strings.ToUpper(word) == word || strings.ToLower(word) == word { + // FOO or foo → Foo + // FOo → FOo + word = ucFirst(strings.ToLower(word)) + } } runes = append(runes, []rune(word)...) }) @@ -250,7 +254,13 @@ func ToGoPrivate(name string) string { wordWalker(name, func(info *wordInfo) { word := info.Word if first { - word = strings.ToLower(info.Word) + if strings.ToUpper(word) == word || strings.ToLower(word) == word { + // ID → id, CAMEL → camel + word = strings.ToLower(info.Word) + } else { + // ITicket → iTicket + word = lcFirst(info.Word) + } first = false } else if info.MatchCommonInitial { word = strings.ToUpper(word) diff --git a/codegen/templates/templates_test.go b/codegen/templates/templates_test.go index cea36a3018f..1e6beb20eea 100644 --- a/codegen/templates/templates_test.go +++ b/codegen/templates/templates_test.go @@ -29,6 +29,8 @@ func TestToGo(t *testing.T) { require.Equal(t, "", ToGo("")) require.Equal(t, "RelatedUrls", ToGo("RelatedUrls")) + require.Equal(t, "ITicket", ToGo("ITicket")) + require.Equal(t, "FooTicket", ToGo("fooTicket")) } func TestToGoPrivate(t *testing.T) { @@ -48,6 +50,9 @@ func TestToGoPrivate(t *testing.T) { require.Equal(t, "utf8Foo", ToGoPrivate("UTF8Foo")) require.Equal(t, "jsonEncoding", ToGoPrivate("JSONEncoding")) + require.Equal(t, "relatedUrls", ToGoPrivate("RelatedUrls")) + require.Equal(t, "iTicket", ToGoPrivate("ITicket")) + require.Equal(t, "rangeArg", ToGoPrivate("Range")) require.Equal(t, "a", ToGoPrivate("A")) @@ -87,6 +92,7 @@ func Test_wordWalker(t *testing.T) { require.Equal(t, []*wordInfo{}, helper("")) require.Equal(t, []*wordInfo{{Word: "Related"}, {Word: "Urls"}}, helper("RelatedUrls")) + require.Equal(t, []*wordInfo{{Word: "ITicket"}}, helper("ITicket")) } func TestCenter(t *testing.T) { diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index eb87e3f064f..ff1805d44be 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -53,7 +53,7 @@ type DirectiveRoot struct { } type ComplexityRoot struct { - Ait struct { + AIt struct { ID func(childComplexity int) int } @@ -169,7 +169,7 @@ type ComplexityRoot struct { ValidArgs func(childComplexity int, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string, _Arg string) int } - Xxit struct { + XXIt struct { ID func(childComplexity int) int } @@ -246,11 +246,11 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in switch typeName + "." + field { case "AIt.ID": - if e.complexity.Ait.ID == nil { + if e.complexity.AIt.ID == nil { break } - return e.complexity.Ait.ID(childComplexity), true + return e.complexity.AIt.ID(childComplexity), true case "AbIt.ID": if e.complexity.AbIt.ID == nil { @@ -755,11 +755,11 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.ValidType.ValidArgs(childComplexity, 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), args["_"].(string)), true case "XXIt.ID": - if e.complexity.Xxit.ID == nil { + if e.complexity.XXIt.ID == nil { break } - return e.complexity.Xxit.ID(childComplexity), true + return e.complexity.XXIt.ID(childComplexity), true case "XxIt.ID": if e.complexity.XxIt.ID == nil { @@ -1690,7 +1690,7 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg // region **************************** field.gotpl ***************************** -func (ec *executionContext) _AIt_id(ctx context.Context, field graphql.CollectedField, obj *Ait) graphql.Marshaler { +func (ec *executionContext) _AIt_id(ctx context.Context, field graphql.CollectedField, obj *AIt) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -3383,7 +3383,7 @@ func (ec *executionContext) _ValidType_validArgs(ctx context.Context, field grap return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _XXIt_id(ctx context.Context, field graphql.CollectedField, obj *Xxit) graphql.Marshaler { +func (ec *executionContext) _XXIt_id(ctx context.Context, field graphql.CollectedField, obj *XXIt) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -4635,7 +4635,7 @@ func (ec *executionContext) _ShapeUnion(ctx context.Context, sel ast.SelectionSe var aItImplementors = []string{"AIt"} -func (ec *executionContext) _AIt(ctx context.Context, sel ast.SelectionSet, obj *Ait) graphql.Marshaler { +func (ec *executionContext) _AIt(ctx context.Context, sel ast.SelectionSet, obj *AIt) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, aItImplementors) out := graphql.NewFieldSet(fields) @@ -5528,7 +5528,7 @@ func (ec *executionContext) _ValidType(ctx context.Context, sel ast.SelectionSet var xXItImplementors = []string{"XXIt"} -func (ec *executionContext) _XXIt(ctx context.Context, sel ast.SelectionSet, obj *Xxit) graphql.Marshaler { +func (ec *executionContext) _XXIt(ctx context.Context, sel ast.SelectionSet, obj *XXIt) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, xXItImplementors) out := graphql.NewFieldSet(fields) diff --git a/codegen/testserver/models-gen.go b/codegen/testserver/models-gen.go index b03f379f332..2ab880335cc 100644 --- a/codegen/testserver/models-gen.go +++ b/codegen/testserver/models-gen.go @@ -9,7 +9,7 @@ import ( "time" ) -type Ait struct { +type AIt struct { ID string `json:"id"` } @@ -88,7 +88,7 @@ type ValidType struct { ValidArgs bool `json:"validArgs"` } -type Xxit struct { +type XXIt struct { ID string `json:"id"` } From bef6c0a960bb9646f617af8c337b17b6c3e63da1 Mon Sep 17 00:00:00 2001 From: Christoph Kraemer Date: Sun, 10 Mar 2019 17:15:19 -0700 Subject: [PATCH 121/147] Fix directives on args with custom type --- codegen/args.gotpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen/args.gotpl b/codegen/args.gotpl index cab7327fe85..4c7212182c8 100644 --- a/codegen/args.gotpl +++ b/codegen/args.gotpl @@ -24,7 +24,7 @@ func (ec *executionContext) {{ $name }}(ctx context.Context, rawArgs map[string] if err != nil { return nil, err } - if data, ok := tmp.({{ $arg.TypeReference.GO }}) ; ok { + if data, ok := tmp.({{ $arg.TypeReference.GO | ref }}) ; ok { arg{{$i}} = data } else { return nil, fmt.Errorf(`unexpected type %T from directive, should be {{ $arg.TypeReference.GO }}`, tmp) From 30d235bc781c1976c08def2ca5283998f4786d76 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Mon, 11 Mar 2019 12:42:15 +1100 Subject: [PATCH 122/147] Fix default scalars --- codegen/testserver/generated.go | 85 +++++++++++++++++++++++ codegen/testserver/models-gen.go | 4 ++ codegen/testserver/scalar_default.graphql | 4 ++ plugin/modelgen/models.go | 22 ++++-- 4 files changed, 109 insertions(+), 6 deletions(-) diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index ff1805d44be..20153bebead 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -74,6 +74,10 @@ type ComplexityRoot struct { Area func(childComplexity int) int } + EmbeddedDefaultScalar struct { + Value func(childComplexity int) int + } + EmbeddedPointer struct { ID func(childComplexity int) int Title func(childComplexity int) int @@ -308,6 +312,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Circle.Area(childComplexity), true + case "EmbeddedDefaultScalar.Value": + if e.complexity.EmbeddedDefaultScalar.Value == nil { + break + } + + return e.complexity.EmbeddedDefaultScalar.Value(childComplexity), true + case "EmbeddedPointer.ID": if e.complexity.EmbeddedPointer.ID == nil { break @@ -925,6 +936,10 @@ scalar MarshalPanic """ This doesnt have an implementation in the typemap, so it should act like a string """ scalar DefaultScalarImplementation + +type EmbeddedDefaultScalar { + value: DefaultScalarImplementation +} `}, &ast.Source{Name: "schema.graphql", Input: `type Query { invalidIdentifier: InvalidIdentifier @@ -1918,6 +1933,29 @@ func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.Coll return ec.marshalOFloat2float64(ctx, field.Selections, res) } +func (ec *executionContext) _EmbeddedDefaultScalar_value(ctx context.Context, field graphql.CollectedField, obj *EmbeddedDefaultScalar) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "EmbeddedDefaultScalar", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Value, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalODefaultScalarImplementation2ᚖstring(ctx, field.Selections, res) +} + func (ec *executionContext) _EmbeddedPointer_ID(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -4760,6 +4798,30 @@ func (ec *executionContext) _Circle(ctx context.Context, sel ast.SelectionSet, o return out } +var embeddedDefaultScalarImplementors = []string{"EmbeddedDefaultScalar"} + +func (ec *executionContext) _EmbeddedDefaultScalar(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedDefaultScalar) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, embeddedDefaultScalarImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("EmbeddedDefaultScalar") + case "value": + out.Values[i] = ec._EmbeddedDefaultScalar_value(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + var embeddedPointerImplementors = []string{"EmbeddedPointer"} func (ec *executionContext) _EmbeddedPointer(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedPointerModel) graphql.Marshaler { @@ -6380,6 +6442,29 @@ func (ec *executionContext) marshalOCircle2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec._Circle(ctx, sel, v) } +func (ec *executionContext) unmarshalODefaultScalarImplementation2string(ctx context.Context, v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalODefaultScalarImplementation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + return graphql.MarshalString(v) +} + +func (ec *executionContext) unmarshalODefaultScalarImplementation2ᚖstring(ctx context.Context, v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalODefaultScalarImplementation2string(ctx, v) + return &res, err +} + +func (ec *executionContext) marshalODefaultScalarImplementation2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.marshalODefaultScalarImplementation2string(ctx, sel, *v) +} + func (ec *executionContext) marshalOError2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx context.Context, sel ast.SelectionSet, v Error) graphql.Marshaler { return ec._Error(ctx, sel, &v) } diff --git a/codegen/testserver/models-gen.go b/codegen/testserver/models-gen.go index 2ab880335cc..7e26b2ccdad 100644 --- a/codegen/testserver/models-gen.go +++ b/codegen/testserver/models-gen.go @@ -17,6 +17,10 @@ type AbIt struct { ID string `json:"id"` } +type EmbeddedDefaultScalar struct { + Value *string `json:"value"` +} + type InnerDirectives struct { Message string `json:"message"` } diff --git a/codegen/testserver/scalar_default.graphql b/codegen/testserver/scalar_default.graphql index 56495bad727..5e3a9c08fd1 100644 --- a/codegen/testserver/scalar_default.graphql +++ b/codegen/testserver/scalar_default.graphql @@ -4,3 +4,7 @@ extend type Query { """ This doesnt have an implementation in the typemap, so it should act like a string """ scalar DefaultScalarImplementation + +type EmbeddedDefaultScalar { + value: DefaultScalarImplementation +} diff --git a/plugin/modelgen/models.go b/plugin/modelgen/models.go index b4e089e994f..41c183c167e 100644 --- a/plugin/modelgen/models.go +++ b/plugin/modelgen/models.go @@ -118,12 +118,22 @@ func (m *Plugin) MutateConfig(cfg *config.Config) error { return err } } else { - // no user defined model, must reference another generated model - typ = types.NewNamed( - types.NewTypeName(0, cfg.Model.Pkg(), templates.ToGo(field.Type.Name()), nil), - nil, - nil, - ) + fieldDef := schema.Types[field.Type.Name()] + if fieldDef.Kind == ast.Scalar { + // no user defined model, referencing a default scalar + typ = types.NewNamed( + types.NewTypeName(0, cfg.Model.Pkg(), "string", nil), + nil, + nil, + ) + } else { + // no user defined model, must reference another generated model + typ = types.NewNamed( + types.NewTypeName(0, cfg.Model.Pkg(), templates.ToGo(field.Type.Name()), nil), + nil, + nil, + ) + } } name := field.Name From d02736dcdd9860685c2ea0c34a9a7e7626316d0f Mon Sep 17 00:00:00 2001 From: Christoph Kraemer Date: Sun, 10 Mar 2019 22:08:58 -0700 Subject: [PATCH 123/147] Added test for fix directives on args with custom type --- codegen/testserver/directive_test.go | 18 ++++++ codegen/testserver/generated.go | 93 ++++++++++++++++++++++++++++ codegen/testserver/resolver.go | 3 + codegen/testserver/schema.graphql | 2 + codegen/testserver/stub.go | 4 ++ 5 files changed, 120 insertions(+) diff --git a/codegen/testserver/directive_test.go b/codegen/testserver/directive_test.go index cdb10632e2e..494be75f959 100644 --- a/codegen/testserver/directive_test.go +++ b/codegen/testserver/directive_test.go @@ -34,6 +34,11 @@ func TestDirectives(t *testing.T) { return &s, nil } + resolvers.QueryResolver.DirectiveInputType = func(ctx context.Context, arg InnerInput) (i *string, e error) { + s := "Ok" + return &s, nil + } + srv := httptest.NewServer( handler.GraphQL( NewExecutableSchema(Config{ @@ -90,6 +95,9 @@ func TestDirectives(t *testing.T) { } return nil, fmt.Errorf("unsupported type %T", res) }, + Custom: func(ctx context.Context, obj interface{}, next graphql.Resolver) (interface{}, error) { + return next(ctx) + }, }, }), handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { @@ -206,5 +214,15 @@ func TestDirectives(t *testing.T) { require.Nil(t, err) require.Equal(t, "Ok", *resp.DirectiveInputNullable) }) + t.Run("when arg has directive", func(t *testing.T) { + var resp struct { + DirectiveInputType *string + } + + err := c.Post(`query { directiveInputType(arg: {id: 1}) }`, &resp) + + require.Nil(t, err) + require.Equal(t, "Ok", *resp.DirectiveInputType) + }) }) } diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index eb87e3f064f..26f9b277cff 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -47,6 +47,8 @@ type ResolverRoot interface { } type DirectiveRoot struct { + Custom func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) + Length func(ctx context.Context, obj interface{}, next graphql.Resolver, min int, max *int) (res interface{}, err error) Range func(ctx context.Context, obj interface{}, next graphql.Resolver, min *int, max *int) (res interface{}, err error) @@ -135,6 +137,7 @@ type ComplexityRoot struct { DirectiveNullableArg func(childComplexity int, arg *int, arg2 *int) int DirectiveInputNullable func(childComplexity int, arg *InputDirectives) int DirectiveInput func(childComplexity int, arg InputDirectives) int + DirectiveInputType func(childComplexity int, arg InnerInput) int InputSlice func(childComplexity int, arg []string) int ShapeUnion func(childComplexity int) int Autobind func(childComplexity int) int @@ -214,6 +217,7 @@ type QueryResolver interface { DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int) (*string, error) DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) + DirectiveInputType(ctx context.Context, arg InnerInput) (*string, error) InputSlice(ctx context.Context, arg []string) (bool, error) ShapeUnion(ctx context.Context) (ShapeUnion, error) Autobind(ctx context.Context) (*Autobind, error) @@ -594,6 +598,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.DirectiveInput(childComplexity, args["arg"].(InputDirectives)), true + case "Query.DirectiveInputType": + if e.complexity.Query.DirectiveInputType == nil { + break + } + + args, err := ec.field_Query_directiveInputType_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.DirectiveInputType(childComplexity, args["arg"].(InnerInput)), true + case "Query.InputSlice": if e.complexity.Query.InputSlice == nil { break @@ -855,6 +871,13 @@ func (ec *executionContext) FieldMiddleware(ctx context.Context, obj interface{} rctx := graphql.GetResolverContext(ctx) for _, d := range rctx.Field.Definition.Directives { switch d.Name { + case "custom": + if ec.directives.Custom != nil { + n := next + next = func(ctx context.Context) (interface{}, error) { + return ec.directives.Custom(ctx, obj, n) + } + } case "length": if ec.directives.Length != nil { rawArgs := d.ArgumentMap(ec.Variables) @@ -943,6 +966,7 @@ scalar DefaultScalarImplementation directiveNullableArg(arg: Int @range(min:0), arg2: Int @range): String directiveInputNullable(arg: InputDirectives): String directiveInput(arg: InputDirectives!): String + directiveInputType(arg: InnerInput! @custom): String inputSlice(arg: [String!]!): Boolean! shapeUnion: ShapeUnion! autobind: Autobind @@ -1054,6 +1078,7 @@ type EmbeddedPointer { directive @length(min: Int!, max: Int) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION directive @range(min: Int = 0, max: Int) on ARGUMENT_DEFINITION +directive @custom on ARGUMENT_DEFINITION enum Status { OK @@ -1286,6 +1311,33 @@ func (ec *executionContext) field_Query_directiveInputNullable_args(ctx context. return args, nil } +func (ec *executionContext) field_Query_directiveInputType_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 InnerInput + if tmp, ok := rawArgs["arg"]; ok { + getArg0 := func(ctx context.Context) (interface{}, error) { + return ec.unmarshalNInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerInput(ctx, tmp) + } + getArg1 := func(ctx context.Context) (res interface{}, err error) { + n := getArg0 + return ec.directives.Custom(ctx, tmp, n) + } + + tmp, err = getArg1(ctx) + if err != nil { + return nil, err + } + if data, ok := tmp.(InnerInput); ok { + arg0 = data + } else { + return nil, fmt.Errorf(`unexpected type %T from directive, should be github.com/99designs/gqlgen/codegen/testserver.InnerInput`, tmp) + } + } + args["arg"] = arg0 + return args, nil +} + func (ec *executionContext) field_Query_directiveInput_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -2799,6 +2851,36 @@ func (ec *executionContext) _Query_directiveInput(ctx context.Context, field gra return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } +func (ec *executionContext) _Query_directiveInputType(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_directiveInputType_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().DirectiveInputType(rctx, args["arg"].(InnerInput)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + func (ec *executionContext) _Query_inputSlice(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -5282,6 +5364,17 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr res = ec._Query_directiveInput(ctx, field) return res }) + case "directiveInputType": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_directiveInputType(ctx, field) + return res + }) case "inputSlice": field := field out.Concurrently(i, func() (res graphql.Marshaler) { diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index 4c1e2294063..8a7ed32cee3 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -101,6 +101,9 @@ func (r *queryResolver) DirectiveInputNullable(ctx context.Context, arg *InputDi func (r *queryResolver) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) { panic("not implemented") } +func (r *queryResolver) DirectiveInputType(ctx context.Context, arg InnerInput) (*string, error) { + panic("not implemented") +} func (r *queryResolver) InputSlice(ctx context.Context, arg []string) (bool, error) { panic("not implemented") } diff --git a/codegen/testserver/schema.graphql b/codegen/testserver/schema.graphql index 5ec9de8d065..0b135308f2a 100644 --- a/codegen/testserver/schema.graphql +++ b/codegen/testserver/schema.graphql @@ -15,6 +15,7 @@ type Query { directiveNullableArg(arg: Int @range(min:0), arg2: Int @range): String directiveInputNullable(arg: InputDirectives): String directiveInput(arg: InputDirectives!): String + directiveInputType(arg: InnerInput! @custom): String inputSlice(arg: [String!]!): Boolean! shapeUnion: ShapeUnion! autobind: Autobind @@ -126,6 +127,7 @@ type EmbeddedPointer { directive @length(min: Int!, max: Int) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION directive @range(min: Int = 0, max: Int) on ARGUMENT_DEFINITION +directive @custom on ARGUMENT_DEFINITION enum Status { OK diff --git a/codegen/testserver/stub.go b/codegen/testserver/stub.go index 4388ad0dd69..2da85a43473 100644 --- a/codegen/testserver/stub.go +++ b/codegen/testserver/stub.go @@ -37,6 +37,7 @@ type Stub struct { DirectiveNullableArg func(ctx context.Context, arg *int, arg2 *int) (*string, error) DirectiveInputNullable func(ctx context.Context, arg *InputDirectives) (*string, error) DirectiveInput func(ctx context.Context, arg InputDirectives) (*string, error) + DirectiveInputType func(ctx context.Context, arg InnerInput) (*string, error) InputSlice func(ctx context.Context, arg []string) (bool, error) ShapeUnion func(ctx context.Context) (ShapeUnion, error) Autobind func(ctx context.Context) (*Autobind, error) @@ -144,6 +145,9 @@ func (r *stubQuery) DirectiveInputNullable(ctx context.Context, arg *InputDirect func (r *stubQuery) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) { return r.QueryResolver.DirectiveInput(ctx, arg) } +func (r *stubQuery) DirectiveInputType(ctx context.Context, arg InnerInput) (*string, error) { + return r.QueryResolver.DirectiveInputType(ctx, arg) +} func (r *stubQuery) InputSlice(ctx context.Context, arg []string) (bool, error) { return r.QueryResolver.InputSlice(ctx, arg) } From 386eede91a4d5b3b2b35944d08716c4ed0e4886a Mon Sep 17 00:00:00 2001 From: Jonatas Baldin Date: Mon, 11 Mar 2019 09:45:46 +0200 Subject: [PATCH 124/147] Add Gin recipe --- docs/content/recipes/gin.md | 53 +++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 docs/content/recipes/gin.md diff --git a/docs/content/recipes/gin.md b/docs/content/recipes/gin.md new file mode 100644 index 00000000000..01b048ded41 --- /dev/null +++ b/docs/content/recipes/gin.md @@ -0,0 +1,53 @@ +--- +title: "Using Gin to setup HTTP handlers" +description: Setting up HTTP handlers using Gin, a HTTP web framework written in Go. +linkTitle: Gin +menu: { main: { parent: 'recipes' } } +--- + +Gin is an excellent alternative for the `net/http` router. From their official [GitHub page](https://github.com/gin-gonic/gin): + +> Gin is a web framework written in Go (Golang). It features a martini-like API with much better performance, up to 40 times faster thanks to httprouter. If you need performance and good productivity, you will love Gin. + +Here are the steps to setup Gin and gqlgen together: + +Install Gin: +```bash +$ go get gin +``` + +In your router file, define the handlers for the GraphQL and Playground endpoints in two different methods and tie then together in the Gin router: +```go +import ( + "github.com/99designs/gqlgen/handler" + "github.com/gin-gonic/gin" +) + +// Defining the Graphql handler +func graphqlHandler() gin.HandlerFunc { + // NewExecutableSchema and Config are in the generated.go file + // Resolver is in the resolver.go file + h := handler.GraphQL(NewExecutableSchema(Config{Resolvers: &Resolver{}})) + + return func(c *gin.Context) { + h.ServeHTTP(c.Writer, c.Request) + } +} + +// Defining the Playground handler +func playgroundHandler() gin.HandlerFunc { + h := handler.Playground("GraphQL", "/query") + + return func(c *gin.Context) { + h.ServeHTTP(c.Writer, c.Request) + } +} + +func main() { + // Setting up Gin + r := gin.Default() + r.POST("/query", graphqlHandler()) + r.GET("/", playgroundHandler()) + r.Run() +} +``` From dd2881455f20f37ec601791bf09e32db9e928790 Mon Sep 17 00:00:00 2001 From: Adam Renberg Tamm Date: Tue, 12 Mar 2019 11:17:58 +0100 Subject: [PATCH 125/147] Allow configuring the complexity limit dynamically per request --- docs/content/reference/complexity.md | 2 +- graphql/context.go | 1 + handler/graphql.go | 16 ++++++++- handler/graphql_test.go | 49 ++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 2 deletions(-) diff --git a/docs/content/reference/complexity.md b/docs/content/reference/complexity.md index 70640351ba4..5f92f5d9f14 100644 --- a/docs/content/reference/complexity.md +++ b/docs/content/reference/complexity.md @@ -56,7 +56,7 @@ func main() { } ``` -Now any query with complexity greater than 5 is rejected by the API. By default, each field and level of depth adds one to the overall query complexity. +Now any query with complexity greater than 5 is rejected by the API. By default, each field and level of depth adds one to the overall query complexity. You can also use `handler.ComplexityLimitFunc` to dynamically configure the complexity limit per request. This helps, but we still have a problem: the `posts` and `related` fields, which return arrays, are much more expensive to resolve than the scalar `title` and `text` fields. However, the default complexity calculation weights them equally. It would make more sense to apply a higher cost to the array fields. diff --git a/graphql/context.go b/graphql/context.go index cc8d659b116..d6b28456cb4 100644 --- a/graphql/context.go +++ b/graphql/context.go @@ -12,6 +12,7 @@ import ( type Resolver func(ctx context.Context) (res interface{}, err error) type FieldMiddleware func(ctx context.Context, next Resolver) (res interface{}, err error) type RequestMiddleware func(ctx context.Context, next func(ctx context.Context) []byte) []byte +type ComplexityLimitFunc func(ctx context.Context) int type RequestContext struct { RawQuery string diff --git a/handler/graphql.go b/handler/graphql.go index 585897a9248..92a0471ce24 100644 --- a/handler/graphql.go +++ b/handler/graphql.go @@ -34,6 +34,7 @@ type Config struct { requestHook graphql.RequestMiddleware tracer graphql.Tracer complexityLimit int + complexityLimitFunc graphql.ComplexityLimitFunc disableIntrospection bool connectionKeepAlivePingInterval time.Duration } @@ -62,7 +63,7 @@ func (c *Config) newRequestContext(es graphql.ExecutableSchema, doc *ast.QueryDo reqCtx.Tracer = hook } - if c.complexityLimit > 0 { + if c.complexityLimit > 0 || c.complexityLimitFunc != nil { reqCtx.ComplexityLimit = c.complexityLimit operationComplexity := complexity.Calculate(es, op, variables) reqCtx.OperationComplexity = operationComplexity @@ -110,6 +111,15 @@ func ComplexityLimit(limit int) Option { } } +// ComplexityLimitFunc allows you to define a function to dynamically set the maximum query complexity that is allowed +// to be executed. +// If a query is submitted that exceeds the limit, a 422 status code will be returned. +func ComplexityLimitFunc(complexityLimitFunc graphql.ComplexityLimitFunc) Option { + return func(cfg *Config) { + cfg.complexityLimitFunc = complexityLimitFunc + } +} + // ResolverMiddleware allows you to define a function that will be called around every resolver, // useful for logging. func ResolverMiddleware(middleware graphql.FieldMiddleware) Option { @@ -381,6 +391,10 @@ func (gh *graphqlHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } }() + if gh.cfg.complexityLimitFunc != nil { + reqCtx.ComplexityLimit = gh.cfg.complexityLimitFunc(ctx) + } + if reqCtx.ComplexityLimit > 0 && reqCtx.OperationComplexity > reqCtx.ComplexityLimit { sendErrorf(w, http.StatusUnprocessableEntity, "operation has complexity %d, which exceeds the limit of %d", reqCtx.OperationComplexity, reqCtx.ComplexityLimit) return diff --git a/handler/graphql_test.go b/handler/graphql_test.go index e6c2d9063e1..f938640716e 100644 --- a/handler/graphql_test.go +++ b/handler/graphql_test.go @@ -1,11 +1,14 @@ package handler import ( + "context" "net/http" "net/http/httptest" "strings" "testing" + "github.com/99designs/gqlgen/graphql" + "github.com/stretchr/testify/assert" ) @@ -127,6 +130,52 @@ func TestHandlerHead(t *testing.T) { assert.Equal(t, http.StatusMethodNotAllowed, resp.Code) } +func TestHandlerComplexity(t *testing.T) { + t.Run("static complexity", func(t *testing.T) { + h := GraphQL(&executableSchemaStub{}, ComplexityLimit(2)) + + t.Run("below complexity limit", func(t *testing.T) { + resp := doRequest(h, "POST", "/graphql", `{"query":"{ me { name } }"}`) + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + }) + + t.Run("above complexity limit", func(t *testing.T) { + resp := doRequest(h, "POST", "/graphql", `{"query":"{ a: me { name } b: me { name } }"}`) + assert.Equal(t, http.StatusUnprocessableEntity, resp.Code) + assert.Equal(t, `{"errors":[{"message":"operation has complexity 4, which exceeds the limit of 2"}],"data":null}`, resp.Body.String()) + }) + }) + + t.Run("dynamic complexity", func(t *testing.T) { + h := GraphQL(&executableSchemaStub{}, ComplexityLimitFunc(func(ctx context.Context) int { + reqCtx := graphql.GetRequestContext(ctx) + if strings.Contains(reqCtx.RawQuery, "dummy") { + return 4 + } + return 2 + })) + + t.Run("below complexity limit", func(t *testing.T) { + resp := doRequest(h, "POST", "/graphql", `{"query":"{ me { name } }"}`) + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + }) + + t.Run("above complexity limit", func(t *testing.T) { + resp := doRequest(h, "POST", "/graphql", `{"query":"{ a: me { name } b: me { name } }"}`) + assert.Equal(t, http.StatusUnprocessableEntity, resp.Code) + assert.Equal(t, `{"errors":[{"message":"operation has complexity 4, which exceeds the limit of 2"}],"data":null}`, resp.Body.String()) + }) + + t.Run("within dynamic complexity limit", func(t *testing.T) { + resp := doRequest(h, "POST", "/graphql", `{"query":"{ a: me { name } dummy: me { name } }"}`) + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String()) + }) + }) +} + func doRequest(handler http.Handler, method string, target string, body string) *httptest.ResponseRecorder { r := httptest.NewRequest(method, target, strings.NewReader(body)) w := httptest.NewRecorder() From a89050aa1f1ffb93950eccb48bf1156da9587850 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Tue, 12 Mar 2019 22:18:10 +1100 Subject: [PATCH 126/147] Bump gqlparser to 1.1.2 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index efea31cea28..f1b37d7d00d 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/stretchr/testify v1.3.0 github.com/urfave/cli v1.20.0 github.com/vektah/dataloaden v0.2.0 - github.com/vektah/gqlparser v1.1.0 + github.com/vektah/gqlparser v1.1.2 golang.org/x/net v0.0.0-20180404174746-b3c676e531a6 // indirect golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect diff --git a/go.sum b/go.sum index 161ab5ad278..90b3684dc67 100644 --- a/go.sum +++ b/go.sum @@ -50,8 +50,8 @@ github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/vektah/dataloaden v0.2.0 h1:lhynDrG7c8mNLahboCo0Wq82tMjmu5yOUv2ds/tBmss= github.com/vektah/dataloaden v0.2.0/go.mod h1:vxM6NuRlgiR0M6wbVTJeKp9vQIs81ZMfCYO+4yq/jbE= -github.com/vektah/gqlparser v1.1.0 h1:3668p2gUlO+PiS81x957Rpr3/FPRWG6cxgCXAvTS1hw= -github.com/vektah/gqlparser v1.1.0/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw= +github.com/vektah/gqlparser v1.1.2 h1:ZsyLGn7/7jDNI+y4SEhI4yAxRChlv15pUHMjijT+e68= +github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw= golang.org/x/net v0.0.0-20180404174746-b3c676e531a6 h1:mge3qS/eMvcfyIAzTMOAy0XUzWG6Lk0N4M8zjuSmdco= golang.org/x/net v0.0.0-20180404174746-b3c676e531a6/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6 h1:iZgcI2DDp6zW5v9Z/5+f0NuqoxNdmzg4hivjk2WLXpY= From 0a92ca465691ea96186481471ec1ba01d6ecfaf8 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Tue, 12 Mar 2019 22:21:33 +1100 Subject: [PATCH 127/147] Support map[string]interface{} in return types --- codegen/config/binder.go | 7 ++ codegen/field.go | 5 + codegen/field.gotpl | 13 +- codegen/object.go | 10 ++ codegen/object.gotpl | 2 +- codegen/testdata/schema.graphql | 6 - codegen/testserver/generated.go | 209 ++++++++++++++++++++++++++++++++ codegen/testserver/gqlgen.yml | 4 + codegen/testserver/maps.graphql | 13 ++ codegen/testserver/maps_test.go | 52 ++++++++ codegen/testserver/resolver.go | 3 + codegen/testserver/stub.go | 4 + codegen/type.gotpl | 8 +- example/todo/generated.go | 9 ++ 14 files changed, 334 insertions(+), 11 deletions(-) create mode 100644 codegen/testserver/maps.graphql create mode 100644 codegen/testserver/maps_test.go diff --git a/codegen/config/binder.go b/codegen/config/binder.go index 0c8c7d614c2..e8b3c459220 100644 --- a/codegen/config/binder.go +++ b/codegen/config/binder.go @@ -204,6 +204,13 @@ func (t *TypeReference) IsPtr() bool { return isPtr } +func (t *TypeReference) IsNilable() bool { + _, isPtr := t.GO.(*types.Pointer) + _, isMap := t.GO.(*types.Map) + _, isInterface := t.GO.(*types.Interface) + return isPtr || isMap || isInterface +} + func (t *TypeReference) IsSlice() bool { _, isSlice := t.GO.(*types.Slice) return isSlice diff --git a/codegen/field.go b/codegen/field.go index e54e9fdad1f..f5f7b22139c 100644 --- a/codegen/field.go +++ b/codegen/field.go @@ -102,6 +102,7 @@ func (b *builder) bindField(obj *Object, f *Field) error { f.IsResolver = true return nil case obj.Type == config.MapType: + f.GoFieldType = GoFieldMap return nil case b.Config.Models[obj.Name].Fields[f.Name].FieldName != "": f.GoFieldName = b.Config.Models[obj.Name].Fields[f.Name].FieldName @@ -298,6 +299,10 @@ func (f *Field) IsVariable() bool { return f.GoFieldType == GoFieldVariable } +func (f *Field) IsMap() bool { + return f.GoFieldType == GoFieldMap +} + func (f *Field) IsConcurrent() bool { if f.Object.DisableConcurrency { return false diff --git a/codegen/field.gotpl b/codegen/field.gotpl index f07a6f03674..17058fd4896 100644 --- a/codegen/field.gotpl +++ b/codegen/field.gotpl @@ -37,7 +37,7 @@ } } {{ else }} - func (ec *executionContext) _{{$object.Name}}_{{$field.Name}}(ctx context.Context, field graphql.CollectedField{{ if not $object.Root }}, obj *{{$object.Type | ref}}{{end}}) graphql.Marshaler { + func (ec *executionContext) _{{$object.Name}}_{{$field.Name}}(ctx context.Context, field graphql.CollectedField{{ if not $object.Root }}, obj {{$object.Reference | ref}}{{end}}) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func () { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -60,6 +60,17 @@ ctx = rctx // use context from middleware stack in children {{- if $field.IsResolver }} return ec.resolvers.{{ $field.ShortInvocation }} + {{- else if $field.IsMap }} + switch v := {{$field.GoReceiverName}}[{{$field.Name|quote}}].(type) { + case {{$field.TypeReference.GO | ref}}: + return v, nil + case {{$field.TypeReference.Elem.GO | ref}}: + return &v, nil + case nil: + return ({{$field.TypeReference.GO | ref}})(nil), nil + default: + return nil, fmt.Errorf("unexpected type %T for field %s", v, {{ $field.Name | quote}}) + } {{- else if $field.IsMethod }} {{- if $field.NoErr }} return {{$field.GoReceiverName}}.{{$field.GoFieldName}}({{ $field.CallArgs }}), nil diff --git a/codegen/object.go b/codegen/object.go index 7b9e3d6f597..539c3164c50 100644 --- a/codegen/object.go +++ b/codegen/object.go @@ -17,6 +17,7 @@ const ( GoFieldUndefined GoFieldType = iota GoFieldMethod GoFieldVariable + GoFieldMap ) type Object struct { @@ -80,6 +81,15 @@ func (b *builder) buildObject(typ *ast.Definition) (*Object, error) { return obj, nil } +func (o *Object) Reference() types.Type { + switch o.Type.(type) { + case *types.Pointer, *types.Slice, *types.Map: + return o.Type + } + + return types.NewPointer(o.Type) +} + type Objects []*Object func (o *Object) Implementors() string { diff --git a/codegen/object.gotpl b/codegen/object.gotpl index 13224ed0233..19da1b1988b 100644 --- a/codegen/object.gotpl +++ b/codegen/object.gotpl @@ -23,7 +23,7 @@ func (ec *executionContext) _{{$object.Name}}(ctx context.Context, sel ast.Selec } } {{- else }} -func (ec *executionContext) _{{$object.Name}}(ctx context.Context, sel ast.SelectionSet{{ if not $object.Root }},obj *{{$object.Type | ref }}{{ end }}) graphql.Marshaler { +func (ec *executionContext) _{{$object.Name}}(ctx context.Context, sel ast.SelectionSet{{ if not $object.Root }},obj {{$object.Reference | ref }}{{ end }}) graphql.Marshaler { fields := graphql.CollectFields(ctx, sel, {{$object.Name|lcFirst}}Implementors) {{if $object.Root}} ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ diff --git a/codegen/testdata/schema.graphql b/codegen/testdata/schema.graphql index d08a37d54c7..5d49426216f 100644 --- a/codegen/testdata/schema.graphql +++ b/codegen/testdata/schema.graphql @@ -1,7 +1,6 @@ type Query { invalidIdentifier: InvalidIdentifier collision: It - mapInput(input: Changes): Boolean recursive(input: RecursiveInputSlice): Boolean nestedInputs(input: [[OuterInput]] = [[{inner: {id: 1}}]]): Boolean nestedOutputs: [[OuterObject]] @@ -49,11 +48,6 @@ type It { id: ID! } -input Changes { - a: Int - b: Int -} - input RecursiveInputSlice { self: [RecursiveInputSlice!] } diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index fa25e518b52..9ba500108f4 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -108,6 +108,11 @@ type ComplexityRoot struct { ID func(childComplexity int) int } + MapStringInterfaceType struct { + A func(childComplexity int) int + B func(childComplexity int) int + } + ModelMethods struct { ResolverField func(childComplexity int) int NoContext func(childComplexity int) int @@ -146,6 +151,7 @@ type ComplexityRoot struct { ShapeUnion func(childComplexity int) int Autobind func(childComplexity int) int DeprecatedField func(childComplexity int) int + MapStringInterface func(childComplexity int, in map[string]interface{}) int Panics func(childComplexity int) int DefaultScalar func(childComplexity int, arg string) int ValidType func(childComplexity int) int @@ -226,6 +232,7 @@ type QueryResolver interface { ShapeUnion(ctx context.Context) (ShapeUnion, error) Autobind(ctx context.Context) (*Autobind, error) DeprecatedField(ctx context.Context) (string, error) + MapStringInterface(ctx context.Context, in map[string]interface{}) (map[string]interface{}, error) Panics(ctx context.Context) (*Panics, error) DefaultScalar(ctx context.Context, arg string) (string, error) ValidType(ctx context.Context) (*ValidType, error) @@ -393,6 +400,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.It.ID(childComplexity), true + case "MapStringInterfaceType.A": + if e.complexity.MapStringInterfaceType.A == nil { + break + } + + return e.complexity.MapStringInterfaceType.A(childComplexity), true + + case "MapStringInterfaceType.B": + if e.complexity.MapStringInterfaceType.B == nil { + break + } + + return e.complexity.MapStringInterfaceType.B(childComplexity), true + case "ModelMethods.ResolverField": if e.complexity.ModelMethods.ResolverField == nil { break @@ -654,6 +675,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.DeprecatedField(childComplexity), true + case "Query.MapStringInterface": + if e.complexity.Query.MapStringInterface == nil { + break + } + + args, err := ec.field_Query_mapStringInterface_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.MapStringInterface(childComplexity, args["in"].(map[string]interface{})), true + case "Query.Panics": if e.complexity.Query.Panics == nil { break @@ -940,6 +973,20 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er } var parsedSchema = gqlparser.MustLoadSchema( + &ast.Source{Name: "maps.graphql", Input: `extend type Query { + mapStringInterface(in: MapStringInterfaceInput): MapStringInterfaceType +} + +type MapStringInterfaceType { + a: String + b: Int +} + +input MapStringInterfaceInput { + a: String + b: Int +} +`}, &ast.Source{Name: "panics.graphql", Input: `extend type Query { panics: Panics } @@ -1441,6 +1488,20 @@ func (ec *executionContext) field_Query_mapInput_args(ctx context.Context, rawAr return args, nil } +func (ec *executionContext) field_Query_mapStringInterface_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 map[string]interface{} + if tmp, ok := rawArgs["in"]; ok { + arg0, err = ec.unmarshalOMapStringInterfaceInput2map(ctx, tmp) + if err != nil { + return nil, err + } + } + args["in"] = arg0 + return args, nil +} + func (ec *executionContext) field_Query_nestedInputs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -2256,6 +2317,70 @@ func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedF return ec.marshalNID2string(ctx, field.Selections, res) } +func (ec *executionContext) _MapStringInterfaceType_a(ctx context.Context, field graphql.CollectedField, obj map[string]interface{}) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "MapStringInterfaceType", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + switch v := obj["a"].(type) { + case *string: + return v, nil + case string: + return &v, nil + case nil: + return (*string)(nil), nil + default: + return nil, fmt.Errorf("unexpected type %T for field %s", v, "a") + } + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _MapStringInterfaceType_b(ctx context.Context, field graphql.CollectedField, obj map[string]interface{}) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "MapStringInterfaceType", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + switch v := obj["b"].(type) { + case *int: + return v, nil + case int: + return &v, nil + case nil: + return (*int)(nil), nil + default: + return nil, fmt.Errorf("unexpected type %T for field %s", v, "b") + } + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*int) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalOInt2ᚖint(ctx, field.Selections, res) +} + func (ec *executionContext) _ModelMethods_resolverField(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3027,6 +3152,36 @@ func (ec *executionContext) _Query_deprecatedField(ctx context.Context, field gr return ec.marshalNString2string(ctx, field.Selections, res) } +func (ec *executionContext) _Query_mapStringInterface(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_mapStringInterface_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().MapStringInterface(rctx, args["in"].(map[string]interface{})) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(map[string]interface{}) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalOMapStringInterfaceType2map(ctx, field.Selections, res) +} + func (ec *executionContext) _Query_panics(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -5083,6 +5238,32 @@ func (ec *executionContext) _It(ctx context.Context, sel ast.SelectionSet, obj * return out } +var mapStringInterfaceTypeImplementors = []string{"MapStringInterfaceType"} + +func (ec *executionContext) _MapStringInterfaceType(ctx context.Context, sel ast.SelectionSet, obj map[string]interface{}) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, mapStringInterfaceTypeImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("MapStringInterfaceType") + case "a": + out.Values[i] = ec._MapStringInterfaceType_a(ctx, field, obj) + case "b": + out.Values[i] = ec._MapStringInterfaceType_b(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + var modelMethodsImplementors = []string{"ModelMethods"} func (ec *executionContext) _ModelMethods(ctx context.Context, sel ast.SelectionSet, obj *ModelMethods) graphql.Marshaler { @@ -5490,6 +5671,17 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } return res }) + case "mapStringInterface": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_mapStringInterface(ctx, field) + return res + }) case "panics": field := field out.Concurrently(i, func() (res graphql.Marshaler) { @@ -6521,6 +6713,9 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast } func (ec *executionContext) unmarshalOChanges2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { + if v == nil { + return nil, nil + } return v.(map[string]interface{}), nil } @@ -6646,6 +6841,20 @@ func (ec *executionContext) marshalOIt2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋco return ec._It(ctx, sel, v) } +func (ec *executionContext) unmarshalOMapStringInterfaceInput2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { + if v == nil { + return nil, nil + } + return v.(map[string]interface{}), nil +} + +func (ec *executionContext) marshalOMapStringInterfaceType2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._MapStringInterfaceType(ctx, sel, v) +} + func (ec *executionContext) marshalOModelMethods2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐModelMethods(ctx context.Context, sel ast.SelectionSet, v ModelMethods) graphql.Marshaler { return ec._ModelMethods(ctx, sel, &v) } diff --git a/codegen/testserver/gqlgen.yml b/codegen/testserver/gqlgen.yml index dff1dd02a47..0e0c0bbe251 100644 --- a/codegen/testserver/gqlgen.yml +++ b/codegen/testserver/gqlgen.yml @@ -56,3 +56,7 @@ models: model: "github.com/99designs/gqlgen/codegen/testserver.MarshalPanic" Autobind: model: "github.com/99designs/gqlgen/codegen/testserver.Autobind" + MapStringInterfaceInput: + model: "map[string]interface{}" + MapStringInterfaceType: + model: "map[string]interface{}" diff --git a/codegen/testserver/maps.graphql b/codegen/testserver/maps.graphql new file mode 100644 index 00000000000..82dc180acd2 --- /dev/null +++ b/codegen/testserver/maps.graphql @@ -0,0 +1,13 @@ +extend type Query { + mapStringInterface(in: MapStringInterfaceInput): MapStringInterfaceType +} + +type MapStringInterfaceType { + a: String + b: Int +} + +input MapStringInterfaceInput { + a: String + b: Int +} diff --git a/codegen/testserver/maps_test.go b/codegen/testserver/maps_test.go new file mode 100644 index 00000000000..e2490909a71 --- /dev/null +++ b/codegen/testserver/maps_test.go @@ -0,0 +1,52 @@ +package testserver + +import ( + "context" + "net/http/httptest" + "testing" + + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/handler" + "github.com/stretchr/testify/require" +) + +func TestMaps(t *testing.T) { + resolver := &Stub{} + resolver.QueryResolver.MapStringInterface = func(ctx context.Context, in map[string]interface{}) (i map[string]interface{}, e error) { + return in, nil + } + + srv := httptest.NewServer( + handler.GraphQL( + NewExecutableSchema(Config{Resolvers: resolver}), + )) + defer srv.Close() + c := client.New(srv.URL) + t.Run("unset", func(t *testing.T) { + var resp struct { + MapStringInterface map[string]interface{} + } + err := c.Post(`query { mapStringInterface { a, b } }`, &resp) + require.NoError(t, err) + require.Nil(t, resp.MapStringInterface) + }) + + t.Run("nil", func(t *testing.T) { + var resp struct { + MapStringInterface map[string]interface{} + } + err := c.Post(`query { mapStringInterface(in: null) { a, b } }`, &resp) + require.NoError(t, err) + require.Nil(t, resp.MapStringInterface) + }) + + t.Run("values", func(t *testing.T) { + var resp struct { + MapStringInterface map[string]interface{} + } + err := c.Post(`query { mapStringInterface(in: { a: "a", b: null }) { a, b } }`, &resp) + require.NoError(t, err) + require.Equal(t, "a", resp.MapStringInterface["a"]) + require.Nil(t, resp.MapStringInterface["b"]) + }) +} diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index 8a7ed32cee3..e39b71a3298 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -116,6 +116,9 @@ func (r *queryResolver) Autobind(ctx context.Context) (*Autobind, error) { func (r *queryResolver) DeprecatedField(ctx context.Context) (string, error) { panic("not implemented") } +func (r *queryResolver) MapStringInterface(ctx context.Context, in map[string]interface{}) (map[string]interface{}, error) { + panic("not implemented") +} func (r *queryResolver) Panics(ctx context.Context) (*Panics, error) { panic("not implemented") } diff --git a/codegen/testserver/stub.go b/codegen/testserver/stub.go index 2da85a43473..183fad3024a 100644 --- a/codegen/testserver/stub.go +++ b/codegen/testserver/stub.go @@ -42,6 +42,7 @@ type Stub struct { ShapeUnion func(ctx context.Context) (ShapeUnion, error) Autobind func(ctx context.Context) (*Autobind, error) DeprecatedField func(ctx context.Context) (string, error) + MapStringInterface func(ctx context.Context, in map[string]interface{}) (map[string]interface{}, error) Panics func(ctx context.Context) (*Panics, error) DefaultScalar func(ctx context.Context, arg string) (string, error) ValidType func(ctx context.Context) (*ValidType, error) @@ -160,6 +161,9 @@ func (r *stubQuery) Autobind(ctx context.Context) (*Autobind, error) { func (r *stubQuery) DeprecatedField(ctx context.Context) (string, error) { return r.QueryResolver.DeprecatedField(ctx) } +func (r *stubQuery) MapStringInterface(ctx context.Context, in map[string]interface{}) (map[string]interface{}, error) { + return r.QueryResolver.MapStringInterface(ctx, in) +} func (r *stubQuery) Panics(ctx context.Context) (*Panics, error) { return r.QueryResolver.Panics(ctx) } diff --git a/codegen/type.gotpl b/codegen/type.gotpl index ce766d3c5f8..531ee96ad4f 100644 --- a/codegen/type.gotpl +++ b/codegen/type.gotpl @@ -1,8 +1,10 @@ {{- range $type := .ReferencedTypes }} {{ with $type.UnmarshalFunc }} func (ec *executionContext) {{ . }}(ctx context.Context, v interface{}) ({{ $type.GO | ref }}, error) { - {{- if $type.IsPtr }} + {{- if $type.IsNilable }} if v == nil { return nil, nil } + {{- end }} + {{- if $type.IsPtr }} res, err := ec.{{ $type.Elem.UnmarshalFunc }}(ctx, v) return &res, err {{- else if $type.IsSlice }} @@ -40,7 +42,7 @@ {{ with $type.MarshalFunc }} func (ec *executionContext) {{ . }}(ctx context.Context, sel ast.SelectionSet, v {{ $type.GO | ref }}) graphql.Marshaler { - {{- if $type.IsPtr }} + {{- if $type.IsNilable }} if v == nil { {{- if $type.GQL.NonNull }} if !ec.HasError(graphql.GetResolverContext(ctx)) { @@ -111,7 +113,7 @@ return {{ $type.Marshaler | call }}(v) {{- end }} {{- else }} - return ec._{{$type.Definition.Name}}(ctx, sel, {{ if not $type.IsPtr}}&{{end}} v) + return ec._{{$type.Definition.Name}}(ctx, sel, {{ if not $type.IsNilable}}&{{end}} v) {{- end }} {{- end }} } diff --git a/example/todo/generated.go b/example/todo/generated.go index 1db0bd6ebf8..b6d49c3650e 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -1909,10 +1909,19 @@ func (ec *executionContext) marshalNID2int(ctx context.Context, sel ast.Selectio } func (ec *executionContext) unmarshalNMap2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { + if v == nil { + return nil, nil + } return graphql.UnmarshalMap(v) } func (ec *executionContext) marshalNMap2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler { + if v == nil { + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } return graphql.MarshalMap(v) } From 765ff73865ac2d61eb8b6c9fe4534e5a4fbc072e Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Tue, 12 Mar 2019 22:43:25 +1100 Subject: [PATCH 128/147] Add some docs on maps --- docs/content/reference/changesets.md | 67 ++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 docs/content/reference/changesets.md diff --git a/docs/content/reference/changesets.md b/docs/content/reference/changesets.md new file mode 100644 index 00000000000..1c7e9b0d9e0 --- /dev/null +++ b/docs/content/reference/changesets.md @@ -0,0 +1,67 @@ +--- +linkTitle: Changesets +title: Using maps as changesets +description: Falling back to map[string]interface{} to allow for presence checks. +menu: { main: { parent: 'reference' } } +--- + +Occasionally you need to distinguish presence from nil (undefined vs null). In gqlgen we do this using maps: + + +```graphql +type Query { + updateUser(id: ID!, changes: UserChanges!): User +} + +type UserChanges { + name: String + email: String +} +``` + +Then in config set the backing type to `map[string]interface{}` +```yaml +models: + UserChanges: + model: "map[string]interface{}" +``` + +After running go generate you should end up with a resolver that looks like this: +```go +func (r *queryResolver) UpdateUser(ctx context.Context, id int, changes map[string]interface{}) (*User, error) { + u := fetchFromDb(id) + /// apply the changes + saveToDb(u) + return u, nil +} +``` + +We often use the mapstructure library to directly apply these changesets directly to the object using reflection: +```go + +func ApplyChanges(changes map[string]interface{}, to interface{}) error { + dec, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{ + ErrorUnused: true, + TagName: "json", + Result: to, + ZeroFields: true, + // This is needed to get mapstructure to call the gqlgen unmarshaler func for custom scalars (eg Date) + DecodeHook: func(a reflect.Type, b reflect.Type, v interface{}) (interface{}, error) { + if reflect.PtrTo(b).Implements(reflect.TypeOf((*graphql.Unmarshaler)(nil)).Elem()) { + resultType := reflect.New(b) + result := resultType.MethodByName("UnmarshalGQL").Call([]reflect.Value{reflect.ValueOf(v)}) + err, _ := result[0].Interface().(error) + return resultType.Elem().Interface(), err + } + + return v, nil + }, + }) + + if err != nil { + return err + } + + return dec.Decode(changes) +} +``` From 37983a5f1c799ee856fe59677578301fac3405d7 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Tue, 12 Mar 2019 23:26:51 +1100 Subject: [PATCH 129/147] remove some invalid test schema --- plugin/modelgen/out/generated.go | 6 ++---- plugin/modelgen/testdata/schema.graphql | 4 ---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/plugin/modelgen/out/generated.go b/plugin/modelgen/out/generated.go index a3f910516aa..6d6cd6c1ea3 100644 --- a/plugin/modelgen/out/generated.go +++ b/plugin/modelgen/out/generated.go @@ -29,10 +29,8 @@ func (ExistingType) IsExistingInterface() {} func (ExistingType) IsExistingUnion() {} type MissingInput struct { - Name *string `json:"name"` - Enum *MissingEnum `json:"enum"` - Int MissingInterface `json:"int"` - Existing *ExistingType `json:"existing"` + Name *string `json:"name"` + Enum *MissingEnum `json:"enum"` } type MissingType struct { diff --git a/plugin/modelgen/testdata/schema.graphql b/plugin/modelgen/testdata/schema.graphql index 6be346bdbcc..ada18dfa1a5 100644 --- a/plugin/modelgen/testdata/schema.graphql +++ b/plugin/modelgen/testdata/schema.graphql @@ -20,8 +20,6 @@ type MissingType implements MissingInterface & ExistingInterface { input MissingInput { name: String enum: MissingEnum - int: MissingInterface - existing: ExistingType } enum MissingEnum { @@ -45,8 +43,6 @@ type ExistingType implements MissingInterface & ExistingInterface { input ExistingInput { name: String enum: ExistingEnum - int: ExistingInterface - existing: MissingType } enum ExistingEnum { From 08f936e1ec91f1af2bca22de8511cc13b47c6e09 Mon Sep 17 00:00:00 2001 From: Nat Welch Date: Tue, 12 Mar 2019 14:38:38 -0400 Subject: [PATCH 130/147] Upgrade graphql-playground to 1.7.20 CSS didn't change but js did. `curl -svL --http1.1 https://cdn.jsdelivr.net/npm/graphql-playground-react@1.7.20/build/static/js/middleware.js | openssl dgst -sha256 -binary | openssl base64 -A` --- handler/playground.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/handler/playground.go b/handler/playground.go index d0038b296d1..0e1ca76863b 100644 --- a/handler/playground.go +++ b/handler/playground.go @@ -49,10 +49,10 @@ func Playground(title string, endpoint string) http.HandlerFunc { err := page.Execute(w, map[string]string{ "title": title, "endpoint": endpoint, - "version": "1.7.8", + "version": "1.7.20", "cssSRI": "sha256-cS9Vc2OBt9eUf4sykRWukeFYaInL29+myBmFDSa7F/U=", "faviconSRI": "sha256-GhTyE+McTU79R4+pRO6ih+4TfsTOrpPwD8ReKFzb3PM=", - "jsSRI": "sha256-ucQsC5k+XYnUlQia6tMKdAOGBbfbDAquMa+oqIooB5A=", + "jsSRI": "sha256-4QG1Uza2GgGdlBL3RCBCGtGeZB6bDbsw8OltCMGeJsA=", }) if err != nil { panic(err) From 6aa9dfc65af4ebd6c5373b854b40fe0a97f6dfbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Corrales=20Solera?= Date: Tue, 12 Mar 2019 20:11:25 +0100 Subject: [PATCH 131/147] Adding entry for workshop --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 66f68c69e35..433b96f3e00 100644 --- a/README.md +++ b/README.md @@ -28,3 +28,4 @@ Read our [Contribution Guidelines](https://github.com/99designs/gqlgen/blob/mast - [Christopher Biscardi @ Gophercon UK 2018](https://youtu.be/FdURVezcdcw) - [Introducing gqlgen: a GraphQL Server Generator for Go](https://99designs.com.au/blog/engineering/gqlgen-a-graphql-server-generator-for-go/) + - [GraphQL workshop for Golang developers by Iván Corrales Solera](https://graphql-go.wesovilabs.com) From f52726dec03743d4e96aa0f56e2b6569d55beaba Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Wed, 13 Mar 2019 10:20:43 +1100 Subject: [PATCH 132/147] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 433b96f3e00..0b302bdd55e 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ If you think you've found a bug, or something isn't behaving the way you think i Read our [Contribution Guidelines](https://github.com/99designs/gqlgen/blob/master/CONTRIBUTING.md) for information on how you can help out gqlgen. -## Talks & Blog Posts +## Other Resources - [Christopher Biscardi @ Gophercon UK 2018](https://youtu.be/FdURVezcdcw) - [Introducing gqlgen: a GraphQL Server Generator for Go](https://99designs.com.au/blog/engineering/gqlgen-a-graphql-server-generator-for-go/) From 27e97535903e956eaf48acb08951b49539c7f80f Mon Sep 17 00:00:00 2001 From: Cody Ley-Han Date: Tue, 12 Mar 2019 21:08:30 -0700 Subject: [PATCH 133/147] Expose IsMethod to resolver context --- codegen/field.gotpl | 1 + codegen/testserver/generated.go | 721 ++++++++++++--------- example/chat/generated.go | 294 +++++---- example/config/generated.go | 301 +++++---- example/dataloader/generated.go | 343 +++++----- example/scalars/generated.go | 322 +++++---- example/selection/generated.go | 301 +++++---- example/starwars/generated/exec.go | 504 ++++++++------ example/todo/generated.go | 294 +++++---- example/type-system-extension/generated.go | 287 ++++---- graphql/context.go | 2 + integration/generated.go | 315 +++++---- 12 files changed, 2107 insertions(+), 1578 deletions(-) diff --git a/codegen/field.gotpl b/codegen/field.gotpl index 17058fd4896..807eea49f91 100644 --- a/codegen/field.gotpl +++ b/codegen/field.gotpl @@ -44,6 +44,7 @@ Object: {{$object.Name|quote}}, Field: field, Args: nil, + IsMethod: {{$field.IsMethod}}, } ctx = graphql.WithResolverContext(ctx, rctx) {{- if $field.Args }} diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 9ba500108f4..d4dff08a84f 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -1822,9 +1822,10 @@ func (ec *executionContext) _AIt_id(ctx context.Context, field graphql.Collected ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "AIt", - Field: field, - Args: nil, + Object: "AIt", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1848,9 +1849,10 @@ func (ec *executionContext) _AbIt_id(ctx context.Context, field graphql.Collecte ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "AbIt", - Field: field, - Args: nil, + Object: "AbIt", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1874,9 +1876,10 @@ func (ec *executionContext) _Autobind_int(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Autobind", - Field: field, - Args: nil, + Object: "Autobind", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1900,9 +1903,10 @@ func (ec *executionContext) _Autobind_int32(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Autobind", - Field: field, - Args: nil, + Object: "Autobind", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1926,9 +1930,10 @@ func (ec *executionContext) _Autobind_int64(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Autobind", - Field: field, - Args: nil, + Object: "Autobind", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1952,9 +1957,10 @@ func (ec *executionContext) _Autobind_idStr(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Autobind", - Field: field, - Args: nil, + Object: "Autobind", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1978,9 +1984,10 @@ func (ec *executionContext) _Autobind_idInt(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Autobind", - Field: field, - Args: nil, + Object: "Autobind", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2004,9 +2011,10 @@ func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Circle", - Field: field, - Args: nil, + Object: "Circle", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2027,9 +2035,10 @@ func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Circle", - Field: field, - Args: nil, + Object: "Circle", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2050,9 +2059,10 @@ func (ec *executionContext) _EmbeddedDefaultScalar_value(ctx context.Context, fi ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "EmbeddedDefaultScalar", - Field: field, - Args: nil, + Object: "EmbeddedDefaultScalar", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2073,9 +2083,10 @@ func (ec *executionContext) _EmbeddedPointer_ID(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "EmbeddedPointer", - Field: field, - Args: nil, + Object: "EmbeddedPointer", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2096,9 +2107,10 @@ func (ec *executionContext) _EmbeddedPointer_Title(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "EmbeddedPointer", - Field: field, - Args: nil, + Object: "EmbeddedPointer", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2119,9 +2131,10 @@ func (ec *executionContext) _Error_id(ctx context.Context, field graphql.Collect ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Error", - Field: field, - Args: nil, + Object: "Error", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2145,9 +2158,10 @@ func (ec *executionContext) _Error_errorOnNonRequiredField(ctx context.Context, ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Error", - Field: field, - Args: nil, + Object: "Error", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2168,9 +2182,10 @@ func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, fie ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Error", - Field: field, - Args: nil, + Object: "Error", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2194,9 +2209,10 @@ func (ec *executionContext) _Error_nilOnRequiredField(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Error", - Field: field, - Args: nil, + Object: "Error", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2220,9 +2236,10 @@ func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "ForcedResolver", - Field: field, - Args: nil, + Object: "ForcedResolver", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2243,9 +2260,10 @@ func (ec *executionContext) _InnerObject_id(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "InnerObject", - Field: field, - Args: nil, + Object: "InnerObject", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2269,9 +2287,10 @@ func (ec *executionContext) _InvalidIdentifier_id(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "InvalidIdentifier", - Field: field, - Args: nil, + Object: "InvalidIdentifier", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2295,9 +2314,10 @@ func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedF ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "It", - Field: field, - Args: nil, + Object: "It", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2321,9 +2341,10 @@ func (ec *executionContext) _MapStringInterfaceType_a(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MapStringInterfaceType", - Field: field, - Args: nil, + Object: "MapStringInterfaceType", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2353,9 +2374,10 @@ func (ec *executionContext) _MapStringInterfaceType_b(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MapStringInterfaceType", - Field: field, - Args: nil, + Object: "MapStringInterfaceType", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2385,9 +2407,10 @@ func (ec *executionContext) _ModelMethods_resolverField(ctx context.Context, fie ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "ModelMethods", - Field: field, - Args: nil, + Object: "ModelMethods", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2411,9 +2434,10 @@ func (ec *executionContext) _ModelMethods_noContext(ctx context.Context, field g ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "ModelMethods", - Field: field, - Args: nil, + Object: "ModelMethods", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2437,9 +2461,10 @@ func (ec *executionContext) _ModelMethods_withContext(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "ModelMethods", - Field: field, - Args: nil, + Object: "ModelMethods", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2463,9 +2488,10 @@ func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "OuterObject", - Field: field, - Args: nil, + Object: "OuterObject", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2489,9 +2515,10 @@ func (ec *executionContext) _Panics_fieldScalarMarshal(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Panics", - Field: field, - Args: nil, + Object: "Panics", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2515,9 +2542,10 @@ func (ec *executionContext) _Panics_fieldFuncMarshal(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Panics", - Field: field, - Args: nil, + Object: "Panics", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2548,9 +2576,10 @@ func (ec *executionContext) _Panics_argUnmarshal(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Panics", - Field: field, - Args: nil, + Object: "Panics", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2581,9 +2610,10 @@ func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2604,9 +2634,10 @@ func (ec *executionContext) _Query_collision(ctx context.Context, field graphql. ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2627,9 +2658,10 @@ func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2657,9 +2689,10 @@ func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql. ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2687,9 +2720,10 @@ func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2717,9 +2751,10 @@ func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2740,9 +2775,10 @@ func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2763,9 +2799,10 @@ func (ec *executionContext) _Query_errorBubble(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2786,9 +2823,10 @@ func (ec *executionContext) _Query_modelMethods(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2809,9 +2847,10 @@ func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2835,9 +2874,10 @@ func (ec *executionContext) _Query_user(ctx context.Context, field graphql.Colle ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2868,9 +2908,10 @@ func (ec *executionContext) _Query_nullableArg(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2898,9 +2939,10 @@ func (ec *executionContext) _Query_directiveArg(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2928,9 +2970,10 @@ func (ec *executionContext) _Query_directiveNullableArg(ctx context.Context, fie ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2958,9 +3001,10 @@ func (ec *executionContext) _Query_directiveInputNullable(ctx context.Context, f ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2988,9 +3032,10 @@ func (ec *executionContext) _Query_directiveInput(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -3018,9 +3063,10 @@ func (ec *executionContext) _Query_directiveInputType(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -3048,9 +3094,10 @@ func (ec *executionContext) _Query_inputSlice(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -3081,9 +3128,10 @@ func (ec *executionContext) _Query_shapeUnion(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3107,9 +3155,10 @@ func (ec *executionContext) _Query_autobind(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3130,9 +3179,10 @@ func (ec *executionContext) _Query_deprecatedField(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3156,9 +3206,10 @@ func (ec *executionContext) _Query_mapStringInterface(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -3186,9 +3237,10 @@ func (ec *executionContext) _Query_panics(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3209,9 +3261,10 @@ func (ec *executionContext) _Query_defaultScalar(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -3242,9 +3295,10 @@ func (ec *executionContext) _Query_validType(ctx context.Context, field graphql. ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3265,9 +3319,10 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -3295,9 +3350,10 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3318,9 +3374,10 @@ func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Rectangle", - Field: field, - Args: nil, + Object: "Rectangle", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3341,9 +3398,10 @@ func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql. ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Rectangle", - Field: field, - Args: nil, + Object: "Rectangle", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3364,9 +3422,10 @@ func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Rectangle", - Field: field, - Args: nil, + Object: "Rectangle", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3443,9 +3502,10 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, + Object: "User", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3469,9 +3529,10 @@ func (ec *executionContext) _User_friends(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, + Object: "User", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3495,9 +3556,10 @@ func (ec *executionContext) _User_created(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, + Object: "User", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3521,9 +3583,10 @@ func (ec *executionContext) _User_updated(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, + Object: "User", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3544,9 +3607,10 @@ func (ec *executionContext) _ValidType_differentCase(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "ValidType", - Field: field, - Args: nil, + Object: "ValidType", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3570,9 +3634,10 @@ func (ec *executionContext) _ValidType_different_case(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "ValidType", - Field: field, - Args: nil, + Object: "ValidType", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3596,9 +3661,10 @@ func (ec *executionContext) _ValidType_validInputKeywords(ctx context.Context, f ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "ValidType", - Field: field, - Args: nil, + Object: "ValidType", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -3629,9 +3695,10 @@ func (ec *executionContext) _ValidType_validArgs(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "ValidType", - Field: field, - Args: nil, + Object: "ValidType", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -3662,9 +3729,10 @@ func (ec *executionContext) _XXIt_id(ctx context.Context, field graphql.Collecte ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "XXIt", - Field: field, - Args: nil, + Object: "XXIt", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3688,9 +3756,10 @@ func (ec *executionContext) _XxIt_id(ctx context.Context, field graphql.Collecte ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "XxIt", - Field: field, - Args: nil, + Object: "XxIt", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3714,9 +3783,10 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3740,9 +3810,10 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3763,9 +3834,10 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3789,9 +3861,10 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3815,9 +3888,10 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3841,9 +3915,10 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3864,9 +3939,10 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3890,9 +3966,10 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3913,9 +3990,10 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3939,9 +4017,10 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3962,9 +4041,10 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3988,9 +4068,10 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4014,9 +4095,10 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4040,9 +4122,10 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4063,9 +4146,10 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4089,9 +4173,10 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4112,9 +4197,10 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4138,9 +4224,10 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4161,9 +4248,10 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4187,9 +4275,10 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4213,9 +4302,10 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4236,9 +4326,10 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4259,9 +4350,10 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4285,9 +4377,10 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4311,9 +4404,10 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4334,9 +4428,10 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4357,9 +4452,10 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -4387,9 +4483,10 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4410,9 +4507,10 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4433,9 +4531,10 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -4463,9 +4562,10 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4486,9 +4586,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4509,9 +4610,10 @@ func (ec *executionContext) _asdfIt_id(ctx context.Context, field graphql.Collec ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "asdfIt", - Field: field, - Args: nil, + Object: "asdfIt", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -4535,9 +4637,10 @@ func (ec *executionContext) _iIt_id(ctx context.Context, field graphql.Collected ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "iIt", - Field: field, - Args: nil, + Object: "iIt", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) diff --git a/example/chat/generated.go b/example/chat/generated.go index 845ab1658ec..00250b4fa2e 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -418,9 +418,10 @@ func (ec *executionContext) _Chatroom_name(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Chatroom", - Field: field, - Args: nil, + Object: "Chatroom", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -444,9 +445,10 @@ func (ec *executionContext) _Chatroom_messages(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Chatroom", - Field: field, - Args: nil, + Object: "Chatroom", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -470,9 +472,10 @@ func (ec *executionContext) _Message_id(ctx context.Context, field graphql.Colle ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Message", - Field: field, - Args: nil, + Object: "Message", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -496,9 +499,10 @@ func (ec *executionContext) _Message_text(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Message", - Field: field, - Args: nil, + Object: "Message", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -522,9 +526,10 @@ func (ec *executionContext) _Message_createdBy(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Message", - Field: field, - Args: nil, + Object: "Message", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -548,9 +553,10 @@ func (ec *executionContext) _Message_createdAt(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Message", - Field: field, - Args: nil, + Object: "Message", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -574,9 +580,10 @@ func (ec *executionContext) _Mutation_post(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Mutation", - Field: field, - Args: nil, + Object: "Mutation", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -607,9 +614,10 @@ func (ec *executionContext) _Query_room(ctx context.Context, field graphql.Colle ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -637,9 +645,10 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -667,9 +676,10 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -724,9 +734,10 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -750,9 +761,10 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -773,9 +785,10 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -799,9 +812,10 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -825,9 +839,10 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -851,9 +866,10 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -874,9 +890,10 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -900,9 +917,10 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -923,9 +941,10 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -949,9 +968,10 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -972,9 +992,10 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -998,9 +1019,10 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1024,9 +1046,10 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1050,9 +1073,10 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1073,9 +1097,10 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1099,9 +1124,10 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1122,9 +1148,10 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1148,9 +1175,10 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1171,9 +1199,10 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1197,9 +1226,10 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1223,9 +1253,10 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1246,9 +1277,10 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1269,9 +1301,10 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1295,9 +1328,10 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1321,9 +1355,10 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1344,9 +1379,10 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1367,9 +1403,10 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1397,9 +1434,10 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1420,9 +1458,10 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1443,9 +1482,10 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1473,9 +1513,10 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1496,9 +1537,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) diff --git a/example/config/generated.go b/example/config/generated.go index 97a7dd2c8af..61757ee47e3 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -331,9 +331,10 @@ func (ec *executionContext) _Mutation_createTodo(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Mutation", - Field: field, - Args: nil, + Object: "Mutation", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -364,9 +365,10 @@ func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -390,9 +392,10 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -420,9 +423,10 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -443,9 +447,10 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Todo", - Field: field, - Args: nil, + Object: "Todo", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -469,9 +474,10 @@ func (ec *executionContext) _Todo_databaseId(ctx context.Context, field graphql. ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Todo", - Field: field, - Args: nil, + Object: "Todo", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -495,9 +501,10 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Todo", - Field: field, - Args: nil, + Object: "Todo", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -521,9 +528,10 @@ func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.Collec ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Todo", - Field: field, - Args: nil, + Object: "Todo", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -547,9 +555,10 @@ func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.Collec ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Todo", - Field: field, - Args: nil, + Object: "Todo", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -573,9 +582,10 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, + Object: "User", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -599,9 +609,10 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, + Object: "User", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -625,9 +636,10 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -651,9 +663,10 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -674,9 +687,10 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -700,9 +714,10 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -726,9 +741,10 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -752,9 +768,10 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -775,9 +792,10 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -801,9 +819,10 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -824,9 +843,10 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -850,9 +870,10 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -873,9 +894,10 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -899,9 +921,10 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -925,9 +948,10 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -951,9 +975,10 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -974,9 +999,10 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1000,9 +1026,10 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1023,9 +1050,10 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1049,9 +1077,10 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1072,9 +1101,10 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1098,9 +1128,10 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1124,9 +1155,10 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1147,9 +1179,10 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1170,9 +1203,10 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1196,9 +1230,10 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1222,9 +1257,10 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1245,9 +1281,10 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1268,9 +1305,10 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1298,9 +1336,10 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1321,9 +1360,10 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1344,9 +1384,10 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1374,9 +1415,10 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1397,9 +1439,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index f2d965d06e4..f2765b9313a 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -398,9 +398,10 @@ func (ec *executionContext) _Address_id(ctx context.Context, field graphql.Colle ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Address", - Field: field, - Args: nil, + Object: "Address", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -424,9 +425,10 @@ func (ec *executionContext) _Address_street(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Address", - Field: field, - Args: nil, + Object: "Address", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -450,9 +452,10 @@ func (ec *executionContext) _Address_country(ctx context.Context, field graphql. ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Address", - Field: field, - Args: nil, + Object: "Address", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -476,9 +479,10 @@ func (ec *executionContext) _Customer_id(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Customer", - Field: field, - Args: nil, + Object: "Customer", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -502,9 +506,10 @@ func (ec *executionContext) _Customer_name(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Customer", - Field: field, - Args: nil, + Object: "Customer", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -528,9 +533,10 @@ func (ec *executionContext) _Customer_address(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Customer", - Field: field, - Args: nil, + Object: "Customer", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -551,9 +557,10 @@ func (ec *executionContext) _Customer_orders(ctx context.Context, field graphql. ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Customer", - Field: field, - Args: nil, + Object: "Customer", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -574,9 +581,10 @@ func (ec *executionContext) _Item_name(ctx context.Context, field graphql.Collec ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Item", - Field: field, - Args: nil, + Object: "Item", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -600,9 +608,10 @@ func (ec *executionContext) _Order_id(ctx context.Context, field graphql.Collect ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Order", - Field: field, - Args: nil, + Object: "Order", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -626,9 +635,10 @@ func (ec *executionContext) _Order_date(ctx context.Context, field graphql.Colle ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Order", - Field: field, - Args: nil, + Object: "Order", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -652,9 +662,10 @@ func (ec *executionContext) _Order_amount(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Order", - Field: field, - Args: nil, + Object: "Order", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -678,9 +689,10 @@ func (ec *executionContext) _Order_items(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Order", - Field: field, - Args: nil, + Object: "Order", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -701,9 +713,10 @@ func (ec *executionContext) _Query_customers(ctx context.Context, field graphql. ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -724,9 +737,10 @@ func (ec *executionContext) _Query_torture1d(ctx context.Context, field graphql. ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -754,9 +768,10 @@ func (ec *executionContext) _Query_torture2d(ctx context.Context, field graphql. ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -784,9 +799,10 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -814,9 +830,10 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -837,9 +854,10 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -863,9 +881,10 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -886,9 +905,10 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -912,9 +932,10 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -938,9 +959,10 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -964,9 +986,10 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -987,9 +1010,10 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1013,9 +1037,10 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1036,9 +1061,10 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1062,9 +1088,10 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1085,9 +1112,10 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1111,9 +1139,10 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1137,9 +1166,10 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1163,9 +1193,10 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1186,9 +1217,10 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1212,9 +1244,10 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1235,9 +1268,10 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1261,9 +1295,10 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1284,9 +1319,10 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1310,9 +1346,10 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1336,9 +1373,10 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1359,9 +1397,10 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1382,9 +1421,10 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1408,9 +1448,10 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1434,9 +1475,10 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1457,9 +1499,10 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1480,9 +1523,10 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1510,9 +1554,10 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1533,9 +1578,10 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1556,9 +1602,10 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1586,9 +1633,10 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1609,9 +1657,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) diff --git a/example/scalars/generated.go b/example/scalars/generated.go index 08bcab5f8a6..e514b80341b 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -369,9 +369,10 @@ func (ec *executionContext) _Address_id(ctx context.Context, field graphql.Colle ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Address", - Field: field, - Args: nil, + Object: "Address", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -395,9 +396,10 @@ func (ec *executionContext) _Address_location(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Address", - Field: field, - Args: nil, + Object: "Address", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -418,9 +420,10 @@ func (ec *executionContext) _Query_user(ctx context.Context, field graphql.Colle ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -448,9 +451,10 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -481,9 +485,10 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -511,9 +516,10 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -534,9 +540,10 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, + Object: "User", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -560,9 +567,10 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, + Object: "User", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -586,9 +594,10 @@ func (ec *executionContext) _User_created(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, + Object: "User", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -609,9 +618,10 @@ func (ec *executionContext) _User_isBanned(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, + Object: "User", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -635,9 +645,10 @@ func (ec *executionContext) _User_primitiveResolver(ctx context.Context, field g ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, + Object: "User", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -661,9 +672,10 @@ func (ec *executionContext) _User_customResolver(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, + Object: "User", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -687,9 +699,10 @@ func (ec *executionContext) _User_address(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, + Object: "User", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -710,9 +723,10 @@ func (ec *executionContext) _User_tier(ctx context.Context, field graphql.Collec ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, + Object: "User", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -733,9 +747,10 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -759,9 +774,10 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -782,9 +798,10 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -808,9 +825,10 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -834,9 +852,10 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -860,9 +879,10 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -883,9 +903,10 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -909,9 +930,10 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -932,9 +954,10 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -958,9 +981,10 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -981,9 +1005,10 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1007,9 +1032,10 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1033,9 +1059,10 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1059,9 +1086,10 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1082,9 +1110,10 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1108,9 +1137,10 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1131,9 +1161,10 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1157,9 +1188,10 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1180,9 +1212,10 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1206,9 +1239,10 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1232,9 +1266,10 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1255,9 +1290,10 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1278,9 +1314,10 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1304,9 +1341,10 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1330,9 +1368,10 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1353,9 +1392,10 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1376,9 +1416,10 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1406,9 +1447,10 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1429,9 +1471,10 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1452,9 +1495,10 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1482,9 +1526,10 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1505,9 +1550,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) diff --git a/example/selection/generated.go b/example/selection/generated.go index a15fc7fcaaf..479e700844f 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -288,9 +288,10 @@ func (ec *executionContext) _Like_reaction(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Like", - Field: field, - Args: nil, + Object: "Like", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -314,9 +315,10 @@ func (ec *executionContext) _Like_sent(ctx context.Context, field graphql.Collec ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Like", - Field: field, - Args: nil, + Object: "Like", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -340,9 +342,10 @@ func (ec *executionContext) _Like_selection(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Like", - Field: field, - Args: nil, + Object: "Like", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -363,9 +366,10 @@ func (ec *executionContext) _Like_collected(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Like", - Field: field, - Args: nil, + Object: "Like", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -386,9 +390,10 @@ func (ec *executionContext) _Post_message(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Post", - Field: field, - Args: nil, + Object: "Post", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -412,9 +417,10 @@ func (ec *executionContext) _Post_sent(ctx context.Context, field graphql.Collec ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Post", - Field: field, - Args: nil, + Object: "Post", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -438,9 +444,10 @@ func (ec *executionContext) _Post_selection(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Post", - Field: field, - Args: nil, + Object: "Post", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -461,9 +468,10 @@ func (ec *executionContext) _Post_collected(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Post", - Field: field, - Args: nil, + Object: "Post", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -484,9 +492,10 @@ func (ec *executionContext) _Query_events(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -507,9 +516,10 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -537,9 +547,10 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -560,9 +571,10 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -586,9 +598,10 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -609,9 +622,10 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -635,9 +649,10 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -661,9 +676,10 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -687,9 +703,10 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -710,9 +727,10 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -736,9 +754,10 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -759,9 +778,10 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -785,9 +805,10 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -808,9 +829,10 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -834,9 +856,10 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -860,9 +883,10 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -886,9 +910,10 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -909,9 +934,10 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -935,9 +961,10 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -958,9 +985,10 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -984,9 +1012,10 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1007,9 +1036,10 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1033,9 +1063,10 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1059,9 +1090,10 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1082,9 +1114,10 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1105,9 +1138,10 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1131,9 +1165,10 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1157,9 +1192,10 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1180,9 +1216,10 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1203,9 +1240,10 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1233,9 +1271,10 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1256,9 +1295,10 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1279,9 +1319,10 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1309,9 +1350,10 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1332,9 +1374,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) diff --git a/example/starwars/generated/exec.go b/example/starwars/generated/exec.go index 65c84b4aa76..cd6d0dc1239 100644 --- a/example/starwars/generated/exec.go +++ b/example/starwars/generated/exec.go @@ -950,9 +950,10 @@ func (ec *executionContext) _Droid_id(ctx context.Context, field graphql.Collect ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Droid", - Field: field, - Args: nil, + Object: "Droid", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -976,9 +977,10 @@ func (ec *executionContext) _Droid_name(ctx context.Context, field graphql.Colle ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Droid", - Field: field, - Args: nil, + Object: "Droid", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1002,9 +1004,10 @@ func (ec *executionContext) _Droid_friends(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Droid", - Field: field, - Args: nil, + Object: "Droid", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1025,9 +1028,10 @@ func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Droid", - Field: field, - Args: nil, + Object: "Droid", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1058,9 +1062,10 @@ func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql. ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Droid", - Field: field, - Args: nil, + Object: "Droid", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1084,9 +1089,10 @@ func (ec *executionContext) _Droid_primaryFunction(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Droid", - Field: field, - Args: nil, + Object: "Droid", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1107,9 +1113,10 @@ func (ec *executionContext) _FriendsConnection_totalCount(ctx context.Context, f ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "FriendsConnection", - Field: field, - Args: nil, + Object: "FriendsConnection", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1133,9 +1140,10 @@ func (ec *executionContext) _FriendsConnection_edges(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "FriendsConnection", - Field: field, - Args: nil, + Object: "FriendsConnection", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1156,9 +1164,10 @@ func (ec *executionContext) _FriendsConnection_friends(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "FriendsConnection", - Field: field, - Args: nil, + Object: "FriendsConnection", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1179,9 +1188,10 @@ func (ec *executionContext) _FriendsConnection_pageInfo(ctx context.Context, fie ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "FriendsConnection", - Field: field, - Args: nil, + Object: "FriendsConnection", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1205,9 +1215,10 @@ func (ec *executionContext) _FriendsEdge_cursor(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "FriendsEdge", - Field: field, - Args: nil, + Object: "FriendsEdge", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1231,9 +1242,10 @@ func (ec *executionContext) _FriendsEdge_node(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "FriendsEdge", - Field: field, - Args: nil, + Object: "FriendsEdge", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1254,9 +1266,10 @@ func (ec *executionContext) _Human_id(ctx context.Context, field graphql.Collect ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Human", - Field: field, - Args: nil, + Object: "Human", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1280,9 +1293,10 @@ func (ec *executionContext) _Human_name(ctx context.Context, field graphql.Colle ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Human", - Field: field, - Args: nil, + Object: "Human", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1306,9 +1320,10 @@ func (ec *executionContext) _Human_height(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Human", - Field: field, - Args: nil, + Object: "Human", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1339,9 +1354,10 @@ func (ec *executionContext) _Human_mass(ctx context.Context, field graphql.Colle ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Human", - Field: field, - Args: nil, + Object: "Human", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1362,9 +1378,10 @@ func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Human", - Field: field, - Args: nil, + Object: "Human", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1385,9 +1402,10 @@ func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Human", - Field: field, - Args: nil, + Object: "Human", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1418,9 +1436,10 @@ func (ec *executionContext) _Human_appearsIn(ctx context.Context, field graphql. ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Human", - Field: field, - Args: nil, + Object: "Human", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1444,9 +1463,10 @@ func (ec *executionContext) _Human_starships(ctx context.Context, field graphql. ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Human", - Field: field, - Args: nil, + Object: "Human", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1467,9 +1487,10 @@ func (ec *executionContext) _Mutation_createReview(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Mutation", - Field: field, - Args: nil, + Object: "Mutation", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1497,9 +1518,10 @@ func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "PageInfo", - Field: field, - Args: nil, + Object: "PageInfo", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1523,9 +1545,10 @@ func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "PageInfo", - Field: field, - Args: nil, + Object: "PageInfo", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1549,9 +1572,10 @@ func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "PageInfo", - Field: field, - Args: nil, + Object: "PageInfo", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1575,9 +1599,10 @@ func (ec *executionContext) _Query_hero(ctx context.Context, field graphql.Colle ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1605,9 +1630,10 @@ func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1638,9 +1664,10 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1671,9 +1698,10 @@ func (ec *executionContext) _Query_character(ctx context.Context, field graphql. ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1701,9 +1729,10 @@ func (ec *executionContext) _Query_droid(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1731,9 +1760,10 @@ func (ec *executionContext) _Query_human(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1761,9 +1791,10 @@ func (ec *executionContext) _Query_starship(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1791,9 +1822,10 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1821,9 +1853,10 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1844,9 +1877,10 @@ func (ec *executionContext) _Review_stars(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Review", - Field: field, - Args: nil, + Object: "Review", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1870,9 +1904,10 @@ func (ec *executionContext) _Review_commentary(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Review", - Field: field, - Args: nil, + Object: "Review", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1893,9 +1928,10 @@ func (ec *executionContext) _Review_time(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Review", - Field: field, - Args: nil, + Object: "Review", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1916,9 +1952,10 @@ func (ec *executionContext) _Starship_id(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Starship", - Field: field, - Args: nil, + Object: "Starship", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1942,9 +1979,10 @@ func (ec *executionContext) _Starship_name(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Starship", - Field: field, - Args: nil, + Object: "Starship", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1968,9 +2006,10 @@ func (ec *executionContext) _Starship_length(ctx context.Context, field graphql. ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Starship", - Field: field, - Args: nil, + Object: "Starship", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2001,9 +2040,10 @@ func (ec *executionContext) _Starship_history(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Starship", - Field: field, - Args: nil, + Object: "Starship", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2027,9 +2067,10 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2053,9 +2094,10 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2076,9 +2118,10 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2102,9 +2145,10 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2128,9 +2172,10 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2154,9 +2199,10 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2177,9 +2223,10 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2203,9 +2250,10 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2226,9 +2274,10 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2252,9 +2301,10 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2275,9 +2325,10 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2301,9 +2352,10 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2327,9 +2379,10 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2353,9 +2406,10 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2376,9 +2430,10 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2402,9 +2457,10 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2425,9 +2481,10 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2451,9 +2508,10 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2474,9 +2532,10 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2500,9 +2559,10 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2526,9 +2586,10 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2549,9 +2610,10 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2572,9 +2634,10 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2598,9 +2661,10 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2624,9 +2688,10 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2647,9 +2712,10 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2670,9 +2736,10 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2700,9 +2767,10 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2723,9 +2791,10 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2746,9 +2815,10 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2776,9 +2846,10 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2799,9 +2870,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) diff --git a/example/todo/generated.go b/example/todo/generated.go index b6d49c3650e..e33ba989f8d 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -411,9 +411,10 @@ func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MyMutation", - Field: field, - Args: nil, + Object: "MyMutation", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -444,9 +445,10 @@ func (ec *executionContext) _MyMutation_updateTodo(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MyMutation", - Field: field, - Args: nil, + Object: "MyMutation", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -474,9 +476,10 @@ func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MyQuery", - Field: field, - Args: nil, + Object: "MyQuery", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -504,9 +507,10 @@ func (ec *executionContext) _MyQuery_lastTodo(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MyQuery", - Field: field, - Args: nil, + Object: "MyQuery", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -527,9 +531,10 @@ func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MyQuery", - Field: field, - Args: nil, + Object: "MyQuery", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -553,9 +558,10 @@ func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MyQuery", - Field: field, - Args: nil, + Object: "MyQuery", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -583,9 +589,10 @@ func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MyQuery", - Field: field, - Args: nil, + Object: "MyQuery", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -606,9 +613,10 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Todo", - Field: field, - Args: nil, + Object: "Todo", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -632,9 +640,10 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Todo", - Field: field, - Args: nil, + Object: "Todo", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -658,9 +667,10 @@ func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.Collec ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Todo", - Field: field, - Args: nil, + Object: "Todo", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -684,9 +694,10 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -710,9 +721,10 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -733,9 +745,10 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -759,9 +772,10 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -785,9 +799,10 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -811,9 +826,10 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -834,9 +850,10 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -860,9 +877,10 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -883,9 +901,10 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -909,9 +928,10 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -932,9 +952,10 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -958,9 +979,10 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -984,9 +1006,10 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1010,9 +1033,10 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1033,9 +1057,10 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1059,9 +1084,10 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1082,9 +1108,10 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1108,9 +1135,10 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1131,9 +1159,10 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1157,9 +1186,10 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1183,9 +1213,10 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1206,9 +1237,10 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1229,9 +1261,10 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1255,9 +1288,10 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1281,9 +1315,10 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1304,9 +1339,10 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1327,9 +1363,10 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1357,9 +1394,10 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1380,9 +1418,10 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1403,9 +1442,10 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1433,9 +1473,10 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1456,9 +1497,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index e21dae94c46..15a78196742 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -444,9 +444,10 @@ func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MyMutation", - Field: field, - Args: nil, + Object: "MyMutation", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -477,9 +478,10 @@ func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MyQuery", - Field: field, - Args: nil, + Object: "MyQuery", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -503,9 +505,10 @@ func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MyQuery", - Field: field, - Args: nil, + Object: "MyQuery", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -533,9 +536,10 @@ func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MyQuery", - Field: field, - Args: nil, + Object: "MyQuery", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -563,9 +567,10 @@ func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "MyQuery", - Field: field, - Args: nil, + Object: "MyQuery", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -586,9 +591,10 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Todo", - Field: field, - Args: nil, + Object: "Todo", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -612,9 +618,10 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Todo", - Field: field, - Args: nil, + Object: "Todo", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -638,9 +645,10 @@ func (ec *executionContext) _Todo_state(ctx context.Context, field graphql.Colle ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Todo", - Field: field, - Args: nil, + Object: "Todo", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -664,9 +672,10 @@ func (ec *executionContext) _Todo_verified(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Todo", - Field: field, - Args: nil, + Object: "Todo", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -690,9 +699,10 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -716,9 +726,10 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -739,9 +750,10 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -765,9 +777,10 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -791,9 +804,10 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -817,9 +831,10 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -840,9 +855,10 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -866,9 +882,10 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -889,9 +906,10 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -915,9 +933,10 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -938,9 +957,10 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -964,9 +984,10 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -990,9 +1011,10 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1016,9 +1038,10 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1039,9 +1062,10 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1065,9 +1089,10 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1088,9 +1113,10 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1114,9 +1140,10 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1137,9 +1164,10 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1163,9 +1191,10 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1189,9 +1218,10 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1212,9 +1242,10 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1235,9 +1266,10 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1261,9 +1293,10 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1287,9 +1320,10 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1310,9 +1344,10 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1333,9 +1368,10 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1363,9 +1399,10 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1386,9 +1423,10 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1409,9 +1447,10 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1439,9 +1478,10 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1462,9 +1502,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) diff --git a/graphql/context.go b/graphql/context.go index d6b28456cb4..58d3c741e12 100644 --- a/graphql/context.go +++ b/graphql/context.go @@ -94,6 +94,8 @@ type ResolverContext struct { Index *int // The result object of resolver Result interface{} + // IsMethod indicates if the resolver is a method + IsMethod bool } func (r *ResolverContext) Path() []interface{} { diff --git a/integration/generated.go b/integration/generated.go index a9044e3f509..4c34a1ebae5 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -418,9 +418,10 @@ func (ec *executionContext) _Element_child(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Element", - Field: field, - Args: nil, + Object: "Element", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -444,9 +445,10 @@ func (ec *executionContext) _Element_error(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Element", - Field: field, - Args: nil, + Object: "Element", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -470,9 +472,10 @@ func (ec *executionContext) _Element_mismatched(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Element", - Field: field, - Args: nil, + Object: "Element", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -493,9 +496,10 @@ func (ec *executionContext) _Query_path(ctx context.Context, field graphql.Colle ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -516,9 +520,10 @@ func (ec *executionContext) _Query_date(ctx context.Context, field graphql.Colle ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -549,9 +554,10 @@ func (ec *executionContext) _Query_viewer(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -572,9 +578,10 @@ func (ec *executionContext) _Query_jsonEncoding(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -598,9 +605,10 @@ func (ec *executionContext) _Query_error(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -631,9 +639,10 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -661,9 +670,10 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -684,9 +694,10 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, + Object: "User", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -710,9 +721,10 @@ func (ec *executionContext) _User_likes(ctx context.Context, field graphql.Colle ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "User", - Field: field, - Args: nil, + Object: "User", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -736,9 +748,10 @@ func (ec *executionContext) _Viewer_user(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "Viewer", - Field: field, - Args: nil, + Object: "Viewer", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -759,9 +772,10 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -785,9 +799,10 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -808,9 +823,10 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -834,9 +850,10 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Directive", - Field: field, - Args: nil, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -860,9 +877,10 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -886,9 +904,10 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -909,9 +928,10 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -935,9 +955,10 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__EnumValue", - Field: field, - Args: nil, + Object: "__EnumValue", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -958,9 +979,10 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -984,9 +1006,10 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1007,9 +1030,10 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1033,9 +1057,10 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1059,9 +1084,10 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1085,9 +1111,10 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Field", - Field: field, - Args: nil, + Object: "__Field", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1108,9 +1135,10 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1134,9 +1162,10 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1157,9 +1186,10 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1183,9 +1213,10 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__InputValue", - Field: field, - Args: nil, + Object: "__InputValue", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1206,9 +1237,10 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1232,9 +1264,10 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1258,9 +1291,10 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1281,9 +1315,10 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1304,9 +1339,10 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Schema", - Field: field, - Args: nil, + Object: "__Schema", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1330,9 +1366,10 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1356,9 +1393,10 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1379,9 +1417,10 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1402,9 +1441,10 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1432,9 +1472,10 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1455,9 +1496,10 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1478,9 +1520,10 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1508,9 +1551,10 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1531,9 +1575,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ - Object: "__Type", - Field: field, - Args: nil, + Object: "__Type", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) From af6dc16d8b2637c961fc5b8ad76418670a3df1e4 Mon Sep 17 00:00:00 2001 From: Cody Ley-Han Date: Tue, 12 Mar 2019 21:58:36 -0700 Subject: [PATCH 134/147] Add test for IsMethod in resolver --- codegen/field.gotpl | 2 +- codegen/testserver/generated.go | 60 +++++++++++----------- codegen/testserver/middleware_test.go | 10 ++++ example/chat/generated.go | 4 +- example/config/generated.go | 6 +-- example/dataloader/generated.go | 12 ++--- example/scalars/generated.go | 8 +-- example/selection/generated.go | 2 +- example/starwars/generated/exec.go | 32 ++++++------ example/todo/generated.go | 10 ++-- example/type-system-extension/generated.go | 6 +-- integration/generated.go | 18 +++---- 12 files changed, 90 insertions(+), 80 deletions(-) diff --git a/codegen/field.gotpl b/codegen/field.gotpl index 807eea49f91..9718a08aadf 100644 --- a/codegen/field.gotpl +++ b/codegen/field.gotpl @@ -44,7 +44,7 @@ Object: {{$object.Name|quote}}, Field: field, Args: nil, - IsMethod: {{$field.IsMethod}}, + IsMethod: {{or $field.IsMethod $field.IsResolver}}, } ctx = graphql.WithResolverContext(ctx, rctx) {{- if $field.Args }} diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index d4dff08a84f..4aaf81397ff 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -2239,7 +2239,7 @@ func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field gra Object: "ForcedResolver", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2410,7 +2410,7 @@ func (ec *executionContext) _ModelMethods_resolverField(ctx context.Context, fie Object: "ModelMethods", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2518,7 +2518,7 @@ func (ec *executionContext) _Panics_fieldScalarMarshal(ctx context.Context, fiel Object: "Panics", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2579,7 +2579,7 @@ func (ec *executionContext) _Panics_argUnmarshal(ctx context.Context, field grap Object: "Panics", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2613,7 +2613,7 @@ func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2637,7 +2637,7 @@ func (ec *executionContext) _Query_collision(ctx context.Context, field graphql. Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2661,7 +2661,7 @@ func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.C Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2692,7 +2692,7 @@ func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql. Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2723,7 +2723,7 @@ func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graph Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2754,7 +2754,7 @@ func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field grap Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2778,7 +2778,7 @@ func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.Col Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2802,7 +2802,7 @@ func (ec *executionContext) _Query_errorBubble(ctx context.Context, field graphq Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2826,7 +2826,7 @@ func (ec *executionContext) _Query_modelMethods(ctx context.Context, field graph Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2850,7 +2850,7 @@ func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.Coll Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2877,7 +2877,7 @@ func (ec *executionContext) _Query_user(ctx context.Context, field graphql.Colle Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2911,7 +2911,7 @@ func (ec *executionContext) _Query_nullableArg(ctx context.Context, field graphq Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2942,7 +2942,7 @@ func (ec *executionContext) _Query_directiveArg(ctx context.Context, field graph Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2973,7 +2973,7 @@ func (ec *executionContext) _Query_directiveNullableArg(ctx context.Context, fie Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -3004,7 +3004,7 @@ func (ec *executionContext) _Query_directiveInputNullable(ctx context.Context, f Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -3035,7 +3035,7 @@ func (ec *executionContext) _Query_directiveInput(ctx context.Context, field gra Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -3066,7 +3066,7 @@ func (ec *executionContext) _Query_directiveInputType(ctx context.Context, field Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -3097,7 +3097,7 @@ func (ec *executionContext) _Query_inputSlice(ctx context.Context, field graphql Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -3131,7 +3131,7 @@ func (ec *executionContext) _Query_shapeUnion(ctx context.Context, field graphql Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3158,7 +3158,7 @@ func (ec *executionContext) _Query_autobind(ctx context.Context, field graphql.C Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3182,7 +3182,7 @@ func (ec *executionContext) _Query_deprecatedField(ctx context.Context, field gr Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3209,7 +3209,7 @@ func (ec *executionContext) _Query_mapStringInterface(ctx context.Context, field Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -3240,7 +3240,7 @@ func (ec *executionContext) _Query_panics(ctx context.Context, field graphql.Col Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3264,7 +3264,7 @@ func (ec *executionContext) _Query_defaultScalar(ctx context.Context, field grap Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -3298,7 +3298,7 @@ func (ec *executionContext) _Query_validType(ctx context.Context, field graphql. Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -3532,7 +3532,7 @@ func (ec *executionContext) _User_friends(ctx context.Context, field graphql.Col Object: "User", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) diff --git a/codegen/testserver/middleware_test.go b/codegen/testserver/middleware_test.go index 05ae43c3e8c..2a48ccf5819 100644 --- a/codegen/testserver/middleware_test.go +++ b/codegen/testserver/middleware_test.go @@ -27,6 +27,7 @@ func TestMiddleware(t *testing.T) { return []User{{ID: 1}}, nil } + areMethods := []bool{} srv := httptest.NewServer( handler.GraphQL( NewExecutableSchema(Config{Resolvers: resolvers}), @@ -38,6 +39,10 @@ func TestMiddleware(t *testing.T) { path, _ := ctx.Value("path").([]int) return next(context.WithValue(ctx, "path", append(path, 2))) }), + handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { + areMethods = append(areMethods, graphql.GetResolverContext(ctx).IsMethod) + return next(ctx) + }), )) c := client.New(srv.URL) @@ -60,6 +65,11 @@ func TestMiddleware(t *testing.T) { err := c.Post(`query { user(id: 1) { id, friends { id } } }`, &resp) + // First resovles user which is a method + // Next resolves id which is not a method + // Finally resolves friends which is a method + assert.Equal(t, []bool{true, false, true}, areMethods) + require.NoError(t, err) require.True(t, called) diff --git a/example/chat/generated.go b/example/chat/generated.go index 00250b4fa2e..df5706589d2 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -583,7 +583,7 @@ func (ec *executionContext) _Mutation_post(ctx context.Context, field graphql.Co Object: "Mutation", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -617,7 +617,7 @@ func (ec *executionContext) _Query_room(ctx context.Context, field graphql.Colle Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) diff --git a/example/config/generated.go b/example/config/generated.go index 61757ee47e3..4a1a8072aa8 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -334,7 +334,7 @@ func (ec *executionContext) _Mutation_createTodo(ctx context.Context, field grap Object: "Mutation", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -368,7 +368,7 @@ func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.Coll Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -450,7 +450,7 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte Object: "Todo", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index f2765b9313a..96ef343f9b2 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -536,7 +536,7 @@ func (ec *executionContext) _Customer_address(ctx context.Context, field graphql Object: "Customer", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -560,7 +560,7 @@ func (ec *executionContext) _Customer_orders(ctx context.Context, field graphql. Object: "Customer", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -692,7 +692,7 @@ func (ec *executionContext) _Order_items(ctx context.Context, field graphql.Coll Object: "Order", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -716,7 +716,7 @@ func (ec *executionContext) _Query_customers(ctx context.Context, field graphql. Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -740,7 +740,7 @@ func (ec *executionContext) _Query_torture1d(ctx context.Context, field graphql. Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -771,7 +771,7 @@ func (ec *executionContext) _Query_torture2d(ctx context.Context, field graphql. Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) diff --git a/example/scalars/generated.go b/example/scalars/generated.go index e514b80341b..a6f1ee720bd 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -423,7 +423,7 @@ func (ec *executionContext) _Query_user(ctx context.Context, field graphql.Colle Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -454,7 +454,7 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -648,7 +648,7 @@ func (ec *executionContext) _User_primitiveResolver(ctx context.Context, field g Object: "User", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -675,7 +675,7 @@ func (ec *executionContext) _User_customResolver(ctx context.Context, field grap Object: "User", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) diff --git a/example/selection/generated.go b/example/selection/generated.go index 479e700844f..10070f5c4b9 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -495,7 +495,7 @@ func (ec *executionContext) _Query_events(ctx context.Context, field graphql.Col Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) diff --git a/example/starwars/generated/exec.go b/example/starwars/generated/exec.go index cd6d0dc1239..452da0ea0d3 100644 --- a/example/starwars/generated/exec.go +++ b/example/starwars/generated/exec.go @@ -1007,7 +1007,7 @@ func (ec *executionContext) _Droid_friends(ctx context.Context, field graphql.Co Object: "Droid", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1031,7 +1031,7 @@ func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field Object: "Droid", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1143,7 +1143,7 @@ func (ec *executionContext) _FriendsConnection_edges(ctx context.Context, field Object: "FriendsConnection", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1167,7 +1167,7 @@ func (ec *executionContext) _FriendsConnection_friends(ctx context.Context, fiel Object: "FriendsConnection", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1381,7 +1381,7 @@ func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.Co Object: "Human", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1405,7 +1405,7 @@ func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field Object: "Human", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1466,7 +1466,7 @@ func (ec *executionContext) _Human_starships(ctx context.Context, field graphql. Object: "Human", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1490,7 +1490,7 @@ func (ec *executionContext) _Mutation_createReview(ctx context.Context, field gr Object: "Mutation", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1602,7 +1602,7 @@ func (ec *executionContext) _Query_hero(ctx context.Context, field graphql.Colle Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1633,7 +1633,7 @@ func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.Co Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1667,7 +1667,7 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1701,7 +1701,7 @@ func (ec *executionContext) _Query_character(ctx context.Context, field graphql. Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1732,7 +1732,7 @@ func (ec *executionContext) _Query_droid(ctx context.Context, field graphql.Coll Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1763,7 +1763,7 @@ func (ec *executionContext) _Query_human(ctx context.Context, field graphql.Coll Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1794,7 +1794,7 @@ func (ec *executionContext) _Query_starship(ctx context.Context, field graphql.C Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -2009,7 +2009,7 @@ func (ec *executionContext) _Starship_length(ctx context.Context, field graphql. Object: "Starship", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) diff --git a/example/todo/generated.go b/example/todo/generated.go index e33ba989f8d..048d26218da 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -414,7 +414,7 @@ func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field gr Object: "MyMutation", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -448,7 +448,7 @@ func (ec *executionContext) _MyMutation_updateTodo(ctx context.Context, field gr Object: "MyMutation", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -479,7 +479,7 @@ func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.Col Object: "MyQuery", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -510,7 +510,7 @@ func (ec *executionContext) _MyQuery_lastTodo(ctx context.Context, field graphql Object: "MyQuery", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -534,7 +534,7 @@ func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.Co Object: "MyQuery", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index 15a78196742..a4098e32f7d 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -447,7 +447,7 @@ func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field gr Object: "MyMutation", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -481,7 +481,7 @@ func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.Co Object: "MyQuery", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -508,7 +508,7 @@ func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.Col Object: "MyQuery", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) diff --git a/integration/generated.go b/integration/generated.go index 4c34a1ebae5..3d1e1ce89c2 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -421,7 +421,7 @@ func (ec *executionContext) _Element_child(ctx context.Context, field graphql.Co Object: "Element", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -448,7 +448,7 @@ func (ec *executionContext) _Element_error(ctx context.Context, field graphql.Co Object: "Element", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -475,7 +475,7 @@ func (ec *executionContext) _Element_mismatched(ctx context.Context, field graph Object: "Element", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -499,7 +499,7 @@ func (ec *executionContext) _Query_path(ctx context.Context, field graphql.Colle Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -523,7 +523,7 @@ func (ec *executionContext) _Query_date(ctx context.Context, field graphql.Colle Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -557,7 +557,7 @@ func (ec *executionContext) _Query_viewer(ctx context.Context, field graphql.Col Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -581,7 +581,7 @@ func (ec *executionContext) _Query_jsonEncoding(ctx context.Context, field graph Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -608,7 +608,7 @@ func (ec *executionContext) _Query_error(ctx context.Context, field graphql.Coll Object: "Query", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -724,7 +724,7 @@ func (ec *executionContext) _User_likes(ctx context.Context, field graphql.Colle Object: "User", Field: field, Args: nil, - IsMethod: false, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) From a48c55b24e22490ef3b6baffec247cf41b2f07f3 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Wed, 13 Mar 2019 21:59:31 +1100 Subject: [PATCH 135/147] Support returning nulls from slices --- codegen/testserver/generated.go | 353 +++++++++++++++++++++ codegen/testserver/models-gen.go | 7 + codegen/testserver/resolver.go | 3 + codegen/testserver/slices.graphql | 10 + codegen/testserver/slices_test.go | 33 ++ codegen/testserver/stub.go | 4 + codegen/type.gotpl | 5 + example/chat/generated.go | 12 + example/config/generated.go | 12 + example/dataloader/generated.go | 30 ++ example/scalars/generated.go | 12 + example/selection/generated.go | 18 ++ example/starwars/generated/exec.go | 21 ++ example/todo/generated.go | 12 + example/type-system-extension/generated.go | 12 + graphql/introspection/type.go | 20 +- integration/generated.go | 18 ++ 17 files changed, 572 insertions(+), 10 deletions(-) create mode 100644 codegen/testserver/slices.graphql create mode 100644 codegen/testserver/slices_test.go diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 4aaf81397ff..7a981ca69f7 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -154,6 +154,7 @@ type ComplexityRoot struct { MapStringInterface func(childComplexity int, in map[string]interface{}) int Panics func(childComplexity int) int DefaultScalar func(childComplexity int, arg string) int + Slices func(childComplexity int) int ValidType func(childComplexity int) int } @@ -163,6 +164,13 @@ type ComplexityRoot struct { Area func(childComplexity int) int } + Slices struct { + Test1 func(childComplexity int) int + Test2 func(childComplexity int) int + Test3 func(childComplexity int) int + Test4 func(childComplexity int) int + } + Subscription struct { Updated func(childComplexity int) int InitPayload func(childComplexity int) int @@ -235,6 +243,7 @@ type QueryResolver interface { MapStringInterface(ctx context.Context, in map[string]interface{}) (map[string]interface{}, error) Panics(ctx context.Context) (*Panics, error) DefaultScalar(ctx context.Context, arg string) (string, error) + Slices(ctx context.Context) (*Slices, error) ValidType(ctx context.Context) (*ValidType, error) } type SubscriptionResolver interface { @@ -706,6 +715,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.DefaultScalar(childComplexity, args["arg"].(string)), true + case "Query.Slices": + if e.complexity.Query.Slices == nil { + break + } + + return e.complexity.Query.Slices(childComplexity), true + case "Query.ValidType": if e.complexity.Query.ValidType == nil { break @@ -734,6 +750,34 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Rectangle.Area(childComplexity), true + case "Slices.Test1": + if e.complexity.Slices.Test1 == nil { + break + } + + return e.complexity.Slices.Test1(childComplexity), true + + case "Slices.Test2": + if e.complexity.Slices.Test2 == nil { + break + } + + return e.complexity.Slices.Test2(childComplexity), true + + case "Slices.Test3": + if e.complexity.Slices.Test3 == nil { + break + } + + return e.complexity.Slices.Test3(childComplexity), true + + case "Slices.Test4": + if e.complexity.Slices.Test4 == nil { + break + } + + return e.complexity.Slices.Test4(childComplexity), true + case "Subscription.Updated": if e.complexity.Subscription.Updated == nil { break @@ -1148,6 +1192,17 @@ enum Status { } scalar Time +`}, + &ast.Source{Name: "slices.graphql", Input: `extend type Query { + slices: Slices +} + +type Slices { + test1: [String] + test2: [String!] + test3: [String]! + test4: [String!]! +} `}, &ast.Source{Name: "validtypes.graphql", Input: `extend type Query { validType: ValidType @@ -3291,6 +3346,30 @@ func (ec *executionContext) _Query_defaultScalar(ctx context.Context, field grap return ec.marshalNDefaultScalarImplementation2string(ctx, field.Selections, res) } +func (ec *executionContext) _Query_slices(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Slices(rctx) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Slices) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalOSlices2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐSlices(ctx, field.Selections, res) +} + func (ec *executionContext) _Query_validType(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3442,6 +3521,108 @@ func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.C return ec.marshalOFloat2float64(ctx, field.Selections, res) } +func (ec *executionContext) _Slices_test1(ctx context.Context, field graphql.CollectedField, obj *Slices) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Slices", + Field: field, + Args: nil, + IsMethod: false, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Test1, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalOString2ᚕᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Slices_test2(ctx context.Context, field graphql.CollectedField, obj *Slices) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Slices", + Field: field, + Args: nil, + IsMethod: false, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Test2, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalOString2ᚕstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Slices_test3(ctx context.Context, field graphql.CollectedField, obj *Slices) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Slices", + Field: field, + Args: nil, + IsMethod: false, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Test3, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNString2ᚕᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Slices_test4(ctx context.Context, field graphql.CollectedField, obj *Slices) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Slices", + Field: field, + Args: nil, + IsMethod: false, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Test4, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNString2ᚕstring(ctx, field.Selections, res) +} + func (ec *executionContext) _Subscription_updated(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Field: field, @@ -5810,6 +5991,17 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } return res }) + case "slices": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_slices(ctx, field) + return res + }) case "validType": field := field out.Concurrently(i, func() (res graphql.Marshaler) { @@ -5864,6 +6056,42 @@ func (ec *executionContext) _Rectangle(ctx context.Context, sel ast.SelectionSet return out } +var slicesImplementors = []string{"Slices"} + +func (ec *executionContext) _Slices(ctx context.Context, sel ast.SelectionSet, obj *Slices) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, slicesImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Slices") + case "test1": + out.Values[i] = ec._Slices_test1(ctx, field, obj) + case "test2": + out.Values[i] = ec._Slices_test2(ctx, field, obj) + case "test3": + out.Values[i] = ec._Slices_test3(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "test4": + out.Values[i] = ec._Slices_test4(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + var subscriptionImplementors = []string{"Subscription"} func (ec *executionContext) _Subscription(ctx context.Context, sel ast.SelectionSet) func() graphql.Marshaler { @@ -6484,6 +6712,35 @@ func (ec *executionContext) marshalNString2ᚕstring(ctx context.Context, sel as return ret } +func (ec *executionContext) unmarshalNString2ᚕᚖstring(ctx context.Context, v interface{}) ([]*string, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]*string, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshalOString2ᚖstring(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalNString2ᚕᚖstring(ctx context.Context, sel ast.SelectionSet, v []*string) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalOString2ᚖstring(ctx, sel, v[i]) + } + + return ret +} + func (ec *executionContext) unmarshalNString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil @@ -7026,6 +7283,9 @@ func (ec *executionContext) marshalOOuterObject2githubᚗcomᚋ99designsᚋgqlge } func (ec *executionContext) marshalOOuterObject2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v [][]*OuterObject) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -7063,6 +7323,9 @@ func (ec *executionContext) marshalOOuterObject2ᚕᚕᚖgithubᚗcomᚋ99design } func (ec *executionContext) marshalOOuterObject2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v []*OuterObject) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -7154,6 +7417,9 @@ func (ec *executionContext) marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋco } func (ec *executionContext) marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx context.Context, sel ast.SelectionSet, v []Shape) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -7190,6 +7456,17 @@ func (ec *executionContext) marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } +func (ec *executionContext) marshalOSlices2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐSlices(ctx context.Context, sel ast.SelectionSet, v Slices) graphql.Marshaler { + return ec._Slices(ctx, sel, &v) +} + +func (ec *executionContext) marshalOSlices2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐSlices(ctx context.Context, sel ast.SelectionSet, v *Slices) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Slices(ctx, sel, v) +} + func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } @@ -7198,6 +7475,70 @@ func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.S return graphql.MarshalString(v) } +func (ec *executionContext) unmarshalOString2ᚕstring(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshalNString2string(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalOString2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNString2string(ctx, sel, v[i]) + } + + return ret +} + +func (ec *executionContext) unmarshalOString2ᚕᚖstring(ctx context.Context, v interface{}) ([]*string, error) { + var vSlice []interface{} + if v != nil { + if tmp1, ok := v.([]interface{}); ok { + vSlice = tmp1 + } else { + vSlice = []interface{}{v} + } + } + var err error + res := make([]*string, len(vSlice)) + for i := range vSlice { + res[i], err = ec.unmarshalOString2ᚖstring(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalOString2ᚕᚖstring(ctx context.Context, sel ast.SelectionSet, v []*string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalOString2ᚖstring(ctx, sel, v[i]) + } + + return ret +} + func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil @@ -7286,6 +7627,9 @@ func (ec *executionContext) marshalOValidType2ᚖgithubᚗcomᚋ99designsᚋgqlg } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -7323,6 +7667,9 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -7360,6 +7707,9 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -7412,6 +7762,9 @@ func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋg } func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 diff --git a/codegen/testserver/models-gen.go b/codegen/testserver/models-gen.go index 7e26b2ccdad..b09dcfdf99e 100644 --- a/codegen/testserver/models-gen.go +++ b/codegen/testserver/models-gen.go @@ -48,6 +48,13 @@ type OuterObject struct { Inner InnerObject `json:"inner"` } +type Slices struct { + Test1 []*string `json:"test1"` + Test2 []string `json:"test2"` + Test3 []*string `json:"test3"` + Test4 []string `json:"test4"` +} + type User struct { ID int `json:"id"` Friends []User `json:"friends"` diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index e39b71a3298..11d9ecd27c4 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -125,6 +125,9 @@ func (r *queryResolver) Panics(ctx context.Context) (*Panics, error) { func (r *queryResolver) DefaultScalar(ctx context.Context, arg string) (string, error) { panic("not implemented") } +func (r *queryResolver) Slices(ctx context.Context) (*Slices, error) { + panic("not implemented") +} func (r *queryResolver) ValidType(ctx context.Context) (*ValidType, error) { panic("not implemented") } diff --git a/codegen/testserver/slices.graphql b/codegen/testserver/slices.graphql new file mode 100644 index 00000000000..7f4ca489f88 --- /dev/null +++ b/codegen/testserver/slices.graphql @@ -0,0 +1,10 @@ +extend type Query { + slices: Slices +} + +type Slices { + test1: [String] + test2: [String!] + test3: [String]! + test4: [String!]! +} diff --git a/codegen/testserver/slices_test.go b/codegen/testserver/slices_test.go new file mode 100644 index 00000000000..2516884705c --- /dev/null +++ b/codegen/testserver/slices_test.go @@ -0,0 +1,33 @@ +package testserver + +import ( + "context" + "net/http/httptest" + "testing" + + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/handler" + "github.com/stretchr/testify/require" +) + +func TestSlices(t *testing.T) { + resolvers := &Stub{} + + srv := httptest.NewServer(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolvers}))) + c := client.New(srv.URL) + + t.Run("nulls vs empty slices", func(t *testing.T) { + resolvers.QueryResolver.Slices = func(ctx context.Context) (slices *Slices, e error) { + return &Slices{}, nil + } + + var resp struct { + Slices Slices + } + c.MustPost(`query { slices { test1, test2, test3, test4 }}`, &resp) + require.Nil(t, resp.Slices.Test1) + require.Nil(t, resp.Slices.Test2) + require.NotNil(t, resp.Slices.Test3) + require.NotNil(t, resp.Slices.Test4) + }) +} diff --git a/codegen/testserver/stub.go b/codegen/testserver/stub.go index 183fad3024a..750afc00c0c 100644 --- a/codegen/testserver/stub.go +++ b/codegen/testserver/stub.go @@ -45,6 +45,7 @@ type Stub struct { MapStringInterface func(ctx context.Context, in map[string]interface{}) (map[string]interface{}, error) Panics func(ctx context.Context) (*Panics, error) DefaultScalar func(ctx context.Context, arg string) (string, error) + Slices func(ctx context.Context) (*Slices, error) ValidType func(ctx context.Context) (*ValidType, error) } SubscriptionResolver struct { @@ -170,6 +171,9 @@ func (r *stubQuery) Panics(ctx context.Context) (*Panics, error) { func (r *stubQuery) DefaultScalar(ctx context.Context, arg string) (string, error) { return r.QueryResolver.DefaultScalar(ctx, arg) } +func (r *stubQuery) Slices(ctx context.Context) (*Slices, error) { + return r.QueryResolver.Slices(ctx) +} func (r *stubQuery) ValidType(ctx context.Context) (*ValidType, error) { return r.QueryResolver.ValidType(ctx) } diff --git a/codegen/type.gotpl b/codegen/type.gotpl index 531ee96ad4f..163c95ac40f 100644 --- a/codegen/type.gotpl +++ b/codegen/type.gotpl @@ -65,6 +65,11 @@ {{- if $type.SelfMarshalling }} return v {{- else if $type.IsSlice }} + {{- if not $type.GQL.NonNull }} + if v == nil { + return graphql.Null + } + {{- end }} ret := make(graphql.Array, len(v)) {{- if not $type.IsScalar }} var wg sync.WaitGroup diff --git a/example/chat/generated.go b/example/chat/generated.go index df5706589d2..274d0664b40 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -2341,6 +2341,9 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2378,6 +2381,9 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2415,6 +2421,9 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2467,6 +2476,9 @@ func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋg } func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 diff --git a/example/config/generated.go b/example/config/generated.go index 4a1a8072aa8..67c72801d31 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -2255,6 +2255,9 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2292,6 +2295,9 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2329,6 +2335,9 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2381,6 +2390,9 @@ func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋg } func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index 96ef343f9b2..b848c7eac16 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -2470,6 +2470,9 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast } func (ec *executionContext) marshalOCustomer2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v []Customer) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2507,6 +2510,9 @@ func (ec *executionContext) marshalOCustomer2ᚕgithubᚗcomᚋ99designsᚋgqlge } func (ec *executionContext) marshalOCustomer2ᚕᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v [][]Customer) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2564,6 +2570,9 @@ func (ec *executionContext) unmarshalOInt2ᚕint(ctx context.Context, v interfac } func (ec *executionContext) marshalOInt2ᚕint(ctx context.Context, sel ast.SelectionSet, v []int) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) for i := range v { ret[i] = ec.marshalNInt2int(ctx, sel, v[i]) @@ -2593,6 +2602,9 @@ func (ec *executionContext) unmarshalOInt2ᚕᚕint(ctx context.Context, v inter } func (ec *executionContext) marshalOInt2ᚕᚕint(ctx context.Context, sel ast.SelectionSet, v [][]int) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) for i := range v { ret[i] = ec.marshalOInt2ᚕint(ctx, sel, v[i]) @@ -2602,6 +2614,9 @@ func (ec *executionContext) marshalOInt2ᚕᚕint(ctx context.Context, sel ast.S } func (ec *executionContext) marshalOItem2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐItem(ctx context.Context, sel ast.SelectionSet, v []Item) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2639,6 +2654,9 @@ func (ec *executionContext) marshalOItem2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ } func (ec *executionContext) marshalOOrder2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐOrder(ctx context.Context, sel ast.SelectionSet, v []Order) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2699,6 +2717,9 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2736,6 +2757,9 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2773,6 +2797,9 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2825,6 +2852,9 @@ func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋg } func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 diff --git a/example/scalars/generated.go b/example/scalars/generated.go index a6f1ee720bd..b460f819bc2 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -2469,6 +2469,9 @@ func (ec *executionContext) marshalOUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2506,6 +2509,9 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2543,6 +2549,9 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2595,6 +2604,9 @@ func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋg } func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 diff --git a/example/selection/generated.go b/example/selection/generated.go index 10070f5c4b9..5f1f46c52c3 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -2053,6 +2053,9 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast } func (ec *executionContext) marshalOEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋselectionᚐEvent(ctx context.Context, sel ast.SelectionSet, v []Event) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2118,6 +2121,9 @@ func (ec *executionContext) unmarshalOString2ᚕstring(ctx context.Context, v in } func (ec *executionContext) marshalOString2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) for i := range v { ret[i] = ec.marshalNString2string(ctx, sel, v[i]) @@ -2142,6 +2148,9 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2179,6 +2188,9 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2216,6 +2228,9 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2268,6 +2283,9 @@ func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋg } func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 diff --git a/example/starwars/generated/exec.go b/example/starwars/generated/exec.go index 452da0ea0d3..4a97131ca8c 100644 --- a/example/starwars/generated/exec.go +++ b/example/starwars/generated/exec.go @@ -4224,6 +4224,9 @@ func (ec *executionContext) marshalOCharacter2githubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v []models.Character) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4304,6 +4307,9 @@ func (ec *executionContext) marshalOFloat2float64(ctx context.Context, sel ast.S } func (ec *executionContext) marshalOFriendsEdge2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐFriendsEdge(ctx context.Context, sel ast.SelectionSet, v []models.FriendsEdge) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4437,6 +4443,9 @@ func (ec *executionContext) marshalOStarship2githubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalOStarship2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐStarship(ctx context.Context, sel ast.SelectionSet, v []models.Starship) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4530,6 +4539,9 @@ func (ec *executionContext) marshalOTime2ᚖtimeᚐTime(ctx context.Context, sel } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4567,6 +4579,9 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4604,6 +4619,9 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4656,6 +4674,9 @@ func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋg } func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 diff --git a/example/todo/generated.go b/example/todo/generated.go index 048d26218da..0cc8fc3d47c 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -2311,6 +2311,9 @@ func (ec *executionContext) marshalOTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2348,6 +2351,9 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2385,6 +2391,9 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2437,6 +2446,9 @@ func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋg } func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index a4098e32f7d..bc00d1a2585 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -2311,6 +2311,9 @@ func (ec *executionContext) marshalOTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2348,6 +2351,9 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2385,6 +2391,9 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2437,6 +2446,9 @@ func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋg } func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 diff --git a/graphql/introspection/type.go b/graphql/introspection/type.go index b963aa0e27d..f1228edf62d 100644 --- a/graphql/introspection/type.go +++ b/graphql/introspection/type.go @@ -62,9 +62,9 @@ func (t *Type) Description() string { func (t *Type) Fields(includeDeprecated bool) []Field { if t.def == nil || (t.def.Kind != ast.Object && t.def.Kind != ast.Interface) { - return nil + return []Field{} } - var fields []Field + fields := []Field{} for _, f := range t.def.Fields { if strings.HasPrefix(f.Name, "__") { continue @@ -93,10 +93,10 @@ func (t *Type) Fields(includeDeprecated bool) []Field { func (t *Type) InputFields() []InputValue { if t.def == nil || t.def.Kind != ast.InputObject { - return nil + return []InputValue{} } - var res []InputValue + res := []InputValue{} for _, f := range t.def.Fields { res = append(res, InputValue{ Name: f.Name, @@ -118,10 +118,10 @@ func defaultValue(value *ast.Value) *string { func (t *Type) Interfaces() []Type { if t.def == nil || t.def.Kind != ast.Object { - return nil + return []Type{} } - var res []Type + res := []Type{} for _, intf := range t.def.Interfaces { res = append(res, *WrapTypeFromDef(t.schema, t.schema.Types[intf])) } @@ -131,10 +131,10 @@ func (t *Type) Interfaces() []Type { func (t *Type) PossibleTypes() []Type { if t.def == nil || (t.def.Kind != ast.Interface && t.def.Kind != ast.Union) { - return nil + return []Type{} } - var res []Type + res := []Type{} for _, pt := range t.schema.GetPossibleTypes(t.def) { res = append(res, *WrapTypeFromDef(t.schema, pt)) } @@ -143,10 +143,10 @@ func (t *Type) PossibleTypes() []Type { func (t *Type) EnumValues(includeDeprecated bool) []EnumValue { if t.def == nil || t.def.Kind != ast.Enum { - return nil + return []EnumValue{} } - var res []EnumValue + res := []EnumValue{} for _, val := range t.def.EnumValues { res = append(res, EnumValue{ Name: val.Name, diff --git a/integration/generated.go b/integration/generated.go index 3d1e1ce89c2..6515e384baa 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -2415,6 +2415,9 @@ func (ec *executionContext) unmarshalOBoolean2ᚕbool(ctx context.Context, v int } func (ec *executionContext) marshalOBoolean2ᚕbool(ctx context.Context, sel ast.SelectionSet, v []bool) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) for i := range v { ret[i] = ec.marshalNBoolean2bool(ctx, sel, v[i]) @@ -2467,6 +2470,9 @@ func (ec *executionContext) marshalOElement2githubᚗcomᚋ99designsᚋgqlgenᚋ } func (ec *executionContext) marshalOElement2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx context.Context, sel ast.SelectionSet, v []*models.Element) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2603,6 +2609,9 @@ func (ec *executionContext) marshalOViewer2ᚖgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2640,6 +2649,9 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2677,6 +2689,9 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2729,6 +2744,9 @@ func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋg } func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 From 12cf01aa60fef7be26b6c78ac3139b407ed7a455 Mon Sep 17 00:00:00 2001 From: Cody Ley-Han Date: Wed, 13 Mar 2019 22:09:24 -0700 Subject: [PATCH 136/147] Allow user to supply path to gqlerror --- graphql/context_test.go | 19 +++++++++++++++++++ graphql/error.go | 4 +++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/graphql/context_test.go b/graphql/context_test.go index 14304bcd3b3..85387e930df 100644 --- a/graphql/context_test.go +++ b/graphql/context_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/vektah/gqlparser/ast" + "github.com/vektah/gqlparser/gqlerror" ) func TestRequestContext_GetErrors(t *testing.T) { @@ -33,8 +34,21 @@ func TestRequestContext_GetErrors(t *testing.T) { Parent: root, Index: &index, } + userProvidedPath := &ResolverContext{ + Parent: child, + Field: CollectedField{ + Field: &ast.Field{ + Alias: "works", + }, + }, + } + ctx = WithResolverContext(ctx, child) c.Error(ctx, errors.New("bar")) + c.Error(ctx, &gqlerror.Error{ + Message: "foo3", + Path: append(child.Path(), "works"), + }) specs := []struct { Name string @@ -51,6 +65,11 @@ func TestRequestContext_GetErrors(t *testing.T) { RCtx: child, Messages: []string{"bar"}, }, + { + Name: "with user provided path", + RCtx: userProvidedPath, + Messages: []string{"foo3"}, + }, } for _, spec := range specs { diff --git a/graphql/error.go b/graphql/error.go index 7f161a4306b..af8b4ce4088 100644 --- a/graphql/error.go +++ b/graphql/error.go @@ -14,7 +14,9 @@ type ExtendedError interface { func DefaultErrorPresenter(ctx context.Context, err error) *gqlerror.Error { if gqlerr, ok := err.(*gqlerror.Error); ok { - gqlerr.Path = GetResolverContext(ctx).Path() + if gqlerr.Path == nil { + gqlerr.Path = GetResolverContext(ctx).Path() + } return gqlerr } From c889b3148f631f9e6a9467ee60cf3d21c0333ff8 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Thu, 14 Mar 2019 20:51:58 +1100 Subject: [PATCH 137/147] Handle colliding fields in complexity root gracefully --- codegen/complexity.go | 11 + codegen/data.go | 1 + codegen/generated!.gotpl | 4 +- codegen/testserver/complexity.graphql | 11 + codegen/testserver/complexity_test.go | 46 ++ codegen/testserver/generated.go | 679 +++++++++++++++------ codegen/testserver/gqlgen.yml | 6 + codegen/testserver/models.go | 5 + codegen/testserver/resolver.go | 12 + codegen/testserver/stub.go | 16 + example/chat/generated.go | 38 +- example/config/generated.go | 30 +- example/dataloader/generated.go | 40 +- example/scalars/generated.go | 68 +-- example/selection/generated.go | 44 +- example/starwars/generated/exec.go | 216 +++---- example/todo/generated.go | 30 +- example/type-system-extension/generated.go | 30 +- integration/generated.go | 50 +- 19 files changed, 867 insertions(+), 470 deletions(-) create mode 100644 codegen/complexity.go create mode 100644 codegen/testserver/complexity.graphql create mode 100644 codegen/testserver/complexity_test.go diff --git a/codegen/complexity.go b/codegen/complexity.go new file mode 100644 index 00000000000..66d21a840e5 --- /dev/null +++ b/codegen/complexity.go @@ -0,0 +1,11 @@ +package codegen + +func (o *Object) UniqueFields() map[string]*Field { + m := map[string]*Field{} + + for _, f := range o.Fields { + m[f.GoFieldName] = f + } + + return m +} diff --git a/codegen/data.go b/codegen/data.go index e7b5a92ef5e..f2ea70b4a43 100644 --- a/codegen/data.go +++ b/codegen/data.go @@ -20,6 +20,7 @@ type Data struct { Inputs Objects Interfaces map[string]*Interface ReferencedTypes map[string]*config.TypeReference + ComplexityRoots map[string]*Object QueryRoot *Object MutationRoot *Object diff --git a/codegen/generated!.gotpl b/codegen/generated!.gotpl index 7c8afe436ea..dce8ce977c7 100644 --- a/codegen/generated!.gotpl +++ b/codegen/generated!.gotpl @@ -46,7 +46,7 @@ type ComplexityRoot struct { {{ range $object := .Objects }} {{ if not $object.IsReserved -}} {{ $object.Name|go }} struct { - {{ range $field := $object.Fields -}} + {{ range $field := $object.UniqueFields -}} {{ if not $field.IsReserved -}} {{ $field.GoFieldName }} {{ $field.ComplexitySignature }} {{ end }} @@ -84,7 +84,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in switch typeName + "." + field { {{ range $object := .Objects }} {{ if not $object.IsReserved }} - {{ range $field := $object.Fields }} + {{ range $field := $object.UniqueFields }} {{ if not $field.IsReserved }} case "{{$object.Name}}.{{$field.GoFieldName}}": if e.complexity.{{$object.Name|go}}.{{$field.GoFieldName}} == nil { diff --git a/codegen/testserver/complexity.graphql b/codegen/testserver/complexity.graphql new file mode 100644 index 00000000000..2908586346d --- /dev/null +++ b/codegen/testserver/complexity.graphql @@ -0,0 +1,11 @@ +extend type Query { + overlapping: OverlappingFields +} + +type OverlappingFields { + oneFoo: Int! + twoFoo: Int! + oldFoo: Int! + newFoo: Int! + new_foo: Int! +} diff --git a/codegen/testserver/complexity_test.go b/codegen/testserver/complexity_test.go new file mode 100644 index 00000000000..2457eda8e88 --- /dev/null +++ b/codegen/testserver/complexity_test.go @@ -0,0 +1,46 @@ +package testserver + +import ( + "context" + "net/http/httptest" + "testing" + + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/handler" + "github.com/stretchr/testify/require" +) + +func TestComplexityCollisions(t *testing.T) { + resolvers := &Stub{} + + srv := httptest.NewServer(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolvers}))) + c := client.New(srv.URL) + + resolvers.QueryResolver.Overlapping = func(ctx context.Context) (fields *OverlappingFields, e error) { + return &OverlappingFields{ + Foo: 2, + NewFoo: 3, + }, nil + } + + resolvers.OverlappingFieldsResolver.OldFoo = func(ctx context.Context, obj *OverlappingFields) (i int, e error) { + return obj.Foo, nil + } + + var resp struct { + Overlapping struct { + OneFoo int `json:"oneFoo"` + TwoFoo int `json:"twoFoo"` + OldFoo int `json:"oldFoo"` + NewFoo int `json:"newFoo"` + New_foo int `json:"new_foo"` + } + } + c.MustPost(`query { overlapping { oneFoo, twoFoo, oldFoo, newFoo, new_foo } }`, &resp) + require.Equal(t, 2, resp.Overlapping.OneFoo) + require.Equal(t, 2, resp.Overlapping.TwoFoo) + require.Equal(t, 2, resp.Overlapping.OldFoo) + require.Equal(t, 3, resp.Overlapping.NewFoo) + require.Equal(t, 3, resp.Overlapping.New_foo) + +} diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 7a981ca69f7..99de6ccc5ed 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -40,6 +40,7 @@ type Config struct { type ResolverRoot interface { ForcedResolver() ForcedResolverResolver ModelMethods() ModelMethodsResolver + OverlappingFields() OverlappingFieldsResolver Panics() PanicsResolver Query() QueryResolver Subscription() SubscriptionResolver @@ -64,16 +65,16 @@ type ComplexityRoot struct { } Autobind struct { + IdInt func(childComplexity int) int + IdStr func(childComplexity int) int Int func(childComplexity int) int Int32 func(childComplexity int) int Int64 func(childComplexity int) int - IdStr func(childComplexity int) int - IdInt func(childComplexity int) int } Circle struct { - Radius func(childComplexity int) int Area func(childComplexity int) int + Radius func(childComplexity int) int } EmbeddedDefaultScalar struct { @@ -86,9 +87,9 @@ type ComplexityRoot struct { } Error struct { - ID func(childComplexity int) int ErrorOnNonRequiredField func(childComplexity int) int ErrorOnRequiredField func(childComplexity int) int + ID func(childComplexity int) int NilOnRequiredField func(childComplexity int) int } @@ -114,8 +115,8 @@ type ComplexityRoot struct { } ModelMethods struct { - ResolverField func(childComplexity int) int NoContext func(childComplexity int) int + ResolverField func(childComplexity int) int WithContext func(childComplexity int) int } @@ -123,45 +124,52 @@ type ComplexityRoot struct { Inner func(childComplexity int) int } + OverlappingFields struct { + Foo func(childComplexity int) int + NewFoo func(childComplexity int) int + OldFoo func(childComplexity int) int + } + Panics struct { - FieldScalarMarshal func(childComplexity int) int - FieldFuncMarshal func(childComplexity int, u []MarshalPanic) int ArgUnmarshal func(childComplexity int, u []MarshalPanic) int + FieldFuncMarshal func(childComplexity int, u []MarshalPanic) int + FieldScalarMarshal func(childComplexity int) int } Query struct { - InvalidIdentifier func(childComplexity int) int + Autobind func(childComplexity int) int Collision func(childComplexity int) int - MapInput func(childComplexity int, input map[string]interface{}) int - Recursive func(childComplexity int, input *RecursiveInputSlice) int - NestedInputs func(childComplexity int, input [][]*OuterInput) int - NestedOutputs func(childComplexity int) int - Shapes func(childComplexity int) int - ErrorBubble func(childComplexity int) int - ModelMethods func(childComplexity int) int - Valid func(childComplexity int) int - User func(childComplexity int, id int) int - NullableArg func(childComplexity int, arg *int) int + DefaultScalar func(childComplexity int, arg string) int + DeprecatedField func(childComplexity int) int DirectiveArg func(childComplexity int, arg string) int - DirectiveNullableArg func(childComplexity int, arg *int, arg2 *int) int - DirectiveInputNullable func(childComplexity int, arg *InputDirectives) int DirectiveInput func(childComplexity int, arg InputDirectives) int + DirectiveInputNullable func(childComplexity int, arg *InputDirectives) int DirectiveInputType func(childComplexity int, arg InnerInput) int + DirectiveNullableArg func(childComplexity int, arg *int, arg2 *int) int + ErrorBubble func(childComplexity int) int InputSlice func(childComplexity int, arg []string) int - ShapeUnion func(childComplexity int) int - Autobind func(childComplexity int) int - DeprecatedField func(childComplexity int) int + InvalidIdentifier func(childComplexity int) int + MapInput func(childComplexity int, input map[string]interface{}) int MapStringInterface func(childComplexity int, in map[string]interface{}) int + ModelMethods func(childComplexity int) int + NestedInputs func(childComplexity int, input [][]*OuterInput) int + NestedOutputs func(childComplexity int) int + NullableArg func(childComplexity int, arg *int) int + Overlapping func(childComplexity int) int Panics func(childComplexity int) int - DefaultScalar func(childComplexity int, arg string) int + Recursive func(childComplexity int, input *RecursiveInputSlice) int + ShapeUnion func(childComplexity int) int + Shapes func(childComplexity int) int Slices func(childComplexity int) int + User func(childComplexity int, id int) int + Valid func(childComplexity int) int ValidType func(childComplexity int) int } Rectangle struct { + Area func(childComplexity int) int Length func(childComplexity int) int Width func(childComplexity int) int - Area func(childComplexity int) int } Slices struct { @@ -172,22 +180,22 @@ type ComplexityRoot struct { } Subscription struct { - Updated func(childComplexity int) int InitPayload func(childComplexity int) int + Updated func(childComplexity int) int } User struct { - ID func(childComplexity int) int - Friends func(childComplexity int) int Created func(childComplexity int) int + Friends func(childComplexity int) int + ID func(childComplexity int) int Updated func(childComplexity int) int } ValidType struct { DifferentCase func(childComplexity int) int DifferentCaseOld func(childComplexity int) int - ValidInputKeywords func(childComplexity int, input *ValidInput) int ValidArgs func(childComplexity int, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string, _Arg string) int + ValidInputKeywords func(childComplexity int, input *ValidInput) int } XXIt struct { @@ -213,6 +221,9 @@ type ForcedResolverResolver interface { type ModelMethodsResolver interface { ResolverField(ctx context.Context, obj *ModelMethods) (bool, error) } +type OverlappingFieldsResolver interface { + OldFoo(ctx context.Context, obj *OverlappingFields) (int, error) +} type PanicsResolver interface { FieldScalarMarshal(ctx context.Context, obj *Panics) ([]MarshalPanic, error) @@ -240,6 +251,7 @@ type QueryResolver interface { ShapeUnion(ctx context.Context) (ShapeUnion, error) Autobind(ctx context.Context) (*Autobind, error) DeprecatedField(ctx context.Context) (string, error) + Overlapping(ctx context.Context) (*OverlappingFields, error) MapStringInterface(ctx context.Context, in map[string]interface{}) (map[string]interface{}, error) Panics(ctx context.Context) (*Panics, error) DefaultScalar(ctx context.Context, arg string) (string, error) @@ -283,6 +295,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.AbIt.ID(childComplexity), true + case "Autobind.IdInt": + if e.complexity.Autobind.IdInt == nil { + break + } + + return e.complexity.Autobind.IdInt(childComplexity), true + + case "Autobind.IdStr": + if e.complexity.Autobind.IdStr == nil { + break + } + + return e.complexity.Autobind.IdStr(childComplexity), true + case "Autobind.Int": if e.complexity.Autobind.Int == nil { break @@ -304,19 +330,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Autobind.Int64(childComplexity), true - case "Autobind.IdStr": - if e.complexity.Autobind.IdStr == nil { - break - } - - return e.complexity.Autobind.IdStr(childComplexity), true - - case "Autobind.IdInt": - if e.complexity.Autobind.IdInt == nil { + case "Circle.Area": + if e.complexity.Circle.Area == nil { break } - return e.complexity.Autobind.IdInt(childComplexity), true + return e.complexity.Circle.Area(childComplexity), true case "Circle.Radius": if e.complexity.Circle.Radius == nil { @@ -325,13 +344,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Circle.Radius(childComplexity), true - case "Circle.Area": - if e.complexity.Circle.Area == nil { - break - } - - return e.complexity.Circle.Area(childComplexity), true - case "EmbeddedDefaultScalar.Value": if e.complexity.EmbeddedDefaultScalar.Value == nil { break @@ -353,13 +365,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.EmbeddedPointer.Title(childComplexity), true - case "Error.ID": - if e.complexity.Error.ID == nil { - break - } - - return e.complexity.Error.ID(childComplexity), true - case "Error.ErrorOnNonRequiredField": if e.complexity.Error.ErrorOnNonRequiredField == nil { break @@ -374,6 +379,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Error.ErrorOnRequiredField(childComplexity), true + case "Error.ID": + if e.complexity.Error.ID == nil { + break + } + + return e.complexity.Error.ID(childComplexity), true + case "Error.NilOnRequiredField": if e.complexity.Error.NilOnRequiredField == nil { break @@ -423,19 +435,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.MapStringInterfaceType.B(childComplexity), true - case "ModelMethods.ResolverField": - if e.complexity.ModelMethods.ResolverField == nil { + case "ModelMethods.NoContext": + if e.complexity.ModelMethods.NoContext == nil { break } - return e.complexity.ModelMethods.ResolverField(childComplexity), true + return e.complexity.ModelMethods.NoContext(childComplexity), true - case "ModelMethods.NoContext": - if e.complexity.ModelMethods.NoContext == nil { + case "ModelMethods.ResolverField": + if e.complexity.ModelMethods.ResolverField == nil { break } - return e.complexity.ModelMethods.NoContext(childComplexity), true + return e.complexity.ModelMethods.ResolverField(childComplexity), true case "ModelMethods.WithContext": if e.complexity.ModelMethods.WithContext == nil { @@ -451,24 +463,26 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.OuterObject.Inner(childComplexity), true - case "Panics.FieldScalarMarshal": - if e.complexity.Panics.FieldScalarMarshal == nil { + case "OverlappingFields.Foo": + if e.complexity.OverlappingFields.Foo == nil { break } - return e.complexity.Panics.FieldScalarMarshal(childComplexity), true + return e.complexity.OverlappingFields.Foo(childComplexity), true - case "Panics.FieldFuncMarshal": - if e.complexity.Panics.FieldFuncMarshal == nil { + case "OverlappingFields.NewFoo": + if e.complexity.OverlappingFields.NewFoo == nil { break } - args, err := ec.field_Panics_fieldFuncMarshal_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + return e.complexity.OverlappingFields.NewFoo(childComplexity), true + + case "OverlappingFields.OldFoo": + if e.complexity.OverlappingFields.OldFoo == nil { + break } - return e.complexity.Panics.FieldFuncMarshal(childComplexity, args["u"].([]MarshalPanic)), true + return e.complexity.OverlappingFields.OldFoo(childComplexity), true case "Panics.ArgUnmarshal": if e.complexity.Panics.ArgUnmarshal == nil { @@ -482,126 +496,105 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Panics.ArgUnmarshal(childComplexity, args["u"].([]MarshalPanic)), true - case "Query.InvalidIdentifier": - if e.complexity.Query.InvalidIdentifier == nil { - break - } - - return e.complexity.Query.InvalidIdentifier(childComplexity), true - - case "Query.Collision": - if e.complexity.Query.Collision == nil { - break - } - - return e.complexity.Query.Collision(childComplexity), true - - case "Query.MapInput": - if e.complexity.Query.MapInput == nil { + case "Panics.FieldFuncMarshal": + if e.complexity.Panics.FieldFuncMarshal == nil { break } - args, err := ec.field_Query_mapInput_args(context.TODO(), rawArgs) + args, err := ec.field_Panics_fieldFuncMarshal_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.MapInput(childComplexity, args["input"].(map[string]interface{})), true + return e.complexity.Panics.FieldFuncMarshal(childComplexity, args["u"].([]MarshalPanic)), true - case "Query.Recursive": - if e.complexity.Query.Recursive == nil { + case "Panics.FieldScalarMarshal": + if e.complexity.Panics.FieldScalarMarshal == nil { break } - args, err := ec.field_Query_recursive_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.Recursive(childComplexity, args["input"].(*RecursiveInputSlice)), true + return e.complexity.Panics.FieldScalarMarshal(childComplexity), true - case "Query.NestedInputs": - if e.complexity.Query.NestedInputs == nil { + case "Query.Autobind": + if e.complexity.Query.Autobind == nil { break } - args, err := ec.field_Query_nestedInputs_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.NestedInputs(childComplexity, args["input"].([][]*OuterInput)), true + return e.complexity.Query.Autobind(childComplexity), true - case "Query.NestedOutputs": - if e.complexity.Query.NestedOutputs == nil { + case "Query.Collision": + if e.complexity.Query.Collision == nil { break } - return e.complexity.Query.NestedOutputs(childComplexity), true + return e.complexity.Query.Collision(childComplexity), true - case "Query.Shapes": - if e.complexity.Query.Shapes == nil { + case "Query.DefaultScalar": + if e.complexity.Query.DefaultScalar == nil { break } - return e.complexity.Query.Shapes(childComplexity), true - - case "Query.ErrorBubble": - if e.complexity.Query.ErrorBubble == nil { - break + args, err := ec.field_Query_defaultScalar_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - return e.complexity.Query.ErrorBubble(childComplexity), true + return e.complexity.Query.DefaultScalar(childComplexity, args["arg"].(string)), true - case "Query.ModelMethods": - if e.complexity.Query.ModelMethods == nil { + case "Query.DeprecatedField": + if e.complexity.Query.DeprecatedField == nil { break } - return e.complexity.Query.ModelMethods(childComplexity), true + return e.complexity.Query.DeprecatedField(childComplexity), true - case "Query.Valid": - if e.complexity.Query.Valid == nil { + case "Query.DirectiveArg": + if e.complexity.Query.DirectiveArg == nil { break } - return e.complexity.Query.Valid(childComplexity), true + args, err := ec.field_Query_directiveArg_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } - case "Query.User": - if e.complexity.Query.User == nil { + return e.complexity.Query.DirectiveArg(childComplexity, args["arg"].(string)), true + + case "Query.DirectiveInput": + if e.complexity.Query.DirectiveInput == nil { break } - args, err := ec.field_Query_user_args(context.TODO(), rawArgs) + args, err := ec.field_Query_directiveInput_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.User(childComplexity, args["id"].(int)), true + return e.complexity.Query.DirectiveInput(childComplexity, args["arg"].(InputDirectives)), true - case "Query.NullableArg": - if e.complexity.Query.NullableArg == nil { + case "Query.DirectiveInputNullable": + if e.complexity.Query.DirectiveInputNullable == nil { break } - args, err := ec.field_Query_nullableArg_args(context.TODO(), rawArgs) + args, err := ec.field_Query_directiveInputNullable_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.NullableArg(childComplexity, args["arg"].(*int)), true + return e.complexity.Query.DirectiveInputNullable(childComplexity, args["arg"].(*InputDirectives)), true - case "Query.DirectiveArg": - if e.complexity.Query.DirectiveArg == nil { + case "Query.DirectiveInputType": + if e.complexity.Query.DirectiveInputType == nil { break } - args, err := ec.field_Query_directiveArg_args(context.TODO(), rawArgs) + args, err := ec.field_Query_directiveInputType_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.DirectiveArg(childComplexity, args["arg"].(string)), true + return e.complexity.Query.DirectiveInputType(childComplexity, args["arg"].(InnerInput)), true case "Query.DirectiveNullableArg": if e.complexity.Query.DirectiveNullableArg == nil { @@ -615,86 +608,100 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.DirectiveNullableArg(childComplexity, args["arg"].(*int), args["arg2"].(*int)), true - case "Query.DirectiveInputNullable": - if e.complexity.Query.DirectiveInputNullable == nil { + case "Query.ErrorBubble": + if e.complexity.Query.ErrorBubble == nil { break } - args, err := ec.field_Query_directiveInputNullable_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.DirectiveInputNullable(childComplexity, args["arg"].(*InputDirectives)), true + return e.complexity.Query.ErrorBubble(childComplexity), true - case "Query.DirectiveInput": - if e.complexity.Query.DirectiveInput == nil { + case "Query.InputSlice": + if e.complexity.Query.InputSlice == nil { break } - args, err := ec.field_Query_directiveInput_args(context.TODO(), rawArgs) + args, err := ec.field_Query_inputSlice_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.DirectiveInput(childComplexity, args["arg"].(InputDirectives)), true + return e.complexity.Query.InputSlice(childComplexity, args["arg"].([]string)), true - case "Query.DirectiveInputType": - if e.complexity.Query.DirectiveInputType == nil { + case "Query.InvalidIdentifier": + if e.complexity.Query.InvalidIdentifier == nil { break } - args, err := ec.field_Query_directiveInputType_args(context.TODO(), rawArgs) + return e.complexity.Query.InvalidIdentifier(childComplexity), true + + case "Query.MapInput": + if e.complexity.Query.MapInput == nil { + break + } + + args, err := ec.field_Query_mapInput_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.DirectiveInputType(childComplexity, args["arg"].(InnerInput)), true + return e.complexity.Query.MapInput(childComplexity, args["input"].(map[string]interface{})), true - case "Query.InputSlice": - if e.complexity.Query.InputSlice == nil { + case "Query.MapStringInterface": + if e.complexity.Query.MapStringInterface == nil { break } - args, err := ec.field_Query_inputSlice_args(context.TODO(), rawArgs) + args, err := ec.field_Query_mapStringInterface_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.InputSlice(childComplexity, args["arg"].([]string)), true + return e.complexity.Query.MapStringInterface(childComplexity, args["in"].(map[string]interface{})), true - case "Query.ShapeUnion": - if e.complexity.Query.ShapeUnion == nil { + case "Query.ModelMethods": + if e.complexity.Query.ModelMethods == nil { break } - return e.complexity.Query.ShapeUnion(childComplexity), true + return e.complexity.Query.ModelMethods(childComplexity), true - case "Query.Autobind": - if e.complexity.Query.Autobind == nil { + case "Query.NestedInputs": + if e.complexity.Query.NestedInputs == nil { break } - return e.complexity.Query.Autobind(childComplexity), true + args, err := ec.field_Query_nestedInputs_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } - case "Query.DeprecatedField": - if e.complexity.Query.DeprecatedField == nil { + return e.complexity.Query.NestedInputs(childComplexity, args["input"].([][]*OuterInput)), true + + case "Query.NestedOutputs": + if e.complexity.Query.NestedOutputs == nil { break } - return e.complexity.Query.DeprecatedField(childComplexity), true + return e.complexity.Query.NestedOutputs(childComplexity), true - case "Query.MapStringInterface": - if e.complexity.Query.MapStringInterface == nil { + case "Query.NullableArg": + if e.complexity.Query.NullableArg == nil { break } - args, err := ec.field_Query_mapStringInterface_args(context.TODO(), rawArgs) + args, err := ec.field_Query_nullableArg_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.MapStringInterface(childComplexity, args["in"].(map[string]interface{})), true + return e.complexity.Query.NullableArg(childComplexity, args["arg"].(*int)), true + + case "Query.Overlapping": + if e.complexity.Query.Overlapping == nil { + break + } + + return e.complexity.Query.Overlapping(childComplexity), true case "Query.Panics": if e.complexity.Query.Panics == nil { @@ -703,17 +710,31 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Panics(childComplexity), true - case "Query.DefaultScalar": - if e.complexity.Query.DefaultScalar == nil { + case "Query.Recursive": + if e.complexity.Query.Recursive == nil { break } - args, err := ec.field_Query_defaultScalar_args(context.TODO(), rawArgs) + args, err := ec.field_Query_recursive_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.DefaultScalar(childComplexity, args["arg"].(string)), true + return e.complexity.Query.Recursive(childComplexity, args["input"].(*RecursiveInputSlice)), true + + case "Query.ShapeUnion": + if e.complexity.Query.ShapeUnion == nil { + break + } + + return e.complexity.Query.ShapeUnion(childComplexity), true + + case "Query.Shapes": + if e.complexity.Query.Shapes == nil { + break + } + + return e.complexity.Query.Shapes(childComplexity), true case "Query.Slices": if e.complexity.Query.Slices == nil { @@ -722,6 +743,25 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Slices(childComplexity), true + case "Query.User": + if e.complexity.Query.User == nil { + break + } + + args, err := ec.field_Query_user_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.User(childComplexity, args["id"].(int)), true + + case "Query.Valid": + if e.complexity.Query.Valid == nil { + break + } + + return e.complexity.Query.Valid(childComplexity), true + case "Query.ValidType": if e.complexity.Query.ValidType == nil { break @@ -729,6 +769,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.ValidType(childComplexity), true + case "Rectangle.Area": + if e.complexity.Rectangle.Area == nil { + break + } + + return e.complexity.Rectangle.Area(childComplexity), true + case "Rectangle.Length": if e.complexity.Rectangle.Length == nil { break @@ -743,13 +790,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Rectangle.Width(childComplexity), true - case "Rectangle.Area": - if e.complexity.Rectangle.Area == nil { - break - } - - return e.complexity.Rectangle.Area(childComplexity), true - case "Slices.Test1": if e.complexity.Slices.Test1 == nil { break @@ -778,26 +818,26 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Slices.Test4(childComplexity), true - case "Subscription.Updated": - if e.complexity.Subscription.Updated == nil { + case "Subscription.InitPayload": + if e.complexity.Subscription.InitPayload == nil { break } - return e.complexity.Subscription.Updated(childComplexity), true + return e.complexity.Subscription.InitPayload(childComplexity), true - case "Subscription.InitPayload": - if e.complexity.Subscription.InitPayload == nil { + case "Subscription.Updated": + if e.complexity.Subscription.Updated == nil { break } - return e.complexity.Subscription.InitPayload(childComplexity), true + return e.complexity.Subscription.Updated(childComplexity), true - case "User.ID": - if e.complexity.User.ID == nil { + case "User.Created": + if e.complexity.User.Created == nil { break } - return e.complexity.User.ID(childComplexity), true + return e.complexity.User.Created(childComplexity), true case "User.Friends": if e.complexity.User.Friends == nil { @@ -806,12 +846,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.User.Friends(childComplexity), true - case "User.Created": - if e.complexity.User.Created == nil { + case "User.ID": + if e.complexity.User.ID == nil { break } - return e.complexity.User.Created(childComplexity), true + return e.complexity.User.ID(childComplexity), true case "User.Updated": if e.complexity.User.Updated == nil { @@ -834,29 +874,29 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.ValidType.DifferentCaseOld(childComplexity), true - case "ValidType.ValidInputKeywords": - if e.complexity.ValidType.ValidInputKeywords == nil { + case "ValidType.ValidArgs": + if e.complexity.ValidType.ValidArgs == nil { break } - args, err := ec.field_ValidType_validInputKeywords_args(context.TODO(), rawArgs) + args, err := ec.field_ValidType_validArgs_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.ValidType.ValidInputKeywords(childComplexity, args["input"].(*ValidInput)), true + return e.complexity.ValidType.ValidArgs(childComplexity, 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), args["_"].(string)), true - case "ValidType.ValidArgs": - if e.complexity.ValidType.ValidArgs == nil { + case "ValidType.ValidInputKeywords": + if e.complexity.ValidType.ValidInputKeywords == nil { break } - args, err := ec.field_ValidType_validArgs_args(context.TODO(), rawArgs) + args, err := ec.field_ValidType_validInputKeywords_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.ValidType.ValidArgs(childComplexity, 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), args["_"].(string)), true + return e.complexity.ValidType.ValidInputKeywords(childComplexity, args["input"].(*ValidInput)), true case "XXIt.ID": if e.complexity.XXIt.ID == nil { @@ -1017,6 +1057,18 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er } var parsedSchema = gqlparser.MustLoadSchema( + &ast.Source{Name: "complexity.graphql", Input: `extend type Query { + overlapping: OverlappingFields +} + +type OverlappingFields { + oneFoo: Int! + twoFoo: Int! + oldFoo: Int! + newFoo: Int! + new_foo: Int! +} +`}, &ast.Source{Name: "maps.graphql", Input: `extend type Query { mapStringInterface(in: MapStringInterfaceInput): MapStringInterfaceType } @@ -2566,6 +2618,141 @@ func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphq return ec.marshalNInnerObject2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerObject(ctx, field.Selections, res) } +func (ec *executionContext) _OverlappingFields_oneFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "OverlappingFields", + Field: field, + Args: nil, + IsMethod: false, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Foo, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) _OverlappingFields_twoFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "OverlappingFields", + Field: field, + Args: nil, + IsMethod: false, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Foo, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) _OverlappingFields_oldFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "OverlappingFields", + Field: field, + Args: nil, + IsMethod: true, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.OverlappingFields().OldFoo(rctx, obj) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) _OverlappingFields_newFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "OverlappingFields", + Field: field, + Args: nil, + IsMethod: false, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.NewFoo, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) _OverlappingFields_new_foo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "OverlappingFields", + Field: field, + Args: nil, + IsMethod: false, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.NewFoo, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNInt2int(ctx, field.Selections, res) +} + func (ec *executionContext) _Panics_fieldScalarMarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3257,6 +3444,30 @@ func (ec *executionContext) _Query_deprecatedField(ctx context.Context, field gr return ec.marshalNString2string(ctx, field.Selections, res) } +func (ec *executionContext) _Query_overlapping(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Overlapping(rctx) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*OverlappingFields) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalOOverlappingFields2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOverlappingFields(ctx, field.Selections, res) +} + func (ec *executionContext) _Query_mapStringInterface(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -5630,6 +5841,62 @@ func (ec *executionContext) _OuterObject(ctx context.Context, sel ast.SelectionS return out } +var overlappingFieldsImplementors = []string{"OverlappingFields"} + +func (ec *executionContext) _OverlappingFields(ctx context.Context, sel ast.SelectionSet, obj *OverlappingFields) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, overlappingFieldsImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("OverlappingFields") + case "oneFoo": + out.Values[i] = ec._OverlappingFields_oneFoo(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "twoFoo": + out.Values[i] = ec._OverlappingFields_twoFoo(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "oldFoo": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._OverlappingFields_oldFoo(ctx, field, obj) + if res == graphql.Null { + invalid = true + } + return res + }) + case "newFoo": + out.Values[i] = ec._OverlappingFields_newFoo(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + case "new_foo": + out.Values[i] = ec._OverlappingFields_new_foo(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + var panicsImplementors = []string{"Panics"} func (ec *executionContext) _Panics(ctx context.Context, sel ast.SelectionSet, obj *Panics) graphql.Marshaler { @@ -5955,6 +6222,17 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } return res }) + case "overlapping": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_overlapping(ctx, field) + return res + }) case "mapStringInterface": field := field out.Concurrently(i, func() (res graphql.Marshaler) { @@ -7369,6 +7647,17 @@ func (ec *executionContext) marshalOOuterObject2ᚖgithubᚗcomᚋ99designsᚋgq return ec._OuterObject(ctx, sel, v) } +func (ec *executionContext) marshalOOverlappingFields2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOverlappingFields(ctx context.Context, sel ast.SelectionSet, v OverlappingFields) graphql.Marshaler { + return ec._OverlappingFields(ctx, sel, &v) +} + +func (ec *executionContext) marshalOOverlappingFields2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOverlappingFields(ctx context.Context, sel ast.SelectionSet, v *OverlappingFields) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._OverlappingFields(ctx, sel, v) +} + func (ec *executionContext) marshalOPanics2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPanics(ctx context.Context, sel ast.SelectionSet, v Panics) graphql.Marshaler { return ec._Panics(ctx, sel, &v) } diff --git a/codegen/testserver/gqlgen.yml b/codegen/testserver/gqlgen.yml index 0e0c0bbe251..9979c5efc9d 100644 --- a/codegen/testserver/gqlgen.yml +++ b/codegen/testserver/gqlgen.yml @@ -60,3 +60,9 @@ models: model: "map[string]interface{}" MapStringInterfaceType: model: "map[string]interface{}" + OverlappingFields: + model: "github.com/99designs/gqlgen/codegen/testserver.OverlappingFields" + fields: + oneFoo: { fieldName: foo } + twoFoo: { fieldName: foo } + oldFoo: { fieldName: foo, resolver: true } diff --git a/codegen/testserver/models.go b/codegen/testserver/models.go index 690b4d31d82..20af8947688 100644 --- a/codegen/testserver/models.go +++ b/codegen/testserver/models.go @@ -71,3 +71,8 @@ type Autobind struct { IdStr string IdInt int } + +type OverlappingFields struct { + Foo int + NewFoo int +} diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index 11d9ecd27c4..f42787e6ef8 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -17,6 +17,9 @@ func (r *Resolver) ForcedResolver() ForcedResolverResolver { func (r *Resolver) ModelMethods() ModelMethodsResolver { return &modelMethodsResolver{r} } +func (r *Resolver) OverlappingFields() OverlappingFieldsResolver { + return &overlappingFieldsResolver{r} +} func (r *Resolver) Panics() PanicsResolver { return &panicsResolver{r} } @@ -42,6 +45,12 @@ func (r *modelMethodsResolver) ResolverField(ctx context.Context, obj *ModelMeth panic("not implemented") } +type overlappingFieldsResolver struct{ *Resolver } + +func (r *overlappingFieldsResolver) OldFoo(ctx context.Context, obj *OverlappingFields) (int, error) { + panic("not implemented") +} + type panicsResolver struct{ *Resolver } func (r *panicsResolver) FieldScalarMarshal(ctx context.Context, obj *Panics) ([]MarshalPanic, error) { @@ -116,6 +125,9 @@ func (r *queryResolver) Autobind(ctx context.Context) (*Autobind, error) { func (r *queryResolver) DeprecatedField(ctx context.Context) (string, error) { panic("not implemented") } +func (r *queryResolver) Overlapping(ctx context.Context) (*OverlappingFields, error) { + panic("not implemented") +} func (r *queryResolver) MapStringInterface(ctx context.Context, in map[string]interface{}) (map[string]interface{}, error) { panic("not implemented") } diff --git a/codegen/testserver/stub.go b/codegen/testserver/stub.go index 750afc00c0c..3965ce4c202 100644 --- a/codegen/testserver/stub.go +++ b/codegen/testserver/stub.go @@ -16,6 +16,9 @@ type Stub struct { ModelMethodsResolver struct { ResolverField func(ctx context.Context, obj *ModelMethods) (bool, error) } + OverlappingFieldsResolver struct { + OldFoo func(ctx context.Context, obj *OverlappingFields) (int, error) + } PanicsResolver struct { FieldScalarMarshal func(ctx context.Context, obj *Panics) ([]MarshalPanic, error) ArgUnmarshal func(ctx context.Context, obj *Panics, u []MarshalPanic) (bool, error) @@ -42,6 +45,7 @@ type Stub struct { ShapeUnion func(ctx context.Context) (ShapeUnion, error) Autobind func(ctx context.Context) (*Autobind, error) DeprecatedField func(ctx context.Context) (string, error) + Overlapping func(ctx context.Context) (*OverlappingFields, error) MapStringInterface func(ctx context.Context, in map[string]interface{}) (map[string]interface{}, error) Panics func(ctx context.Context) (*Panics, error) DefaultScalar func(ctx context.Context, arg string) (string, error) @@ -63,6 +67,9 @@ func (r *Stub) ForcedResolver() ForcedResolverResolver { func (r *Stub) ModelMethods() ModelMethodsResolver { return &stubModelMethods{r} } +func (r *Stub) OverlappingFields() OverlappingFieldsResolver { + return &stubOverlappingFields{r} +} func (r *Stub) Panics() PanicsResolver { return &stubPanics{r} } @@ -88,6 +95,12 @@ func (r *stubModelMethods) ResolverField(ctx context.Context, obj *ModelMethods) return r.ModelMethodsResolver.ResolverField(ctx, obj) } +type stubOverlappingFields struct{ *Stub } + +func (r *stubOverlappingFields) OldFoo(ctx context.Context, obj *OverlappingFields) (int, error) { + return r.OverlappingFieldsResolver.OldFoo(ctx, obj) +} + type stubPanics struct{ *Stub } func (r *stubPanics) FieldScalarMarshal(ctx context.Context, obj *Panics) ([]MarshalPanic, error) { @@ -162,6 +175,9 @@ func (r *stubQuery) Autobind(ctx context.Context) (*Autobind, error) { func (r *stubQuery) DeprecatedField(ctx context.Context) (string, error) { return r.QueryResolver.DeprecatedField(ctx) } +func (r *stubQuery) Overlapping(ctx context.Context) (*OverlappingFields, error) { + return r.QueryResolver.Overlapping(ctx) +} func (r *stubQuery) MapStringInterface(ctx context.Context, in map[string]interface{}) (map[string]interface{}, error) { return r.QueryResolver.MapStringInterface(ctx, in) } diff --git a/example/chat/generated.go b/example/chat/generated.go index 274d0664b40..9081ed4439b 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -45,15 +45,15 @@ type DirectiveRoot struct { type ComplexityRoot struct { Chatroom struct { - Name func(childComplexity int) int Messages func(childComplexity int) int + Name func(childComplexity int) int } Message struct { + CreatedAt func(childComplexity int) int + CreatedBy func(childComplexity int) int ID func(childComplexity int) int Text func(childComplexity int) int - CreatedBy func(childComplexity int) int - CreatedAt func(childComplexity int) int } Mutation struct { @@ -94,13 +94,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { - case "Chatroom.Name": - if e.complexity.Chatroom.Name == nil { - break - } - - return e.complexity.Chatroom.Name(childComplexity), true - case "Chatroom.Messages": if e.complexity.Chatroom.Messages == nil { break @@ -108,19 +101,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Chatroom.Messages(childComplexity), true - case "Message.ID": - if e.complexity.Message.ID == nil { + case "Chatroom.Name": + if e.complexity.Chatroom.Name == nil { break } - return e.complexity.Message.ID(childComplexity), true + return e.complexity.Chatroom.Name(childComplexity), true - case "Message.Text": - if e.complexity.Message.Text == nil { + case "Message.CreatedAt": + if e.complexity.Message.CreatedAt == nil { break } - return e.complexity.Message.Text(childComplexity), true + return e.complexity.Message.CreatedAt(childComplexity), true case "Message.CreatedBy": if e.complexity.Message.CreatedBy == nil { @@ -129,12 +122,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Message.CreatedBy(childComplexity), true - case "Message.CreatedAt": - if e.complexity.Message.CreatedAt == nil { + case "Message.ID": + if e.complexity.Message.ID == nil { break } - return e.complexity.Message.CreatedAt(childComplexity), true + return e.complexity.Message.ID(childComplexity), true + + case "Message.Text": + if e.complexity.Message.Text == nil { + break + } + + return e.complexity.Message.Text(childComplexity), true case "Mutation.Post": if e.complexity.Mutation.Post == nil { diff --git a/example/config/generated.go b/example/config/generated.go index 67c72801d31..c95c8f1a063 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -51,16 +51,16 @@ type ComplexityRoot struct { } Todo struct { - ID func(childComplexity int) int DatabaseID func(childComplexity int) int Description func(childComplexity int) int Done func(childComplexity int) int + ID func(childComplexity int) int User func(childComplexity int) int } User struct { - ID func(childComplexity int) int FullName func(childComplexity int) int + ID func(childComplexity int) int } } @@ -108,13 +108,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Todos(childComplexity), true - case "Todo.ID": - if e.complexity.Todo.ID == nil { - break - } - - return e.complexity.Todo.ID(childComplexity), true - case "Todo.DatabaseID": if e.complexity.Todo.DatabaseID == nil { break @@ -136,19 +129,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Todo.Done(childComplexity), true - case "Todo.User": - if e.complexity.Todo.User == nil { + case "Todo.ID": + if e.complexity.Todo.ID == nil { break } - return e.complexity.Todo.User(childComplexity), true + return e.complexity.Todo.ID(childComplexity), true - case "User.ID": - if e.complexity.User.ID == nil { + case "Todo.User": + if e.complexity.Todo.User == nil { break } - return e.complexity.User.ID(childComplexity), true + return e.complexity.Todo.User(childComplexity), true case "User.FullName": if e.complexity.User.FullName == nil { @@ -157,6 +150,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.User.FullName(childComplexity), true + case "User.ID": + if e.complexity.User.ID == nil { + break + } + + return e.complexity.User.ID(childComplexity), true + } return 0, false } diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index b848c7eac16..ab15069c1a6 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -44,15 +44,15 @@ type DirectiveRoot struct { type ComplexityRoot struct { Address struct { + Country func(childComplexity int) int ID func(childComplexity int) int Street func(childComplexity int) int - Country func(childComplexity int) int } Customer struct { + Address func(childComplexity int) int ID func(childComplexity int) int Name func(childComplexity int) int - Address func(childComplexity int) int Orders func(childComplexity int) int } @@ -61,9 +61,9 @@ type ComplexityRoot struct { } Order struct { - ID func(childComplexity int) int - Date func(childComplexity int) int Amount func(childComplexity int) int + Date func(childComplexity int) int + ID func(childComplexity int) int Items func(childComplexity int) int } @@ -102,6 +102,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { + case "Address.Country": + if e.complexity.Address.Country == nil { + break + } + + return e.complexity.Address.Country(childComplexity), true + case "Address.ID": if e.complexity.Address.ID == nil { break @@ -116,12 +123,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Address.Street(childComplexity), true - case "Address.Country": - if e.complexity.Address.Country == nil { + case "Customer.Address": + if e.complexity.Customer.Address == nil { break } - return e.complexity.Address.Country(childComplexity), true + return e.complexity.Customer.Address(childComplexity), true case "Customer.ID": if e.complexity.Customer.ID == nil { @@ -137,13 +144,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Customer.Name(childComplexity), true - case "Customer.Address": - if e.complexity.Customer.Address == nil { - break - } - - return e.complexity.Customer.Address(childComplexity), true - case "Customer.Orders": if e.complexity.Customer.Orders == nil { break @@ -158,12 +158,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Item.Name(childComplexity), true - case "Order.ID": - if e.complexity.Order.ID == nil { + case "Order.Amount": + if e.complexity.Order.Amount == nil { break } - return e.complexity.Order.ID(childComplexity), true + return e.complexity.Order.Amount(childComplexity), true case "Order.Date": if e.complexity.Order.Date == nil { @@ -172,12 +172,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Order.Date(childComplexity), true - case "Order.Amount": - if e.complexity.Order.Amount == nil { + case "Order.ID": + if e.complexity.Order.ID == nil { break } - return e.complexity.Order.Amount(childComplexity), true + return e.complexity.Order.ID(childComplexity), true case "Order.Items": if e.complexity.Order.Items == nil { diff --git a/example/scalars/generated.go b/example/scalars/generated.go index b460f819bc2..e611828ae3e 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -50,18 +50,18 @@ type ComplexityRoot struct { } Query struct { - User func(childComplexity int, id external.ObjectID) int Search func(childComplexity int, input *model.SearchArgs) int + User func(childComplexity int, id external.ObjectID) int } User struct { - ID func(childComplexity int) int - Name func(childComplexity int) int + Address func(childComplexity int) int Created func(childComplexity int) int + CustomResolver func(childComplexity int) int + ID func(childComplexity int) int IsBanned func(childComplexity int) int + Name func(childComplexity int) int PrimitiveResolver func(childComplexity int) int - CustomResolver func(childComplexity int) int - Address func(childComplexity int) int Tier func(childComplexity int) int } } @@ -104,78 +104,78 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Address.Location(childComplexity), true - case "Query.User": - if e.complexity.Query.User == nil { + case "Query.Search": + if e.complexity.Query.Search == nil { break } - args, err := ec.field_Query_user_args(context.TODO(), rawArgs) + args, err := ec.field_Query_search_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.User(childComplexity, args["id"].(external.ObjectID)), true + return e.complexity.Query.Search(childComplexity, args["input"].(*model.SearchArgs)), true - case "Query.Search": - if e.complexity.Query.Search == nil { + case "Query.User": + if e.complexity.Query.User == nil { break } - args, err := ec.field_Query_search_args(context.TODO(), rawArgs) + args, err := ec.field_Query_user_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.Search(childComplexity, args["input"].(*model.SearchArgs)), true + return e.complexity.Query.User(childComplexity, args["id"].(external.ObjectID)), true - case "User.ID": - if e.complexity.User.ID == nil { + case "User.Address": + if e.complexity.User.Address == nil { break } - return e.complexity.User.ID(childComplexity), true + return e.complexity.User.Address(childComplexity), true - case "User.Name": - if e.complexity.User.Name == nil { + case "User.Created": + if e.complexity.User.Created == nil { break } - return e.complexity.User.Name(childComplexity), true + return e.complexity.User.Created(childComplexity), true - case "User.Created": - if e.complexity.User.Created == nil { + case "User.CustomResolver": + if e.complexity.User.CustomResolver == nil { break } - return e.complexity.User.Created(childComplexity), true + return e.complexity.User.CustomResolver(childComplexity), true - case "User.IsBanned": - if e.complexity.User.IsBanned == nil { + case "User.ID": + if e.complexity.User.ID == nil { break } - return e.complexity.User.IsBanned(childComplexity), true + return e.complexity.User.ID(childComplexity), true - case "User.PrimitiveResolver": - if e.complexity.User.PrimitiveResolver == nil { + case "User.IsBanned": + if e.complexity.User.IsBanned == nil { break } - return e.complexity.User.PrimitiveResolver(childComplexity), true + return e.complexity.User.IsBanned(childComplexity), true - case "User.CustomResolver": - if e.complexity.User.CustomResolver == nil { + case "User.Name": + if e.complexity.User.Name == nil { break } - return e.complexity.User.CustomResolver(childComplexity), true + return e.complexity.User.Name(childComplexity), true - case "User.Address": - if e.complexity.User.Address == nil { + case "User.PrimitiveResolver": + if e.complexity.User.PrimitiveResolver == nil { break } - return e.complexity.User.Address(childComplexity), true + return e.complexity.User.PrimitiveResolver(childComplexity), true case "User.Tier": if e.complexity.User.Tier == nil { diff --git a/example/selection/generated.go b/example/selection/generated.go index 5f1f46c52c3..18a99e88ba6 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -43,17 +43,17 @@ type DirectiveRoot struct { type ComplexityRoot struct { Like struct { + Collected func(childComplexity int) int Reaction func(childComplexity int) int - Sent func(childComplexity int) int Selection func(childComplexity int) int - Collected func(childComplexity int) int + Sent func(childComplexity int) int } Post struct { + Collected func(childComplexity int) int Message func(childComplexity int) int - Sent func(childComplexity int) int Selection func(childComplexity int) int - Collected func(childComplexity int) int + Sent func(childComplexity int) int } Query struct { @@ -80,19 +80,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { - case "Like.Reaction": - if e.complexity.Like.Reaction == nil { + case "Like.Collected": + if e.complexity.Like.Collected == nil { break } - return e.complexity.Like.Reaction(childComplexity), true + return e.complexity.Like.Collected(childComplexity), true - case "Like.Sent": - if e.complexity.Like.Sent == nil { + case "Like.Reaction": + if e.complexity.Like.Reaction == nil { break } - return e.complexity.Like.Sent(childComplexity), true + return e.complexity.Like.Reaction(childComplexity), true case "Like.Selection": if e.complexity.Like.Selection == nil { @@ -101,26 +101,26 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Like.Selection(childComplexity), true - case "Like.Collected": - if e.complexity.Like.Collected == nil { + case "Like.Sent": + if e.complexity.Like.Sent == nil { break } - return e.complexity.Like.Collected(childComplexity), true + return e.complexity.Like.Sent(childComplexity), true - case "Post.Message": - if e.complexity.Post.Message == nil { + case "Post.Collected": + if e.complexity.Post.Collected == nil { break } - return e.complexity.Post.Message(childComplexity), true + return e.complexity.Post.Collected(childComplexity), true - case "Post.Sent": - if e.complexity.Post.Sent == nil { + case "Post.Message": + if e.complexity.Post.Message == nil { break } - return e.complexity.Post.Sent(childComplexity), true + return e.complexity.Post.Message(childComplexity), true case "Post.Selection": if e.complexity.Post.Selection == nil { @@ -129,12 +129,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Post.Selection(childComplexity), true - case "Post.Collected": - if e.complexity.Post.Collected == nil { + case "Post.Sent": + if e.complexity.Post.Sent == nil { break } - return e.complexity.Post.Collected(childComplexity), true + return e.complexity.Post.Sent(childComplexity), true case "Query.Events": if e.complexity.Query.Events == nil { diff --git a/example/starwars/generated/exec.go b/example/starwars/generated/exec.go index 4a97131ca8c..f31dcbe29b3 100644 --- a/example/starwars/generated/exec.go +++ b/example/starwars/generated/exec.go @@ -49,19 +49,19 @@ type DirectiveRoot struct { type ComplexityRoot struct { Droid struct { - ID func(childComplexity int) int - Name func(childComplexity int) int + AppearsIn func(childComplexity int) int Friends func(childComplexity int) int FriendsConnection func(childComplexity int, first *int, after *string) int - AppearsIn func(childComplexity int) int + ID func(childComplexity int) int + Name func(childComplexity int) int PrimaryFunction func(childComplexity int) int } FriendsConnection struct { - TotalCount func(childComplexity int) int Edges func(childComplexity int) int Friends func(childComplexity int) int PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int } FriendsEdge struct { @@ -70,13 +70,13 @@ type ComplexityRoot struct { } Human struct { - ID func(childComplexity int) int - Name func(childComplexity int) int - Height func(childComplexity int, unit models.LengthUnit) int - Mass func(childComplexity int) int + AppearsIn func(childComplexity int) int Friends func(childComplexity int) int FriendsConnection func(childComplexity int, first *int, after *string) int - AppearsIn func(childComplexity int) int + Height func(childComplexity int, unit models.LengthUnit) int + ID func(childComplexity int) int + Mass func(childComplexity int) int + Name func(childComplexity int) int Starships func(childComplexity int) int } @@ -85,32 +85,32 @@ type ComplexityRoot struct { } PageInfo struct { - StartCursor func(childComplexity int) int EndCursor func(childComplexity int) int HasNextPage func(childComplexity int) int + StartCursor func(childComplexity int) int } Query struct { - Hero func(childComplexity int, episode *models.Episode) int - Reviews func(childComplexity int, episode models.Episode, since *time.Time) int - Search func(childComplexity int, text string) int Character func(childComplexity int, id string) int Droid func(childComplexity int, id string) int + Hero func(childComplexity int, episode *models.Episode) int Human func(childComplexity int, id string) int + Reviews func(childComplexity int, episode models.Episode, since *time.Time) int + Search func(childComplexity int, text string) int Starship func(childComplexity int, id string) int } Review struct { - Stars func(childComplexity int) int Commentary func(childComplexity int) int + Stars func(childComplexity int) int Time func(childComplexity int) int } Starship struct { + History func(childComplexity int) int ID func(childComplexity int) int - Name func(childComplexity int) int Length func(childComplexity int, unit *models.LengthUnit) int - History func(childComplexity int) int + Name func(childComplexity int) int } } @@ -159,19 +159,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { - case "Droid.ID": - if e.complexity.Droid.ID == nil { - break - } - - return e.complexity.Droid.ID(childComplexity), true - - case "Droid.Name": - if e.complexity.Droid.Name == nil { + case "Droid.AppearsIn": + if e.complexity.Droid.AppearsIn == nil { break } - return e.complexity.Droid.Name(childComplexity), true + return e.complexity.Droid.AppearsIn(childComplexity), true case "Droid.Friends": if e.complexity.Droid.Friends == nil { @@ -192,26 +185,26 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Droid.FriendsConnection(childComplexity, args["first"].(*int), args["after"].(*string)), true - case "Droid.AppearsIn": - if e.complexity.Droid.AppearsIn == nil { + case "Droid.ID": + if e.complexity.Droid.ID == nil { break } - return e.complexity.Droid.AppearsIn(childComplexity), true + return e.complexity.Droid.ID(childComplexity), true - case "Droid.PrimaryFunction": - if e.complexity.Droid.PrimaryFunction == nil { + case "Droid.Name": + if e.complexity.Droid.Name == nil { break } - return e.complexity.Droid.PrimaryFunction(childComplexity), true + return e.complexity.Droid.Name(childComplexity), true - case "FriendsConnection.TotalCount": - if e.complexity.FriendsConnection.TotalCount == nil { + case "Droid.PrimaryFunction": + if e.complexity.Droid.PrimaryFunction == nil { break } - return e.complexity.FriendsConnection.TotalCount(childComplexity), true + return e.complexity.Droid.PrimaryFunction(childComplexity), true case "FriendsConnection.Edges": if e.complexity.FriendsConnection.Edges == nil { @@ -234,6 +227,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.FriendsConnection.PageInfo(childComplexity), true + case "FriendsConnection.TotalCount": + if e.complexity.FriendsConnection.TotalCount == nil { + break + } + + return e.complexity.FriendsConnection.TotalCount(childComplexity), true + case "FriendsEdge.Cursor": if e.complexity.FriendsEdge.Cursor == nil { break @@ -248,64 +248,64 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.FriendsEdge.Node(childComplexity), true - case "Human.ID": - if e.complexity.Human.ID == nil { + case "Human.AppearsIn": + if e.complexity.Human.AppearsIn == nil { break } - return e.complexity.Human.ID(childComplexity), true + return e.complexity.Human.AppearsIn(childComplexity), true - case "Human.Name": - if e.complexity.Human.Name == nil { + case "Human.Friends": + if e.complexity.Human.Friends == nil { break } - return e.complexity.Human.Name(childComplexity), true + return e.complexity.Human.Friends(childComplexity), true - case "Human.Height": - if e.complexity.Human.Height == nil { + case "Human.FriendsConnection": + if e.complexity.Human.FriendsConnection == nil { break } - args, err := ec.field_Human_height_args(context.TODO(), rawArgs) + args, err := ec.field_Human_friendsConnection_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Human.Height(childComplexity, args["unit"].(models.LengthUnit)), true + return e.complexity.Human.FriendsConnection(childComplexity, args["first"].(*int), args["after"].(*string)), true - case "Human.Mass": - if e.complexity.Human.Mass == nil { + case "Human.Height": + if e.complexity.Human.Height == nil { break } - return e.complexity.Human.Mass(childComplexity), true - - case "Human.Friends": - if e.complexity.Human.Friends == nil { - break + args, err := ec.field_Human_height_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - return e.complexity.Human.Friends(childComplexity), true + return e.complexity.Human.Height(childComplexity, args["unit"].(models.LengthUnit)), true - case "Human.FriendsConnection": - if e.complexity.Human.FriendsConnection == nil { + case "Human.ID": + if e.complexity.Human.ID == nil { break } - args, err := ec.field_Human_friendsConnection_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + return e.complexity.Human.ID(childComplexity), true + + case "Human.Mass": + if e.complexity.Human.Mass == nil { + break } - return e.complexity.Human.FriendsConnection(childComplexity, args["first"].(*int), args["after"].(*string)), true + return e.complexity.Human.Mass(childComplexity), true - case "Human.AppearsIn": - if e.complexity.Human.AppearsIn == nil { + case "Human.Name": + if e.complexity.Human.Name == nil { break } - return e.complexity.Human.AppearsIn(childComplexity), true + return e.complexity.Human.Name(childComplexity), true case "Human.Starships": if e.complexity.Human.Starships == nil { @@ -326,13 +326,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.CreateReview(childComplexity, args["episode"].(models.Episode), args["review"].(models.Review)), true - case "PageInfo.StartCursor": - if e.complexity.PageInfo.StartCursor == nil { - break - } - - return e.complexity.PageInfo.StartCursor(childComplexity), true - case "PageInfo.EndCursor": if e.complexity.PageInfo.EndCursor == nil { break @@ -347,77 +340,84 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.PageInfo.HasNextPage(childComplexity), true - case "Query.Hero": - if e.complexity.Query.Hero == nil { + case "PageInfo.StartCursor": + if e.complexity.PageInfo.StartCursor == nil { break } - args, err := ec.field_Query_hero_args(context.TODO(), rawArgs) + return e.complexity.PageInfo.StartCursor(childComplexity), true + + case "Query.Character": + if e.complexity.Query.Character == nil { + break + } + + args, err := ec.field_Query_character_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.Hero(childComplexity, args["episode"].(*models.Episode)), true + return e.complexity.Query.Character(childComplexity, args["id"].(string)), true - case "Query.Reviews": - if e.complexity.Query.Reviews == nil { + case "Query.Droid": + if e.complexity.Query.Droid == nil { break } - args, err := ec.field_Query_reviews_args(context.TODO(), rawArgs) + args, err := ec.field_Query_droid_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.Reviews(childComplexity, args["episode"].(models.Episode), args["since"].(*time.Time)), true + return e.complexity.Query.Droid(childComplexity, args["id"].(string)), true - case "Query.Search": - if e.complexity.Query.Search == nil { + case "Query.Hero": + if e.complexity.Query.Hero == nil { break } - args, err := ec.field_Query_search_args(context.TODO(), rawArgs) + args, err := ec.field_Query_hero_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.Search(childComplexity, args["text"].(string)), true + return e.complexity.Query.Hero(childComplexity, args["episode"].(*models.Episode)), true - case "Query.Character": - if e.complexity.Query.Character == nil { + case "Query.Human": + if e.complexity.Query.Human == nil { break } - args, err := ec.field_Query_character_args(context.TODO(), rawArgs) + args, err := ec.field_Query_human_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.Character(childComplexity, args["id"].(string)), true + return e.complexity.Query.Human(childComplexity, args["id"].(string)), true - case "Query.Droid": - if e.complexity.Query.Droid == nil { + case "Query.Reviews": + if e.complexity.Query.Reviews == nil { break } - args, err := ec.field_Query_droid_args(context.TODO(), rawArgs) + args, err := ec.field_Query_reviews_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.Droid(childComplexity, args["id"].(string)), true + return e.complexity.Query.Reviews(childComplexity, args["episode"].(models.Episode), args["since"].(*time.Time)), true - case "Query.Human": - if e.complexity.Query.Human == nil { + case "Query.Search": + if e.complexity.Query.Search == nil { break } - args, err := ec.field_Query_human_args(context.TODO(), rawArgs) + args, err := ec.field_Query_search_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.Human(childComplexity, args["id"].(string)), true + return e.complexity.Query.Search(childComplexity, args["text"].(string)), true case "Query.Starship": if e.complexity.Query.Starship == nil { @@ -431,19 +431,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Starship(childComplexity, args["id"].(string)), true - case "Review.Stars": - if e.complexity.Review.Stars == nil { + case "Review.Commentary": + if e.complexity.Review.Commentary == nil { break } - return e.complexity.Review.Stars(childComplexity), true + return e.complexity.Review.Commentary(childComplexity), true - case "Review.Commentary": - if e.complexity.Review.Commentary == nil { + case "Review.Stars": + if e.complexity.Review.Stars == nil { break } - return e.complexity.Review.Commentary(childComplexity), true + return e.complexity.Review.Stars(childComplexity), true case "Review.Time": if e.complexity.Review.Time == nil { @@ -452,19 +452,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Review.Time(childComplexity), true - case "Starship.ID": - if e.complexity.Starship.ID == nil { + case "Starship.History": + if e.complexity.Starship.History == nil { break } - return e.complexity.Starship.ID(childComplexity), true + return e.complexity.Starship.History(childComplexity), true - case "Starship.Name": - if e.complexity.Starship.Name == nil { + case "Starship.ID": + if e.complexity.Starship.ID == nil { break } - return e.complexity.Starship.Name(childComplexity), true + return e.complexity.Starship.ID(childComplexity), true case "Starship.Length": if e.complexity.Starship.Length == nil { @@ -478,12 +478,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Starship.Length(childComplexity, args["unit"].(*models.LengthUnit)), true - case "Starship.History": - if e.complexity.Starship.History == nil { + case "Starship.Name": + if e.complexity.Starship.Name == nil { break } - return e.complexity.Starship.History(childComplexity), true + return e.complexity.Starship.Name(childComplexity), true } return 0, false diff --git a/example/todo/generated.go b/example/todo/generated.go index 0cc8fc3d47c..08ffac652d7 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -48,15 +48,15 @@ type ComplexityRoot struct { } MyQuery struct { - Todo func(childComplexity int, id int) int LastTodo func(childComplexity int) int + Todo func(childComplexity int, id int) int Todos func(childComplexity int) int } Todo struct { + Done func(childComplexity int) int ID func(childComplexity int) int Text func(childComplexity int) int - Done func(childComplexity int) int } } @@ -109,6 +109,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.MyMutation.UpdateTodo(childComplexity, args["id"].(int), args["changes"].(map[string]interface{})), true + case "MyQuery.LastTodo": + if e.complexity.MyQuery.LastTodo == nil { + break + } + + return e.complexity.MyQuery.LastTodo(childComplexity), true + case "MyQuery.Todo": if e.complexity.MyQuery.Todo == nil { break @@ -121,19 +128,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.MyQuery.Todo(childComplexity, args["id"].(int)), true - case "MyQuery.LastTodo": - if e.complexity.MyQuery.LastTodo == nil { + case "MyQuery.Todos": + if e.complexity.MyQuery.Todos == nil { break } - return e.complexity.MyQuery.LastTodo(childComplexity), true + return e.complexity.MyQuery.Todos(childComplexity), true - case "MyQuery.Todos": - if e.complexity.MyQuery.Todos == nil { + case "Todo.Done": + if e.complexity.Todo.Done == nil { break } - return e.complexity.MyQuery.Todos(childComplexity), true + return e.complexity.Todo.Done(childComplexity), true case "Todo.ID": if e.complexity.Todo.ID == nil { @@ -149,13 +156,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Todo.Text(childComplexity), true - case "Todo.Done": - if e.complexity.Todo.Done == nil { - break - } - - return e.complexity.Todo.Done(childComplexity), true - } return 0, false } diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index bc00d1a2585..d15500fd9f9 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -60,14 +60,14 @@ type ComplexityRoot struct { } MyQuery struct { - Todos func(childComplexity int) int Todo func(childComplexity int, id string) int + Todos func(childComplexity int) int } Todo struct { ID func(childComplexity int) int - Text func(childComplexity int) int State func(childComplexity int) int + Text func(childComplexity int) int Verified func(childComplexity int) int } } @@ -107,13 +107,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.MyMutation.CreateTodo(childComplexity, args["todo"].(TodoInput)), true - case "MyQuery.Todos": - if e.complexity.MyQuery.Todos == nil { - break - } - - return e.complexity.MyQuery.Todos(childComplexity), true - case "MyQuery.Todo": if e.complexity.MyQuery.Todo == nil { break @@ -126,19 +119,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.MyQuery.Todo(childComplexity, args["id"].(string)), true - case "Todo.ID": - if e.complexity.Todo.ID == nil { + case "MyQuery.Todos": + if e.complexity.MyQuery.Todos == nil { break } - return e.complexity.Todo.ID(childComplexity), true + return e.complexity.MyQuery.Todos(childComplexity), true - case "Todo.Text": - if e.complexity.Todo.Text == nil { + case "Todo.ID": + if e.complexity.Todo.ID == nil { break } - return e.complexity.Todo.Text(childComplexity), true + return e.complexity.Todo.ID(childComplexity), true case "Todo.State": if e.complexity.Todo.State == nil { @@ -147,6 +140,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Todo.State(childComplexity), true + case "Todo.Text": + if e.complexity.Todo.Text == nil { + break + } + + return e.complexity.Todo.Text(childComplexity), true + case "Todo.Verified": if e.complexity.Todo.Verified == nil { break diff --git a/integration/generated.go b/integration/generated.go index 6515e384baa..6b17e93743e 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -52,16 +52,16 @@ type ComplexityRoot struct { } Query struct { - Path func(childComplexity int) int Date func(childComplexity int, filter models.DateFilter) int - Viewer func(childComplexity int) int - JSONEncoding func(childComplexity int) int Error func(childComplexity int, typeArg *models.ErrorType) int + JSONEncoding func(childComplexity int) int + Path func(childComplexity int) int + Viewer func(childComplexity int) int } User struct { - Name func(childComplexity int) int Likes func(childComplexity int) int + Name func(childComplexity int) int } Viewer struct { @@ -121,13 +121,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Element.Mismatched(childComplexity), true - case "Query.Path": - if e.complexity.Query.Path == nil { - break - } - - return e.complexity.Query.Path(childComplexity), true - case "Query.Date": if e.complexity.Query.Date == nil { break @@ -140,12 +133,17 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Date(childComplexity, args["filter"].(models.DateFilter)), true - case "Query.Viewer": - if e.complexity.Query.Viewer == nil { + case "Query.Error": + if e.complexity.Query.Error == nil { break } - return e.complexity.Query.Viewer(childComplexity), true + args, err := ec.field_Query_error_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Error(childComplexity, args["type"].(*models.ErrorType)), true case "Query.JSONEncoding": if e.complexity.Query.JSONEncoding == nil { @@ -154,24 +152,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.JSONEncoding(childComplexity), true - case "Query.Error": - if e.complexity.Query.Error == nil { + case "Query.Path": + if e.complexity.Query.Path == nil { break } - args, err := ec.field_Query_error_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.Error(childComplexity, args["type"].(*models.ErrorType)), true + return e.complexity.Query.Path(childComplexity), true - case "User.Name": - if e.complexity.User.Name == nil { + case "Query.Viewer": + if e.complexity.Query.Viewer == nil { break } - return e.complexity.User.Name(childComplexity), true + return e.complexity.Query.Viewer(childComplexity), true case "User.Likes": if e.complexity.User.Likes == nil { @@ -180,6 +173,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.User.Likes(childComplexity), true + case "User.Name": + if e.complexity.User.Name == nil { + break + } + + return e.complexity.User.Name(childComplexity), true + case "Viewer.User": if e.complexity.Viewer.User == nil { break From 8e1590d784e27a0dc3fbb4779453ad3a732f1e53 Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Sat, 16 Mar 2019 22:18:45 +1100 Subject: [PATCH 138/147] Move ambient imports into cmd package The getting started docs for dep suggest creating a local gqlgen script, however these ambient import are in the root, so dep misses them. This was changed in 0.8 but the ambient imports weren't moved. --- ambient.go => cmd/ambient.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename ambient.go => cmd/ambient.go (96%) diff --git a/ambient.go b/cmd/ambient.go similarity index 96% rename from ambient.go rename to cmd/ambient.go index 350bc75cc6a..7838fdf16d5 100644 --- a/ambient.go +++ b/cmd/ambient.go @@ -1,4 +1,4 @@ -package main +package cmd import ( // Import and ignore the ambient imports listed below so dependency managers From 8257d423e8c2d936bf03de1aa4f6215dfdf7229c Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Mon, 18 Mar 2019 11:37:29 +1100 Subject: [PATCH 139/147] Check Go type rather than GQL type for ptr This is probably a more correct way to check whether we should wrap the type in a pointer or not, rather than looking at the GrapQL definition. There may be use-cases where a GraphQL interface/union might be mapped to a Go stuct. --- codegen/config/binder.go | 13 +++++++++---- plugin/modelgen/models.go | 15 +++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/codegen/config/binder.go b/codegen/config/binder.go index e8b3c459220..98ceba8ebb6 100644 --- a/codegen/config/binder.go +++ b/codegen/config/binder.go @@ -399,7 +399,7 @@ func (b *Binder) TypeReference(schemaType *ast.Type, bindTarget types.Type) (ret ref.GO = obj.Type() } - ref.GO = b.CopyModifiersFromAst(schemaType, def.Kind != ast.Interface, ref.GO) + ref.GO = b.CopyModifiersFromAst(schemaType, ref.GO) if bindTarget != nil { if err = code.CompatibleTypes(ref.GO, bindTarget); err != nil { @@ -414,12 +414,17 @@ func (b *Binder) TypeReference(schemaType *ast.Type, bindTarget types.Type) (ret return nil, fmt.Errorf("%s has type compatible with %s", schemaType.Name(), bindTarget.String()) } -func (b *Binder) CopyModifiersFromAst(t *ast.Type, usePtr bool, base types.Type) types.Type { +func (b *Binder) CopyModifiersFromAst(t *ast.Type, base types.Type) types.Type { if t.Elem != nil { - return types.NewSlice(b.CopyModifiersFromAst(t.Elem, usePtr, base)) + return types.NewSlice(b.CopyModifiersFromAst(t.Elem, base)) } - if !t.NonNull && usePtr { + var isInterface bool + if named, ok := base.(*types.Named); ok { + _, isInterface = named.Underlying().(*types.Interface) + } + + if !isInterface && !t.NonNull { return types.NewPointer(base) } diff --git a/plugin/modelgen/models.go b/plugin/modelgen/models.go index 41c183c167e..508cc14d074 100644 --- a/plugin/modelgen/models.go +++ b/plugin/modelgen/models.go @@ -119,14 +119,22 @@ func (m *Plugin) MutateConfig(cfg *config.Config) error { } } else { fieldDef := schema.Types[field.Type.Name()] - if fieldDef.Kind == ast.Scalar { + switch fieldDef.Kind { + case ast.Scalar: // no user defined model, referencing a default scalar typ = types.NewNamed( types.NewTypeName(0, cfg.Model.Pkg(), "string", nil), nil, nil, ) - } else { + case ast.Interface, ast.Union: + // no user defined model, referencing a generated interface type + typ = types.NewNamed( + types.NewTypeName(0, cfg.Model.Pkg(), templates.ToGo(field.Type.Name()), nil), + types.NewInterfaceType([]*types.Func{}, []types.Type{}), + nil, + ) + default: // no user defined model, must reference another generated model typ = types.NewNamed( types.NewTypeName(0, cfg.Model.Pkg(), templates.ToGo(field.Type.Name()), nil), @@ -141,10 +149,9 @@ func (m *Plugin) MutateConfig(cfg *config.Config) error { name = nameOveride } - fd := schema.Types[field.Type.Name()] it.Fields = append(it.Fields, &Field{ Name: name, - Type: binder.CopyModifiersFromAst(field.Type, fd.Kind != ast.Interface, typ), + Type: binder.CopyModifiersFromAst(field.Type, typ), Description: field.Description, Tag: `json:"` + field.Name + `"`, }) From f02dabb7bad39e049323e05b171feb8f387d257a Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Mon, 18 Mar 2019 14:39:31 +1100 Subject: [PATCH 140/147] Add test case for union pointer --- codegen/testserver/generated.go | 209 ++++++++++++++++++++++++++++++ codegen/testserver/models-gen.go | 16 +++ codegen/testserver/resolver.go | 3 + codegen/testserver/stub.go | 4 + codegen/testserver/useptr.graphql | 13 ++ codegen/testserver/useptr_test.go | 14 ++ 6 files changed, 259 insertions(+) create mode 100644 codegen/testserver/useptr.graphql create mode 100644 codegen/testserver/useptr_test.go diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 99de6ccc5ed..caa65855d79 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -56,6 +56,10 @@ type DirectiveRoot struct { } type ComplexityRoot struct { + A struct { + ID func(childComplexity int) int + } + AIt struct { ID func(childComplexity int) int } @@ -72,6 +76,10 @@ type ComplexityRoot struct { Int64 func(childComplexity int) int } + B struct { + ID func(childComplexity int) int + } + Circle struct { Area func(childComplexity int) int Radius func(childComplexity int) int @@ -155,6 +163,7 @@ type ComplexityRoot struct { NestedInputs func(childComplexity int, input [][]*OuterInput) int NestedOutputs func(childComplexity int) int NullableArg func(childComplexity int, arg *int) int + OptionalUnion func(childComplexity int) int Overlapping func(childComplexity int) int Panics func(childComplexity int) int Recursive func(childComplexity int, input *RecursiveInputSlice) int @@ -256,6 +265,7 @@ type QueryResolver interface { Panics(ctx context.Context) (*Panics, error) DefaultScalar(ctx context.Context, arg string) (string, error) Slices(ctx context.Context) (*Slices, error) + OptionalUnion(ctx context.Context) (TestUnion, error) ValidType(ctx context.Context) (*ValidType, error) } type SubscriptionResolver interface { @@ -281,6 +291,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { + case "A.ID": + if e.complexity.A.ID == nil { + break + } + + return e.complexity.A.ID(childComplexity), true + case "AIt.ID": if e.complexity.AIt.ID == nil { break @@ -330,6 +347,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Autobind.Int64(childComplexity), true + case "B.ID": + if e.complexity.B.ID == nil { + break + } + + return e.complexity.B.ID(childComplexity), true + case "Circle.Area": if e.complexity.Circle.Area == nil { break @@ -696,6 +720,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.NullableArg(childComplexity, args["arg"].(*int)), true + case "Query.OptionalUnion": + if e.complexity.Query.OptionalUnion == nil { + break + } + + return e.complexity.Query.OptionalUnion(childComplexity), true + case "Query.Overlapping": if e.complexity.Query.Overlapping == nil { break @@ -1255,6 +1286,20 @@ type Slices { test3: [String]! test4: [String!]! } +`}, + &ast.Source{Name: "useptr.graphql", Input: `type A { + id: ID! +} + +type B { + id: ID! +} + +union TestUnion = A | B + +extend type Query { + optionalUnion: TestUnion +} `}, &ast.Source{Name: "validtypes.graphql", Input: `extend type Query { validType: ValidType @@ -1925,6 +1970,33 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg // region **************************** field.gotpl ***************************** +func (ec *executionContext) _A_id(ctx context.Context, field graphql.CollectedField, obj *A) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "A", + Field: field, + Args: nil, + IsMethod: false, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNID2string(ctx, field.Selections, res) +} + func (ec *executionContext) _AIt_id(ctx context.Context, field graphql.CollectedField, obj *AIt) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -2114,6 +2186,33 @@ func (ec *executionContext) _Autobind_idInt(ctx context.Context, field graphql.C return ec.marshalNID2int(ctx, field.Selections, res) } +func (ec *executionContext) _B_id(ctx context.Context, field graphql.CollectedField, obj *B) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "B", + Field: field, + Args: nil, + IsMethod: false, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNID2string(ctx, field.Selections, res) +} + func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.CollectedField, obj *Circle) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -3581,6 +3680,30 @@ func (ec *executionContext) _Query_slices(ctx context.Context, field graphql.Col return ec.marshalOSlices2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐSlices(ctx, field.Selections, res) } +func (ec *executionContext) _Query_optionalUnion(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().OptionalUnion(rctx) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(TestUnion) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalOTestUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐTestUnion(ctx, field.Selections, res) +} + func (ec *executionContext) _Query_validType(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -5399,10 +5522,54 @@ func (ec *executionContext) _ShapeUnion(ctx context.Context, sel ast.SelectionSe } } +func (ec *executionContext) _TestUnion(ctx context.Context, sel ast.SelectionSet, obj *TestUnion) graphql.Marshaler { + switch obj := (*obj).(type) { + case nil: + return graphql.Null + case A: + return ec._A(ctx, sel, &obj) + case *A: + return ec._A(ctx, sel, obj) + case B: + return ec._B(ctx, sel, &obj) + case *B: + return ec._B(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** +var aImplementors = []string{"A", "TestUnion"} + +func (ec *executionContext) _A(ctx context.Context, sel ast.SelectionSet, obj *A) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, aImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("A") + case "id": + out.Values[i] = ec._A_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + var aItImplementors = []string{"AIt"} func (ec *executionContext) _AIt(ctx context.Context, sel ast.SelectionSet, obj *AIt) graphql.Marshaler { @@ -5504,6 +5671,33 @@ func (ec *executionContext) _Autobind(ctx context.Context, sel ast.SelectionSet, return out } +var bImplementors = []string{"B", "TestUnion"} + +func (ec *executionContext) _B(ctx context.Context, sel ast.SelectionSet, obj *B) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, bImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("B") + case "id": + out.Values[i] = ec._B_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + var circleImplementors = []string{"Circle", "Shape", "ShapeUnion"} func (ec *executionContext) _Circle(ctx context.Context, sel ast.SelectionSet, obj *Circle) graphql.Marshaler { @@ -6280,6 +6474,17 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr res = ec._Query_slices(ctx, field) return res }) + case "optionalUnion": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_optionalUnion(ctx, field) + return res + }) case "validType": field := field out.Concurrently(i, func() (res graphql.Marshaler) { @@ -7843,6 +8048,10 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as return ec.marshalOString2string(ctx, sel, *v) } +func (ec *executionContext) marshalOTestUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐTestUnion(ctx context.Context, sel ast.SelectionSet, v TestUnion) graphql.Marshaler { + return ec._TestUnion(ctx, sel, &v) +} + func (ec *executionContext) unmarshalOThirdParty2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐThirdParty(ctx context.Context, v interface{}) (ThirdParty, error) { return UnmarshalThirdParty(v) } diff --git a/codegen/testserver/models-gen.go b/codegen/testserver/models-gen.go index b09dcfdf99e..25f8522713b 100644 --- a/codegen/testserver/models-gen.go +++ b/codegen/testserver/models-gen.go @@ -9,6 +9,16 @@ import ( "time" ) +type TestUnion interface { + IsTestUnion() +} + +type A struct { + ID string `json:"id"` +} + +func (A) IsTestUnion() {} + type AIt struct { ID string `json:"id"` } @@ -17,6 +27,12 @@ type AbIt struct { ID string `json:"id"` } +type B struct { + ID string `json:"id"` +} + +func (B) IsTestUnion() {} + type EmbeddedDefaultScalar struct { Value *string `json:"value"` } diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index f42787e6ef8..e0fba141e8d 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -140,6 +140,9 @@ func (r *queryResolver) DefaultScalar(ctx context.Context, arg string) (string, func (r *queryResolver) Slices(ctx context.Context) (*Slices, error) { panic("not implemented") } +func (r *queryResolver) OptionalUnion(ctx context.Context) (TestUnion, error) { + panic("not implemented") +} func (r *queryResolver) ValidType(ctx context.Context) (*ValidType, error) { panic("not implemented") } diff --git a/codegen/testserver/stub.go b/codegen/testserver/stub.go index 3965ce4c202..6706ead178b 100644 --- a/codegen/testserver/stub.go +++ b/codegen/testserver/stub.go @@ -50,6 +50,7 @@ type Stub struct { Panics func(ctx context.Context) (*Panics, error) DefaultScalar func(ctx context.Context, arg string) (string, error) Slices func(ctx context.Context) (*Slices, error) + OptionalUnion func(ctx context.Context) (TestUnion, error) ValidType func(ctx context.Context) (*ValidType, error) } SubscriptionResolver struct { @@ -190,6 +191,9 @@ func (r *stubQuery) DefaultScalar(ctx context.Context, arg string) (string, erro func (r *stubQuery) Slices(ctx context.Context) (*Slices, error) { return r.QueryResolver.Slices(ctx) } +func (r *stubQuery) OptionalUnion(ctx context.Context) (TestUnion, error) { + return r.QueryResolver.OptionalUnion(ctx) +} func (r *stubQuery) ValidType(ctx context.Context) (*ValidType, error) { return r.QueryResolver.ValidType(ctx) } diff --git a/codegen/testserver/useptr.graphql b/codegen/testserver/useptr.graphql new file mode 100644 index 00000000000..23c1af0b421 --- /dev/null +++ b/codegen/testserver/useptr.graphql @@ -0,0 +1,13 @@ +type A { + id: ID! +} + +type B { + id: ID! +} + +union TestUnion = A | B + +extend type Query { + optionalUnion: TestUnion +} diff --git a/codegen/testserver/useptr_test.go b/codegen/testserver/useptr_test.go new file mode 100644 index 00000000000..ba088f49dc0 --- /dev/null +++ b/codegen/testserver/useptr_test.go @@ -0,0 +1,14 @@ +package testserver + +import ( + "reflect" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestUserPtr(t *testing.T) { + s := &Stub{} + r := reflect.TypeOf(s.QueryResolver.OptionalUnion) + require.True(t, r.Out(0).Kind() == reflect.Interface) +} From a2cce0d14984402fccd9e8abb9f286a80e7296fb Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Mon, 18 Mar 2019 13:46:19 +1100 Subject: [PATCH 141/147] Use graphql.String for types wrapping a basic string --- codegen/config/binder.go | 95 +++++++++++++++---------- codegen/testserver/generated.go | 95 +++++++++++++++++++++++++ codegen/testserver/gqlgen.yml | 2 + codegen/testserver/models.go | 8 +++ codegen/testserver/resolver.go | 3 + codegen/testserver/stub.go | 4 ++ codegen/testserver/typefallback.graphql | 9 +++ codegen/testserver/typefallback_test.go | 30 ++++++++ codegen/type.gotpl | 19 +++-- 9 files changed, 220 insertions(+), 45 deletions(-) create mode 100644 codegen/testserver/typefallback.graphql create mode 100644 codegen/testserver/typefallback_test.go diff --git a/codegen/config/binder.go b/codegen/config/binder.go index 98ceba8ebb6..5e8c1cf6969 100644 --- a/codegen/config/binder.go +++ b/codegen/config/binder.go @@ -158,9 +158,11 @@ func (b *Binder) PointerTo(ref *TypeReference) *TypeReference { newRef := &TypeReference{ GO: types.NewPointer(ref.GO), GQL: ref.GQL, + CastType: ref.CastType, Definition: ref.Definition, Unmarshaler: ref.Unmarshaler, Marshaler: ref.Marshaler, + IsMarshaler: ref.IsMarshaler, } b.References = append(b.References, newRef) @@ -172,8 +174,10 @@ type TypeReference struct { Definition *ast.Definition GQL *ast.Type GO types.Type + CastType types.Type // Before calling marshalling functions cast from/to this base type Marshaler *types.Func // When using external marshalling functions this will point to the Marshal function Unmarshaler *types.Func // When using external marshalling functions this will point to the Unmarshal function + IsMarshaler bool // Does the type implement graphql.Marshaler and graphql.Unmarshaler } func (ref *TypeReference) Elem() *TypeReference { @@ -181,9 +185,11 @@ func (ref *TypeReference) Elem() *TypeReference { return &TypeReference{ GO: p.Elem(), GQL: ref.GQL, + CastType: ref.CastType, Definition: ref.Definition, Unmarshaler: ref.Unmarshaler, Marshaler: ref.Marshaler, + IsMarshaler: ref.IsMarshaler, } } @@ -191,9 +197,11 @@ func (ref *TypeReference) Elem() *TypeReference { return &TypeReference{ GO: s.Elem(), GQL: ref.GQL.Elem, + CastType: ref.CastType, Definition: ref.Definition, Unmarshaler: ref.Unmarshaler, Marshaler: ref.Marshaler, + IsMarshaler: ref.IsMarshaler, } } return nil @@ -249,44 +257,6 @@ func (t *TypeReference) HasIsZero() bool { return false } -func (t *TypeReference) SelfMarshalling() bool { - it := t.GO - if ptr, isPtr := it.(*types.Pointer); isPtr { - it = ptr.Elem() - } - namedType, ok := it.(*types.Named) - if !ok { - return false - } - - for i := 0; i < namedType.NumMethods(); i++ { - switch namedType.Method(i).Name() { - case "MarshalGQL": - return true - } - } - return false -} - -func (t *TypeReference) SelfUnmarshalling() bool { - it := t.GO - if ptr, isPtr := it.(*types.Pointer); isPtr { - it = ptr.Elem() - } - namedType, ok := it.(*types.Named) - if !ok { - return false - } - - for i := 0; i < namedType.NumMethods(); i++ { - switch namedType.Method(i).Name() { - case "UnmarshalGQL": - return true - } - } - return false -} - func (t *TypeReference) UniquenessKey() string { var nullability = "O" if t.GQL.NonNull { @@ -395,6 +365,22 @@ func (b *Binder) TypeReference(schemaType *ast.Type, bindTarget types.Type) (ret ref.GO = fun.Type().(*types.Signature).Params().At(0).Type() ref.Marshaler = fun ref.Unmarshaler = types.NewFunc(0, fun.Pkg(), "Unmarshal"+typeName, nil) + } else if hasMethod(obj.Type(), "MarshalGQL") && hasMethod(obj.Type(), "UnmarshalGQL") { + ref.GO = obj.Type() + ref.IsMarshaler = true + } else if underlying := basicUnderlying(obj.Type()); underlying != nil && underlying.Kind() == types.String { + // Special case for named types wrapping strings. Used by default enum implementations. + + ref.GO = obj.Type() + ref.CastType = underlying + + underlyingRef, err := b.TypeReference(&ast.Type{NamedType: "String"}, nil) + if err != nil { + return nil, err + } + + ref.Marshaler = underlyingRef.Marshaler + ref.Unmarshaler = underlyingRef.Unmarshaler } else { ref.GO = obj.Type() } @@ -430,3 +416,36 @@ func (b *Binder) CopyModifiersFromAst(t *ast.Type, base types.Type) types.Type { return base } + +func hasMethod(it types.Type, name string) bool { + if ptr, isPtr := it.(*types.Pointer); isPtr { + it = ptr.Elem() + } + namedType, ok := it.(*types.Named) + if !ok { + return false + } + + for i := 0; i < namedType.NumMethods(); i++ { + if namedType.Method(i).Name() == name { + return true + } + } + return false +} + +func basicUnderlying(it types.Type) *types.Basic { + if ptr, isPtr := it.(*types.Pointer); isPtr { + it = ptr.Elem() + } + namedType, ok := it.(*types.Named) + if !ok { + return nil + } + + if basic, ok := namedType.Underlying().(*types.Basic); ok { + return basic + } + + return nil +} diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index caa65855d79..28508675288 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -155,6 +155,7 @@ type ComplexityRoot struct { DirectiveInputType func(childComplexity int, arg InnerInput) int DirectiveNullableArg func(childComplexity int, arg *int, arg2 *int) int ErrorBubble func(childComplexity int) int + Fallback func(childComplexity int, arg FallbackToStringEncoding) int InputSlice func(childComplexity int, arg []string) int InvalidIdentifier func(childComplexity int) int MapInput func(childComplexity int, input map[string]interface{}) int @@ -265,6 +266,7 @@ type QueryResolver interface { Panics(ctx context.Context) (*Panics, error) DefaultScalar(ctx context.Context, arg string) (string, error) Slices(ctx context.Context) (*Slices, error) + Fallback(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) OptionalUnion(ctx context.Context) (TestUnion, error) ValidType(ctx context.Context) (*ValidType, error) } @@ -639,6 +641,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.ErrorBubble(childComplexity), true + case "Query.Fallback": + if e.complexity.Query.Fallback == nil { + break + } + + args, err := ec.field_Query_fallback_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Fallback(childComplexity, args["arg"].(FallbackToStringEncoding)), true + case "Query.InputSlice": if e.complexity.Query.InputSlice == nil { break @@ -1286,6 +1300,16 @@ type Slices { test3: [String]! test4: [String!]! } +`}, + &ast.Source{Name: "typefallback.graphql", Input: `extend type Query { + fallback(arg: FallbackToStringEncoding!): FallbackToStringEncoding! +} + +enum FallbackToStringEncoding { + A + B + C +} `}, &ast.Source{Name: "useptr.graphql", Input: `type A { id: ID! @@ -1612,6 +1636,20 @@ func (ec *executionContext) field_Query_directiveNullableArg_args(ctx context.Co return args, nil } +func (ec *executionContext) field_Query_fallback_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 FallbackToStringEncoding + if tmp, ok := rawArgs["arg"]; ok { + arg0, err = ec.unmarshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐFallbackToStringEncoding(ctx, tmp) + if err != nil { + return nil, err + } + } + args["arg"] = arg0 + return args, nil +} + func (ec *executionContext) field_Query_inputSlice_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -3680,6 +3718,40 @@ func (ec *executionContext) _Query_slices(ctx context.Context, field graphql.Col return ec.marshalOSlices2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐSlices(ctx, field.Selections, res) } +func (ec *executionContext) _Query_fallback(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, + } + ctx = graphql.WithResolverContext(ctx, rctx) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_fallback_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx.Args = args + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Fallback(rctx, args["arg"].(FallbackToStringEncoding)) + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(FallbackToStringEncoding) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐFallbackToStringEncoding(ctx, field.Selections, res) +} + func (ec *executionContext) _Query_optionalUnion(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -6474,6 +6546,20 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr res = ec._Query_slices(ctx, field) return res }) + case "fallback": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_fallback(ctx, field) + if res == graphql.Null { + invalid = true + } + return res + }) case "optionalUnion": field := field out.Concurrently(i, func() (res graphql.Marshaler) { @@ -7056,6 +7142,15 @@ func (ec *executionContext) marshalNDefaultScalarImplementation2string(ctx conte return graphql.MarshalString(v) } +func (ec *executionContext) unmarshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐFallbackToStringEncoding(ctx context.Context, v interface{}) (FallbackToStringEncoding, error) { + tmp, err := graphql.UnmarshalString(v) + return FallbackToStringEncoding(tmp), err +} + +func (ec *executionContext) marshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐFallbackToStringEncoding(ctx context.Context, sel ast.SelectionSet, v FallbackToStringEncoding) graphql.Marshaler { + return graphql.MarshalString(string(v)) +} + func (ec *executionContext) unmarshalNID2int(ctx context.Context, v interface{}) (int, error) { return graphql.UnmarshalIntID(v) } diff --git a/codegen/testserver/gqlgen.yml b/codegen/testserver/gqlgen.yml index 9979c5efc9d..b3e47496542 100644 --- a/codegen/testserver/gqlgen.yml +++ b/codegen/testserver/gqlgen.yml @@ -66,3 +66,5 @@ models: oneFoo: { fieldName: foo } twoFoo: { fieldName: foo } oldFoo: { fieldName: foo, resolver: true } + FallbackToStringEncoding: + model: "github.com/99designs/gqlgen/codegen/testserver.FallbackToStringEncoding" diff --git a/codegen/testserver/models.go b/codegen/testserver/models.go index 20af8947688..3ee710a50fc 100644 --- a/codegen/testserver/models.go +++ b/codegen/testserver/models.go @@ -76,3 +76,11 @@ type OverlappingFields struct { Foo int NewFoo int } + +type FallbackToStringEncoding string + +const ( + FallbackToStringEncodingA FallbackToStringEncoding = "A" + FallbackToStringEncodingB FallbackToStringEncoding = "B" + FallbackToStringEncodingC FallbackToStringEncoding = "C" +) diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index e0fba141e8d..b00e7ee0b69 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -140,6 +140,9 @@ func (r *queryResolver) DefaultScalar(ctx context.Context, arg string) (string, func (r *queryResolver) Slices(ctx context.Context) (*Slices, error) { panic("not implemented") } +func (r *queryResolver) Fallback(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) { + panic("not implemented") +} func (r *queryResolver) OptionalUnion(ctx context.Context) (TestUnion, error) { panic("not implemented") } diff --git a/codegen/testserver/stub.go b/codegen/testserver/stub.go index 6706ead178b..36a100b96fc 100644 --- a/codegen/testserver/stub.go +++ b/codegen/testserver/stub.go @@ -50,6 +50,7 @@ type Stub struct { Panics func(ctx context.Context) (*Panics, error) DefaultScalar func(ctx context.Context, arg string) (string, error) Slices func(ctx context.Context) (*Slices, error) + Fallback func(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) OptionalUnion func(ctx context.Context) (TestUnion, error) ValidType func(ctx context.Context) (*ValidType, error) } @@ -191,6 +192,9 @@ func (r *stubQuery) DefaultScalar(ctx context.Context, arg string) (string, erro func (r *stubQuery) Slices(ctx context.Context) (*Slices, error) { return r.QueryResolver.Slices(ctx) } +func (r *stubQuery) Fallback(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) { + return r.QueryResolver.Fallback(ctx, arg) +} func (r *stubQuery) OptionalUnion(ctx context.Context) (TestUnion, error) { return r.QueryResolver.OptionalUnion(ctx) } diff --git a/codegen/testserver/typefallback.graphql b/codegen/testserver/typefallback.graphql new file mode 100644 index 00000000000..e1ff1a59d7c --- /dev/null +++ b/codegen/testserver/typefallback.graphql @@ -0,0 +1,9 @@ +extend type Query { + fallback(arg: FallbackToStringEncoding!): FallbackToStringEncoding! +} + +enum FallbackToStringEncoding { + A + B + C +} diff --git a/codegen/testserver/typefallback_test.go b/codegen/testserver/typefallback_test.go new file mode 100644 index 00000000000..0b0f83135ef --- /dev/null +++ b/codegen/testserver/typefallback_test.go @@ -0,0 +1,30 @@ +package testserver + +import ( + "context" + "net/http/httptest" + "testing" + + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/handler" + "github.com/stretchr/testify/require" +) + +func TestTypeFallback(t *testing.T) { + resolvers := &Stub{} + + srv := httptest.NewServer(handler.GraphQL(NewExecutableSchema(Config{Resolvers: resolvers}))) + c := client.New(srv.URL) + + resolvers.QueryResolver.Fallback = func(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) { + return arg, nil + } + + t.Run("fallback to string passthrough", func(t *testing.T) { + var resp struct { + Fallback string + } + c.MustPost(`query { fallback(arg: A) }`, &resp) + require.Equal(t, "A", resp.Fallback) + }) +} diff --git a/codegen/type.gotpl b/codegen/type.gotpl index 163c95ac40f..f727baaca3c 100644 --- a/codegen/type.gotpl +++ b/codegen/type.gotpl @@ -27,10 +27,15 @@ return res, nil {{- else }} {{- if $type.Unmarshaler }} - return {{ $type.Unmarshaler | call }}(v) + {{- if $type.CastType }} + tmp, err := {{ $type.Unmarshaler | call }}(v) + return {{ $type.GO | ref }}(tmp), err + {{- else}} + return {{ $type.Unmarshaler | call }}(v) + {{- end }} {{- else if eq ($type.GO | ref) "map[string]interface{}" }} return v.(map[string]interface{}), nil - {{- else if $type.SelfUnmarshalling -}} + {{- else if $type.IsMarshaler -}} var res {{ $type.GO | ref }} return res, res.UnmarshalGQL(v) {{- else }} @@ -62,9 +67,7 @@ } {{- end }} - {{- if $type.SelfMarshalling }} - return v - {{- else if $type.IsSlice }} + {{- if $type.IsSlice }} {{- if not $type.GQL.NonNull }} if v == nil { return graphql.Null @@ -111,11 +114,13 @@ return ret {{- else }} - {{- if $type.Marshaler }} + {{- if $type.IsMarshaler }} + return v + {{- else if $type.Marshaler }} {{- if $type.IsPtr }} return ec.{{ $type.Elem.MarshalFunc }}(ctx, sel, *v) {{- else }} - return {{ $type.Marshaler | call }}(v) + return {{ $type.Marshaler | call }}({{- if $type.CastType }}{{ $type.CastType | ref }}(v){{else}}v{{- end }}) {{- end }} {{- else }} return ec._{{$type.Definition.Name}}(ctx, sel, {{ if not $type.IsNilable}}&{{end}} v) From d567d5c8f737fc9870e4772e9e04e5e0dbe04e7a Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Mon, 18 Mar 2019 15:55:46 +1100 Subject: [PATCH 142/147] Inject non-spec builtin values only if defined --- codegen/config/config.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/codegen/config/config.go b/codegen/config/config.go index 7b175be4d6c..7a7232b58d9 100644 --- a/codegen/config/config.go +++ b/codegen/config/config.go @@ -342,8 +342,6 @@ func (c *Config) InjectBuiltins(s *ast.Schema) { "Float": {Model: StringList{"github.com/99designs/gqlgen/graphql.Float"}}, "String": {Model: StringList{"github.com/99designs/gqlgen/graphql.String"}}, "Boolean": {Model: StringList{"github.com/99designs/gqlgen/graphql.Boolean"}}, - "Time": {Model: StringList{"github.com/99designs/gqlgen/graphql.Time"}}, - "Map": {Model: StringList{"github.com/99designs/gqlgen/graphql.Map"}}, "Int": {Model: StringList{ "github.com/99designs/gqlgen/graphql.Int", "github.com/99designs/gqlgen/graphql.Int32", @@ -362,6 +360,18 @@ func (c *Config) InjectBuiltins(s *ast.Schema) { c.Models[typeName] = entry } } + + // These are additional types that are injected if defined in the schema as scalars. + extraBuiltins := TypeMap{ + "Time": {Model: StringList{"github.com/99designs/gqlgen/graphql.Time"}}, + "Map": {Model: StringList{"github.com/99designs/gqlgen/graphql.Map"}}, + } + + for typeName, entry := range extraBuiltins { + if t, ok := s.Types[typeName]; ok && t.Kind == ast.Scalar { + c.Models[typeName] = entry + } + } } func (c *Config) LoadSchema() (*ast.Schema, map[string]string, error) { From d27e6eb65e8fb62ac9893c2992157a5050923c57 Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Mon, 18 Mar 2019 16:01:44 +1100 Subject: [PATCH 143/147] Add example case for object type overriding builtin scalar --- codegen/testserver/builtinscalar.graphql | 8 +++ codegen/testserver/generated.go | 74 ++++++++++++++++++++++++ codegen/testserver/models-gen.go | 6 ++ 3 files changed, 88 insertions(+) create mode 100644 codegen/testserver/builtinscalar.graphql diff --git a/codegen/testserver/builtinscalar.graphql b/codegen/testserver/builtinscalar.graphql new file mode 100644 index 00000000000..deb8a9f6242 --- /dev/null +++ b/codegen/testserver/builtinscalar.graphql @@ -0,0 +1,8 @@ + +""" +Since gqlgen defines default implementation for a Map scalar, this tests that the builtin is _not_ +added to the TypeMap +""" +type Map { + id: ID! +} diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index caa65855d79..f7b527d82fa 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -117,6 +117,10 @@ type ComplexityRoot struct { ID func(childComplexity int) int } + Map struct { + ID func(childComplexity int) int + } + MapStringInterfaceType struct { A func(childComplexity int) int B func(childComplexity int) int @@ -445,6 +449,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.It.ID(childComplexity), true + case "Map.ID": + if e.complexity.Map.ID == nil { + break + } + + return e.complexity.Map.ID(childComplexity), true + case "MapStringInterfaceType.A": if e.complexity.MapStringInterfaceType.A == nil { break @@ -1088,6 +1099,15 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er } var parsedSchema = gqlparser.MustLoadSchema( + &ast.Source{Name: "builtinscalar.graphql", Input: ` +""" +Since gqlgen defines default implementation for a Map scalar, this tests that the builtin is _not_ +added to the TypeMap +""" +type Map { + id: ID! +} +`}, &ast.Source{Name: "complexity.graphql", Input: `extend type Query { overlapping: OverlappingFields } @@ -2543,6 +2563,33 @@ func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedF return ec.marshalNID2string(ctx, field.Selections, res) } +func (ec *executionContext) _Map_id(ctx context.Context, field graphql.CollectedField, obj *Map) graphql.Marshaler { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "Map", + Field: field, + Args: nil, + IsMethod: false, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNID2string(ctx, field.Selections, res) +} + func (ec *executionContext) _MapStringInterfaceType_a(ctx context.Context, field graphql.CollectedField, obj map[string]interface{}) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() @@ -5927,6 +5974,33 @@ func (ec *executionContext) _It(ctx context.Context, sel ast.SelectionSet, obj * return out } +var mapImplementors = []string{"Map"} + +func (ec *executionContext) _Map(ctx context.Context, sel ast.SelectionSet, obj *Map) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, mapImplementors) + + out := graphql.NewFieldSet(fields) + invalid := false + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Map") + case "id": + out.Values[i] = ec._Map_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + return out +} + var mapStringInterfaceTypeImplementors = []string{"MapStringInterfaceType"} func (ec *executionContext) _MapStringInterfaceType(ctx context.Context, sel ast.SelectionSet, obj map[string]interface{}) graphql.Marshaler { diff --git a/codegen/testserver/models-gen.go b/codegen/testserver/models-gen.go index 25f8522713b..c1331c1dba3 100644 --- a/codegen/testserver/models-gen.go +++ b/codegen/testserver/models-gen.go @@ -56,6 +56,12 @@ type InputDirectives struct { ThirdParty *ThirdParty `json:"thirdParty"` } +// Since gqlgen defines default implementation for a Map scalar, this tests that the builtin is _not_ +// added to the TypeMap +type Map struct { + ID string `json:"id"` +} + type OuterInput struct { Inner InnerInput `json:"inner"` } From d10e048e5be9ec34451a8c180d19cbcdcedc753c Mon Sep 17 00:00:00 2001 From: Mathew Byrne Date: Mon, 18 Mar 2019 16:24:43 +1100 Subject: [PATCH 144/147] Add docs for built-in scalar implementations --- docs/content/reference/scalars.md | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/docs/content/reference/scalars.md b/docs/content/reference/scalars.md index 961cd748c07..ec9a9fcf0b6 100644 --- a/docs/content/reference/scalars.md +++ b/docs/content/reference/scalars.md @@ -1,14 +1,32 @@ --- -linkTitle: Custom Scalars -title: Using custom graphql types in golang -description: Defining custom GraphQL scalar types using gqlgen +linkTitle: Scalars +title: Mapping GraphQL scalar types to Go types +description: Mapping GraphQL scalar types to Go types menu: { main: { parent: 'reference' } } --- -There are two different ways to implement scalars in gqlgen, depending on your need. +## Built-in helpers +gqlgen ships with two built-in helpers for common custom scalar use-cases, `Time` and `Map`. Adding either of these to a schema will automatically add the marshalling behaviour to Go types. + +### Time + +```graphql +scalar Time +``` + +Maps a `Time` GraphQL scalar to a Go `time.Time` struct. + +### Map + +```graphql +scalar Map +``` + +Maps an arbitrary GraphQL value to a `map[string]{interface}` Go type. + +## Custom scalars with user defined types -## With user defined types For user defined types you can implement the graphql.Marshal and graphql.Unmarshal interfaces and they will be called. ```go @@ -55,7 +73,7 @@ models: ``` -## Custom scalars for types you don't control +## Custom scalars with third party types Sometimes you cant add methods to a type because its in another repo, part of the standard library (eg string or time.Time). To do this we can build an external marshaler: From 52624e5372f260077e90645732dd24b8d1fad317 Mon Sep 17 00:00:00 2001 From: Antek Baranski <3769441+Sauraus@users.noreply.github.com> Date: Thu, 21 Mar 2019 13:13:15 -0700 Subject: [PATCH 145/147] Fix Gin installation instruction Current `go get gin` instruction results in an error from Go: `package gin: unrecognized import path "gin" (import path does not begin with hostname)` --- docs/content/recipes/gin.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/recipes/gin.md b/docs/content/recipes/gin.md index 01b048ded41..fb4e4456892 100644 --- a/docs/content/recipes/gin.md +++ b/docs/content/recipes/gin.md @@ -13,7 +13,7 @@ Here are the steps to setup Gin and gqlgen together: Install Gin: ```bash -$ go get gin +$ go get github.com/gin-gonic/gin ``` In your router file, define the handlers for the GraphQL and Playground endpoints in two different methods and tie then together in the Gin router: From 055157f979f06a490979726db7ec20d8d9a634d4 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Wed, 27 Mar 2019 13:38:24 +1100 Subject: [PATCH 146/147] Update ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 89f1be95e27..37f1dd60500 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,5 +1,10 @@ -### Expected Behaviour +### What happened? -### Actual Behavior +### What did you expect? ### Minimal graphql.schema and models to reproduce + +### versions +`gqlgen version`? +`go version`? +dep or go modules? From 7b533df1a00be66e2ebe7a4268add80a5aa123e1 Mon Sep 17 00:00:00 2001 From: Adam Scarr Date: Wed, 27 Mar 2019 13:38:52 +1100 Subject: [PATCH 147/147] Update ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 37f1dd60500..1b9e422f96d 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -5,6 +5,6 @@ ### Minimal graphql.schema and models to reproduce ### versions -`gqlgen version`? -`go version`? -dep or go modules? + - `gqlgen version`? + - `go version`? + - dep or go modules?