diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 89f1be95e27..1b9e422f96d 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? diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000000..461709ecf8e --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,27 @@ +# Contribution Guidelines + +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. diff --git a/README.md b/README.md index 708f66127d1..0b302bdd55e 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,31 @@ # 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](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. + +## 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. + +## 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/) + - [GraphQL workshop for Golang developers by Iván Corrales Solera](https://graphql-go.wesovilabs.com) 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 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 { 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) 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/config/binder.go b/codegen/config/binder.go index 15e456c52e1..5e8c1cf6969 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 } } @@ -153,31 +158,26 @@ 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) 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 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 { @@ -185,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, } } @@ -195,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 @@ -208,6 +212,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 @@ -246,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 { @@ -392,11 +365,27 @@ 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() } - 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 { @@ -411,14 +400,52 @@ 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)) + } + + var isInterface bool + if named, ok := base.(*types.Named); ok { + _, isInterface = named.Underlying().(*types.Interface) } - if !t.NonNull && usePtr { + if !isInterface && !t.NonNull { return types.NewPointer(base) } 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/config/config.go b/codegen/config/config.go index 49f7ad90c5c..e23d7e9c689 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)) } } @@ -339,12 +339,14 @@ 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", + }}, "Upload": {Model: StringList{"github.com/99designs/gqlgen/graphql.Upload"}}, "ID": { Model: StringList{ @@ -359,6 +361,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) { diff --git a/codegen/data.go b/codegen/data.go index df1188b75a4..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 @@ -62,9 +63,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/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..9718a08aadf 100644 --- a/codegen/field.gotpl +++ b/codegen/field.gotpl @@ -37,13 +37,14 @@ } } {{ 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{ Object: {{$object.Name|quote}}, Field: field, Args: nil, + IsMethod: {{or $field.IsMethod $field.IsResolver}}, } ctx = graphql.WithResolverContext(ctx, rctx) {{- if $field.Args }} @@ -60,6 +61,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/generated!.gotpl b/codegen/generated!.gotpl index ca9e754929e..dce8ce977c7 100644 --- a/codegen/generated!.gotpl +++ b/codegen/generated!.gotpl @@ -45,8 +45,8 @@ type DirectiveRoot struct { type ComplexityRoot struct { {{ range $object := .Objects }} {{ if not $object.IsReserved -}} - {{ $object.Name|toCamel }} struct { - {{ range $field := $object.Fields -}} + {{ $object.Name|go }} struct { + {{ range $field := $object.UniqueFields -}} {{ if not $field.IsReserved -}} {{ $field.GoFieldName }} {{ $field.ComplexitySignature }} {{ end }} @@ -84,10 +84,10 @@ 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|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/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/templates/templates.go b/codegen/templates/templates.go index 8522824e5c9..9d45b6718ef 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,41 +227,116 @@ func Call(p *types.Func) string { return pkg + p.Name() } -func ToCamel(s string) string { - if s == "_" { - return "_" - } - buffer := make([]rune, 0, len(s)) - upper := true - lastWasUpper := false - - for _, c := range s { - if isDelimiter(c) { - upper = true - continue - } - if !lastWasUpper && unicode.IsUpper(c) { - upper = true +func ToGo(name string) string { + runes := make([]rune, 0, len(name)) + + wordWalker(name, func(info *wordInfo) { + word := info.Word + if info.MatchCommonInitial { + word = strings.ToUpper(word) + } else if !info.HasCommonInitial { + 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)...) + }) + + return string(runes) +} - if upper { - buffer = append(buffer, unicode.ToUpper(c)) - } else { - buffer = append(buffer, unicode.ToLower(c)) +func ToGoPrivate(name string) string { + runes := make([]rune, 0, len(name)) + + first := true + wordWalker(name, func(info *wordInfo) { + word := info.Word + if first { + 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) + } else if !info.HasCommonInitial { + word = ucFirst(strings.ToLower(word)) } - upper = false - lastWasUpper = unicode.IsUpper(c) - } + runes = append(runes, []rune(word)...) + }) - return string(buffer) + return sanitizeKeywords(string(runes)) } -func ToGo(name string) string { - return lintName(ToCamel(name)) +type wordInfo struct { + Word string + MatchCommonInitial bool + HasCommonInitial bool } -func ToGoPrivate(name string) string { - return lintName(sanitizeKeywords(lcFirst(ToCamel(name)))) +// 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)) { + 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 isDelimiter(runes[i+1]) { + // underscore; shift the remainder forward over any run of underscores + eow = true + n := 1 + for i+n+1 < len(runes) && isDelimiter(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++ + + // [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 + } + + matchCommonInitial := false + if commonInitialisms[strings.ToUpper(word)] { + hasCommonInitial = true + matchCommonInitial = true + } + + f(&wordInfo{ + Word: word, + MatchCommonInitial: matchCommonInitial, + HasCommonInitial: hasCommonInitial, + }) + hasCommonInitial = false + w = i + } } var keywords = []string{ @@ -304,74 +378,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. diff --git a/codegen/templates/templates_test.go b/codegen/templates/templates_test.go index 31f518b4bcc..1e6beb20eea 100644 --- a/codegen/templates/templates_test.go +++ b/codegen/templates/templates_test.go @@ -6,12 +6,93 @@ import ( "github.com/stretchr/testify/require" ) -func TestToUpper(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")) +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, "ID", ToGo("id")) + 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) { + 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, "relatedUrls", ToGoPrivate("RelatedUrls")) + require.Equal(t, "iTicket", ToGoPrivate("ITicket")) + + require.Equal(t, "rangeArg", ToGoPrivate("Range")) + + 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) { + + helper := func(str string) []*wordInfo { + resultList := []*wordInfo{} + wordWalker(str, func(info *wordInfo) { + resultList = append(resultList, info) + }) + return resultList + } + + 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")) + require.Equal(t, []*wordInfo{{Word: "ITicket"}}, helper("ITicket")) } func TestCenter(t *testing.T) { 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/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/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/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 5be09523697..7b9c87a1f44 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 @@ -47,15 +48,45 @@ 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) } type ComplexityRoot struct { + A struct { + ID func(childComplexity int) int + } + + AIt struct { + ID func(childComplexity int) int + } + + AbIt struct { + ID func(childComplexity int) int + } + + 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 + } + + B struct { + ID func(childComplexity int) int + } + Circle struct { - Radius func(childComplexity int) int Area func(childComplexity int) int + Radius func(childComplexity int) int + } + + EmbeddedDefaultScalar struct { + Value func(childComplexity int) int } EmbeddedPointer struct { @@ -64,9 +95,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 } @@ -86,9 +117,18 @@ 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 + } + ModelMethods struct { - ResolverField func(childComplexity int) int NoContext func(childComplexity int) int + ResolverField func(childComplexity int) int WithContext func(childComplexity int) int } @@ -96,58 +136,96 @@ 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 + DefaultScalar func(childComplexity int, arg string) int + DeprecatedField func(childComplexity int) int + DirectiveArg func(childComplexity int, arg string) 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 + 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 - Recursive func(childComplexity int, input *RecursiveInputSlice) 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 - 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 - InputSlice func(childComplexity int, arg []string) int - ShapeUnion func(childComplexity int) int + OptionalUnion func(childComplexity int) int + Overlapping func(childComplexity int) int Panics func(childComplexity int) 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 { + 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 + 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 { + 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 } } @@ -157,6 +235,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) @@ -179,9 +260,18 @@ 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) + 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) + 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) } type SubscriptionResolver interface { @@ -207,12 +297,68 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { - case "Circle.Radius": - if e.complexity.Circle.Radius == nil { + case "A.ID": + if e.complexity.A.ID == nil { break } - return e.complexity.Circle.Radius(childComplexity), true + return e.complexity.A.ID(childComplexity), true + + 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.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 + } + + 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 "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 { @@ -221,6 +367,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Circle.Area(childComplexity), true + case "Circle.Radius": + if e.complexity.Circle.Radius == nil { + break + } + + return e.complexity.Circle.Radius(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 @@ -235,13 +395,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 @@ -256,6 +409,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 @@ -291,12 +451,26 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.It.ID(childComplexity), true - case "ModelMethods.ResolverField": - if e.complexity.ModelMethods.ResolverField == nil { + case "Map.ID": + if e.complexity.Map.ID == nil { break } - return e.complexity.ModelMethods.ResolverField(childComplexity), true + return e.complexity.Map.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.NoContext": if e.complexity.ModelMethods.NoContext == nil { @@ -305,6 +479,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.ModelMethods.NoContext(childComplexity), true + case "ModelMethods.ResolverField": + if e.complexity.ModelMethods.ResolverField == nil { + break + } + + return e.complexity.ModelMethods.ResolverField(childComplexity), true + case "ModelMethods.WithContext": if e.complexity.ModelMethods.WithContext == nil { break @@ -319,24 +500,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 { @@ -350,181 +533,231 @@ 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 { + case "Panics.FieldFuncMarshal": + if e.complexity.Panics.FieldFuncMarshal == nil { break } - return e.complexity.Query.InvalidIdentifier(childComplexity), true - - case "Query.Collision": - if e.complexity.Query.Collision == nil { - break + args, err := ec.field_Panics_fieldFuncMarshal_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - return e.complexity.Query.Collision(childComplexity), true + return e.complexity.Panics.FieldFuncMarshal(childComplexity, args["u"].([]MarshalPanic)), true - case "Query.MapInput": - if e.complexity.Query.MapInput == nil { + case "Panics.FieldScalarMarshal": + if e.complexity.Panics.FieldScalarMarshal == nil { break } - args, err := ec.field_Query_mapInput_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.FieldScalarMarshal(childComplexity), true - case "Query.Recursive": - if e.complexity.Query.Recursive == nil { + case "Query.Autobind": + if e.complexity.Query.Autobind == nil { break } - args, err := ec.field_Query_recursive_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + return e.complexity.Query.Autobind(childComplexity), true + + case "Query.Collision": + if e.complexity.Query.Collision == nil { + break } - return e.complexity.Query.Recursive(childComplexity, args["input"].(*RecursiveInputSlice)), true + return e.complexity.Query.Collision(childComplexity), true - case "Query.NestedInputs": - if e.complexity.Query.NestedInputs == nil { + case "Query.DefaultScalar": + if e.complexity.Query.DefaultScalar == nil { break } - args, err := ec.field_Query_nestedInputs_args(context.TODO(), rawArgs) + args, err := ec.field_Query_defaultScalar_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.NestedInputs(childComplexity, args["input"].([][]*OuterInput)), true + return e.complexity.Query.DefaultScalar(childComplexity, args["arg"].(string)), true - case "Query.NestedOutputs": - if e.complexity.Query.NestedOutputs == nil { + case "Query.DeprecatedField": + if e.complexity.Query.DeprecatedField == nil { break } - return e.complexity.Query.NestedOutputs(childComplexity), true + return e.complexity.Query.DeprecatedField(childComplexity), true - case "Query.Shapes": - if e.complexity.Query.Shapes == nil { + case "Query.DirectiveArg": + if e.complexity.Query.DirectiveArg == nil { break } - return e.complexity.Query.Shapes(childComplexity), true - - case "Query.ErrorBubble": - if e.complexity.Query.ErrorBubble == nil { - break + args, err := ec.field_Query_directiveArg_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - return e.complexity.Query.ErrorBubble(childComplexity), true + return e.complexity.Query.DirectiveArg(childComplexity, args["arg"].(string)), true - case "Query.ModelMethods": - if e.complexity.Query.ModelMethods == nil { + case "Query.DirectiveInput": + if e.complexity.Query.DirectiveInput == nil { break } - return e.complexity.Query.ModelMethods(childComplexity), true - - case "Query.Valid": - if e.complexity.Query.Valid == nil { - break + args, err := ec.field_Query_directiveInput_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - return e.complexity.Query.Valid(childComplexity), true + return e.complexity.Query.DirectiveInput(childComplexity, args["arg"].(InputDirectives)), true - case "Query.User": - if e.complexity.Query.User == nil { + case "Query.DirectiveInputNullable": + if e.complexity.Query.DirectiveInputNullable == nil { break } - args, err := ec.field_Query_user_args(context.TODO(), rawArgs) + args, err := ec.field_Query_directiveInputNullable_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.User(childComplexity, args["id"].(int)), true + return e.complexity.Query.DirectiveInputNullable(childComplexity, args["arg"].(*InputDirectives)), true - case "Query.NullableArg": - if e.complexity.Query.NullableArg == nil { + case "Query.DirectiveInputType": + if e.complexity.Query.DirectiveInputType == nil { break } - args, err := ec.field_Query_nullableArg_args(context.TODO(), rawArgs) + args, err := ec.field_Query_directiveInputType_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.NullableArg(childComplexity, args["arg"].(*int)), true + return e.complexity.Query.DirectiveInputType(childComplexity, args["arg"].(InnerInput)), true - case "Query.DirectiveArg": - if e.complexity.Query.DirectiveArg == nil { + case "Query.DirectiveNullableArg": + if e.complexity.Query.DirectiveNullableArg == nil { break } - args, err := ec.field_Query_directiveArg_args(context.TODO(), rawArgs) + args, err := ec.field_Query_directiveNullableArg_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.DirectiveArg(childComplexity, args["arg"].(string)), true + return e.complexity.Query.DirectiveNullableArg(childComplexity, args["arg"].(*int), args["arg2"].(*int)), true - case "Query.DirectiveNullableArg": - if e.complexity.Query.DirectiveNullableArg == nil { + case "Query.ErrorBubble": + if e.complexity.Query.ErrorBubble == nil { break } - args, err := ec.field_Query_directiveNullableArg_args(context.TODO(), rawArgs) + 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.DirectiveNullableArg(childComplexity, args["arg"].(*int), args["arg2"].(*int)), true + return e.complexity.Query.Fallback(childComplexity, args["arg"].(FallbackToStringEncoding)), true - case "Query.DirectiveInputNullable": - if e.complexity.Query.DirectiveInputNullable == nil { + case "Query.InputSlice": + if e.complexity.Query.InputSlice == nil { break } - args, err := ec.field_Query_directiveInputNullable_args(context.TODO(), rawArgs) + args, err := ec.field_Query_inputSlice_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.DirectiveInputNullable(childComplexity, args["arg"].(*InputDirectives)), true + return e.complexity.Query.InputSlice(childComplexity, args["arg"].([]string)), true - case "Query.DirectiveInput": - if e.complexity.Query.DirectiveInput == nil { + case "Query.InvalidIdentifier": + if e.complexity.Query.InvalidIdentifier == nil { break } - args, err := ec.field_Query_directiveInput_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.DirectiveInput(childComplexity, args["arg"].(InputDirectives)), 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.NestedInputs": + if e.complexity.Query.NestedInputs == 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 + + case "Query.NestedOutputs": + if e.complexity.Query.NestedOutputs == nil { + break + } + + return e.complexity.Query.NestedOutputs(childComplexity), true + + case "Query.NullableArg": + if e.complexity.Query.NullableArg == nil { + break + } + + args, err := ec.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.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 + } + + return e.complexity.Query.Overlapping(childComplexity), true case "Query.Panics": if e.complexity.Query.Panics == nil { @@ -533,6 +766,58 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Panics(childComplexity), true + case "Query.Recursive": + if e.complexity.Query.Recursive == 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 + + 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 { + break + } + + 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 @@ -540,6 +825,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 @@ -554,19 +846,33 @@ 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 { + case "Slices.Test1": + if e.complexity.Slices.Test1 == nil { break } - return e.complexity.Rectangle.Area(childComplexity), true + return e.complexity.Slices.Test1(childComplexity), true - case "Subscription.Updated": - if e.complexity.Subscription.Updated == nil { + case "Slices.Test2": + if e.complexity.Slices.Test2 == nil { break } - return e.complexity.Subscription.Updated(childComplexity), true + 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.InitPayload": if e.complexity.Subscription.InitPayload == nil { @@ -575,12 +881,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Subscription.InitPayload(childComplexity), true - case "User.ID": - if e.complexity.User.ID == nil { + case "Subscription.Updated": + if e.complexity.Subscription.Updated == nil { break } - return e.complexity.User.ID(childComplexity), true + return e.complexity.Subscription.Updated(childComplexity), true + + case "User.Created": + if e.complexity.User.Created == nil { + break + } + + return e.complexity.User.Created(childComplexity), true case "User.Friends": if e.complexity.User.Friends == nil { @@ -589,12 +902,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 { @@ -617,6 +930,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.ValidType.DifferentCaseOld(childComplexity), 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 + case "ValidType.ValidInputKeywords": if e.complexity.ValidType.ValidInputKeywords == nil { break @@ -629,17 +954,33 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.ValidType.ValidInputKeywords(childComplexity, args["input"].(*ValidInput)), true - case "ValidType.ValidArgs": - if e.complexity.ValidType.ValidArgs == nil { + case "XXIt.ID": + if e.complexity.XXIt.ID == nil { break } - args, err := ec.field_ValidType_validArgs_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + return e.complexity.XXIt.ID(childComplexity), true + + case "XxIt.ID": + if e.complexity.XxIt.ID == nil { + break } - 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.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 @@ -714,6 +1055,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) @@ -765,6 +1113,41 @@ 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 +} + +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 +} + +type MapStringInterfaceType { + a: String + b: Int +} + +input MapStringInterfaceInput { + a: String + b: Int +} +`}, &ast.Source{Name: "panics.graphql", Input: `extend type Query { panics: Panics } @@ -777,6 +1160,17 @@ 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 + +type EmbeddedDefaultScalar { + value: DefaultScalarImplementation +} `}, &ast.Source{Name: "schema.graphql", Input: `type Query { invalidIdentifier: InvalidIdentifier @@ -795,8 +1189,11 @@ scalar MarshalPanic 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 + deprecatedField: String! @deprecated(reason: "test deprecated directive") } type Subscription { @@ -811,6 +1208,15 @@ type User { updated: Time } +type Autobind { + int: Int! + int32: Int! + int64: Int! + + idStr: ID! + idInt: ID! +} + type Error { id: ID! errorOnNonRequiredField: String @@ -895,6 +1301,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 @@ -902,6 +1309,41 @@ 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: "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! +} + +type B { + id: ID! +} + +union TestUnion = A | B + +extend type Query { + optionalUnion: TestUnion +} `}, &ast.Source{Name: "validtypes.graphql", Input: `extend type Query { validType: ValidType @@ -971,6 +1413,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! } `}, ) @@ -1064,12 +1515,26 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs return args, nil } -func (ec *executionContext) field_Query_directiveArg_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +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 { - getArg0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalNString2string(ctx, tmp) } + 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{}{} + var arg0 string + if tmp, ok := rawArgs["arg"]; ok { + 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 @@ -1104,6 +1569,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{}{} @@ -1164,6 +1656,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{}{} @@ -1192,6 +1698,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{}{} @@ -1508,13 +2028,257 @@ 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) }() + rctx := &graphql.ResolverContext{ + Object: "AIt", + 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) _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, + 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) _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, + 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.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, + 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.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, + 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.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, + 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.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, + 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.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) _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) }() 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) @@ -1525,94 +2289,668 @@ func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.Co if resTmp == nil { return graphql.Null } - res := resTmp.(float64) + res := resTmp.(float64) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalOFloat2float64(ctx, field.Selections, res) +} + +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, + 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 obj.Area(), nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(float64) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + 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, + 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.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) }() + rctx := &graphql.ResolverContext{ + Object: "EmbeddedPointer", + 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 { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalOString2string(ctx, field.Selections, res) +} + +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, + 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.Title, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalOString2string(ctx, field.Selections, res) +} + +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, + 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) _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, + 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 obj.ErrorOnNonRequiredField() + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalOString2string(ctx, field.Selections, res) +} + +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, + 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 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 ec.marshalNString2string(ctx, field.Selections, res) +} + +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, + 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 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) + return ec.marshalNString2ᚖstring(ctx, field.Selections, res) +} + +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, + 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.ForcedResolver().Field(rctx, obj) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*Circle) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + 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 { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { ec.Tracer.EndFieldExecution(ctx) }() + rctx := &graphql.ResolverContext{ + Object: "InnerObject", + 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.(int) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +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, + 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.(int) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +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{ + Object: "It", + 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) _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) }() + rctx := &graphql.ResolverContext{ + Object: "MapStringInterfaceType", + 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 + 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, + 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 + 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) }() + rctx := &graphql.ResolverContext{ + Object: "ModelMethods", + 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.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 ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +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, + 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 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 ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +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, + 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 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 ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +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, + 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.Inner, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(InnerObject) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + 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.marshalOFloat2float64(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.CollectedField, obj *Circle) graphql.Marshaler { +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: "Circle", - Field: field, - Args: nil, + 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 obj.Area(), nil + 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.(float64) + res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOFloat2float64(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) _EmbeddedPointer_ID(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) graphql.Marshaler { +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: "EmbeddedPointer", - Field: field, - Args: nil, + 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.ID, nil + return obj.NewFoo, 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 ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) _EmbeddedPointer_Title(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) graphql.Marshaler { +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: "EmbeddedPointer", - Field: field, - Args: nil, + 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.Title, nil + return obj.NewFoo, 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 ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) _Error_id(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { +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: "Error", - Field: field, - Args: nil, + Object: "Panics", + 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 obj.ID, nil + return ec.resolvers.Panics().FieldScalarMarshal(rctx, obj) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1620,48 +2958,67 @@ func (ec *executionContext) _Error_id(ctx context.Context, field graphql.Collect } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]MarshalPanic) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNID2string(ctx, field.Selections, res) + return ec.marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanic(ctx, field.Selections, res) } -func (ec *executionContext) _Error_errorOnNonRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { +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: "Error", - Field: field, - Args: nil, + Object: "Panics", + Field: field, + Args: nil, + IsMethod: true, } 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.ErrorOnNonRequiredField() + 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.(string) + res := resTmp.([]MarshalPanic) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanic(ctx, field.Selections, res) } -func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { +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: "Error", - Field: field, - Args: nil, + Object: "Panics", + Field: field, + Args: nil, + IsMethod: true, } 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 obj.ErrorOnRequiredField() + return ec.resolvers.Panics().ArgUnmarshal(rctx, obj, args["u"].([]MarshalPanic)) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1669,256 +3026,263 @@ func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, fie } return graphql.Null } - res := resTmp.(string) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _Error_nilOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) graphql.Marshaler { +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: "Error", - Field: field, - Args: nil, + Object: "Query", + 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) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.NilOnRequiredField(), nil + return ec.resolvers.Query().InvalidIdentifier(rctx) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*invalid_packagename.InvalidIdentifier) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOInvalidIdentifier2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx, field.Selections, res) } -func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field graphql.CollectedField, obj *ForcedResolver) graphql.Marshaler { +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: "ForcedResolver", - Field: field, - Args: nil, + Object: "Query", + 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) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.ForcedResolver().Field(rctx, obj) + return ec.resolvers.Query().Collision(rctx) }) if resTmp == nil { return graphql.Null } - res := resTmp.(*Circle) + res := resTmp.(*introspection1.It) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOCircle2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCircle(ctx, field.Selections, res) + return ec.marshalOIt2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋintrospectionᚐIt(ctx, field.Selections, res) } -func (ec *executionContext) _InnerObject_id(ctx context.Context, field graphql.CollectedField, obj *InnerObject) graphql.Marshaler { +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: "InnerObject", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } 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, 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.resolvers.Query().MapInput(rctx, args["input"].(map[string]interface{})) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(int) + res := resTmp.(*bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) } -func (ec *executionContext) _InvalidIdentifier_id(ctx context.Context, field graphql.CollectedField, obj *invalid_packagename.InvalidIdentifier) graphql.Marshaler { +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: "InvalidIdentifier", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } 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, 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.resolvers.Query().Recursive(rctx, args["input"].(*RecursiveInputSlice)) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(int) + res := resTmp.(*bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) } -func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedField, obj *introspection1.It) graphql.Marshaler { +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: "It", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } 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, 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.resolvers.Query().NestedInputs(rctx, args["input"].([][]*OuterInput)) }) 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 ec.marshalNID2string(ctx, field.Selections, res) + return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) } -func (ec *executionContext) _ModelMethods_resolverField(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) graphql.Marshaler { +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: "ModelMethods", - Field: field, - Args: nil, + Object: "Query", + 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) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.ModelMethods().ResolverField(rctx, obj) + return ec.resolvers.Query().NestedOutputs(rctx) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } 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) _ModelMethods_noContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) graphql.Marshaler { +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: "ModelMethods", - Field: field, - Args: nil, + Object: "Query", + 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) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.NoContext(), nil + return ec.resolvers.Query().Shapes(rctx) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.([]Shape) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx, field.Selections, res) } -func (ec *executionContext) _ModelMethods_withContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) graphql.Marshaler { +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: "ModelMethods", - Field: field, - Args: nil, + Object: "Query", + 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) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.WithContext(ctx), nil + return ec.resolvers.Query().ErrorBubble(rctx) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*Error) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx, field.Selections, res) } -func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphql.CollectedField, obj *OuterObject) graphql.Marshaler { +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: "OuterObject", - Field: field, - Args: nil, + Object: "Query", + 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) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Inner, nil + return ec.resolvers.Query().ModelMethods(rctx) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(InnerObject) + res := resTmp.(*ModelMethods) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNInnerObject2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerObject(ctx, field.Selections, res) + return ec.marshalOModelMethods2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐModelMethods(ctx, field.Selections, res) } -func (ec *executionContext) _Panics_fieldScalarMarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) graphql.Marshaler { +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: "Panics", - Field: field, - Args: nil, + Object: "Query", + 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) { + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Panics().FieldScalarMarshal(rctx, obj) + return ec.resolvers.Query().Valid(rctx) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1926,32 +3290,33 @@ func (ec *executionContext) _Panics_fieldScalarMarshal(ctx context.Context, fiel } return graphql.Null } - res := resTmp.([]MarshalPanic) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanic(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Panics_fieldFuncMarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) graphql.Marshaler { +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: "Panics", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Panics_fieldFuncMarshal_args(ctx, rawArgs) + 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, 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.FieldFuncMarshal(ctx, args["u"].([]MarshalPanic)), nil + return ec.resolvers.Query().User(rctx, args["id"].(int)) }) if resTmp == nil { if !ec.HasError(rctx) { @@ -1959,102 +3324,117 @@ func (ec *executionContext) _Panics_fieldFuncMarshal(ctx context.Context, field } return graphql.Null } - res := resTmp.([]MarshalPanic) + res := resTmp.(*User) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanic(ctx, field.Selections, res) + return ec.marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) _Panics_argUnmarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) graphql.Marshaler { +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: "Panics", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Panics_argUnmarshal_args(ctx, rawArgs) + 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, 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.Panics().ArgUnmarshal(rctx, obj, args["u"].([]MarshalPanic)) + return ec.resolvers.Query().NullableArg(rctx, args["arg"].(*int)) }) 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 ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +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, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } 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().InvalidIdentifier(rctx) + return ec.resolvers.Query().DirectiveArg(rctx, args["arg"].(string)) }) if resTmp == nil { return graphql.Null } - res := resTmp.(*invalid_packagename.InvalidIdentifier) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOInvalidIdentifier2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _Query_collision(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +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, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } 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().Collision(rctx) + return ec.resolvers.Query().DirectiveNullableArg(rctx, args["arg"].(*int), args["arg2"].(*int)) }) if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection1.It) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOIt2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋintrospectionᚐIt(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +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, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_mapInput_args(ctx, rawArgs) + args, err := ec.field_Query_directiveInputNullable_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -2063,28 +3443,29 @@ 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().DirectiveInputNullable(rctx, args["arg"].(*InputDirectives)) }) if resTmp == nil { return graphql.Null } - res := resTmp.(*bool) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +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, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_recursive_args(ctx, rawArgs) + args, err := ec.field_Query_directiveInput_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -2093,28 +3474,29 @@ func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql. 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)) + return ec.resolvers.Query().DirectiveInput(rctx, args["arg"].(InputDirectives)) }) if resTmp == nil { return graphql.Null } - res := resTmp.(*bool) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +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, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_nestedInputs_args(ctx, rawArgs) + args, err := ec.field_Query_directiveInputType_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -2123,146 +3505,165 @@ func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graph 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)) + return ec.resolvers.Query().DirectiveInputType(rctx, args["arg"].(InnerInput)) }) if resTmp == nil { return graphql.Null } - res := resTmp.(*bool) + res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +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, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } 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().NestedOutputs(rctx) + 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.([][]*OuterObject) + res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOOuterObject2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +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, + 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().Shapes(rctx) + 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.([]Shape) + res := resTmp.(ShapeUnion) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx, field.Selections, res) + return ec.marshalNShapeUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShapeUnion(ctx, field.Selections, res) } -func (ec *executionContext) _Query_errorBubble(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +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, + 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().ErrorBubble(rctx) + return ec.resolvers.Query().Autobind(rctx) }) if resTmp == nil { return graphql.Null } - res := resTmp.(*Error) + res := resTmp.(*Autobind) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx, field.Selections, res) + return ec.marshalOAutobind2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐAutobind(ctx, field.Selections, res) } -func (ec *executionContext) _Query_modelMethods(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +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, + 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().ModelMethods(rctx) + 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.(*ModelMethods) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOModelMethods2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐModelMethods(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +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, + 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().Valid(rctx) + return ec.resolvers.Query().Overlapping(rctx) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*OverlappingFields) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOOverlappingFields2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOverlappingFields(ctx, field.Selections, res) } -func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +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, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_user_args(ctx, rawArgs) + args, err := ec.field_Query_mapStringInterface_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -2271,61 +3672,53 @@ func (ec *executionContext) _Query_user(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().User(rctx, args["id"].(int)) + return ec.resolvers.Query().MapStringInterface(rctx, args["in"].(map[string]interface{})) }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(*User) + res := resTmp.(map[string]interface{}) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx, field.Selections, res) + return ec.marshalOMapStringInterfaceType2map(ctx, field.Selections, res) } -func (ec *executionContext) _Query_nullableArg(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +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, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } 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)) + return ec.resolvers.Query().Panics(rctx) }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*Panics) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOPanics2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPanics(ctx, field.Selections, res) } -func (ec *executionContext) _Query_directiveArg(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +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, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_directiveArg_args(ctx, rawArgs) + args, err := ec.field_Query_defaultScalar_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -2334,58 +3727,56 @@ func (ec *executionContext) _Query_directiveArg(ctx context.Context, field graph 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)) + 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) + res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNDefaultScalarImplementation2string(ctx, field.Selections, res) } -func (ec *executionContext) _Query_directiveNullableArg(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +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, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } 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)) + return ec.resolvers.Query().Slices(rctx) }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*Slices) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOSlices2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐSlices(ctx, field.Selections, res) } -func (ec *executionContext) _Query_directiveInputNullable(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +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, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_directiveInputNullable_args(ctx, rawArgs) + args, err := ec.field_Query_fallback_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -2394,58 +3785,80 @@ func (ec *executionContext) _Query_directiveInputNullable(ctx context.Context, f 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)) + 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.(*string) + res := resTmp.(FallbackToStringEncoding) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐFallbackToStringEncoding(ctx, field.Selections, res) } -func (ec *executionContext) _Query_directiveInput(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +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, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } 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) + 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 } - rctx.Args = args + 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) }() + 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().DirectiveInput(rctx, args["arg"].(InputDirectives)) + return ec.resolvers.Query().ValidType(rctx) }) if resTmp == nil { return graphql.Null } - res := resTmp.(*string) + res := resTmp.(*ValidType) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalOValidType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐValidType(ctx, field.Selections, res) } -func (ec *executionContext) _Query_inputSlice(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{ - Object: "Query", - Field: field, - Args: nil, + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_inputSlice_args(ctx, rawArgs) + args, err := ec.field_Query___type_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -2454,212 +3867,213 @@ func (ec *executionContext) _Query_inputSlice(ctx context.Context, field graphql 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)) + 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 ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) _Query_shapeUnion(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{ - 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) 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) + return ec.introspectSchema() }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(ShapeUnion) + res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalNShapeUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShapeUnion(ctx, field.Selections, res) + return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } -func (ec *executionContext) _Query_panics(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +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: "Query", - Field: field, - Args: nil, + Object: "Rectangle", + Field: field, + Args: nil, + IsMethod: false, } 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().Panics(rctx) + return obj.Length, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*Panics) + res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOPanics2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPanics(ctx, field.Selections, res) + return ec.marshalOFloat2float64(ctx, field.Selections, res) } -func (ec *executionContext) _Query_validType(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +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: "Query", - Field: field, - Args: nil, + Object: "Rectangle", + Field: field, + Args: nil, + IsMethod: false, } 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().ValidType(rctx) + return obj.Width, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*ValidType) + res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOValidType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐValidType(ctx, field.Selections, res) + return ec.marshalOFloat2float64(ctx, field.Selections, res) } -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +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: "Query", - Field: field, - Args: nil, + Object: "Rectangle", + Field: field, + Args: nil, + IsMethod: true, } 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.Area(), nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalOFloat2float64(ctx, field.Selections, res) } -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +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: "Query", - Field: field, - Args: nil, + Object: "Slices", + Field: field, + Args: nil, + IsMethod: false, } 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.Test1, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Schema) + res := resTmp.([]*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) + return ec.marshalOString2ᚕᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { +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: "Rectangle", - Field: field, - Args: nil, + 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.Length, nil + return obj.Test2, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.(float64) + res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOFloat2float64(ctx, field.Selections, res) + return ec.marshalOString2ᚕstring(ctx, field.Selections, res) } -func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { +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: "Rectangle", - Field: field, - Args: nil, + 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.Width, nil + return obj.Test3, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(float64) + res := resTmp.([]*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOFloat2float64(ctx, field.Selections, res) + return ec.marshalNString2ᚕᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.CollectedField, obj *Rectangle) graphql.Marshaler { +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: "Rectangle", - Field: field, - Args: nil, + 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.Area(), nil + return obj.Test4, nil }) if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(float64) + res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) - return ec.marshalOFloat2float64(ctx, field.Selections, res) + return ec.marshalNString2ᚕstring(ctx, field.Selections, res) } func (ec *executionContext) _Subscription_updated(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { @@ -2722,9 +4136,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) @@ -2748,9 +4163,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: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2774,9 +4190,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) @@ -2800,9 +4217,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) @@ -2823,9 +4241,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) @@ -2849,9 +4268,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) @@ -2875,9 +4295,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) @@ -2908,9 +4329,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) @@ -2937,13 +4359,68 @@ 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, + 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) _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, + 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) ___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, + Object: "__Directive", + Field: field, + Args: nil, + IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -2967,9 +4444,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) @@ -2990,9 +4468,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) @@ -3016,9 +4495,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) @@ -3042,9 +4522,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) @@ -3068,9 +4549,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) @@ -3091,9 +4573,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) @@ -3117,9 +4600,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) @@ -3140,9 +4624,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) @@ -3166,9 +4651,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) @@ -3189,9 +4675,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) @@ -3215,9 +4702,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) @@ -3241,9 +4729,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) @@ -3267,9 +4756,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) @@ -3290,9 +4780,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) @@ -3316,9 +4807,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) @@ -3339,9 +4831,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) @@ -3365,9 +4858,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) @@ -3388,9 +4882,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) @@ -3414,9 +4909,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) @@ -3440,9 +4936,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) @@ -3463,9 +4960,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) @@ -3486,9 +4984,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) @@ -3512,9 +5011,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) @@ -3538,9 +5038,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) @@ -3561,9 +5062,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) @@ -3584,9 +5086,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) @@ -3614,9 +5117,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) @@ -3637,9 +5141,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) @@ -3660,9 +5165,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) @@ -3690,9 +5196,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) @@ -3713,9 +5220,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) @@ -3732,6 +5240,60 @@ 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, + 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) _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, + 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) +} + // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** @@ -4079,10 +5641,182 @@ 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 { + 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 { + 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 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 { @@ -4109,6 +5843,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 { @@ -4288,6 +6046,59 @@ 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 { + 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 { @@ -4370,6 +6181,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 { @@ -4631,6 +6498,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) { @@ -4659,6 +6537,53 @@ 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 "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 "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) { + 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) { @@ -4670,6 +6595,56 @@ 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 "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 "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) { + 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) { @@ -4724,6 +6699,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 { @@ -4781,8 +6792,77 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj if out.Values[i] == graphql.Null { invalid = true } - case "updated": - out.Values[i] = ec._User_updated(ctx, field, obj) + case "updated": + out.Values[i] = ec._User_updated(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalid { + return graphql.Null + } + 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 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)) } @@ -4794,34 +6874,19 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj return out } -var validTypeImplementors = []string{"ValidType"} +var xxItImplementors = []string{"XxIt"} -func (ec *executionContext) _ValidType(ctx context.Context, sel ast.SelectionSet, obj *ValidType) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, validTypeImplementors) +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("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) + 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 } @@ -5077,6 +7142,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 ***************************** @@ -5089,6 +7208,31 @@ 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) 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) +} + +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 +7265,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) @@ -5204,6 +7364,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 @@ -5501,6 +7690,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) } @@ -5525,6 +7725,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 } @@ -5539,6 +7742,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) } @@ -5627,6 +7853,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) } @@ -5695,6 +7935,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 @@ -5732,6 +7975,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 @@ -5775,6 +8021,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) } @@ -5823,6 +8080,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 @@ -5859,6 +8119,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) } @@ -5867,6 +8138,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 @@ -5882,6 +8217,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) } @@ -5955,6 +8294,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 @@ -5992,6 +8334,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 @@ -6029,6 +8374,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 @@ -6081,6 +8429,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/gqlgen.yml b/codegen/testserver/gqlgen.yml index 26a1572c51e..b3e47496542 100644 --- a/codegen/testserver/gqlgen.yml +++ b/codegen/testserver/gqlgen.yml @@ -54,3 +54,17 @@ 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" + MapStringInterfaceInput: + 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 } + FallbackToStringEncoding: + model: "github.com/99designs/gqlgen/codegen/testserver.FallbackToStringEncoding" 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/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/codegen/testserver/models-gen.go b/codegen/testserver/models-gen.go index f0af1136297..c1331c1dba3 100644 --- a/codegen/testserver/models-gen.go +++ b/codegen/testserver/models-gen.go @@ -9,6 +9,34 @@ import ( "time" ) +type TestUnion interface { + IsTestUnion() +} + +type A struct { + ID string `json:"id"` +} + +func (A) IsTestUnion() {} + +type AIt struct { + ID string `json:"id"` +} + +type AbIt struct { + ID string `json:"id"` +} + +type B struct { + ID string `json:"id"` +} + +func (B) IsTestUnion() {} + +type EmbeddedDefaultScalar struct { + Value *string `json:"value"` +} + type InnerDirectives struct { Message string `json:"message"` } @@ -28,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"` } @@ -36,6 +70,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"` @@ -80,6 +121,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/models.go b/codegen/testserver/models.go index bedcb790114..3ee710a50fc 100644 --- a/codegen/testserver/models.go +++ b/codegen/testserver/models.go @@ -62,3 +62,25 @@ 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 +} + +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 565a4c6a4eb..b00e7ee0b69 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) { @@ -101,15 +110,42 @@ 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") } 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) 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") +} 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) 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") +} 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..5e3a9c08fd1 --- /dev/null +++ b/codegen/testserver/scalar_default.graphql @@ -0,0 +1,10 @@ +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 + +type EmbeddedDefaultScalar { + value: 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/schema.graphql b/codegen/testserver/schema.graphql index c400847ad97..0b135308f2a 100644 --- a/codegen/testserver/schema.graphql +++ b/codegen/testserver/schema.graphql @@ -15,8 +15,11 @@ 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 + deprecatedField: String! @deprecated(reason: "test deprecated directive") } type Subscription { @@ -31,6 +34,15 @@ type User { updated: Time } +type Autobind { + int: Int! + int32: Int! + int64: Int! + + idStr: ID! + idInt: ID! +} + type Error { id: ID! errorOnNonRequiredField: String @@ -115,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/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 1e732362073..36a100b96fc 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) @@ -37,9 +40,18 @@ 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) + 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) + 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) } SubscriptionResolver struct { @@ -57,6 +69,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} } @@ -82,6 +97,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) { @@ -141,15 +162,42 @@ 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) } 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) 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) +} 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) 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) +} func (r *stubQuery) ValidType(ctx context.Context) (*ValidType, error) { return r.QueryResolver.ValidType(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/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) +} 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/codegen/type.gotpl b/codegen/type.gotpl index ce766d3c5f8..f727baaca3c 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 }} @@ -25,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 }} @@ -40,7 +47,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)) { @@ -60,9 +67,12 @@ } {{- end }} - {{- if $type.SelfMarshalling }} - return v - {{- else if $type.IsSlice }} + {{- 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 @@ -104,14 +114,16 @@ 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.IsPtr}}&{{end}} v) + return ec._{{$type.Definition.Name}}(ctx, sel, {{ if not $type.IsNilable}}&{{end}} v) {{- end }} {{- end }} } 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/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/content/introduction.md b/docs/content/introduction.md index 1d98c9b1e1f..6ee0d144fa9 100644 --- a/docs/content/introduction.md +++ b/docs/content/introduction.md @@ -1,31 +1,6 @@ --- 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: - - - 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. - - -## Getting started - -First take a look at 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. - - -## 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. - - -## Talks - - - [Christopher Biscardi @ Gophercon UK 2018](https://youtu.be/FdURVezcdcw) diff --git a/docs/content/recipes/gin.md b/docs/content/recipes/gin.md new file mode 100644 index 00000000000..fb4e4456892 --- /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 github.com/gin-gonic/gin +``` + +In your router file, define the handlers for the GraphQL and Playground endpoints in two different methods and tie then together in the Gin router: +```go +import ( + "github.com/99designs/gqlgen/handler" + "github.com/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() +} +``` 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) +} +``` 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/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. + + 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: 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 }} 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; +} diff --git a/example/chat/generated.go b/example/chat/generated.go index 845ab1658ec..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 { @@ -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: true, } 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: true, } 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) @@ -2299,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 @@ -2336,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 @@ -2373,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 @@ -2425,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 97a7dd2c8af..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 } @@ -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: true, } 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: true, } 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: true, } 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) @@ -2212,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 @@ -2249,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 @@ -2286,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 @@ -2338,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 f2d965d06e4..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 { @@ -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: true, } 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: true, } 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: true, } 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: true, } 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: true, } 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: true, } 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) @@ -2421,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 @@ -2458,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 @@ -2515,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]) @@ -2544,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]) @@ -2553,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 @@ -2590,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 @@ -2650,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 @@ -2687,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 @@ -2724,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 @@ -2776,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 08bcab5f8a6..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 { @@ -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: true, } 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: true, } 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: true, } 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: true, } 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) @@ -2423,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 @@ -2460,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 @@ -2497,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 @@ -2549,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 a15fc7fcaaf..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 { @@ -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: true, } 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) @@ -2010,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 @@ -2075,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]) @@ -2099,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 @@ -2136,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 @@ -2173,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 @@ -2225,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/.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 87% rename from example/starwars/generated.go rename to example/starwars/generated/exec.go index 99116eac698..f31dcbe29b3 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" @@ -48,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 { @@ -69,78 +70,78 @@ type ComplexityRoot struct { } Human struct { - ID func(childComplexity int) int - Name func(childComplexity int) int - Height func(childComplexity int, unit 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 } Mutation struct { - CreateReview func(childComplexity int, episode Episode, review Review) int + CreateReview func(childComplexity int, episode models.Episode, review models.Review) int } 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 *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 + 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 + Length func(childComplexity int, unit *models.LengthUnit) int Name func(childComplexity int) int - Length func(childComplexity int, unit *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 { @@ -158,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 { @@ -191,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 { @@ -233,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 @@ -247,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"].(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 { @@ -323,14 +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 - - case "PageInfo.StartCursor": - if e.complexity.PageInfo.StartCursor == nil { - break - } - - return e.complexity.PageInfo.StartCursor(childComplexity), true + return e.complexity.Mutation.CreateReview(childComplexity, args["episode"].(models.Episode), args["review"].(models.Review)), true case "PageInfo.EndCursor": if e.complexity.PageInfo.EndCursor == nil { @@ -346,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"].(*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"].(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 { @@ -430,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 { @@ -451,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 { @@ -475,14 +476,14 @@ 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 { + 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 @@ -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,13 +946,14 @@ 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{ - 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) @@ -971,13 +973,14 @@ 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{ - 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) @@ -997,13 +1000,14 @@ 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{ - Object: "Droid", - Field: field, - Args: nil, + Object: "Droid", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1014,19 +1018,20 @@ 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{ - Object: "Droid", - Field: field, - Args: nil, + Object: "Droid", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1047,19 +1052,20 @@ 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{ - 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) @@ -1073,19 +1079,20 @@ 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{ - 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) @@ -1102,13 +1109,14 @@ 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{ - 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) @@ -1128,13 +1136,14 @@ 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{ - 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) @@ -1145,19 +1154,20 @@ 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{ - 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) @@ -1168,19 +1178,20 @@ 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{ - 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) @@ -1194,19 +1205,20 @@ 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{ - 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) @@ -1226,13 +1238,14 @@ 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{ - 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) @@ -1243,19 +1256,20 @@ 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{ - 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) @@ -1275,13 +1289,14 @@ 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{ - 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) @@ -1301,13 +1316,14 @@ 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{ - Object: "Human", - Field: field, - Args: nil, + Object: "Human", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1320,7 +1336,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,13 +1350,14 @@ 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{ - 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) @@ -1357,13 +1374,14 @@ 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{ - Object: "Human", - Field: field, - Args: nil, + Object: "Human", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1374,19 +1392,20 @@ 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{ - Object: "Human", - Field: field, - Args: nil, + Object: "Human", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1407,19 +1426,20 @@ 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{ - 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) @@ -1433,19 +1453,20 @@ 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{ - Object: "Human", - Field: field, - Args: nil, + Object: "Human", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) @@ -1456,19 +1477,20 @@ 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 { 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: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1481,24 +1503,25 @@ 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{ - 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) @@ -1518,13 +1541,14 @@ 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{ - 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) @@ -1544,13 +1568,14 @@ 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{ - 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) @@ -1574,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: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1589,24 +1615,25 @@ 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 { 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) @@ -1619,7 +1646,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,19 +1654,20 @@ 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 { 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) @@ -1660,19 +1688,20 @@ 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 { 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) @@ -1690,19 +1719,20 @@ 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 { 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) @@ -1720,19 +1750,20 @@ 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 { 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) @@ -1750,19 +1781,20 @@ 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 { 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) @@ -1780,19 +1812,20 @@ 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 { 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) @@ -1820,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) @@ -1839,13 +1873,14 @@ 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{ - 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) @@ -1865,13 +1900,14 @@ 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{ - 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) @@ -1888,13 +1924,14 @@ 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{ - 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) @@ -1911,13 +1948,14 @@ 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{ - 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) @@ -1937,13 +1975,14 @@ 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{ - 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) @@ -1963,13 +2002,14 @@ 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{ - Object: "Starship", - Field: field, - Args: nil, + Object: "Starship", + Field: field, + Args: nil, + IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) @@ -1982,7 +2022,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,13 +2036,14 @@ 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{ - 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) @@ -2026,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) @@ -2052,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) @@ -2075,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) @@ -2101,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) @@ -2127,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) @@ -2153,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) @@ -2176,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) @@ -2202,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) @@ -2225,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) @@ -2251,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) @@ -2274,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) @@ -2300,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) @@ -2326,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) @@ -2352,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) @@ -2375,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) @@ -2401,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) @@ -2424,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) @@ -2450,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) @@ -2473,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) @@ -2499,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) @@ -2525,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) @@ -2548,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) @@ -2571,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) @@ -2597,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) @@ -2623,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) @@ -2646,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) @@ -2669,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) @@ -2699,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) @@ -2722,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) @@ -2745,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) @@ -2775,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) @@ -2798,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) @@ -2821,8 +2894,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 +2928,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 +2972,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 +3036,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 +3090,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 +3119,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 +3227,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 +3377,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 +3408,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 +3710,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 +3733,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 +3743,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 +3767,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 +3788,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 +3802,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 +3880,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 +3912,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 +3925,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 +3957,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 +3970,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 +4219,14 @@ 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 { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4174,7 +4250,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 +4263,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 +4306,10 @@ 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 { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4254,7 +4333,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 +4346,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 +4403,49 @@ 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 { + if v == nil { + return graphql.Null + } ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4387,7 +4469,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 +4482,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 } @@ -4457,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 @@ -4494,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 @@ -4531,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 @@ -4583,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/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/example/todo/generated.go b/example/todo/generated.go index 1db0bd6ebf8..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 } @@ -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: true, } 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: true, } 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: true, } 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: true, } 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: true, } 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) @@ -1909,10 +1951,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) } @@ -2260,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 @@ -2297,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 @@ -2334,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 @@ -2386,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 e21dae94c46..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 @@ -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: true, } 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: true, } 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: true, } 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) @@ -2270,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 @@ -2307,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 @@ -2344,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 @@ -2396,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/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= diff --git a/graphql/context.go b/graphql/context.go index cc8d659b116..58d3c741e12 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 @@ -93,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/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 } 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 +} 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/handler/graphql.go b/handler/graphql.go index 28eb0e22a32..a54307e9c5c 100644 --- a/handler/graphql.go +++ b/handler/graphql.go @@ -1,11 +1,13 @@ package handler import ( + "bytes" "context" "encoding/json" "errors" "fmt" "io" + "mime/multipart" "net/http" "regexp" "strconv" @@ -42,6 +44,7 @@ type Config struct { requestHook graphql.RequestMiddleware tracer graphql.Tracer complexityLimit int + complexityLimitFunc graphql.ComplexityLimitFunc disableIntrospection bool connectionKeepAlivePingInterval time.Duration } @@ -70,7 +73,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 @@ -118,6 +121,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 { @@ -397,6 +409,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 7fd3a30e00f..526ca4c4ccf 100644 --- a/handler/graphql_test.go +++ b/handler/graphql_test.go @@ -1,6 +1,7 @@ package handler import ( + "context" "bytes" "context" "io/ioutil" @@ -12,6 +13,7 @@ import ( "testing" "github.com/99designs/gqlgen/graphql" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/vektah/gqlparser/ast" @@ -430,6 +432,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()) + }) + }) +} + type file struct { mapKey string name string diff --git a/handler/playground.go b/handler/playground.go index b3297f44ab3..0e1ca76863b 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.20", + "cssSRI": "sha256-cS9Vc2OBt9eUf4sykRWukeFYaInL29+myBmFDSa7F/U=", + "faviconSRI": "sha256-GhTyE+McTU79R4+pRO6ih+4TfsTOrpPwD8ReKFzb3PM=", + "jsSRI": "sha256-4QG1Uza2GgGdlBL3RCBCGtGeZB6bDbsw8OltCMGeJsA=", }) if err != nil { panic(err) diff --git a/integration/generated.go b/integration/generated.go index a9044e3f509..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 @@ -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: true, } 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: true, } 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: true, } 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: true, } 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: true, } 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: true, } 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: true, } 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: true, } 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: true, } 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) @@ -2370,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]) @@ -2422,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 @@ -2558,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 @@ -2595,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 @@ -2632,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 @@ -2684,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 diff --git a/internal/code/imports.go b/internal/code/imports.go index 27343212799..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,9 +41,13 @@ 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) } + importPath = QualifyPackagePath(importPath) p, _ := packages.Load(nil, importPath) if len(p) != 1 || p[0].Name == "" { 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/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 { diff --git a/plugin/modelgen/models.go b/plugin/modelgen/models.go index 2be7dfb2cfa..508cc14d074 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 { @@ -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 { @@ -120,12 +118,30 @@ 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()] + 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, + ) + 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), + nil, + nil, + ) + } } name := field.Name @@ -133,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: templates.ToGo(name), - Type: binder.CopyModifiersFromAst(field.Type, fd.Kind != ast.Interface, typ), + Name: name, + Type: binder.CopyModifiersFromAst(field.Type, typ), Description: field.Description, Tag: `json:"` + field.Name + `"`, }) @@ -145,20 +160,20 @@ 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, }) } b.Enums = append(b.Enums, it) + case ast.Scalar: + b.Scalars = append(b.Scalars, schemaType.Name) } } @@ -167,13 +182,16 @@ 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") } if len(b.Models) == 0 && len(b.Enums) == 0 { 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())) } 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 { 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,