diff --git a/codegen/args.go b/codegen/args.go index 8ae1e097b35..ea3bacbff19 100644 --- a/codegen/args.go +++ b/codegen/args.go @@ -83,7 +83,7 @@ nextArg: } // no matching arg found, abort - return fmt.Errorf("arg %s not found on method", param.Name()) + return fmt.Errorf("%s is not in schema", param.Name()) } field.Args = newArgs diff --git a/codegen/config/binder.go b/codegen/config/binder.go index 29f23cfa8a4..372fde0b74d 100644 --- a/codegen/config/binder.go +++ b/codegen/config/binder.go @@ -2,6 +2,7 @@ package config import ( "fmt" + "go/token" "go/types" "regexp" "strings" @@ -33,6 +34,27 @@ func (c *Config) NewBinder(s *ast.Schema) (*Binder, error) { }, nil } +func (b *Binder) TypePosition(typ types.Type) token.Position { + named, isNamed := typ.(*types.Named) + if !isNamed { + return token.Position{ + Filename: "unknown", + } + } + + return b.ObjectPosition(named.Obj()) +} + +func (b *Binder) ObjectPosition(typ types.Object) token.Position { + if typ == nil { + return token.Position{ + Filename: "unknown", + } + } + pkg := b.getPkg(typ.Pkg().Path()) + return pkg.Fset.Position(typ.Pos()) +} + func (b *Binder) FindType(pkgName string, typeName string) (types.Type, error) { obj, err := b.FindObject(pkgName, typeName) if err != nil { diff --git a/codegen/data.go b/codegen/data.go index e390f588bf2..df1188b75a4 100644 --- a/codegen/data.go +++ b/codegen/data.go @@ -132,50 +132,29 @@ func (b *builder) injectIntrospectionRoots(s *Data) error { return fmt.Errorf("root query type must be defined") } - typeType, err := b.Binder.TypeReference(ast.NamedType("__Type", nil)) - if err != nil { - return errors.Wrap(err, "unable to find root Type introspection type") - } - stringRef, err := b.Binder.TypeReference(ast.NonNullNamedType("String", nil)) - if err != nil { - return errors.Wrap(err, "unable to find root string type reference") - } - - obj.Fields = append(obj.Fields, &Field{ - TypeReference: typeType, - FieldDefinition: &ast.FieldDefinition{ - Name: "__type", - }, - GoFieldType: GoFieldMethod, - GoReceiverName: "ec", - GoFieldName: "introspectType", - Args: []*FieldArgument{ + __type, err := b.buildField(obj, &ast.FieldDefinition{ + Name: "__type", + Type: ast.NamedType("__Type", nil), + Arguments: []*ast.ArgumentDefinition{ { - ArgumentDefinition: &ast.ArgumentDefinition{ - Name: "name", - }, - TypeReference: stringRef, - Object: &Object{}, + Name: "name", + Type: ast.NonNullNamedType("String", nil), }, }, - Object: obj, }) - - schemaType, err := b.Binder.TypeReference(ast.NamedType("__Schema", nil)) if err != nil { - return errors.Wrap(err, "unable to find root Schema introspection type") + return err } - obj.Fields = append(obj.Fields, &Field{ - TypeReference: schemaType, - FieldDefinition: &ast.FieldDefinition{ - Name: "__schema", - }, - GoFieldType: GoFieldMethod, - GoReceiverName: "ec", - GoFieldName: "introspectSchema", - Object: obj, + __schema, err := b.buildField(obj, &ast.FieldDefinition{ + Name: "__schema", + Type: ast.NamedType("__Schema", nil), }) + if err != nil { + return err + } + + obj.Fields = append(obj.Fields, __type, __schema) return nil } diff --git a/codegen/errors_test.go b/codegen/errors_test.go index 2cd16b593bd..53c213aed5a 100644 --- a/codegen/errors_test.go +++ b/codegen/errors_test.go @@ -10,7 +10,7 @@ import ( func TestTypeUnionAsInput(t *testing.T) { err := generate("inputunion", `testdata/unioninput.graphqls`) - require.EqualError(t, err, "unable to build object definition: Query.addBookmark: cannot use Bookmarkable! as argument b because UNION is not a valid input type") + require.EqualError(t, err, "unable to build object definition: cannot use Bookmarkable! as argument b because UNION is not a valid input type") } func TestTypeInInput(t *testing.T) { diff --git a/codegen/field.go b/codegen/field.go index 057aa7265ac..c10666e28f1 100644 --- a/codegen/field.go +++ b/codegen/field.go @@ -3,6 +3,7 @@ package codegen import ( "fmt" "go/types" + "log" "reflect" "strconv" "strings" @@ -51,6 +52,16 @@ func (b *builder) buildField(obj *Object, field *ast.FieldDefinition) (*Field, e GoReceiverName: "obj", } + if obj.Kind == ast.InputObject && !f.TypeReference.Definition.IsInputType() { + return nil, errors.Errorf( + "%s.%s: cannot use %s because %s is not a valid input type", + obj.Name, + field.Name, + f.TypeReference.Definition.Name, + f.TypeReference.Definition.Kind, + ) + } + if field.DefaultValue != nil { var err error f.Default, err = field.DefaultValue.Value(nil) @@ -59,18 +70,6 @@ func (b *builder) buildField(obj *Object, field *ast.FieldDefinition) (*Field, e } } - typeEntry, entryExists := b.Config.Models[obj.Definition.Name] - if entryExists { - if typeField, ok := typeEntry.Fields[field.Name]; ok { - if typeField.Resolver { - f.IsResolver = true - } - if typeField.FieldName != "" { - f.GoFieldName = templates.ToGo(typeField.FieldName) - } - } - } - for _, arg := range field.Arguments { newArg, err := b.buildArg(obj, arg) if err != nil { @@ -78,92 +77,147 @@ func (b *builder) buildField(obj *Object, field *ast.FieldDefinition) (*Field, e } f.Args = append(f.Args, newArg) } + + if err = b.bindField(obj, &f); err != nil { + log.Printf(err.Error()) + } + return &f, nil } -func (b *builder) bindMethod(t types.Type, field *Field) error { - namedType, err := findGoNamedType(t) +func (b *builder) bindField(obj *Object, f *Field) error { + switch { + case f.Name == "__schema": + f.GoFieldType = GoFieldMethod + f.GoReceiverName = "ec" + f.GoFieldName = "introspectSchema" + return nil + case f.Name == "__type": + f.GoFieldType = GoFieldMethod + f.GoReceiverName = "ec" + f.GoFieldName = "introspectType" + return nil + case obj.Root: + f.IsResolver = true + return nil + case b.Config.Models[obj.Name].Fields[f.Name].Resolver: + f.IsResolver = true + return nil + case obj.Type == config.MapType: + return nil + case b.Config.Models[obj.Name].Fields[f.Name].FieldName != "": + f.Name = b.Config.Models[obj.Name].Fields[f.Name].FieldName + } + + target, err := b.findBindTarget(obj.Type.(*types.Named), f.Name) if err != nil { return err } - method := b.findMethod(namedType, field.GoFieldName) - if method == nil { - return fmt.Errorf("no method named %s", field.GoFieldName) - } - sig := method.Type().(*types.Signature) + pos := b.Binder.ObjectPosition(target) + + switch target := target.(type) { + case nil: + f.IsResolver = true + + objPos := b.Binder.TypePosition(obj.Type) + return fmt.Errorf( + "%s:%d adding resolver method for %s.%s, nothing matched", + objPos.Filename, + objPos.Line, + obj.Name, + f.Name, + ) + case *types.Func: + sig := target.Type().(*types.Signature) + if sig.Results().Len() == 1 { + f.NoErr = true + } else if sig.Results().Len() != 2 { + return fmt.Errorf("method has wrong number of args") + } + params := sig.Params() + // If the first argument is the context, remove it from the comparison and set + // the MethodHasContext flag so that the context will be passed to this model's method + if params.Len() > 0 && params.At(0).Type().String() == "context.Context" { + f.MethodHasContext = true + vars := make([]*types.Var, params.Len()-1) + for i := 1; i < params.Len(); i++ { + vars[i-1] = params.At(i) + } + params = types.NewTuple(vars...) + } - if sig.Results().Len() == 1 { - field.NoErr = true - } else if sig.Results().Len() != 2 { - return fmt.Errorf("method has wrong number of args") - } - params := sig.Params() - // If the first argument is the context, remove it from the comparison and set - // the MethodHasContext flag so that the context will be passed to this model's method - if params.Len() > 0 && params.At(0).Type().String() == "context.Context" { - field.MethodHasContext = true - vars := make([]*types.Var, params.Len()-1) - for i := 1; i < params.Len(); i++ { - vars[i-1] = params.At(i) + if err = b.bindArgs(f, params); err != nil { + return errors.Wrapf(err, "%s:%d", pos.Filename, pos.Line) } - params = types.NewTuple(vars...) - } - if err := b.bindArgs(field, params); err != nil { - return err - } + result := sig.Results().At(0) + if err = code.CompatibleTypes(f.TypeReference.GO, result.Type()); err != nil { + return errors.Wrapf(err, "%s:%d %s is not compatible with %s", pos.Filename, pos.Line, f.TypeReference.GO.String(), result.Type().String()) + } - result := sig.Results().At(0) - if err = code.CompatibleTypes(field.TypeReference.GO, result.Type()); err != nil { - return errors.Wrapf(err, "%s is not compatible with %s", field.TypeReference.GO.String(), result.String()) - } + // success, args and return type match. Bind to method + f.GoFieldType = GoFieldMethod + f.GoReceiverName = "obj" + f.GoFieldName = target.Name() + f.TypeReference.GO = result.Type() - // success, args and return type match. Bind to method - field.GoFieldType = GoFieldMethod - field.GoReceiverName = "obj" - field.GoFieldName = method.Name() - field.TypeReference.GO = result.Type() - return nil -} + return nil -func (b *builder) bindVar(t types.Type, field *Field) error { - underlying, ok := t.Underlying().(*types.Struct) - if !ok { - return fmt.Errorf("not a struct") - } + case *types.Var: + if err = code.CompatibleTypes(f.TypeReference.GO, target.Type()); err != nil { + return errors.Wrapf(err, "%s:%d %s is not compatible with %s", pos.Filename, pos.Line, f.TypeReference.GO.String(), target.Type().String()) + } - structField, err := b.findField(underlying, field.GoFieldName) - if err != nil { - return err - } + // success, bind to var + f.GoFieldType = GoFieldVariable + f.GoReceiverName = "obj" + f.GoFieldName = target.Name() + f.TypeReference.GO = target.Type() - if err = code.CompatibleTypes(field.TypeReference.GO, structField.Type()); err != nil { - return errors.Wrapf(err, "%s is not compatible with %s", field.TypeReference.GO.String(), field.TypeReference.GO.String()) + return nil + default: + panic(fmt.Errorf("unknown bind target %T for %s", target, f.Name)) } - - // success, bind to var - field.GoFieldType = GoFieldVariable - field.GoReceiverName = "obj" - field.GoFieldName = structField.Name() - field.TypeReference.GO = structField.Type() - return nil } // findField attempts to match the name to a struct field with the following // priorites: -// 1. If struct tag is passed then struct tag has highest priority -// 2. Actual Field name -// 3. Field in an embedded struct -func (b *builder) findField(typ *types.Struct, name string) (*types.Var, error) { +// 1. Any method with a matching name +// 2. Any Fields with a struct tag (see config.StructTag) +// 3. Any fields with a matching name +// 4. Same logic again for embedded fields +func (b *builder) findBindTarget(named *types.Named, name string) (types.Object, error) { + for i := 0; i < named.NumMethods(); i++ { + method := named.Method(i) + if !method.Exported() { + continue + } + + if !strings.EqualFold(method.Name(), name) { + continue + } + + return method, nil + } + + strukt, ok := named.Underlying().(*types.Struct) + if !ok { + return nil, fmt.Errorf("not a struct") + } + return b.findBindStructTarget(strukt, name) +} + +func (b *builder) findBindStructTarget(strukt *types.Struct, name string) (types.Object, error) { + // struct tags have the highest priority if b.Config.StructTag != "" { var foundField *types.Var - for i := 0; i < typ.NumFields(); i++ { - field := typ.Field(i) + for i := 0; i < strukt.NumFields(); i++ { + field := strukt.Field(i) if !field.Exported() { continue } - tags := reflect.StructTag(typ.Tag(i)) + tags := reflect.StructTag(strukt.Tag(i)) if val, ok := tags.Lookup(b.Config.StructTag); ok && equalFieldName(val, name) { if foundField != nil { return nil, errors.Errorf("tag %s is ambigious; multiple fields have the same tag value of %s", b.Config.StructTag, val) @@ -177,8 +231,9 @@ func (b *builder) findField(typ *types.Struct, name string) (*types.Var, error) } } - for i := 0; i < typ.NumFields(); i++ { - field := typ.Field(i) + // Then matching field names + for i := 0; i < strukt.NumFields(); i++ { + field := strukt.Field(i) if !field.Exported() { continue } @@ -187,64 +242,45 @@ func (b *builder) findField(typ *types.Struct, name string) (*types.Var, error) } } - for i := 0; i < typ.NumFields(); i++ { - field := typ.Field(i) + // Then look in embedded structs + for i := 0; i < strukt.NumFields(); i++ { + field := strukt.Field(i) if !field.Exported() { continue } - if field.Anonymous() { - fieldType := field.Type() - - if ptr, ok := fieldType.(*types.Pointer); ok { - fieldType = ptr.Elem() - } - - // Type.Underlying() returns itself for all types except types.Named, where it returns a struct type. - // It should be safe to always call. - if named, ok := fieldType.Underlying().(*types.Struct); ok { - f, err := b.findField(named, name) - if err != nil && !strings.HasPrefix(err.Error(), "no field named") { - return nil, err - } - if f != nil { - return f, nil - } - } - } - } - - return nil, fmt.Errorf("no field named %s", name) -} - -func (b *builder) findMethod(typ *types.Named, name string) *types.Func { - for i := 0; i < typ.NumMethods(); i++ { - method := typ.Method(i) - if !method.Exported() { + if !field.Anonymous() { continue } - if strings.EqualFold(method.Name(), name) { - return method + fieldType := field.Type() + if ptr, ok := fieldType.(*types.Pointer); ok { + fieldType = ptr.Elem() } - } - if s, ok := typ.Underlying().(*types.Struct); ok { - for i := 0; i < s.NumFields(); i++ { - field := s.Field(i) - if !field.Anonymous() { - continue + switch fieldType := fieldType.(type) { + case *types.Named: + f, err := b.findBindTarget(fieldType, name) + if err != nil { + return nil, err } - - if named, ok := field.Type().(*types.Named); ok { - if f := b.findMethod(named, name); f != nil { - return f - } + if f != nil { + return f, nil + } + case *types.Struct: + f, err := b.findBindStructTarget(fieldType, name) + if err != nil { + return nil, err + } + if f != nil { + return f, nil } + default: + panic(fmt.Errorf("unknown embedded field type %T", field.Type())) } } - return nil + return nil, nil } func (f *Field) HasDirectives() bool { diff --git a/codegen/field_test.go b/codegen/field_test.go index cdd9a21f3fd..6702a606974 100644 --- a/codegen/field_test.go +++ b/codegen/field_test.go @@ -65,7 +65,7 @@ type Embed struct { for _, tt := range tests { b := builder{Config: &config.Config{StructTag: tt.Tag}} - field, err := b.findField(tt.Struct, tt.Field) + field, err := b.findBindStructTarget(tt.Struct, tt.Field) if tt.ShouldError { require.Nil(t, field, tt.Name) require.Error(t, err, tt.Name) diff --git a/codegen/object.go b/codegen/object.go index 20e5533a375..243b35371a4 100644 --- a/codegen/object.go +++ b/codegen/object.go @@ -2,7 +2,6 @@ package codegen import ( "go/types" - "log" "strconv" "strings" "unicode" @@ -72,45 +71,10 @@ func (b *builder) buildObject(typ *ast.Definition) (*Object, error) { var f *Field f, err = b.buildField(obj, field) if err != nil { - return nil, errors.Wrap(err, typ.Name+"."+field.Name) - } - - if typ.Kind == ast.InputObject && !f.TypeReference.Definition.IsInputType() { - return nil, errors.Errorf( - "%s.%s: cannot use %s because %s is not a valid input type", - typ.Name, - field.Name, - f.TypeReference.Definition.Name, - f.TypeReference.Definition.Kind, - ) + return nil, err } obj.Fields = append(obj.Fields, f) - - if obj.Root { - f.IsResolver = true - } else if !f.IsResolver { - // first try binding to a method - methodErr := b.bindMethod(obj.Type, f) - if methodErr == nil { - continue - } - - // otherwise try binding to a var - varErr := b.bindVar(obj.Type, f) - - // if both failed, add a resolver - if varErr != nil { - f.IsResolver = true - - log.Printf("\nadding resolver method for %s.%s to %s\n %s\n %s", - obj.Name, - field.Name, - obj.Type.String(), - methodErr.Error(), - varErr.Error()) - } - } } return obj, nil diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 10749ed35e7..3efb3719ca6 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -4312,29 +4312,23 @@ func (ec *executionContext) unmarshalBoolean2ᚖbool(v interface{}) (*bool, erro } func (ec *executionContext) marshalBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalBoolean2bool(ctx, sel, *v) } func (ec *executionContext) marshalCircle2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCircle(ctx context.Context, sel ast.SelectionSet, v *Circle) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._Circle(ctx, sel, v) } func (ec *executionContext) marshalError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx context.Context, sel ast.SelectionSet, v *Error) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._Error(ctx, sel, v) } @@ -4363,11 +4357,9 @@ func (ec *executionContext) unmarshalKeywords2ᚖgithubᚗcomᚋ99designsᚋgqlg } func (ec *executionContext) marshalModelMethods2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐModelMethods(ctx context.Context, sel ast.SelectionSet, v *ModelMethods) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._ModelMethods(ctx, sel, v) } @@ -4380,11 +4372,9 @@ func (ec *executionContext) unmarshalOuterInput2ᚖgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshalOuterObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v *OuterObject) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._OuterObject(ctx, sel, v) } @@ -4397,38 +4387,30 @@ func (ec *executionContext) unmarshalRecursiveInputSlice2ᚖgithubᚗcomᚋ99des } func (ec *executionContext) marshalIt2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋintrospectionᚐIt(ctx context.Context, sel ast.SelectionSet, v *introspection1.It) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._It(ctx, sel, v) } func (ec *executionContext) marshalInvalidIdentifier2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx context.Context, sel ast.SelectionSet, v *invalid_packagename.InvalidIdentifier) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._InvalidIdentifier(ctx, sel, v) } func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Schema(ctx, sel, v) } func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Type(ctx, sel, v) } @@ -4441,11 +4423,9 @@ func (ec *executionContext) unmarshalInt2ᚖint(v interface{}) (*int, error) { } func (ec *executionContext) marshalInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalInt2int(ctx, sel, *v) } @@ -4458,11 +4438,9 @@ func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, e } func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalString2string(ctx, sel, *v) } @@ -4487,7 +4465,6 @@ func (ec *executionContext) unmarshalOuterInput2ᚕᚖgithubᚗcomᚋ99designs } func (ec *executionContext) marshalOuterObject2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v []*OuterObject) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4539,7 +4516,6 @@ func (ec *executionContext) unmarshalOuterInput2ᚕᚕᚖgithubᚗcomᚋ99design } func (ec *executionContext) marshalOuterObject2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v [][]*OuterObject) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4591,7 +4567,6 @@ func (ec *executionContext) unmarshalRecursiveInputSlice2ᚕgithubᚗcomᚋ99des } func (ec *executionContext) marshalShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx context.Context, sel ast.SelectionSet, v []Shape) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4623,7 +4598,6 @@ func (ec *executionContext) marshalShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ } func (ec *executionContext) marshalUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx context.Context, sel ast.SelectionSet, v []User) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4655,7 +4629,6 @@ func (ec *executionContext) marshalUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋc } func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4687,7 +4660,6 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4719,7 +4691,6 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4751,7 +4722,6 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4783,7 +4753,6 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4835,7 +4804,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{} } func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4871,7 +4839,6 @@ func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { } func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) } @@ -4880,17 +4847,14 @@ func (ec *executionContext) unmarshalFloat2float64(v interface{}) (float64, erro } func (ec *executionContext) marshalFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { - return graphql.MarshalFloat(v) } func (ec *executionContext) marshalCircle2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCircle(ctx context.Context, sel ast.SelectionSet, v Circle) graphql.Marshaler { - return ec._Circle(ctx, sel, &v) } func (ec *executionContext) marshalError2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx context.Context, sel ast.SelectionSet, v Error) graphql.Marshaler { - return ec._Error(ctx, sel, &v) } @@ -4903,7 +4867,6 @@ func (ec *executionContext) unmarshalInnerInput2githubᚗcomᚋ99designsᚋgqlge } func (ec *executionContext) marshalInnerObject2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerObject(ctx context.Context, sel ast.SelectionSet, v InnerObject) graphql.Marshaler { - return ec._InnerObject(ctx, sel, &v) } @@ -4916,7 +4879,6 @@ func (ec *executionContext) unmarshalKeywords2githubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalModelMethods2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐModelMethods(ctx context.Context, sel ast.SelectionSet, v ModelMethods) graphql.Marshaler { - return ec._ModelMethods(ctx, sel, &v) } @@ -4925,7 +4887,6 @@ func (ec *executionContext) unmarshalOuterInput2githubᚗcomᚋ99designsᚋgqlge } func (ec *executionContext) marshalOuterObject2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v OuterObject) graphql.Marshaler { - return ec._OuterObject(ctx, sel, &v) } @@ -4934,52 +4895,42 @@ func (ec *executionContext) unmarshalRecursiveInputSlice2githubᚗcomᚋ99design } func (ec *executionContext) marshalShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx context.Context, sel ast.SelectionSet, v Shape) graphql.Marshaler { - return ec._Shape(ctx, sel, &v) } func (ec *executionContext) marshalUser2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler { - return ec._User(ctx, sel, &v) } func (ec *executionContext) marshalIt2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋintrospectionᚐIt(ctx context.Context, sel ast.SelectionSet, v introspection1.It) graphql.Marshaler { - return ec._It(ctx, sel, &v) } func (ec *executionContext) marshalInvalidIdentifier2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx context.Context, sel ast.SelectionSet, v invalid_packagename.InvalidIdentifier) graphql.Marshaler { - return ec._InvalidIdentifier(ctx, sel, &v) } func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) } func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) } func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) } func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) } func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) } func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) } @@ -4988,7 +4939,6 @@ func (ec *executionContext) unmarshalInt2int(v interface{}) (int, error) { } func (ec *executionContext) marshalInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - return graphql.MarshalInt(v) } @@ -5001,7 +4951,6 @@ func (ec *executionContext) unmarshalID2string(v interface{}) (string, error) { } func (ec *executionContext) marshalID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalID(v) } @@ -5010,7 +4959,6 @@ func (ec *executionContext) unmarshalString2string(v interface{}) (string, error } func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -5019,7 +4967,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) ( } func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -5028,7 +4975,6 @@ func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, e } func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } diff --git a/codegen/type.gotpl b/codegen/type.gotpl index c96bf844f6a..37aab4b1a95 100644 --- a/codegen/type.gotpl +++ b/codegen/type.gotpl @@ -40,11 +40,6 @@ func (ec *executionContext) marshal{{ $type.Definition.Name }}2{{ $type.GO | ts }}(ctx context.Context, sel ast.SelectionSet, v {{ $type.GO | ref }}) graphql.Marshaler { {{- if $type.IsPtr }} if v == nil { - {{- if $type.GQL.NonNull }} - if !ec.HasError(graphql.GetResolverContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - {{- end }} return graphql.Null } {{- end }} diff --git a/example/chat/generated.go b/example/chat/generated.go index e2dbf7c4a7c..27672e9c291 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -1932,29 +1932,23 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshalChatroom2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐChatroom(ctx context.Context, sel ast.SelectionSet, v *Chatroom) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._Chatroom(ctx, sel, v) } func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Schema(ctx, sel, v) } func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Type(ctx, sel, v) } @@ -1967,16 +1961,13 @@ func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, e } func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalString2string(ctx, sel, *v) } func (ec *executionContext) marshalMessage2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx context.Context, sel ast.SelectionSet, v []Message) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2008,7 +1999,6 @@ func (ec *executionContext) marshalMessage2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2040,7 +2030,6 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2072,7 +2061,6 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2104,7 +2092,6 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2136,7 +2123,6 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2188,7 +2174,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{} } func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2224,47 +2209,38 @@ func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { } func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) } func (ec *executionContext) marshalChatroom2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐChatroom(ctx context.Context, sel ast.SelectionSet, v Chatroom) graphql.Marshaler { - return ec._Chatroom(ctx, sel, &v) } func (ec *executionContext) marshalMessage2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐMessage(ctx context.Context, sel ast.SelectionSet, v Message) graphql.Marshaler { - return ec._Message(ctx, sel, &v) } func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) } func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) } func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) } func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) } func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) } func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) } @@ -2273,7 +2249,6 @@ func (ec *executionContext) unmarshalID2string(v interface{}) (string, error) { } func (ec *executionContext) marshalID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalID(v) } @@ -2282,7 +2257,6 @@ func (ec *executionContext) unmarshalString2string(v interface{}) (string, error } func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2291,7 +2265,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) ( } func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2300,7 +2273,6 @@ func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, e } func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2309,7 +2281,6 @@ func (ec *executionContext) unmarshalTime2timeᚐTime(v interface{}) (time.Time, } func (ec *executionContext) marshalTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - return graphql.MarshalTime(v) } diff --git a/example/config/generated.go b/example/config/generated.go index 3de72488f4f..2538c61bcf1 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -49,16 +49,16 @@ type ComplexityRoot struct { } Todo struct { - Id func(childComplexity int) int - DatabaseId func(childComplexity int) int - Text func(childComplexity int) int - Done func(childComplexity int) int - User func(childComplexity int) int + Id func(childComplexity int) int + DatabaseId func(childComplexity int) int + Description func(childComplexity int) int + Done func(childComplexity int) int + User func(childComplexity int) int } User struct { - Id func(childComplexity int) int - Name func(childComplexity int) int + Id func(childComplexity int) int + FullName func(childComplexity int) int } } @@ -120,12 +120,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Todo.DatabaseId(childComplexity), true - case "Todo.text": - if e.complexity.Todo.Text == nil { + case "Todo.Description": + if e.complexity.Todo.Description == nil { break } - return e.complexity.Todo.Text(childComplexity), true + return e.complexity.Todo.Description(childComplexity), true case "Todo.done": if e.complexity.Todo.Done == nil { @@ -148,12 +148,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.User.Id(childComplexity), true - case "User.name": - if e.complexity.User.Name == nil { + case "User.FullName": + if e.complexity.User.FullName == nil { break } - return e.complexity.User.Name(childComplexity), true + return e.complexity.User.FullName(childComplexity), true } return 0, false @@ -489,7 +489,7 @@ func (ec *executionContext) _Todo_databaseId(ctx context.Context, field graphql. return ec.marshalInt2int(ctx, field.Selections, res) } -func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { +func (ec *executionContext) _Todo_Description(ctx context.Context, field graphql.CollectedField, obj *Todo) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -593,7 +593,7 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte return ec.marshalID2string(ctx, field.Selections, res) } -func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { +func (ec *executionContext) _User_FullName(ctx context.Context, field graphql.CollectedField, obj *User) graphql.Marshaler { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ @@ -1430,7 +1430,7 @@ func (ec *executionContext) unmarshalInputNewTodo(v interface{}) (NewTodo, error if err != nil { return it, err } - case "userId": + case "UserID": var err error it.UserID, err = ec.unmarshalString2string(v) if err != nil { @@ -1545,8 +1545,8 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj if out.Values[i] == graphql.Null { invalid = true } - case "text": - out.Values[i] = ec._Todo_text(ctx, field, obj) + case "Description": + out.Values[i] = ec._Todo_Description(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } @@ -1587,8 +1587,8 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj if out.Values[i] == graphql.Null { invalid = true } - case "name": - out.Values[i] = ec._User_name(ctx, field, obj) + case "FullName": + out.Values[i] = ec._User_FullName(ctx, field, obj) if out.Values[i] == graphql.Null { invalid = true } @@ -1849,20 +1849,16 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Schema(ctx, sel, v) } func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Type(ctx, sel, v) } @@ -1875,16 +1871,13 @@ func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, e } func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalString2string(ctx, sel, *v) } func (ec *executionContext) marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐTodo(ctx context.Context, sel ast.SelectionSet, v []Todo) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1916,7 +1909,6 @@ func (ec *executionContext) marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋe } func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1948,7 +1940,6 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1980,7 +1971,6 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2012,7 +2002,6 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2044,7 +2033,6 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2096,7 +2084,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{} } func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2132,7 +2119,6 @@ func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { } func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) } @@ -2141,42 +2127,34 @@ func (ec *executionContext) unmarshalNewTodo2githubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { - return ec._Todo(ctx, sel, &v) } func (ec *executionContext) marshalUser2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler { - return ec._User(ctx, sel, &v) } func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) } func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) } func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) } func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) } func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) } func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) } @@ -2185,7 +2163,6 @@ func (ec *executionContext) unmarshalInt2int(v interface{}) (int, error) { } func (ec *executionContext) marshalInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - return graphql.MarshalInt(v) } @@ -2194,7 +2171,6 @@ func (ec *executionContext) unmarshalID2string(v interface{}) (string, error) { } func (ec *executionContext) marshalID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalID(v) } @@ -2203,7 +2179,6 @@ func (ec *executionContext) unmarshalString2string(v interface{}) (string, error } func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2212,7 +2187,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) ( } func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2221,7 +2195,6 @@ func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, e } func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index b467524125f..1cfbd291c75 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -2083,29 +2083,23 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshalAddress2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐAddress(ctx context.Context, sel ast.SelectionSet, v *Address) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._Address(ctx, sel, v) } func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Schema(ctx, sel, v) } func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Type(ctx, sel, v) } @@ -2118,16 +2112,13 @@ func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, e } func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalString2string(ctx, sel, *v) } func (ec *executionContext) marshalCustomer2ᚕᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v [][]Customer) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2179,7 +2170,6 @@ func (ec *executionContext) unmarshalInt2ᚕᚕint(v interface{}) ([][]int, erro } func (ec *executionContext) marshalInt2ᚕᚕint(ctx context.Context, sel ast.SelectionSet, v [][]int) graphql.Marshaler { - ret := make(graphql.Array, len(v)) for i := range v { ret[i] = ec.marshalInt2ᚕint(ctx, sel, v[i]) @@ -2189,7 +2179,6 @@ func (ec *executionContext) marshalInt2ᚕᚕint(ctx context.Context, sel ast.Se } func (ec *executionContext) marshalCustomer2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v []Customer) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2221,7 +2210,6 @@ func (ec *executionContext) marshalCustomer2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalItem2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐItem(ctx context.Context, sel ast.SelectionSet, v []Item) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2253,7 +2241,6 @@ func (ec *executionContext) marshalItem2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋe } func (ec *executionContext) marshalOrder2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐOrder(ctx context.Context, sel ast.SelectionSet, v []Order) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2285,7 +2272,6 @@ func (ec *executionContext) marshalOrder2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ } func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2317,7 +2303,6 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2349,7 +2334,6 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2381,7 +2365,6 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2413,7 +2396,6 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2465,7 +2447,6 @@ func (ec *executionContext) unmarshalInt2ᚕint(v interface{}) ([]int, error) { } func (ec *executionContext) marshalInt2ᚕint(ctx context.Context, sel ast.SelectionSet, v []int) graphql.Marshaler { - ret := make(graphql.Array, len(v)) for i := range v { ret[i] = ec.marshalInt2int(ctx, sel, v[i]) @@ -2495,7 +2476,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{} } func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2531,7 +2511,6 @@ func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { } func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) } @@ -2540,57 +2519,46 @@ func (ec *executionContext) unmarshalFloat2float64(v interface{}) (float64, erro } func (ec *executionContext) marshalFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { - return graphql.MarshalFloat(v) } func (ec *executionContext) marshalAddress2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐAddress(ctx context.Context, sel ast.SelectionSet, v Address) graphql.Marshaler { - return ec._Address(ctx, sel, &v) } func (ec *executionContext) marshalCustomer2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v Customer) graphql.Marshaler { - return ec._Customer(ctx, sel, &v) } func (ec *executionContext) marshalItem2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐItem(ctx context.Context, sel ast.SelectionSet, v Item) graphql.Marshaler { - return ec._Item(ctx, sel, &v) } func (ec *executionContext) marshalOrder2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐOrder(ctx context.Context, sel ast.SelectionSet, v Order) graphql.Marshaler { - return ec._Order(ctx, sel, &v) } func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) } func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) } func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) } func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) } func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) } func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) } @@ -2599,7 +2567,6 @@ func (ec *executionContext) unmarshalInt2int(v interface{}) (int, error) { } func (ec *executionContext) marshalInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - return graphql.MarshalInt(v) } @@ -2608,7 +2575,6 @@ func (ec *executionContext) unmarshalString2string(v interface{}) (string, error } func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2617,7 +2583,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) ( } func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2626,7 +2591,6 @@ func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, e } func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2635,7 +2599,6 @@ func (ec *executionContext) unmarshalTime2timeᚐTime(v interface{}) (time.Time, } func (ec *executionContext) marshalTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - return graphql.MarshalTime(v) } diff --git a/example/scalars/generated.go b/example/scalars/generated.go index bb4f03625d1..4ab97d8e144 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -1953,13 +1953,10 @@ func (ec *executionContext) unmarshalPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, sel ast.SelectionSet, v *model.Point) graphql.Marshaler { - if v == nil { return graphql.Null } - return v - } func (ec *executionContext) unmarshalSearchArgs2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v interface{}) (*model.SearchArgs, error) { @@ -1971,29 +1968,23 @@ func (ec *executionContext) unmarshalSearchArgs2ᚖgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshalUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._User(ctx, sel, v) } func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Schema(ctx, sel, v) } func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Type(ctx, sel, v) } @@ -2006,11 +1997,9 @@ func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, e } func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalString2string(ctx, sel, *v) } @@ -2023,16 +2012,13 @@ func (ec *executionContext) unmarshalTimestamp2ᚖtimeᚐTime(v interface{}) (*t } func (ec *executionContext) marshalTimestamp2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalTimestamp2timeᚐTime(ctx, sel, *v) } func (ec *executionContext) marshalUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v []model.User) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2064,7 +2050,6 @@ func (ec *executionContext) marshalUser2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋe } func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2096,7 +2081,6 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2128,7 +2112,6 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2160,7 +2143,6 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2192,7 +2174,6 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2244,7 +2225,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{} } func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2280,7 +2260,6 @@ func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { } func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) } @@ -2289,12 +2268,10 @@ func (ec *executionContext) unmarshalID2githubᚗcomᚋ99designsᚋgqlgenᚋexam } func (ec *executionContext) marshalID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(ctx context.Context, sel ast.SelectionSet, v external.ObjectID) graphql.Marshaler { - return model.MarshalID(v) } func (ec *executionContext) marshalAddress2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐAddress(ctx context.Context, sel ast.SelectionSet, v model.Address) graphql.Marshaler { - return ec._Address(ctx, sel, &v) } @@ -2304,9 +2281,7 @@ func (ec *executionContext) unmarshalBanned2githubᚗcomᚋ99designsᚋgqlgenᚋ } func (ec *executionContext) marshalBanned2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐBanned(ctx context.Context, sel ast.SelectionSet, v model.Banned) graphql.Marshaler { - return v - } func (ec *executionContext) unmarshalPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(v interface{}) (model.Point, error) { @@ -2315,9 +2290,7 @@ func (ec *executionContext) unmarshalPoint2githubᚗcomᚋ99designsᚋgqlgenᚋe } func (ec *executionContext) marshalPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, sel ast.SelectionSet, v model.Point) graphql.Marshaler { - return v - } func (ec *executionContext) unmarshalSearchArgs2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(v interface{}) (model.SearchArgs, error) { @@ -2330,43 +2303,34 @@ func (ec *executionContext) unmarshalTier2githubᚗcomᚋ99designsᚋgqlgenᚋex } func (ec *executionContext) marshalTier2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐTier(ctx context.Context, sel ast.SelectionSet, v model.Tier) graphql.Marshaler { - return v - } func (ec *executionContext) marshalUser2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v model.User) graphql.Marshaler { - return ec._User(ctx, sel, &v) } func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) } func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) } func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) } func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) } func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) } func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) } @@ -2375,7 +2339,6 @@ func (ec *executionContext) unmarshalString2string(v interface{}) (string, error } func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2384,7 +2347,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) ( } func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2393,7 +2355,6 @@ func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, e } func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2402,7 +2363,6 @@ func (ec *executionContext) unmarshalTimestamp2timeᚐTime(v interface{}) (time. } func (ec *executionContext) marshalTimestamp2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - return model.MarshalTimestamp(v) } diff --git a/example/selection/generated.go b/example/selection/generated.go index b4c2aa2b541..4c076024652 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -1732,20 +1732,16 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Schema(ctx, sel, v) } func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Type(ctx, sel, v) } @@ -1758,16 +1754,13 @@ func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, e } func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalString2string(ctx, sel, *v) } func (ec *executionContext) marshalEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋselectionᚐEvent(ctx context.Context, sel ast.SelectionSet, v []Event) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1799,7 +1792,6 @@ func (ec *executionContext) marshalEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ } func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1831,7 +1823,6 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1863,7 +1854,6 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1895,7 +1885,6 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1927,7 +1916,6 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1979,7 +1967,6 @@ func (ec *executionContext) unmarshalString2ᚕstring(v interface{}) ([]string, } func (ec *executionContext) marshalString2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) for i := range v { ret[i] = ec.marshalString2string(ctx, sel, v[i]) @@ -2009,7 +1996,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{} } func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2045,42 +2031,34 @@ func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { } func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) } func (ec *executionContext) marshalEvent2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋselectionᚐEvent(ctx context.Context, sel ast.SelectionSet, v Event) graphql.Marshaler { - return ec._Event(ctx, sel, &v) } func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) } func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) } func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) } func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) } func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) } func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) } @@ -2089,7 +2067,6 @@ func (ec *executionContext) unmarshalString2string(v interface{}) (string, error } func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2098,7 +2075,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) ( } func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2107,7 +2083,6 @@ func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, e } func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2116,7 +2091,6 @@ func (ec *executionContext) unmarshalTime2timeᚐTime(v interface{}) (time.Time, } func (ec *executionContext) marshalTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - return graphql.MarshalTime(v) } diff --git a/example/starwars/generated.go b/example/starwars/generated.go index 17df8f7229e..ffbad29c928 100644 --- a/example/starwars/generated.go +++ b/example/starwars/generated.go @@ -3553,11 +3553,9 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshalDroid2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐDroid(ctx context.Context, sel ast.SelectionSet, v *Droid) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._Droid(ctx, sel, v) } @@ -3570,21 +3568,16 @@ func (ec *executionContext) unmarshalEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlge } func (ec *executionContext) marshalEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v *Episode) graphql.Marshaler { - if v == nil { return graphql.Null } - return v - } func (ec *executionContext) marshalHuman2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐHuman(ctx context.Context, sel ast.SelectionSet, v *Human) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._Human(ctx, sel, v) } @@ -3597,48 +3590,37 @@ func (ec *executionContext) unmarshalLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshalLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(ctx context.Context, sel ast.SelectionSet, v *LengthUnit) graphql.Marshaler { - if v == nil { return graphql.Null } - return v - } func (ec *executionContext) marshalReview2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx context.Context, sel ast.SelectionSet, v *Review) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._Review(ctx, sel, v) } func (ec *executionContext) marshalStarship2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx context.Context, sel ast.SelectionSet, v *Starship) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._Starship(ctx, sel, v) } func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Schema(ctx, sel, v) } func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Type(ctx, sel, v) } @@ -3651,11 +3633,9 @@ func (ec *executionContext) unmarshalInt2ᚖint(v interface{}) (*int, error) { } func (ec *executionContext) marshalInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalInt2int(ctx, sel, *v) } @@ -3668,11 +3648,9 @@ func (ec *executionContext) unmarshalID2ᚖstring(v interface{}) (*string, error } func (ec *executionContext) marshalID2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalID2string(ctx, sel, *v) } @@ -3685,11 +3663,9 @@ func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, e } func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalString2string(ctx, sel, *v) } @@ -3702,11 +3678,9 @@ func (ec *executionContext) unmarshalTime2ᚖtimeᚐTime(v interface{}) (*time.T } func (ec *executionContext) marshalTime2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalTime2timeᚐTime(ctx, sel, *v) } @@ -3731,7 +3705,6 @@ func (ec *executionContext) unmarshalInt2ᚕᚕint(v interface{}) ([][]int, erro } func (ec *executionContext) marshalInt2ᚕᚕint(ctx context.Context, sel ast.SelectionSet, v [][]int) graphql.Marshaler { - ret := make(graphql.Array, len(v)) for i := range v { ret[i] = ec.marshalInt2ᚕint(ctx, sel, v[i]) @@ -3741,7 +3714,6 @@ func (ec *executionContext) marshalInt2ᚕᚕint(ctx context.Context, sel ast.Se } func (ec *executionContext) marshalCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v []Character) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -3793,7 +3765,6 @@ func (ec *executionContext) unmarshalEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlge } func (ec *executionContext) marshalEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v []Episode) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -3825,7 +3796,6 @@ func (ec *executionContext) marshalEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalFriendsEdge2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsEdge(ctx context.Context, sel ast.SelectionSet, v []FriendsEdge) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -3857,7 +3827,6 @@ func (ec *executionContext) marshalFriendsEdge2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshalReview2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx context.Context, sel ast.SelectionSet, v []Review) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -3889,7 +3858,6 @@ func (ec *executionContext) marshalReview2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalSearchResult2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐSearchResult(ctx context.Context, sel ast.SelectionSet, v []SearchResult) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -3921,7 +3889,6 @@ func (ec *executionContext) marshalSearchResult2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshalStarship2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx context.Context, sel ast.SelectionSet, v []Starship) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -3953,7 +3920,6 @@ func (ec *executionContext) marshalStarship2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -3985,7 +3951,6 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4017,7 +3982,6 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4049,7 +4013,6 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4081,7 +4044,6 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4133,7 +4095,6 @@ func (ec *executionContext) unmarshalInt2ᚕint(v interface{}) ([]int, error) { } func (ec *executionContext) marshalInt2ᚕint(ctx context.Context, sel ast.SelectionSet, v []int) graphql.Marshaler { - ret := make(graphql.Array, len(v)) for i := range v { ret[i] = ec.marshalInt2int(ctx, sel, v[i]) @@ -4163,7 +4124,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{} } func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -4199,7 +4159,6 @@ func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { } func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) } @@ -4208,17 +4167,14 @@ func (ec *executionContext) unmarshalFloat2float64(v interface{}) (float64, erro } func (ec *executionContext) marshalFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { - return graphql.MarshalFloat(v) } func (ec *executionContext) marshalCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v Character) graphql.Marshaler { - return ec._Character(ctx, sel, &v) } func (ec *executionContext) marshalDroid2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐDroid(ctx context.Context, sel ast.SelectionSet, v Droid) graphql.Marshaler { - return ec._Droid(ctx, sel, &v) } @@ -4228,23 +4184,18 @@ func (ec *executionContext) unmarshalEpisode2githubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v Episode) graphql.Marshaler { - return v - } func (ec *executionContext) marshalFriendsConnection2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsConnection(ctx context.Context, sel ast.SelectionSet, v FriendsConnection) graphql.Marshaler { - return ec._FriendsConnection(ctx, sel, &v) } func (ec *executionContext) marshalFriendsEdge2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐFriendsEdge(ctx context.Context, sel ast.SelectionSet, v FriendsEdge) graphql.Marshaler { - return ec._FriendsEdge(ctx, sel, &v) } func (ec *executionContext) marshalHuman2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐHuman(ctx context.Context, sel ast.SelectionSet, v Human) graphql.Marshaler { - return ec._Human(ctx, sel, &v) } @@ -4254,18 +4205,14 @@ func (ec *executionContext) unmarshalLengthUnit2githubᚗcomᚋ99designsᚋgqlge } func (ec *executionContext) marshalLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐLengthUnit(ctx context.Context, sel ast.SelectionSet, v LengthUnit) graphql.Marshaler { - return v - } func (ec *executionContext) marshalPageInfo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐPageInfo(ctx context.Context, sel ast.SelectionSet, v PageInfo) graphql.Marshaler { - return ec._PageInfo(ctx, sel, &v) } func (ec *executionContext) marshalReview2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐReview(ctx context.Context, sel ast.SelectionSet, v Review) graphql.Marshaler { - return ec._Review(ctx, sel, &v) } @@ -4274,42 +4221,34 @@ func (ec *executionContext) unmarshalReviewInput2githubᚗcomᚋ99designsᚋgqlg } func (ec *executionContext) marshalSearchResult2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐSearchResult(ctx context.Context, sel ast.SelectionSet, v SearchResult) graphql.Marshaler { - return ec._SearchResult(ctx, sel, &v) } func (ec *executionContext) marshalStarship2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚐStarship(ctx context.Context, sel ast.SelectionSet, v Starship) graphql.Marshaler { - return ec._Starship(ctx, sel, &v) } func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) } func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) } func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) } func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) } func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) } func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) } @@ -4318,7 +4257,6 @@ func (ec *executionContext) unmarshalInt2int(v interface{}) (int, error) { } func (ec *executionContext) marshalInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - return graphql.MarshalInt(v) } @@ -4327,7 +4265,6 @@ func (ec *executionContext) unmarshalID2string(v interface{}) (string, error) { } func (ec *executionContext) marshalID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalID(v) } @@ -4336,7 +4273,6 @@ func (ec *executionContext) unmarshalString2string(v interface{}) (string, error } func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -4345,7 +4281,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) ( } func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -4354,7 +4289,6 @@ func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, e } func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -4363,7 +4297,6 @@ func (ec *executionContext) unmarshalTime2timeᚐTime(v interface{}) (time.Time, } func (ec *executionContext) marshalTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - return graphql.MarshalTime(v) } diff --git a/example/todo/generated.go b/example/todo/generated.go index 3f127bcfa85..020f2d06589 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -1884,38 +1884,30 @@ func (ec *executionContext) unmarshalBoolean2ᚖbool(v interface{}) (*bool, erro } func (ec *executionContext) marshalBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalBoolean2bool(ctx, sel, *v) } func (ec *executionContext) marshalTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._Todo(ctx, sel, v) } func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Schema(ctx, sel, v) } func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Type(ctx, sel, v) } @@ -1928,16 +1920,13 @@ func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, e } func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalString2string(ctx, sel, *v) } func (ec *executionContext) marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v []Todo) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1969,7 +1958,6 @@ func (ec *executionContext) marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋe } func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2001,7 +1989,6 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2033,7 +2020,6 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2065,7 +2051,6 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2097,7 +2082,6 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2149,7 +2133,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{} } func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2185,7 +2168,6 @@ func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { } func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) } @@ -2195,9 +2177,7 @@ func (ec *executionContext) unmarshalRole2githubᚗcomᚋ99designsᚋgqlgenᚋex } func (ec *executionContext) marshalRole2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐRole(ctx context.Context, sel ast.SelectionSet, v Role) graphql.Marshaler { - return v - } func (ec *executionContext) unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodoInput(v interface{}) (TodoInput, error) { @@ -2205,37 +2185,30 @@ func (ec *executionContext) unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { - return ec._Todo(ctx, sel, &v) } func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) } func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) } func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) } func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) } func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) } func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) } @@ -2244,7 +2217,6 @@ func (ec *executionContext) unmarshalInt2int(v interface{}) (int, error) { } func (ec *executionContext) marshalInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - return graphql.MarshalInt(v) } @@ -2253,7 +2225,6 @@ func (ec *executionContext) unmarshalMap2map(v interface{}) (map[string]interfac } func (ec *executionContext) marshalMap2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler { - return graphql.MarshalMap(v) } @@ -2262,7 +2233,6 @@ func (ec *executionContext) unmarshalString2string(v interface{}) (string, error } func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2271,7 +2241,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) ( } func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2280,7 +2249,6 @@ func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, e } func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index a682889cc4a..b9cf6c165ba 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -1899,29 +1899,23 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshalTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec._Todo(ctx, sel, v) } func (ec *executionContext) marshal__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Schema(ctx, sel, v) } func (ec *executionContext) marshal__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.___Type(ctx, sel, v) } @@ -1934,16 +1928,13 @@ func (ec *executionContext) unmarshalString2ᚖstring(v interface{}) (*string, e } func (ec *executionContext) marshalString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { return graphql.Null } - return ec.marshalString2string(ctx, sel, *v) } func (ec *executionContext) marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v []Todo) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -1975,7 +1966,6 @@ func (ec *executionContext) marshalTodo2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋe } func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2007,7 +1997,6 @@ func (ec *executionContext) marshal__Directive2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2039,7 +2028,6 @@ func (ec *executionContext) marshal__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgql } func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2071,7 +2059,6 @@ func (ec *executionContext) marshal__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2103,7 +2090,6 @@ func (ec *executionContext) marshal__InputValue2ᚕgithubᚗcomᚋ99designsᚋgq } func (ec *executionContext) marshal__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2155,7 +2141,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2ᚕstring(v interface{} } func (ec *executionContext) marshal__DirectiveLocation2ᚕstring(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { - ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 @@ -2191,7 +2176,6 @@ func (ec *executionContext) unmarshalBoolean2bool(v interface{}) (bool, error) { } func (ec *executionContext) marshalBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) } @@ -2201,9 +2185,7 @@ func (ec *executionContext) unmarshalState2githubᚗcomᚋ99designsᚋgqlgenᚋe } func (ec *executionContext) marshalState2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐState(ctx context.Context, sel ast.SelectionSet, v State) graphql.Marshaler { - return v - } func (ec *executionContext) unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodoInput(v interface{}) (TodoInput, error) { @@ -2211,37 +2193,30 @@ func (ec *executionContext) unmarshalTodoInput2githubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { - return ec._Todo(ctx, sel, &v) } func (ec *executionContext) marshal__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { - return ec.___Directive(ctx, sel, &v) } func (ec *executionContext) marshal__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { - return ec.___EnumValue(ctx, sel, &v) } func (ec *executionContext) marshal__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { - return ec.___Field(ctx, sel, &v) } func (ec *executionContext) marshal__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { - return ec.___InputValue(ctx, sel, &v) } func (ec *executionContext) marshal__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) } func (ec *executionContext) marshal__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) } @@ -2250,7 +2225,6 @@ func (ec *executionContext) unmarshalID2string(v interface{}) (string, error) { } func (ec *executionContext) marshalID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalID(v) } @@ -2259,7 +2233,6 @@ func (ec *executionContext) unmarshalString2string(v interface{}) (string, error } func (ec *executionContext) marshalString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2268,7 +2241,6 @@ func (ec *executionContext) unmarshal__DirectiveLocation2string(v interface{}) ( } func (ec *executionContext) marshal__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } @@ -2277,7 +2249,6 @@ func (ec *executionContext) unmarshal__TypeKind2string(v interface{}) (string, e } func (ec *executionContext) marshal__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) } diff --git a/integration/generated.go b/integration/generated.go index 3940c1de2c5..42d7c2ef604 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -70,7 +70,6 @@ type ComplexityRoot struct { type ElementResolver interface { Child(ctx context.Context, obj *models.Element) (models.Element, error) Error(ctx context.Context, obj *models.Element) (bool, error) - Mismatched(ctx context.Context, obj *models.Element) ([]bool, error) } type QueryResolver interface { Path(ctx context.Context) ([]*models.Element, error) @@ -476,7 +475,7 @@ func (ec *executionContext) _Element_mismatched(ctx context.Context, field graph ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Element().Mismatched(rctx, obj) + return obj.Mismatched, nil }) if resTmp == nil { return graphql.Null @@ -1627,11 +1626,7 @@ func (ec *executionContext) _Element(ctx context.Context, sel ast.SelectionSet, return res }) case "mismatched": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - res = ec._Element_mismatched(ctx, field, obj) - return res - }) + out.Values[i] = ec._Element_mismatched(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) }