From 30e9b3f1b16098e10e675db77d7cb999890e3ff1 Mon Sep 17 00:00:00 2001 From: Luke Cawood Date: Mon, 20 Jul 2020 15:28:44 +1000 Subject: [PATCH 1/7] Bind directly to pointer types when possible, instead of always binding to value types --- codegen/config/binder.go | 8 + codegen/testserver/generated.go | 337 +++++----------- codegen/testserver/resolver.go | 8 +- codegen/type.go | 6 +- codegen/type.gotpl | 48 ++- example/chat/generated.go | 52 +-- example/config/generated.go | 52 +-- example/dataloader/generated.go | 67 ++-- .../accounts/graph/generated/generated.go | 55 +-- .../products/graph/generated/generated.go | 72 ++-- .../reviews/graph/generated/generated.go | 55 +-- example/fileupload/generated.go | 67 ++-- example/scalars/.gqlgen.yml | 2 + example/scalars/generated.go | 364 +++++++++++++++--- example/scalars/model/model.go | 21 +- example/scalars/resolvers.go | 4 + example/scalars/schema.graphql | 5 + example/selection/generated.go | 45 ++- example/starwars/generated/exec.go | 147 +++---- example/todo/generated.go | 52 +-- example/type-system-extension/generated.go | 49 ++- integration/generated.go | 104 ++--- 22 files changed, 872 insertions(+), 748 deletions(-) diff --git a/codegen/config/binder.go b/codegen/config/binder.go index 45729603a97..514ccc6742e 100644 --- a/codegen/config/binder.go +++ b/codegen/config/binder.go @@ -167,6 +167,7 @@ type TypeReference struct { Definition *ast.Definition GQL *ast.Type GO types.Type + Target types.Type CastType types.Type // Before calling marshalling functions cast from/to this base type Marshaler *types.Func // When using external marshalling functions this will point to the Marshal function Unmarshaler *types.Func // When using external marshalling functions this will point to the Unmarshal function @@ -177,6 +178,7 @@ func (ref *TypeReference) Elem() *TypeReference { if p, isPtr := ref.GO.(*types.Pointer); isPtr { return &TypeReference{ GO: p.Elem(), + Target: ref.Target, GQL: ref.GQL, CastType: ref.CastType, Definition: ref.Definition, @@ -189,6 +191,7 @@ func (ref *TypeReference) Elem() *TypeReference { if ref.IsSlice() { return &TypeReference{ GO: ref.GO.(*types.Slice).Elem(), + Target: ref.Target, GQL: ref.GQL.Elem, CastType: ref.CastType, Definition: ref.Definition, @@ -266,6 +269,10 @@ func (t *TypeReference) UnmarshalFunc() string { return "unmarshal" + t.UniquenessKey() } +func (t *TypeReference) IsTargetNilable() bool { + return IsNilable(t.Target) +} + func (b *Binder) PushRef(ret *TypeReference) { b.References = append(b.References, ret) } @@ -366,6 +373,7 @@ func (b *Binder) TypeReference(schemaType *ast.Type, bindTarget types.Type) (ret ref.GO = obj.Type() } + ref.Target = ref.GO ref.GO = b.CopyModifiersFromAst(schemaType, ref.GO) if bindTarget != nil { diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 584ff77306a..fbba338ffe4 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -12861,7 +12861,8 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(v) + in := v + res := graphql.MarshalBoolean(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -12882,7 +12883,8 @@ func (ec *executionContext) marshalNBytes2ᚕbyte(ctx context.Context, sel ast.S } return graphql.Null } - res := MarshalBytes(v) + in := v + res := MarshalBytes(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -12891,10 +12893,6 @@ func (ec *executionContext) marshalNBytes2ᚕbyte(ctx context.Context, sel ast.S return res } -func (ec *executionContext) marshalNCheckIssue8962githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCheckIssue896(ctx context.Context, sel ast.SelectionSet, v CheckIssue896) graphql.Marshaler { - return ec._CheckIssue896(ctx, sel, &v) -} - func (ec *executionContext) marshalNCheckIssue8962ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCheckIssue896(ctx context.Context, sel ast.SelectionSet, v *CheckIssue896) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -12911,7 +12909,8 @@ func (ec *executionContext) unmarshalNDefaultScalarImplementation2string(ctx con } func (ec *executionContext) marshalNDefaultScalarImplementation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -12960,7 +12959,8 @@ func (ec *executionContext) unmarshalNFallbackToStringEncoding2githubᚗcomᚋ99 } func (ec *executionContext) marshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐFallbackToStringEncoding(ctx context.Context, sel ast.SelectionSet, v FallbackToStringEncoding) graphql.Marshaler { - res := graphql.MarshalString(string(v)) + in := v + res := graphql.MarshalString(string(in)) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -12975,7 +12975,8 @@ func (ec *executionContext) unmarshalNID2int(ctx context.Context, v interface{}) } func (ec *executionContext) marshalNID2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - res := graphql.MarshalIntID(v) + in := v + res := graphql.MarshalIntID(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -12990,7 +12991,8 @@ func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface } func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalID(v) + in := v + res := graphql.MarshalID(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -12999,14 +13001,10 @@ func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.Selec return res } -func (ec *executionContext) unmarshalNInnerDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(ctx context.Context, v interface{}) (InnerDirectives, error) { - res, err := ec.unmarshalInputInnerDirectives(ctx, v) - return res, graphql.WrapErrorWithInputPath(ctx, err) -} - func (ec *executionContext) unmarshalNInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(ctx context.Context, v interface{}) (*InnerDirectives, error) { - res, err := ec.unmarshalNInnerDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := ec.unmarshalInputInnerDirectives(ctx, v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) unmarshalNInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerInput(ctx context.Context, v interface{}) (InnerInput, error) { @@ -13015,12 +13013,9 @@ func (ec *executionContext) unmarshalNInnerInput2githubᚗcomᚋ99designsᚋgqlg } func (ec *executionContext) unmarshalNInnerInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerInput(ctx context.Context, v interface{}) (*InnerInput, error) { - res, err := ec.unmarshalNInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerInput(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) -} - -func (ec *executionContext) marshalNInnerObject2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerObject(ctx context.Context, sel ast.SelectionSet, v InnerObject) graphql.Marshaler { - return ec._InnerObject(ctx, sel, &v) + tmp, err := ec.unmarshalInputInnerInput(ctx, v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalNInnerObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerObject(ctx context.Context, sel ast.SelectionSet, v *InnerObject) graphql.Marshaler { @@ -13044,7 +13039,8 @@ func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{} } func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - res := graphql.MarshalInt(v) + in := v + res := graphql.MarshalInt(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -13059,7 +13055,8 @@ func (ec *executionContext) unmarshalNInt2int32(ctx context.Context, v interface } func (ec *executionContext) marshalNInt2int32(ctx context.Context, sel ast.SelectionSet, v int32) graphql.Marshaler { - res := graphql.MarshalInt32(v) + in := v + res := graphql.MarshalInt32(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -13074,7 +13071,8 @@ func (ec *executionContext) unmarshalNInt2int64(ctx context.Context, v interface } func (ec *executionContext) marshalNInt2int64(ctx context.Context, sel ast.SelectionSet, v int64) graphql.Marshaler { - res := graphql.MarshalInt64(v) + in := v + res := graphql.MarshalInt64(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -13083,10 +13081,6 @@ func (ec *executionContext) marshalNInt2int64(ctx context.Context, sel ast.Selec return res } -func (ec *executionContext) marshalNLoopA2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐLoopA(ctx context.Context, sel ast.SelectionSet, v LoopA) graphql.Marshaler { - return ec._LoopA(ctx, sel, &v) -} - func (ec *executionContext) marshalNLoopA2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐLoopA(ctx context.Context, sel ast.SelectionSet, v *LoopA) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -13097,10 +13091,6 @@ func (ec *executionContext) marshalNLoopA2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec._LoopA(ctx, sel, v) } -func (ec *executionContext) marshalNLoopB2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐLoopB(ctx context.Context, sel ast.SelectionSet, v LoopB) graphql.Marshaler { - return ec._LoopB(ctx, sel, &v) -} - func (ec *executionContext) marshalNLoopB2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐLoopB(ctx context.Context, sel ast.SelectionSet, v *LoopB) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -13151,14 +13141,10 @@ func (ec *executionContext) marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋg return ret } -func (ec *executionContext) unmarshalNNestedInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐNestedInput(ctx context.Context, v interface{}) (NestedInput, error) { - res, err := ec.unmarshalInputNestedInput(ctx, v) - return res, graphql.WrapErrorWithInputPath(ctx, err) -} - func (ec *executionContext) unmarshalNNestedInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐNestedInput(ctx context.Context, v interface{}) (*NestedInput, error) { - res, err := ec.unmarshalNNestedInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐNestedInput(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := ec.unmarshalInputNestedInput(ctx, v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐNode(ctx context.Context, sel ast.SelectionSet, v Node) graphql.Marshaler { @@ -13279,7 +13265,8 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -13349,8 +13336,9 @@ func (ec *executionContext) marshalNString2ᚕᚖstring(ctx context.Context, sel } func (ec *executionContext) unmarshalNString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { - res, err := ec.unmarshalNString2string(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalString(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalNString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { @@ -13360,7 +13348,14 @@ func (ec *executionContext) marshalNString2ᚖstring(ctx context.Context, sel as } return graphql.Null } - return ec.marshalNString2string(ctx, sel, *v) + in := *v + res := graphql.MarshalString(in) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + } + return res } func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v interface{}) (time.Time, error) { @@ -13369,7 +13364,8 @@ func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v in } func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - res := graphql.MarshalTime(v) + in := v + res := graphql.MarshalTime(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -13384,7 +13380,8 @@ func (ec *executionContext) unmarshalNUUID2string(ctx context.Context, v interfa } func (ec *executionContext) marshalNUUID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -13460,7 +13457,8 @@ func (ec *executionContext) unmarshalNWrappedScalar2githubᚗcomᚋ99designsᚋg } func (ec *executionContext) marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐWrappedScalar(ctx context.Context, sel ast.SelectionSet, v WrappedScalar) graphql.Marshaler { - res := graphql.MarshalString(string(v)) + in := v + res := graphql.MarshalString(string(in)) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -13540,7 +13538,8 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -13713,7 +13712,8 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -13729,10 +13729,6 @@ func (ec *executionContext) marshalOAnimal2githubᚗcomᚋ99designsᚋgqlgenᚋc return ec._Animal(ctx, sel, v) } -func (ec *executionContext) marshalOAutobind2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐAutobind(ctx context.Context, sel ast.SelectionSet, v Autobind) graphql.Marshaler { - return ec._Autobind(ctx, sel, &v) -} - func (ec *executionContext) marshalOAutobind2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐAutobind(ctx context.Context, sel ast.SelectionSet, v *Autobind) graphql.Marshaler { if v == nil { return graphql.Null @@ -13753,22 +13749,25 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) + in := v + return graphql.MarshalBoolean(in) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOBoolean2bool(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalBoolean(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOBoolean2bool(ctx, sel, *v) + in := *v + return graphql.MarshalBoolean(in) } func (ec *executionContext) unmarshalOChanges2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { @@ -13778,10 +13777,6 @@ func (ec *executionContext) unmarshalOChanges2map(ctx context.Context, v interfa return v.(map[string]interface{}), nil } -func (ec *executionContext) marshalOCheckIssue8962githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCheckIssue896(ctx context.Context, sel ast.SelectionSet, v CheckIssue896) graphql.Marshaler { - return ec._CheckIssue896(ctx, sel, &v) -} - func (ec *executionContext) marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCheckIssue896(ctx context.Context, sel ast.SelectionSet, v []*CheckIssue896) graphql.Marshaler { if v == nil { return graphql.Null @@ -13869,10 +13864,6 @@ func (ec *executionContext) marshalOCheckIssue8962ᚖgithubᚗcomᚋ99designsᚋ return ec._CheckIssue896(ctx, sel, v) } -func (ec *executionContext) marshalOCircle2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCircle(ctx context.Context, sel ast.SelectionSet, v Circle) graphql.Marshaler { - return ec._Circle(ctx, sel, &v) -} - func (ec *executionContext) marshalOCircle2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐCircle(ctx context.Context, sel ast.SelectionSet, v *Circle) graphql.Marshaler { if v == nil { return graphql.Null @@ -13880,32 +13871,21 @@ func (ec *executionContext) marshalOCircle2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec._Circle(ctx, sel, v) } -func (ec *executionContext) unmarshalODefaultScalarImplementation2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.WrapErrorWithInputPath(ctx, err) -} - -func (ec *executionContext) marshalODefaultScalarImplementation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) -} - func (ec *executionContext) unmarshalODefaultScalarImplementation2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalODefaultScalarImplementation2string(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalString(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalODefaultScalarImplementation2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalODefaultScalarImplementation2string(ctx, sel, *v) -} - -func (ec *executionContext) marshalOEmbeddedCase12githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐEmbeddedCase1(ctx context.Context, sel ast.SelectionSet, v EmbeddedCase1) graphql.Marshaler { - return ec._EmbeddedCase1(ctx, sel, &v) + in := *v + return graphql.MarshalString(in) } func (ec *executionContext) marshalOEmbeddedCase12ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐEmbeddedCase1(ctx context.Context, sel ast.SelectionSet, v *EmbeddedCase1) graphql.Marshaler { @@ -13915,10 +13895,6 @@ func (ec *executionContext) marshalOEmbeddedCase12ᚖgithubᚗcomᚋ99designsᚋ return ec._EmbeddedCase1(ctx, sel, v) } -func (ec *executionContext) marshalOEmbeddedCase22githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐEmbeddedCase2(ctx context.Context, sel ast.SelectionSet, v EmbeddedCase2) graphql.Marshaler { - return ec._EmbeddedCase2(ctx, sel, &v) -} - func (ec *executionContext) marshalOEmbeddedCase22ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐEmbeddedCase2(ctx context.Context, sel ast.SelectionSet, v *EmbeddedCase2) graphql.Marshaler { if v == nil { return graphql.Null @@ -13926,10 +13902,6 @@ func (ec *executionContext) marshalOEmbeddedCase22ᚖgithubᚗcomᚋ99designsᚋ return ec._EmbeddedCase2(ctx, sel, v) } -func (ec *executionContext) marshalOEmbeddedCase32githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐEmbeddedCase3(ctx context.Context, sel ast.SelectionSet, v EmbeddedCase3) graphql.Marshaler { - return ec._EmbeddedCase3(ctx, sel, &v) -} - func (ec *executionContext) marshalOEmbeddedCase32ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐEmbeddedCase3(ctx context.Context, sel ast.SelectionSet, v *EmbeddedCase3) graphql.Marshaler { if v == nil { return graphql.Null @@ -13937,10 +13909,6 @@ func (ec *executionContext) marshalOEmbeddedCase32ᚖgithubᚗcomᚋ99designsᚋ return ec._EmbeddedCase3(ctx, sel, v) } -func (ec *executionContext) marshalOError2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx context.Context, sel ast.SelectionSet, v Error) graphql.Marshaler { - return ec._Error(ctx, sel, &v) -} - func (ec *executionContext) marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx context.Context, sel ast.SelectionSet, v *Error) graphql.Marshaler { if v == nil { return graphql.Null @@ -13948,10 +13916,6 @@ func (ec *executionContext) marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec._Error(ctx, sel, v) } -func (ec *executionContext) marshalOErrors2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐErrors(ctx context.Context, sel ast.SelectionSet, v Errors) graphql.Marshaler { - return ec._Errors(ctx, sel, &v) -} - func (ec *executionContext) marshalOErrors2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐErrors(ctx context.Context, sel ast.SelectionSet, v *Errors) graphql.Marshaler { if v == nil { return graphql.Null @@ -13965,24 +13929,16 @@ func (ec *executionContext) unmarshalOFloat2float64(ctx context.Context, v inter } func (ec *executionContext) marshalOFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { - return graphql.MarshalFloat(v) -} - -func (ec *executionContext) unmarshalOInnerDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(ctx context.Context, v interface{}) (InnerDirectives, error) { - res, err := ec.unmarshalInputInnerDirectives(ctx, v) - return res, graphql.WrapErrorWithInputPath(ctx, err) + in := v + return graphql.MarshalFloat(in) } func (ec *executionContext) unmarshalOInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(ctx context.Context, v interface{}) (*InnerDirectives, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOInnerDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) -} - -func (ec *executionContext) unmarshalOInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(ctx context.Context, v interface{}) (InputDirectives, error) { - res, err := ec.unmarshalInputInputDirectives(ctx, v) + tmp, err := ec.unmarshalInputInnerDirectives(ctx, v) + res := &tmp return res, graphql.WrapErrorWithInputPath(ctx, err) } @@ -13990,12 +13946,8 @@ func (ec *executionContext) unmarshalOInputDirectives2ᚖgithubᚗcomᚋ99design if v == nil { return nil, nil } - res, err := ec.unmarshalOInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) -} - -func (ec *executionContext) unmarshalOInputWithEnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputWithEnumValue(ctx context.Context, v interface{}) (InputWithEnumValue, error) { - res, err := ec.unmarshalInputInputWithEnumValue(ctx, v) + tmp, err := ec.unmarshalInputInputDirectives(ctx, v) + res := &tmp return res, graphql.WrapErrorWithInputPath(ctx, err) } @@ -14003,36 +13955,26 @@ func (ec *executionContext) unmarshalOInputWithEnumValue2ᚖgithubᚗcomᚋ99des if v == nil { return nil, nil } - res, err := ec.unmarshalOInputWithEnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputWithEnumValue(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) -} - -func (ec *executionContext) unmarshalOInt2int(ctx context.Context, v interface{}) (int, error) { - res, err := graphql.UnmarshalInt(v) + tmp, err := ec.unmarshalInputInputWithEnumValue(ctx, v) + res := &tmp return res, graphql.WrapErrorWithInputPath(ctx, err) } -func (ec *executionContext) marshalOInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - return graphql.MarshalInt(v) -} - func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v interface{}) (*int, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOInt2int(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalInt(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOInt2int(ctx, sel, *v) -} - -func (ec *executionContext) marshalOInvalidIdentifier2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx context.Context, sel ast.SelectionSet, v invalid_packagename.InvalidIdentifier) graphql.Marshaler { - return ec._InvalidIdentifier(ctx, sel, &v) + in := *v + return graphql.MarshalInt(in) } func (ec *executionContext) marshalOInvalidIdentifier2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx context.Context, sel ast.SelectionSet, v *invalid_packagename.InvalidIdentifier) graphql.Marshaler { @@ -14042,10 +13984,6 @@ func (ec *executionContext) marshalOInvalidIdentifier2ᚖgithubᚗcomᚋ99design return ec._InvalidIdentifier(ctx, sel, v) } -func (ec *executionContext) marshalOIt2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋintrospectionᚐIt(ctx context.Context, sel ast.SelectionSet, v introspection1.It) graphql.Marshaler { - return ec._It(ctx, sel, &v) -} - func (ec *executionContext) marshalOIt2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋintrospectionᚐIt(ctx context.Context, sel ast.SelectionSet, v *introspection1.It) graphql.Marshaler { if v == nil { return graphql.Null @@ -14067,10 +14005,6 @@ func (ec *executionContext) marshalOMapStringInterfaceType2map(ctx context.Conte return ec._MapStringInterfaceType(ctx, sel, v) } -func (ec *executionContext) marshalOModelMethods2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐModelMethods(ctx context.Context, sel ast.SelectionSet, v ModelMethods) graphql.Marshaler { - return ec._ModelMethods(ctx, sel, &v) -} - func (ec *executionContext) marshalOModelMethods2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐModelMethods(ctx context.Context, sel ast.SelectionSet, v *ModelMethods) graphql.Marshaler { if v == nil { return graphql.Null @@ -14078,21 +14012,13 @@ func (ec *executionContext) marshalOModelMethods2ᚖgithubᚗcomᚋ99designsᚋg return ec._ModelMethods(ctx, sel, v) } -func (ec *executionContext) unmarshalONestedMapInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐNestedMapInput(ctx context.Context, v interface{}) (NestedMapInput, error) { - res, err := ec.unmarshalInputNestedMapInput(ctx, v) - return res, graphql.WrapErrorWithInputPath(ctx, err) -} - func (ec *executionContext) unmarshalONestedMapInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐNestedMapInput(ctx context.Context, v interface{}) (*NestedMapInput, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalONestedMapInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐNestedMapInput(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) -} - -func (ec *executionContext) marshalOObjectDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐObjectDirectives(ctx context.Context, sel ast.SelectionSet, v ObjectDirectives) graphql.Marshaler { - return ec._ObjectDirectives(ctx, sel, &v) + tmp, err := ec.unmarshalInputNestedMapInput(ctx, v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOObjectDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐObjectDirectives(ctx context.Context, sel ast.SelectionSet, v *ObjectDirectives) graphql.Marshaler { @@ -14102,10 +14028,6 @@ func (ec *executionContext) marshalOObjectDirectives2ᚖgithubᚗcomᚋ99designs return ec._ObjectDirectives(ctx, sel, v) } -func (ec *executionContext) marshalOObjectDirectivesWithCustomGoModel2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐObjectDirectivesWithCustomGoModel(ctx context.Context, sel ast.SelectionSet, v ObjectDirectivesWithCustomGoModel) graphql.Marshaler { - return ec._ObjectDirectivesWithCustomGoModel(ctx, sel, &v) -} - func (ec *executionContext) marshalOObjectDirectivesWithCustomGoModel2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐObjectDirectivesWithCustomGoModel(ctx context.Context, sel ast.SelectionSet, v *ObjectDirectivesWithCustomGoModel) graphql.Marshaler { if v == nil { return graphql.Null @@ -14113,11 +14035,6 @@ func (ec *executionContext) marshalOObjectDirectivesWithCustomGoModel2ᚖgithub return ec._ObjectDirectivesWithCustomGoModel(ctx, sel, v) } -func (ec *executionContext) unmarshalOOuterInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(ctx context.Context, v interface{}) (OuterInput, error) { - res, err := ec.unmarshalInputOuterInput(ctx, v) - return res, graphql.WrapErrorWithInputPath(ctx, err) -} - func (ec *executionContext) unmarshalOOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(ctx context.Context, v interface{}) ([][]*OuterInput, error) { if v == nil { return nil, nil @@ -14170,12 +14087,9 @@ func (ec *executionContext) unmarshalOOuterInput2ᚖgithubᚗcomᚋ99designsᚋg if v == nil { return nil, nil } - res, err := ec.unmarshalOOuterInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterInput(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) -} - -func (ec *executionContext) marshalOOuterObject2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v OuterObject) graphql.Marshaler { - return ec._OuterObject(ctx, sel, &v) + tmp, err := ec.unmarshalInputOuterInput(ctx, v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOOuterObject2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v [][]*OuterObject) graphql.Marshaler { @@ -14265,10 +14179,6 @@ func (ec *executionContext) marshalOOuterObject2ᚖgithubᚗcomᚋ99designsᚋgq return ec._OuterObject(ctx, sel, v) } -func (ec *executionContext) marshalOOverlappingFields2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOverlappingFields(ctx context.Context, sel ast.SelectionSet, v OverlappingFields) graphql.Marshaler { - return ec._OverlappingFields(ctx, sel, &v) -} - func (ec *executionContext) marshalOOverlappingFields2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOverlappingFields(ctx context.Context, sel ast.SelectionSet, v *OverlappingFields) graphql.Marshaler { if v == nil { return graphql.Null @@ -14276,10 +14186,6 @@ func (ec *executionContext) marshalOOverlappingFields2ᚖgithubᚗcomᚋ99design return ec._OverlappingFields(ctx, sel, v) } -func (ec *executionContext) marshalOPanics2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPanics(ctx context.Context, sel ast.SelectionSet, v Panics) graphql.Marshaler { - return ec._Panics(ctx, sel, &v) -} - func (ec *executionContext) marshalOPanics2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPanics(ctx context.Context, sel ast.SelectionSet, v *Panics) graphql.Marshaler { if v == nil { return graphql.Null @@ -14287,11 +14193,6 @@ func (ec *executionContext) marshalOPanics2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec._Panics(ctx, sel, v) } -func (ec *executionContext) unmarshalORecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(ctx context.Context, v interface{}) (RecursiveInputSlice, error) { - res, err := ec.unmarshalInputRecursiveInputSlice(ctx, v) - return res, graphql.WrapErrorWithInputPath(ctx, err) -} - func (ec *executionContext) unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSliceᚄ(ctx context.Context, v interface{}) ([]RecursiveInputSlice, error) { if v == nil { return nil, nil @@ -14320,8 +14221,9 @@ func (ec *executionContext) unmarshalORecursiveInputSlice2ᚖgithubᚗcomᚋ99de if v == nil { return nil, nil } - res, err := ec.unmarshalORecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := ec.unmarshalInputRecursiveInputSlice(ctx, v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx context.Context, sel ast.SelectionSet, v Shape) graphql.Marshaler { @@ -14371,10 +14273,6 @@ func (ec *executionContext) marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) marshalOSlices2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐSlices(ctx context.Context, sel ast.SelectionSet, v Slices) graphql.Marshaler { - return ec._Slices(ctx, sel, &v) -} - func (ec *executionContext) marshalOSlices2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐSlices(ctx context.Context, sel ast.SelectionSet, v *Slices) graphql.Marshaler { if v == nil { return graphql.Null @@ -14388,7 +14286,8 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) + in := v + return graphql.MarshalString(in) } func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { @@ -14467,15 +14366,17 @@ func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v in if v == nil { return nil, nil } - res, err := ec.unmarshalOString2string(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalString(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOString2string(ctx, sel, *v) + in := *v + return graphql.MarshalString(in) } func (ec *executionContext) marshalOTestUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐTestUnion(ctx context.Context, sel ast.SelectionSet, v TestUnion) graphql.Marshaler { @@ -14485,69 +14386,47 @@ func (ec *executionContext) marshalOTestUnion2githubᚗcomᚋ99designsᚋgqlgen return ec._TestUnion(ctx, sel, v) } -func (ec *executionContext) unmarshalOThirdParty2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐThirdParty(ctx context.Context, v interface{}) (ThirdParty, error) { - res, err := UnmarshalThirdParty(v) - return res, graphql.WrapErrorWithInputPath(ctx, err) -} - -func (ec *executionContext) marshalOThirdParty2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐThirdParty(ctx context.Context, sel ast.SelectionSet, v ThirdParty) graphql.Marshaler { - return MarshalThirdParty(v) -} - func (ec *executionContext) unmarshalOThirdParty2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐThirdParty(ctx context.Context, v interface{}) (*ThirdParty, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOThirdParty2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐThirdParty(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := UnmarshalThirdParty(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOThirdParty2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐThirdParty(ctx context.Context, sel ast.SelectionSet, v *ThirdParty) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOThirdParty2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐThirdParty(ctx, sel, *v) -} - -func (ec *executionContext) unmarshalOTime2timeᚐTime(ctx context.Context, v interface{}) (time.Time, error) { - res, err := graphql.UnmarshalTime(v) - return res, graphql.WrapErrorWithInputPath(ctx, err) -} - -func (ec *executionContext) marshalOTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - return graphql.MarshalTime(v) + in := *v + return MarshalThirdParty(in) } func (ec *executionContext) unmarshalOTime2ᚖtimeᚐTime(ctx context.Context, v interface{}) (*time.Time, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOTime2timeᚐTime(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalTime(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOTime2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOTime2timeᚐTime(ctx, sel, *v) -} - -func (ec *executionContext) unmarshalOValidInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐValidInput(ctx context.Context, v interface{}) (ValidInput, error) { - res, err := ec.unmarshalInputValidInput(ctx, v) - return res, graphql.WrapErrorWithInputPath(ctx, err) + in := *v + return graphql.MarshalTime(in) } func (ec *executionContext) unmarshalOValidInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐValidInput(ctx context.Context, v interface{}) (*ValidInput, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOValidInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐValidInput(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) -} - -func (ec *executionContext) marshalOValidType2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐValidType(ctx context.Context, sel ast.SelectionSet, v ValidType) graphql.Marshaler { - return ec._ValidType(ctx, sel, &v) + tmp, err := ec.unmarshalInputValidInput(ctx, v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOValidType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐValidType(ctx context.Context, sel ast.SelectionSet, v *ValidType) graphql.Marshaler { @@ -14677,10 +14556,6 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg return ret } -func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { if v == nil { return graphql.Null @@ -14688,10 +14563,6 @@ func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlge return ec.___Schema(ctx, sel, v) } -func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index e8f1a3a8599..9b0e2e584ee 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -332,9 +332,7 @@ func (r *wrappedSliceResolver) Get(ctx context.Context, obj WrappedSlice, idx in } // BackedByInterface returns BackedByInterfaceResolver implementation. -func (r *Resolver) BackedByInterface() BackedByInterfaceResolver { - return &backedByInterfaceResolver{r} -} +func (r *Resolver) BackedByInterface() BackedByInterfaceResolver { return &backedByInterfaceResolver{r} } // Errors returns ErrorsResolver implementation. func (r *Resolver) Errors() ErrorsResolver { return &errorsResolver{r} } @@ -349,9 +347,7 @@ func (r *Resolver) ModelMethods() ModelMethodsResolver { return &modelMethodsRes func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } // OverlappingFields returns OverlappingFieldsResolver implementation. -func (r *Resolver) OverlappingFields() OverlappingFieldsResolver { - return &overlappingFieldsResolver{r} -} +func (r *Resolver) OverlappingFields() OverlappingFieldsResolver { return &overlappingFieldsResolver{r} } // Panics returns PanicsResolver implementation. func (r *Resolver) Panics() PanicsResolver { return &panicsResolver{r} } diff --git a/codegen/type.go b/codegen/type.go index df036fcdf73..a18de31ae87 100644 --- a/codegen/type.go +++ b/codegen/type.go @@ -25,7 +25,11 @@ func (b *builder) buildTypes() map[string]*config.TypeReference { } ret[key] = ref - ref = ref.Elem() + if ref.IsSlice() { + ref = ref.Elem() + } else { + break + } } } return ret diff --git a/codegen/type.gotpl b/codegen/type.gotpl index cc8b21bcafa..f1639ea0db4 100644 --- a/codegen/type.gotpl +++ b/codegen/type.gotpl @@ -4,10 +4,7 @@ {{- if and $type.IsNilable (not $type.GQL.NonNull) }} if v == nil { return nil, nil } {{- end }} - {{- if $type.IsPtr }} - res, err := ec.{{ $type.Elem.UnmarshalFunc }}(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) - {{- else if $type.IsSlice }} + {{- if $type.IsSlice }} var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -31,6 +28,14 @@ {{- if $type.CastType }} tmp, err := {{ $type.Unmarshaler | call }}(v) return {{ $type.GO | ref }}(tmp), graphql.WrapErrorWithInputPath(ctx, err) + {{- else if and $type.IsTargetNilable (not $type.IsNilable) }} + tmp, err := {{ $type.Unmarshaler | call }}(v) + res := *tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) + {{- else if and (not $type.IsTargetNilable) $type.IsNilable }} + tmp, err := {{ $type.Unmarshaler | call }}(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) {{- else}} res, err := {{ $type.Unmarshaler | call }}(v) return res, graphql.WrapErrorWithInputPath(ctx, err) @@ -38,12 +43,26 @@ {{- else if eq ($type.GO | ref) "map[string]interface{}" }} return v.(map[string]interface{}), nil {{- else if $type.IsMarshaler }} - var res {{ $type.GO | ref }} + {{- if $type.IsNilable }} + var res = new({{ $type.Elem.GO | ref }}) + {{- else}} + var res {{ $type.GO | ref }} + {{- end }} err := res.UnmarshalGQL(v) return res, graphql.WrapErrorWithInputPath(ctx, err) {{- else }} - res, err := ec.unmarshalInput{{ $type.GQL.Name }}(ctx, v) - return res, graphql.WrapErrorWithInputPath(ctx, err) + {{- if and $type.IsTargetNilable (not $type.IsNilable) }} + tmp, err := ec.unmarshalInput{{ $type.GQL.Name }}(ctx, v) + res := *tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) + {{- else if and (not $type.IsTargetNilable) $type.IsNilable }} + tmp, err := ec.unmarshalInput{{ $type.GQL.Name }}(ctx, v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) + {{- else}} + res, err := ec.unmarshalInput{{ $type.GQL.Name }}(ctx, v) + return res, graphql.WrapErrorWithInputPath(ctx, err) + {{- end }} {{- end }} {{- end }} } @@ -110,10 +129,15 @@ {{- if $type.IsMarshaler }} return v {{- else if $type.Marshaler }} - {{- if $type.IsPtr }} - return ec.{{ $type.Elem.MarshalFunc }}(ctx, sel, *v) - {{- else if $type.GQL.NonNull }} - res := {{ $type.Marshaler | call }}({{- if $type.CastType }}{{ $type.CastType | ref }}(v){{else}}v{{- end }}) + {{- if and $type.IsTargetNilable (not $type.IsNilable) }} + in := &v + {{- else if and (not $type.IsTargetNilable) $type.IsNilable }} + in := *v + {{- else}} + in := v + {{- end }} + {{- if $type.GQL.NonNull }} + res := {{ $type.Marshaler | call }}({{- if $type.CastType }}{{ $type.CastType | ref }}(in){{else}}in{{- end }}) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -121,7 +145,7 @@ } return res {{- else }} - return {{ $type.Marshaler | call }}({{- if $type.CastType }}{{ $type.CastType | ref }}(v){{else}}v{{- end }}) + return {{ $type.Marshaler | call }}({{- if $type.CastType }}{{ $type.CastType | ref }}(in){{else}}in{{- end }}) {{- end }} {{- else }} return ec._{{$type.Definition.Name}}(ctx, sel, {{ if not $type.IsNilable}}&{{end}} v) diff --git a/example/chat/generated.go b/example/chat/generated.go index 7e7e5d2143a..a513be1f77f 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -2342,7 +2342,8 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(v) + in := v + res := graphql.MarshalBoolean(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2357,7 +2358,8 @@ func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface } func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalID(v) + in := v + res := graphql.MarshalID(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2423,7 +2425,8 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2438,7 +2441,8 @@ func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v in } func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - res := graphql.MarshalTime(v) + in := v + res := graphql.MarshalTime(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2494,7 +2498,8 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2667,7 +2672,8 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2682,26 +2688,25 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) + in := v + return graphql.MarshalBoolean(in) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOBoolean2bool(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalBoolean(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOBoolean2bool(ctx, sel, *v) -} - -func (ec *executionContext) marshalOChatroom2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐChatroom(ctx context.Context, sel ast.SelectionSet, v Chatroom) graphql.Marshaler { - return ec._Chatroom(ctx, sel, &v) + in := *v + return graphql.MarshalBoolean(in) } func (ec *executionContext) marshalOChatroom2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐChatroom(ctx context.Context, sel ast.SelectionSet, v *Chatroom) graphql.Marshaler { @@ -2717,22 +2722,25 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) + in := v + return graphql.MarshalString(in) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOString2string(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalString(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOString2string(ctx, sel, *v) + in := *v + return graphql.MarshalString(in) } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { @@ -2855,10 +2863,6 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg return ret } -func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { if v == nil { return graphql.Null @@ -2866,10 +2870,6 @@ func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlge return ec.___Schema(ctx, sel, v) } -func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/example/config/generated.go b/example/config/generated.go index de77bd4a5ea..45a8af78c9d 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -2214,7 +2214,8 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(v) + in := v + res := graphql.MarshalBoolean(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2229,7 +2230,8 @@ func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface } func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalID(v) + in := v + res := graphql.MarshalID(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2244,7 +2246,8 @@ func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{} } func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - res := graphql.MarshalInt(v) + in := v + res := graphql.MarshalInt(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2264,7 +2267,8 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2324,10 +2328,6 @@ func (ec *executionContext) marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ return ec._Todo(ctx, sel, v) } -func (ec *executionContext) marshalNUser2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler { - return ec._User(ctx, sel, &v) -} - func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋconfigᚐUser(ctx context.Context, sel ast.SelectionSet, v *User) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -2385,7 +2385,8 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2558,7 +2559,8 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2573,22 +2575,25 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) + in := v + return graphql.MarshalBoolean(in) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOBoolean2bool(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalBoolean(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOBoolean2bool(ctx, sel, *v) + in := *v + return graphql.MarshalBoolean(in) } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { @@ -2597,7 +2602,8 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) + in := v + return graphql.MarshalString(in) } func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { @@ -2640,15 +2646,17 @@ func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v in if v == nil { return nil, nil } - res, err := ec.unmarshalOString2string(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalString(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOString2string(ctx, sel, *v) + in := *v + return graphql.MarshalString(in) } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { @@ -2771,10 +2779,6 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg return ret } -func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { if v == nil { return graphql.Null @@ -2782,10 +2786,6 @@ func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlge return ec.___Schema(ctx, sel, v) } -func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index 075e7397c14..147492a7a09 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -2509,7 +2509,8 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(v) + in := v + res := graphql.MarshalBoolean(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2518,10 +2519,6 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se return res } -func (ec *executionContext) marshalNCustomer2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v Customer) graphql.Marshaler { - return ec._Customer(ctx, sel, &v) -} - func (ec *executionContext) marshalNCustomer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v *Customer) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -2538,7 +2535,8 @@ func (ec *executionContext) unmarshalNFloat2float64(ctx context.Context, v inter } func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { - res := graphql.MarshalFloat(v) + in := v + res := graphql.MarshalFloat(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2553,7 +2551,8 @@ func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{} } func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - res := graphql.MarshalInt(v) + in := v + res := graphql.MarshalInt(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2562,10 +2561,6 @@ func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.Selecti return res } -func (ec *executionContext) marshalNItem2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐItem(ctx context.Context, sel ast.SelectionSet, v Item) graphql.Marshaler { - return ec._Item(ctx, sel, &v) -} - func (ec *executionContext) marshalNItem2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐItem(ctx context.Context, sel ast.SelectionSet, v *Item) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -2576,10 +2571,6 @@ func (ec *executionContext) marshalNItem2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ return ec._Item(ctx, sel, v) } -func (ec *executionContext) marshalNOrder2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐOrder(ctx context.Context, sel ast.SelectionSet, v Order) graphql.Marshaler { - return ec._Order(ctx, sel, &v) -} - func (ec *executionContext) marshalNOrder2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐOrder(ctx context.Context, sel ast.SelectionSet, v *Order) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -2596,7 +2587,8 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2611,7 +2603,8 @@ func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v in } func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - res := graphql.MarshalTime(v) + in := v + res := graphql.MarshalTime(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2667,7 +2660,8 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2840,7 +2834,8 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2849,10 +2844,6 @@ func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel a return res } -func (ec *executionContext) marshalOAddress2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐAddress(ctx context.Context, sel ast.SelectionSet, v Address) graphql.Marshaler { - return ec._Address(ctx, sel, &v) -} - func (ec *executionContext) marshalOAddress2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐAddress(ctx context.Context, sel ast.SelectionSet, v *Address) graphql.Marshaler { if v == nil { return graphql.Null @@ -2866,22 +2857,25 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) + in := v + return graphql.MarshalBoolean(in) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOBoolean2bool(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalBoolean(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOBoolean2bool(ctx, sel, *v) + in := *v + return graphql.MarshalBoolean(in) } func (ec *executionContext) marshalOCustomer2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v [][]*Customer) graphql.Marshaler { @@ -3122,22 +3116,25 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) + in := v + return graphql.MarshalString(in) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOString2string(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalString(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOString2string(ctx, sel, *v) + in := *v + return graphql.MarshalString(in) } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { @@ -3260,10 +3257,6 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg return ret } -func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { if v == nil { return graphql.Null @@ -3271,10 +3264,6 @@ func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlge return ec.___Schema(ctx, sel, v) } -func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/example/federation/accounts/graph/generated/generated.go b/example/federation/accounts/graph/generated/generated.go index 810ef99a9d5..e6751f1d816 100644 --- a/example/federation/accounts/graph/generated/generated.go +++ b/example/federation/accounts/graph/generated/generated.go @@ -2134,7 +2134,8 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(v) + in := v + res := graphql.MarshalBoolean(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2149,7 +2150,8 @@ func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface } func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalID(v) + in := v + res := graphql.MarshalID(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2164,7 +2166,8 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2199,7 +2202,8 @@ func (ec *executionContext) marshalN_Any2map(ctx context.Context, sel ast.Select } return graphql.Null } - res := graphql.MarshalMap(v) + in := v + res := graphql.MarshalMap(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2281,7 +2285,8 @@ func (ec *executionContext) unmarshalN_FieldSet2string(ctx context.Context, v in } func (ec *executionContext) marshalN_FieldSet2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2341,7 +2346,8 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2514,7 +2520,8 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2529,22 +2536,25 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) + in := v + return graphql.MarshalBoolean(in) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOBoolean2bool(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalBoolean(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOBoolean2bool(ctx, sel, *v) + in := *v + return graphql.MarshalBoolean(in) } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { @@ -2553,26 +2563,25 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) + in := v + return graphql.MarshalString(in) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOString2string(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalString(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOString2string(ctx, sel, *v) -} - -func (ec *executionContext) marshalOUser2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋaccountsᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v model.User) graphql.Marshaler { - return ec._User(ctx, sel, &v) + in := *v + return graphql.MarshalString(in) } func (ec *executionContext) marshalOUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋaccountsᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { @@ -2709,10 +2718,6 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg return ret } -func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { if v == nil { return graphql.Null @@ -2720,10 +2725,6 @@ func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlge return ec.___Schema(ctx, sel, v) } -func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/example/federation/products/graph/generated/generated.go b/example/federation/products/graph/generated/generated.go index 3d0a390d1e2..a25fd614512 100644 --- a/example/federation/products/graph/generated/generated.go +++ b/example/federation/products/graph/generated/generated.go @@ -2209,7 +2209,8 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(v) + in := v + res := graphql.MarshalBoolean(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2224,7 +2225,8 @@ func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{} } func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - res := graphql.MarshalInt(v) + in := v + res := graphql.MarshalInt(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2253,7 +2255,8 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2274,7 +2277,8 @@ func (ec *executionContext) marshalN_Any2map(ctx context.Context, sel ast.Select } return graphql.Null } - res := graphql.MarshalMap(v) + in := v + res := graphql.MarshalMap(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2356,7 +2360,8 @@ func (ec *executionContext) unmarshalN_FieldSet2string(ctx context.Context, v in } func (ec *executionContext) marshalN_FieldSet2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2416,7 +2421,8 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2589,7 +2595,8 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2604,50 +2611,42 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) + in := v + return graphql.MarshalBoolean(in) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOBoolean2bool(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalBoolean(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOBoolean2bool(ctx, sel, *v) -} - -func (ec *executionContext) unmarshalOInt2int(ctx context.Context, v interface{}) (int, error) { - res, err := graphql.UnmarshalInt(v) - return res, graphql.WrapErrorWithInputPath(ctx, err) -} - -func (ec *executionContext) marshalOInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - return graphql.MarshalInt(v) + in := *v + return graphql.MarshalBoolean(in) } func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v interface{}) (*int, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOInt2int(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalInt(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOInt2int(ctx, sel, *v) -} - -func (ec *executionContext) marshalOProduct2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋproductsᚋgraphᚋmodelᚐProduct(ctx context.Context, sel ast.SelectionSet, v model.Product) graphql.Marshaler { - return ec._Product(ctx, sel, &v) + in := *v + return graphql.MarshalInt(in) } func (ec *executionContext) marshalOProduct2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋproductsᚋgraphᚋmodelᚐProduct(ctx context.Context, sel ast.SelectionSet, v []*model.Product) graphql.Marshaler { @@ -2703,22 +2702,25 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) + in := v + return graphql.MarshalString(in) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOString2string(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalString(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOString2string(ctx, sel, *v) + in := *v + return graphql.MarshalString(in) } func (ec *executionContext) marshalO_Entity2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v fedruntime.Entity) graphql.Marshaler { @@ -2848,10 +2850,6 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg return ret } -func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { if v == nil { return graphql.Null @@ -2859,10 +2857,6 @@ func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlge return ec.___Schema(ctx, sel, v) } -func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/example/federation/reviews/graph/generated/generated.go b/example/federation/reviews/graph/generated/generated.go index a339df5b37d..def58941b6a 100644 --- a/example/federation/reviews/graph/generated/generated.go +++ b/example/federation/reviews/graph/generated/generated.go @@ -2478,7 +2478,8 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(v) + in := v + res := graphql.MarshalBoolean(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2493,7 +2494,8 @@ func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface } func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalID(v) + in := v + res := graphql.MarshalID(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2522,7 +2524,8 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2557,7 +2560,8 @@ func (ec *executionContext) marshalN_Any2map(ctx context.Context, sel ast.Select } return graphql.Null } - res := graphql.MarshalMap(v) + in := v + res := graphql.MarshalMap(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2639,7 +2643,8 @@ func (ec *executionContext) unmarshalN_FieldSet2string(ctx context.Context, v in } func (ec *executionContext) marshalN_FieldSet2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2699,7 +2704,8 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2872,7 +2878,8 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2887,26 +2894,25 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) + in := v + return graphql.MarshalBoolean(in) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOBoolean2bool(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalBoolean(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOBoolean2bool(ctx, sel, *v) -} - -func (ec *executionContext) marshalOReview2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋreviewsᚋgraphᚋmodelᚐReview(ctx context.Context, sel ast.SelectionSet, v model.Review) graphql.Marshaler { - return ec._Review(ctx, sel, &v) + in := *v + return graphql.MarshalBoolean(in) } func (ec *executionContext) marshalOReview2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋreviewsᚋgraphᚋmodelᚐReview(ctx context.Context, sel ast.SelectionSet, v []*model.Review) graphql.Marshaler { @@ -2962,22 +2968,25 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) + in := v + return graphql.MarshalString(in) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOString2string(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalString(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOString2string(ctx, sel, *v) + in := *v + return graphql.MarshalString(in) } func (ec *executionContext) marshalO_Entity2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v fedruntime.Entity) graphql.Marshaler { @@ -3107,10 +3116,6 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg return ret } -func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { if v == nil { return graphql.Null @@ -3118,10 +3123,6 @@ func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlge return ec.___Schema(ctx, sel, v) } -func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/example/fileupload/generated.go b/example/fileupload/generated.go index 64f6653a259..fc8a68dfac5 100644 --- a/example/fileupload/generated.go +++ b/example/fileupload/generated.go @@ -2262,7 +2262,8 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(v) + in := v + res := graphql.MarshalBoolean(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2328,7 +2329,8 @@ func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{} } func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - res := graphql.MarshalInt(v) + in := v + res := graphql.MarshalInt(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2343,7 +2345,8 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2358,7 +2361,8 @@ func (ec *executionContext) unmarshalNUpload2githubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalNUpload2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, sel ast.SelectionSet, v graphql.Upload) graphql.Marshaler { - res := graphql.MarshalUpload(v) + in := v + res := graphql.MarshalUpload(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2398,8 +2402,9 @@ func (ec *executionContext) marshalNUpload2ᚕᚖgithubᚗcomᚋ99designsᚋgqlg } func (ec *executionContext) unmarshalNUpload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, v interface{}) (*graphql.Upload, error) { - res, err := ec.unmarshalNUpload2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalUpload(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalNUpload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, sel ast.SelectionSet, v *graphql.Upload) graphql.Marshaler { @@ -2409,7 +2414,14 @@ func (ec *executionContext) marshalNUpload2ᚖgithubᚗcomᚋ99designsᚋgqlgen } return graphql.Null } - return ec.marshalNUpload2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx, sel, *v) + in := *v + res := graphql.MarshalUpload(in) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + } + return res } func (ec *executionContext) unmarshalNUploadFile2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfileuploadᚋmodelᚐUploadFile(ctx context.Context, v interface{}) (model.UploadFile, error) { @@ -2439,8 +2451,9 @@ func (ec *executionContext) unmarshalNUploadFile2ᚕᚖgithubᚗcomᚋ99designs } func (ec *executionContext) unmarshalNUploadFile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfileuploadᚋmodelᚐUploadFile(ctx context.Context, v interface{}) (*model.UploadFile, error) { - res, err := ec.unmarshalNUploadFile2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfileuploadᚋmodelᚐUploadFile(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := ec.unmarshalInputUploadFile(ctx, v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { @@ -2490,7 +2503,8 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2663,7 +2677,8 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2678,22 +2693,25 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) + in := v + return graphql.MarshalBoolean(in) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOBoolean2bool(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalBoolean(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOBoolean2bool(ctx, sel, *v) + in := *v + return graphql.MarshalBoolean(in) } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { @@ -2702,22 +2720,25 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) + in := v + return graphql.MarshalString(in) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOString2string(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalString(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOString2string(ctx, sel, *v) + in := *v + return graphql.MarshalString(in) } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { @@ -2840,10 +2861,6 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg return ret } -func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { if v == nil { return graphql.Null @@ -2851,10 +2868,6 @@ func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlge return ec.___Schema(ctx, sel, v) } -func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/example/scalars/.gqlgen.yml b/example/scalars/.gqlgen.yml index e92ce20865c..7566fbda80e 100644 --- a/example/scalars/.gqlgen.yml +++ b/example/scalars/.gqlgen.yml @@ -16,3 +16,5 @@ models: model: github.com/99designs/gqlgen/example/scalars/model.Tier Banned: model: github.com/99designs/gqlgen/example/scalars/model.Banned + DarkMode: + model: github.com/99designs/gqlgen/example/scalars/model.Preferences diff --git a/example/scalars/generated.go b/example/scalars/generated.go index a6d0034fa6e..de3a7f107d4 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -51,8 +51,9 @@ type ComplexityRoot struct { } Query struct { - Search func(childComplexity int, input *model.SearchArgs) int - User func(childComplexity int, id external.ObjectID) int + Search func(childComplexity int, input *model.SearchArgs) int + User func(childComplexity int, id external.ObjectID) int + UserByTier func(childComplexity int, tier model.Tier, darkMode *model.Prefs) int } User struct { @@ -61,15 +62,19 @@ type ComplexityRoot struct { CustomResolver func(childComplexity int) int ID func(childComplexity int) int IsBanned func(childComplexity int) int + Modified func(childComplexity int) int Name func(childComplexity int) int PrimitiveResolver func(childComplexity int) int + PtrPrefs func(childComplexity int) int Tier func(childComplexity int) int + ValPrefs func(childComplexity int) int } } type QueryResolver interface { User(ctx context.Context, id external.ObjectID) (*model.User, error) Search(ctx context.Context, input *model.SearchArgs) ([]*model.User, error) + UserByTier(ctx context.Context, tier model.Tier, darkMode *model.Prefs) ([]*model.User, error) } type UserResolver interface { PrimitiveResolver(ctx context.Context, obj *model.User) (string, error) @@ -129,6 +134,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.User(childComplexity, args["id"].(external.ObjectID)), true + case "Query.userByTier": + if e.complexity.Query.UserByTier == nil { + break + } + + args, err := ec.field_Query_userByTier_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.UserByTier(childComplexity, args["tier"].(model.Tier), args["darkMode"].(*model.Prefs)), true + case "User.address": if e.complexity.User.Address == nil { break @@ -164,6 +181,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.User.IsBanned(childComplexity), true + case "User.modified": + if e.complexity.User.Modified == nil { + break + } + + return e.complexity.User.Modified(childComplexity), true + case "User.name": if e.complexity.User.Name == nil { break @@ -178,6 +202,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.User.PrimitiveResolver(childComplexity), true + case "User.ptrPrefs": + if e.complexity.User.PtrPrefs == nil { + break + } + + return e.complexity.User.PtrPrefs(childComplexity), true + case "User.tier": if e.complexity.User.Tier == nil { break @@ -185,6 +216,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.User.Tier(childComplexity), true + case "User.valPrefs": + if e.complexity.User.ValPrefs == nil { + break + } + + return e.complexity.User.ValPrefs(childComplexity), true + } return 0, false } @@ -238,12 +276,16 @@ var sources = []*ast.Source{ {Name: "schema.graphql", Input: `type Query { user(id: ID!): User search(input: SearchArgs = {location: "37,144", isBanned: false}): [User!]! + userByTier(tier: Tier!, darkMode: DarkMode!): [User!]! } type User { id: ID! name: String! created: Timestamp + modified: Timestamp + valPrefs: DarkMode + ptrPrefs: DarkMode isBanned: Banned! primitiveResolver: String! customResolver: Point! @@ -271,6 +313,7 @@ enum Tier { scalar Timestamp scalar Point scalar Banned +scalar DarkMode `, BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) @@ -309,6 +352,30 @@ func (ec *executionContext) field_Query_search_args(ctx context.Context, rawArgs return args, nil } +func (ec *executionContext) field_Query_userByTier_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.Tier + if tmp, ok := rawArgs["tier"]; ok { + ctx := graphql.WithFieldInputContext(ctx, graphql.NewFieldInputWithField("tier")) + arg0, err = ec.unmarshalNTier2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐTier(ctx, tmp) + if err != nil { + return nil, err + } + } + args["tier"] = arg0 + var arg1 *model.Prefs + if tmp, ok := rawArgs["darkMode"]; ok { + ctx := graphql.WithFieldInputContext(ctx, graphql.NewFieldInputWithField("darkMode")) + arg1, err = ec.unmarshalNDarkMode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPrefs(ctx, tmp) + if err != nil { + return nil, err + } + } + args["darkMode"] = arg1 + return args, nil +} + func (ec *executionContext) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -506,6 +573,47 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col return ec.marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUserᚄ(ctx, field.Selections, res) } +func (ec *executionContext) _Query_userByTier(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, + } + + ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_userByTier_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().UserByTier(rctx, args["tier"].(model.Tier), args["darkMode"].(*model.Prefs)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.User) + fc.Result = res + return ec.marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUserᚄ(ctx, field.Selections, res) +} + func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { @@ -674,6 +782,99 @@ func (ec *executionContext) _User_created(ctx context.Context, field graphql.Col return ec.marshalOTimestamp2timeᚐTime(ctx, field.Selections, res) } +func (ec *executionContext) _User_modified(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "User", + Field: field, + Args: nil, + IsMethod: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Modified, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*time.Time) + fc.Result = res + return ec.marshalOTimestamp2ᚖtimeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) _User_valPrefs(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "User", + Field: field, + Args: nil, + IsMethod: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ValPrefs, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(model.Prefs) + fc.Result = res + return ec.marshalODarkMode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPrefs(ctx, field.Selections, res) +} + +func (ec *executionContext) _User_ptrPrefs(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "User", + Field: field, + Args: nil, + IsMethod: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PtrPrefs, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.Prefs) + fc.Result = res + return ec.marshalODarkMode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPrefs(ctx, field.Selections, res) +} + func (ec *executionContext) _User_isBanned(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { @@ -2006,6 +2207,20 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } return res }) + case "userByTier": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_userByTier(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } + return res + }) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": @@ -2044,6 +2259,12 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj } case "created": out.Values[i] = ec._User_created(ctx, field, obj) + case "modified": + out.Values[i] = ec._User_modified(ctx, field, obj) + case "valPrefs": + out.Values[i] = ec._User_valPrefs(ctx, field, obj) + case "ptrPrefs": + out.Values[i] = ec._User_ptrPrefs(ctx, field, obj) case "isBanned": out.Values[i] = ec._User_isBanned(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -2353,7 +2574,30 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(v) + in := v + res := graphql.MarshalBoolean(in) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + } + return res +} + +func (ec *executionContext) unmarshalNDarkMode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPrefs(ctx context.Context, v interface{}) (*model.Prefs, error) { + res, err := model.UnmarshalPreferences(v) + return res, graphql.WrapErrorWithInputPath(ctx, err) +} + +func (ec *executionContext) marshalNDarkMode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPrefs(ctx context.Context, sel ast.SelectionSet, v *model.Prefs) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + in := v + res := model.MarshalPreferences(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2368,7 +2612,8 @@ func (ec *executionContext) unmarshalNID2githubᚗcomᚋ99designsᚋgqlgenᚋexa } func (ec *executionContext) marshalNID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(ctx context.Context, sel ast.SelectionSet, v external.ObjectID) graphql.Marshaler { - res := model.MarshalID(v) + in := v + res := model.MarshalID(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2388,8 +2633,9 @@ func (ec *executionContext) marshalNPoint2githubᚗcomᚋ99designsᚋgqlgenᚋex } func (ec *executionContext) unmarshalNPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, v interface{}) (*model.Point, error) { - res, err := ec.unmarshalNPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + var res = new(model.Point) + err := res.UnmarshalGQL(v) + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalNPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, sel ast.SelectionSet, v *model.Point) graphql.Marshaler { @@ -2408,7 +2654,8 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2417,8 +2664,14 @@ func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.S return res } -func (ec *executionContext) marshalNUser2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v model.User) graphql.Marshaler { - return ec._User(ctx, sel, &v) +func (ec *executionContext) unmarshalNTier2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐTier(ctx context.Context, v interface{}) (model.Tier, error) { + var res model.Tier + err := res.UnmarshalGQL(v) + return res, graphql.WrapErrorWithInputPath(ctx, err) +} + +func (ec *executionContext) marshalNTier2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐTier(ctx context.Context, sel ast.SelectionSet, v model.Tier) graphql.Marshaler { + return v } func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUserᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.User) graphql.Marshaler { @@ -2515,7 +2768,8 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2688,7 +2942,8 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2717,60 +2972,77 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) + in := v + return graphql.MarshalBoolean(in) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOBoolean2bool(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalBoolean(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOBoolean2bool(ctx, sel, *v) + in := *v + return graphql.MarshalBoolean(in) } -func (ec *executionContext) unmarshalOPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, v interface{}) (model.Point, error) { - var res model.Point - err := res.UnmarshalGQL(v) +func (ec *executionContext) unmarshalODarkMode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPrefs(ctx context.Context, v interface{}) (model.Prefs, error) { + tmp, err := model.UnmarshalPreferences(v) + res := *tmp return res, graphql.WrapErrorWithInputPath(ctx, err) } -func (ec *executionContext) marshalOPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, sel ast.SelectionSet, v model.Point) graphql.Marshaler { - return v +func (ec *executionContext) marshalODarkMode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPrefs(ctx context.Context, sel ast.SelectionSet, v model.Prefs) graphql.Marshaler { + in := &v + return model.MarshalPreferences(in) } -func (ec *executionContext) unmarshalOPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, v interface{}) (*model.Point, error) { +func (ec *executionContext) unmarshalODarkMode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPrefs(ctx context.Context, v interface{}) (*model.Prefs, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := model.UnmarshalPreferences(v) + return res, graphql.WrapErrorWithInputPath(ctx, err) } -func (ec *executionContext) marshalOPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, sel ast.SelectionSet, v *model.Point) graphql.Marshaler { +func (ec *executionContext) marshalODarkMode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPrefs(ctx context.Context, sel ast.SelectionSet, v *model.Prefs) graphql.Marshaler { if v == nil { return graphql.Null } - return v + in := v + return model.MarshalPreferences(in) } -func (ec *executionContext) unmarshalOSearchArgs2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(ctx context.Context, v interface{}) (model.SearchArgs, error) { - res, err := ec.unmarshalInputSearchArgs(ctx, v) +func (ec *executionContext) unmarshalOPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, v interface{}) (*model.Point, error) { + if v == nil { + return nil, nil + } + var res = new(model.Point) + err := res.UnmarshalGQL(v) return res, graphql.WrapErrorWithInputPath(ctx, err) } +func (ec *executionContext) marshalOPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, sel ast.SelectionSet, v *model.Point) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + func (ec *executionContext) unmarshalOSearchArgs2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(ctx context.Context, v interface{}) (*model.SearchArgs, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOSearchArgs2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐSearchArgs(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := ec.unmarshalInputSearchArgs(ctx, v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { @@ -2779,22 +3051,25 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) + in := v + return graphql.MarshalString(in) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOString2string(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalString(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOString2string(ctx, sel, *v) + in := *v + return graphql.MarshalString(in) } func (ec *executionContext) unmarshalOTier2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐTier(ctx context.Context, v interface{}) (model.Tier, error) { @@ -2813,26 +3088,25 @@ func (ec *executionContext) unmarshalOTimestamp2timeᚐTime(ctx context.Context, } func (ec *executionContext) marshalOTimestamp2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - return model.MarshalTimestamp(v) + in := v + return model.MarshalTimestamp(in) } func (ec *executionContext) unmarshalOTimestamp2ᚖtimeᚐTime(ctx context.Context, v interface{}) (*time.Time, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOTimestamp2timeᚐTime(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := model.UnmarshalTimestamp(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOTimestamp2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOTimestamp2timeᚐTime(ctx, sel, *v) -} - -func (ec *executionContext) marshalOUser2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v model.User) graphql.Marshaler { - return ec._User(ctx, sel, &v) + in := *v + return model.MarshalTimestamp(in) } func (ec *executionContext) marshalOUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { @@ -2962,10 +3236,6 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg return ret } -func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { if v == nil { return graphql.Null @@ -2973,10 +3243,6 @@ func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlge return ec.___Schema(ctx, sel, v) } -func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/example/scalars/model/model.go b/example/scalars/model/model.go index d95cb8ff393..2079756f770 100644 --- a/example/scalars/model/model.go +++ b/example/scalars/model/model.go @@ -38,7 +38,10 @@ func (b *Banned) UnmarshalGQL(v interface{}) error { type User struct { ID external.ObjectID Name string - Created time.Time // direct binding to builtin types with external Marshal/Unmarshal methods + Created time.Time // direct binding to builtin types with external Marshal/Unmarshal methods + Modified *time.Time // direct binding to builtin types with external Marshal/Unmarshal methods + ValPrefs Prefs // external un/marshal that act on pointers + PtrPrefs *Prefs IsBanned Banned Address Address Tier Tier @@ -174,3 +177,19 @@ func (e *Tier) UnmarshalGQL(v interface{}) error { func (e Tier) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } + +type Prefs struct { + DarkMode bool +} + +func MarshalPreferences(p *Prefs) graphql.Marshaler { + return graphql.MarshalBoolean(p.DarkMode) +} + +func UnmarshalPreferences(v interface{}) (*Prefs, error) { + tmp, err := graphql.UnmarshalBoolean(v) + if err != nil { + return nil, err + } + return &Prefs{DarkMode: tmp}, nil +} diff --git a/example/scalars/resolvers.go b/example/scalars/resolvers.go index 661ce1baca8..d05359e92c5 100644 --- a/example/scalars/resolvers.go +++ b/example/scalars/resolvers.go @@ -24,6 +24,10 @@ func (r *Resolver) User() UserResolver { type queryResolver struct{ *Resolver } +func (r *queryResolver) UserByTier(ctx context.Context, tier model.Tier, darkMode *model.Prefs) ([]*model.User, error) { + panic("implement me") +} + func (r *queryResolver) User(ctx context.Context, id external.ObjectID) (*model.User, error) { return &model.User{ ID: id, diff --git a/example/scalars/schema.graphql b/example/scalars/schema.graphql index 2bf00540ff5..fe5c879d83f 100644 --- a/example/scalars/schema.graphql +++ b/example/scalars/schema.graphql @@ -1,12 +1,16 @@ type Query { user(id: ID!): User search(input: SearchArgs = {location: "37,144", isBanned: false}): [User!]! + userByTier(tier: Tier!, darkMode: DarkMode!): [User!]! } type User { id: ID! name: String! created: Timestamp + modified: Timestamp + valPrefs: DarkMode + ptrPrefs: DarkMode isBanned: Banned! primitiveResolver: String! customResolver: Point! @@ -34,3 +38,4 @@ enum Tier { scalar Timestamp scalar Point scalar Banned +scalar DarkMode diff --git a/example/selection/generated.go b/example/selection/generated.go index e4da3adca59..6af73bcb0ad 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -2088,7 +2088,8 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(v) + in := v + res := graphql.MarshalBoolean(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2113,7 +2114,8 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2128,7 +2130,8 @@ func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v in } func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - res := graphql.MarshalTime(v) + in := v + res := graphql.MarshalTime(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2184,7 +2187,8 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2357,7 +2361,8 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2372,22 +2377,25 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) + in := v + return graphql.MarshalBoolean(in) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOBoolean2bool(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalBoolean(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOBoolean2bool(ctx, sel, *v) + in := *v + return graphql.MarshalBoolean(in) } func (ec *executionContext) marshalOEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋselectionᚐEventᚄ(ctx context.Context, sel ast.SelectionSet, v []Event) graphql.Marshaler { @@ -2436,7 +2444,8 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) + in := v + return graphql.MarshalString(in) } func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { @@ -2479,15 +2488,17 @@ func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v in if v == nil { return nil, nil } - res, err := ec.unmarshalOString2string(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalString(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOString2string(ctx, sel, *v) + in := *v + return graphql.MarshalString(in) } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { @@ -2610,10 +2621,6 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg return ret } -func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { if v == nil { return graphql.Null @@ -2621,10 +2628,6 @@ func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlge return ec.___Schema(ctx, sel, v) } -func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/example/starwars/generated/exec.go b/example/starwars/generated/exec.go index 69a6ca11937..053347ed683 100644 --- a/example/starwars/generated/exec.go +++ b/example/starwars/generated/exec.go @@ -4245,7 +4245,8 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(v) + in := v + res := graphql.MarshalBoolean(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -4338,7 +4339,8 @@ func (ec *executionContext) unmarshalNFloat2float64(ctx context.Context, v inter } func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { - res := graphql.MarshalFloat(v) + in := v + res := graphql.MarshalFloat(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -4361,10 +4363,6 @@ func (ec *executionContext) marshalNFriendsConnection2ᚖgithubᚗcomᚋ99design return ec._FriendsConnection(ctx, sel, v) } -func (ec *executionContext) marshalNFriendsEdge2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐFriendsEdge(ctx context.Context, sel ast.SelectionSet, v models.FriendsEdge) graphql.Marshaler { - return ec._FriendsEdge(ctx, sel, &v) -} - func (ec *executionContext) marshalNFriendsEdge2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐFriendsEdge(ctx context.Context, sel ast.SelectionSet, v *models.FriendsEdge) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -4381,7 +4379,8 @@ func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface } func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalID(v) + in := v + res := graphql.MarshalID(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -4396,7 +4395,8 @@ func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{} } func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - res := graphql.MarshalInt(v) + in := v + res := graphql.MarshalInt(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -4469,10 +4469,6 @@ func (ec *executionContext) marshalNPageInfo2githubᚗcomᚋ99designsᚋgqlgen return ec._PageInfo(ctx, sel, &v) } -func (ec *executionContext) marshalNReview2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐReview(ctx context.Context, sel ast.SelectionSet, v models.Review) graphql.Marshaler { - return ec._Review(ctx, sel, &v) -} - func (ec *executionContext) marshalNReview2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐReviewᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.Review) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup @@ -4572,10 +4568,6 @@ func (ec *executionContext) marshalNSearchResult2ᚕgithubᚗcomᚋ99designsᚋg return ret } -func (ec *executionContext) marshalNStarship2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐStarship(ctx context.Context, sel ast.SelectionSet, v models.Starship) graphql.Marshaler { - return ec._Starship(ctx, sel, &v) -} - func (ec *executionContext) marshalNStarship2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐStarship(ctx context.Context, sel ast.SelectionSet, v *models.Starship) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -4592,7 +4584,8 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -4648,7 +4641,8 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -4821,7 +4815,8 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -4836,22 +4831,25 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) + in := v + return graphql.MarshalBoolean(in) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOBoolean2bool(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalBoolean(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOBoolean2bool(ctx, sel, *v) + in := *v + return graphql.MarshalBoolean(in) } func (ec *executionContext) marshalOCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v models.Character) graphql.Marshaler { @@ -4901,10 +4899,6 @@ func (ec *executionContext) marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlg return ret } -func (ec *executionContext) marshalODroid2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐDroid(ctx context.Context, sel ast.SelectionSet, v models.Droid) graphql.Marshaler { - return ec._Droid(ctx, sel, &v) -} - func (ec *executionContext) marshalODroid2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐDroid(ctx context.Context, sel ast.SelectionSet, v *models.Droid) graphql.Marshaler { if v == nil { return graphql.Null @@ -4912,22 +4906,13 @@ func (ec *executionContext) marshalODroid2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec._Droid(ctx, sel, v) } -func (ec *executionContext) unmarshalOEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐEpisode(ctx context.Context, v interface{}) (models.Episode, error) { - var res models.Episode - err := res.UnmarshalGQL(v) - return res, graphql.WrapErrorWithInputPath(ctx, err) -} - -func (ec *executionContext) marshalOEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v models.Episode) graphql.Marshaler { - return v -} - func (ec *executionContext) unmarshalOEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐEpisode(ctx context.Context, v interface{}) (*models.Episode, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐEpisode(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + var res = new(models.Episode) + err := res.UnmarshalGQL(v) + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v *models.Episode) graphql.Marshaler { @@ -4943,7 +4928,8 @@ func (ec *executionContext) unmarshalOFloat2float64(ctx context.Context, v inter } func (ec *executionContext) marshalOFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { - return graphql.MarshalFloat(v) + in := v + return graphql.MarshalFloat(in) } func (ec *executionContext) marshalOFriendsEdge2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐFriendsEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.FriendsEdge) graphql.Marshaler { @@ -4986,10 +4972,6 @@ func (ec *executionContext) marshalOFriendsEdge2ᚕᚖgithubᚗcomᚋ99designs return ret } -func (ec *executionContext) marshalOHuman2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐHuman(ctx context.Context, sel ast.SelectionSet, v models.Human) graphql.Marshaler { - return ec._Human(ctx, sel, &v) -} - func (ec *executionContext) marshalOHuman2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐHuman(ctx context.Context, sel ast.SelectionSet, v *models.Human) graphql.Marshaler { if v == nil { return graphql.Null @@ -4997,52 +4979,38 @@ func (ec *executionContext) marshalOHuman2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec._Human(ctx, sel, v) } -func (ec *executionContext) unmarshalOID2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalID(v) - return res, graphql.WrapErrorWithInputPath(ctx, err) -} - -func (ec *executionContext) marshalOID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalID(v) -} - func (ec *executionContext) unmarshalOID2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOID2string(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalID(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOID2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOID2string(ctx, sel, *v) -} - -func (ec *executionContext) unmarshalOInt2int(ctx context.Context, v interface{}) (int, error) { - res, err := graphql.UnmarshalInt(v) - return res, graphql.WrapErrorWithInputPath(ctx, err) -} - -func (ec *executionContext) marshalOInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - return graphql.MarshalInt(v) + in := *v + return graphql.MarshalID(in) } func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v interface{}) (*int, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOInt2int(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalInt(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOInt2int(ctx, sel, *v) + in := *v + return graphql.MarshalInt(in) } func (ec *executionContext) unmarshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐLengthUnit(ctx context.Context, v interface{}) (models.LengthUnit, error) { @@ -5059,8 +5027,9 @@ func (ec *executionContext) unmarshalOLengthUnit2ᚖgithubᚗcomᚋ99designsᚋg if v == nil { return nil, nil } - res, err := ec.unmarshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐLengthUnit(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + var res = new(models.LengthUnit) + err := res.UnmarshalGQL(v) + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐLengthUnit(ctx context.Context, sel ast.SelectionSet, v *models.LengthUnit) graphql.Marshaler { @@ -5070,10 +5039,6 @@ func (ec *executionContext) marshalOLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgql return v } -func (ec *executionContext) marshalOReview2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐReview(ctx context.Context, sel ast.SelectionSet, v models.Review) graphql.Marshaler { - return ec._Review(ctx, sel, &v) -} - func (ec *executionContext) marshalOReview2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐReview(ctx context.Context, sel ast.SelectionSet, v *models.Review) graphql.Marshaler { if v == nil { return graphql.Null @@ -5081,10 +5046,6 @@ func (ec *executionContext) marshalOReview2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec._Review(ctx, sel, v) } -func (ec *executionContext) marshalOStarship2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐStarship(ctx context.Context, sel ast.SelectionSet, v models.Starship) graphql.Marshaler { - return ec._Starship(ctx, sel, &v) -} - func (ec *executionContext) marshalOStarship2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐStarshipᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.Starship) graphql.Marshaler { if v == nil { return graphql.Null @@ -5138,22 +5099,25 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) + in := v + return graphql.MarshalString(in) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOString2string(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalString(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOString2string(ctx, sel, *v) + in := *v + return graphql.MarshalString(in) } func (ec *executionContext) unmarshalOTime2timeᚐTime(ctx context.Context, v interface{}) (time.Time, error) { @@ -5162,22 +5126,25 @@ func (ec *executionContext) unmarshalOTime2timeᚐTime(ctx context.Context, v in } func (ec *executionContext) marshalOTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - return graphql.MarshalTime(v) + in := v + return graphql.MarshalTime(in) } func (ec *executionContext) unmarshalOTime2ᚖtimeᚐTime(ctx context.Context, v interface{}) (*time.Time, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOTime2timeᚐTime(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalTime(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOTime2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOTime2timeᚐTime(ctx, sel, *v) + in := *v + return graphql.MarshalTime(in) } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { @@ -5300,10 +5267,6 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg return ret } -func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { if v == nil { return graphql.Null @@ -5311,10 +5274,6 @@ func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlge return ec.___Schema(ctx, sel, v) } -func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/example/todo/generated.go b/example/todo/generated.go index b76a4a54957..ebba2f2e925 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -2235,7 +2235,8 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(v) + in := v + res := graphql.MarshalBoolean(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2250,7 +2251,8 @@ func (ec *executionContext) unmarshalNID2int(ctx context.Context, v interface{}) } func (ec *executionContext) marshalNID2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - res := graphql.MarshalIntID(v) + in := v + res := graphql.MarshalIntID(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2271,7 +2273,8 @@ func (ec *executionContext) marshalNMap2map(ctx context.Context, sel ast.Selecti } return graphql.Null } - res := graphql.MarshalMap(v) + in := v + res := graphql.MarshalMap(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2296,7 +2299,8 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2408,7 +2412,8 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2581,7 +2586,8 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2596,22 +2602,25 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) + in := v + return graphql.MarshalBoolean(in) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOBoolean2bool(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalBoolean(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOBoolean2bool(ctx, sel, *v) + in := *v + return graphql.MarshalBoolean(in) } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { @@ -2620,26 +2629,25 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) + in := v + return graphql.MarshalString(in) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOString2string(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalString(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOString2string(ctx, sel, *v) -} - -func (ec *executionContext) marshalOTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { - return ec._Todo(ctx, sel, &v) + in := *v + return graphql.MarshalString(in) } func (ec *executionContext) marshalOTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { @@ -2769,10 +2777,6 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg return ret } -func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { if v == nil { return graphql.Null @@ -2780,10 +2784,6 @@ func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlge return ec.___Schema(ctx, sel, v) } -func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index 089b18ff3d2..99abb9f9692 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -2210,7 +2210,8 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(v) + in := v + res := graphql.MarshalBoolean(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2225,7 +2226,8 @@ func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface } func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalID(v) + in := v + res := graphql.MarshalID(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2250,7 +2252,8 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2362,7 +2365,8 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2535,7 +2539,8 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2550,22 +2555,25 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) + in := v + return graphql.MarshalBoolean(in) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOBoolean2bool(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalBoolean(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOBoolean2bool(ctx, sel, *v) + in := *v + return graphql.MarshalBoolean(in) } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { @@ -2574,26 +2582,25 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) + in := v + return graphql.MarshalString(in) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOString2string(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalString(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOString2string(ctx, sel, *v) -} - -func (ec *executionContext) marshalOTodo2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { - return ec._Todo(ctx, sel, &v) + in := *v + return graphql.MarshalString(in) } func (ec *executionContext) marshalOTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { @@ -2723,10 +2730,6 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg return ret } -func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { if v == nil { return graphql.Null @@ -2734,10 +2737,6 @@ func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlge return ec.___Schema(ctx, sel, v) } -func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/integration/generated.go b/integration/generated.go index 4adb4c661c6..e11f85e097e 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -2501,7 +2501,8 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - res := graphql.MarshalBoolean(v) + in := v + res := graphql.MarshalBoolean(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2535,7 +2536,8 @@ func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{} } func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - res := graphql.MarshalInt(v) + in := v + res := graphql.MarshalInt(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2550,7 +2552,8 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2636,7 +2639,8 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2809,7 +2813,8 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) + in := v + res := graphql.MarshalString(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2824,7 +2829,8 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - return graphql.MarshalBoolean(v) + in := v + return graphql.MarshalBoolean(in) } func (ec *executionContext) unmarshalOBoolean2ᚕboolᚄ(ctx context.Context, v interface{}) ([]bool, error) { @@ -2867,33 +2873,26 @@ func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v int if v == nil { return nil, nil } - res, err := ec.unmarshalOBoolean2bool(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalBoolean(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOBoolean2bool(ctx, sel, *v) -} - -func (ec *executionContext) unmarshalODATE_FILTER_OP2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(ctx context.Context, v interface{}) (models.DateFilterOp, error) { - var res models.DateFilterOp - err := res.UnmarshalGQL(v) - return res, graphql.WrapErrorWithInputPath(ctx, err) -} - -func (ec *executionContext) marshalODATE_FILTER_OP2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(ctx context.Context, sel ast.SelectionSet, v models.DateFilterOp) graphql.Marshaler { - return v + in := *v + return graphql.MarshalBoolean(in) } func (ec *executionContext) unmarshalODATE_FILTER_OP2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(ctx context.Context, v interface{}) (*models.DateFilterOp, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalODATE_FILTER_OP2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + var res = new(models.DateFilterOp) + err := res.UnmarshalGQL(v) + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalODATE_FILTER_OP2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(ctx context.Context, sel ast.SelectionSet, v *models.DateFilterOp) graphql.Marshaler { @@ -2903,10 +2902,6 @@ func (ec *executionContext) marshalODATE_FILTER_OP2ᚖgithubᚗcomᚋ99designs return v } -func (ec *executionContext) marshalOElement2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx context.Context, sel ast.SelectionSet, v models.Element) graphql.Marshaler { - return ec._Element(ctx, sel, &v) -} - func (ec *executionContext) marshalOElement2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐElement(ctx context.Context, sel ast.SelectionSet, v []*models.Element) graphql.Marshaler { if v == nil { return graphql.Null @@ -2954,22 +2949,13 @@ func (ec *executionContext) marshalOElement2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec._Element(ctx, sel, v) } -func (ec *executionContext) unmarshalOErrorType2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(ctx context.Context, v interface{}) (models.ErrorType, error) { - var res models.ErrorType - err := res.UnmarshalGQL(v) - return res, graphql.WrapErrorWithInputPath(ctx, err) -} - -func (ec *executionContext) marshalOErrorType2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(ctx context.Context, sel ast.SelectionSet, v models.ErrorType) graphql.Marshaler { - return v -} - func (ec *executionContext) unmarshalOErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(ctx context.Context, v interface{}) (*models.ErrorType, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOErrorType2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + var res = new(models.ErrorType) + err := res.UnmarshalGQL(v) + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐErrorType(ctx context.Context, sel ast.SelectionSet, v *models.ErrorType) graphql.Marshaler { @@ -2979,28 +2965,21 @@ func (ec *executionContext) marshalOErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlg return v } -func (ec *executionContext) unmarshalOInt2int(ctx context.Context, v interface{}) (int, error) { - res, err := graphql.UnmarshalInt(v) - return res, graphql.WrapErrorWithInputPath(ctx, err) -} - -func (ec *executionContext) marshalOInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - return graphql.MarshalInt(v) -} - func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v interface{}) (*int, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOInt2int(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalInt(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOInt2int(ctx, sel, *v) + in := *v + return graphql.MarshalInt(in) } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { @@ -3009,26 +2988,25 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - return graphql.MarshalString(v) + in := v + return graphql.MarshalString(in) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalOString2string(ctx, v) - return &res, graphql.WrapErrorWithInputPath(ctx, err) + tmp, err := graphql.UnmarshalString(v) + res := &tmp + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - return ec.marshalOString2string(ctx, sel, *v) -} - -func (ec *executionContext) marshalOUser2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋremote_apiᚐUser(ctx context.Context, sel ast.SelectionSet, v remote_api.User) graphql.Marshaler { - return ec._User(ctx, sel, &v) + in := *v + return graphql.MarshalString(in) } func (ec *executionContext) marshalOUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋremote_apiᚐUser(ctx context.Context, sel ast.SelectionSet, v *remote_api.User) graphql.Marshaler { @@ -3038,10 +3016,6 @@ func (ec *executionContext) marshalOUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ return ec._User(ctx, sel, v) } -func (ec *executionContext) marshalOViewer2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐViewer(ctx context.Context, sel ast.SelectionSet, v models.Viewer) graphql.Marshaler { - return ec._Viewer(ctx, sel, &v) -} - func (ec *executionContext) marshalOViewer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐViewer(ctx context.Context, sel ast.SelectionSet, v *models.Viewer) graphql.Marshaler { if v == nil { return graphql.Null @@ -3169,10 +3143,6 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg return ret } -func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { - return ec.___Schema(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { if v == nil { return graphql.Null @@ -3180,10 +3150,6 @@ func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlge return ec.___Schema(ctx, sel, v) } -func (ec *executionContext) marshalO__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { - return ec.___Type(ctx, sel, &v) -} - func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { if v == nil { return graphql.Null From c5b01934bfd67678d867a42e09ffedf02a68ddf6 Mon Sep 17 00:00:00 2001 From: Luke Cawood Date: Tue, 11 Aug 2020 17:11:00 +1000 Subject: [PATCH 2/7] Remove unused special cast case for string enums --- codegen/config/binder.go | 41 +------- codegen/testserver/generated.go | 121 +----------------------- codegen/testserver/resolver.go | 4 - codegen/testserver/stub.go | 4 - codegen/testserver/typefallback.graphql | 9 -- codegen/testserver/typefallback_test.go | 28 ------ codegen/testserver/wrapped_type.go | 22 ++++- codegen/type.gotpl | 9 +- 8 files changed, 33 insertions(+), 205 deletions(-) delete mode 100644 codegen/testserver/typefallback.graphql delete mode 100644 codegen/testserver/typefallback_test.go diff --git a/codegen/config/binder.go b/codegen/config/binder.go index 514ccc6742e..a4f84fed808 100644 --- a/codegen/config/binder.go +++ b/codegen/config/binder.go @@ -151,7 +151,6 @@ func (b *Binder) PointerTo(ref *TypeReference) *TypeReference { newRef := &TypeReference{ GO: types.NewPointer(ref.GO), GQL: ref.GQL, - CastType: ref.CastType, Definition: ref.Definition, Unmarshaler: ref.Unmarshaler, Marshaler: ref.Marshaler, @@ -168,7 +167,6 @@ type TypeReference struct { GQL *ast.Type GO types.Type Target types.Type - CastType types.Type // Before calling marshalling functions cast from/to this base type Marshaler *types.Func // When using external marshalling functions this will point to the Marshal function Unmarshaler *types.Func // When using external marshalling functions this will point to the Unmarshal function IsMarshaler bool // Does the type implement graphql.Marshaler and graphql.Unmarshaler @@ -180,7 +178,6 @@ func (ref *TypeReference) Elem() *TypeReference { GO: p.Elem(), Target: ref.Target, GQL: ref.GQL, - CastType: ref.CastType, Definition: ref.Definition, Unmarshaler: ref.Unmarshaler, Marshaler: ref.Marshaler, @@ -193,7 +190,6 @@ func (ref *TypeReference) Elem() *TypeReference { GO: ref.GO.(*types.Slice).Elem(), Target: ref.Target, GQL: ref.GQL.Elem, - CastType: ref.CastType, Definition: ref.Definition, Unmarshaler: ref.Unmarshaler, Marshaler: ref.Marshaler, @@ -349,27 +345,16 @@ func (b *Binder) TypeReference(schemaType *ast.Type, bindTarget types.Type) (ret return nil, err } - if fun, isFunc := obj.(*types.Func); isFunc { + fun, isFunc := obj.(*types.Func) + switch { + case isFunc: ref.GO = fun.Type().(*types.Signature).Params().At(0).Type() ref.Marshaler = fun ref.Unmarshaler = types.NewFunc(0, fun.Pkg(), "Unmarshal"+typeName, nil) - } else if hasMethod(obj.Type(), "MarshalGQL") && hasMethod(obj.Type(), "UnmarshalGQL") { + case hasMethod(obj.Type(), "MarshalGQL") && hasMethod(obj.Type(), "UnmarshalGQL"): ref.GO = obj.Type() ref.IsMarshaler = true - } else if underlying := basicUnderlying(obj.Type()); def.IsLeafType() && underlying != nil && underlying.Kind() == types.String { - // Special case for named types wrapping strings. Used by default enum implementations. - - ref.GO = obj.Type() - ref.CastType = underlying - - underlyingRef, err := b.TypeReference(&ast.Type{NamedType: "String"}, nil) - if err != nil { - return nil, err - } - - ref.Marshaler = underlyingRef.Marshaler - ref.Unmarshaler = underlyingRef.Unmarshaler - } else { + default: ref.GO = obj.Type() } @@ -446,19 +431,3 @@ func hasMethod(it types.Type, name string) bool { } return false } - -func basicUnderlying(it types.Type) *types.Basic { - if ptr, isPtr := it.(*types.Pointer); isPtr { - it = ptr.Elem() - } - namedType, ok := it.(*types.Named) - if !ok { - return nil - } - - if basic, ok := namedType.Underlying().(*types.Basic); ok { - return basic - } - - return nil -} diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index fbba338ffe4..65a117a2430 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -277,7 +277,6 @@ type ComplexityRoot struct { EnumInInput func(childComplexity int, input *InputWithEnumValue) int ErrorBubble func(childComplexity int) int Errors func(childComplexity int) int - Fallback func(childComplexity int, arg FallbackToStringEncoding) int InputNullableSlice func(childComplexity int, arg []string) int InputSlice func(childComplexity int, arg []string) int InvalidIdentifier func(childComplexity int) int @@ -462,7 +461,6 @@ type QueryResolver interface { DefaultScalar(ctx context.Context, arg string) (string, error) Slices(ctx context.Context) (*Slices, error) ScalarSlice(ctx context.Context) ([]byte, error) - Fallback(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) OptionalUnion(ctx context.Context) (TestUnion, error) ValidType(ctx context.Context) (*ValidType, error) WrappedStruct(ctx context.Context) (*WrappedStruct, error) @@ -1203,18 +1201,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Errors(childComplexity), true - case "Query.fallback": - if e.complexity.Query.Fallback == nil { - break - } - - args, err := ec.field_Query_fallback_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.Fallback(childComplexity, args["arg"].(FallbackToStringEncoding)), true - case "Query.inputNullableSlice": if e.complexity.Query.InputNullableSlice == nil { break @@ -2200,16 +2186,6 @@ type Slices { } scalar Bytes -`, BuiltIn: false}, - {Name: "typefallback.graphql", Input: `extend type Query { - fallback(arg: FallbackToStringEncoding!): FallbackToStringEncoding! -} - -enum FallbackToStringEncoding { - A - B - C -} `, BuiltIn: false}, {Name: "useptr.graphql", Input: `type A { id: ID! @@ -2712,21 +2688,6 @@ func (ec *executionContext) field_Query_enumInInput_args(ctx context.Context, ra return args, nil } -func (ec *executionContext) field_Query_fallback_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 FallbackToStringEncoding - if tmp, ok := rawArgs["arg"]; ok { - ctx := graphql.WithFieldInputContext(ctx, graphql.NewFieldInputWithField("arg")) - arg0, err = ec.unmarshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐFallbackToStringEncoding(ctx, tmp) - if err != nil { - return nil, err - } - } - args["arg"] = arg0 - return args, nil -} - func (ec *executionContext) field_Query_inputNullableSlice_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -7310,44 +7271,6 @@ func (ec *executionContext) _Query_scalarSlice(ctx context.Context, field graphq return ec.marshalNBytes2ᚕbyte(ctx, field.Selections, res) } -func (ec *executionContext) _Query_fallback(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Query", - Field: field, - Args: nil, - IsMethod: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_fallback_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Fallback(rctx, args["arg"].(FallbackToStringEncoding)) - }) - - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(FallbackToStringEncoding) - fc.Result = res - return ec.marshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐFallbackToStringEncoding(ctx, field.Selections, res) -} - func (ec *executionContext) _Query_optionalUnion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { @@ -12110,20 +12033,6 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } return res }) - case "fallback": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_fallback(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - }) case "optionalUnion": field := field out.Concurrently(i, func() (res graphql.Marshaler) { @@ -12953,22 +12862,6 @@ func (ec *executionContext) marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec._Error(ctx, sel, v) } -func (ec *executionContext) unmarshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐFallbackToStringEncoding(ctx context.Context, v interface{}) (FallbackToStringEncoding, error) { - tmp, err := graphql.UnmarshalString(v) - return FallbackToStringEncoding(tmp), graphql.WrapErrorWithInputPath(ctx, err) -} - -func (ec *executionContext) marshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐFallbackToStringEncoding(ctx context.Context, sel ast.SelectionSet, v FallbackToStringEncoding) graphql.Marshaler { - in := v - res := graphql.MarshalString(string(in)) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - } - return res -} - func (ec *executionContext) unmarshalNID2int(ctx context.Context, v interface{}) (int, error) { res, err := graphql.UnmarshalIntID(v) return res, graphql.WrapErrorWithInputPath(ctx, err) @@ -13452,19 +13345,13 @@ func (ec *executionContext) marshalNWrappedMap2githubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) unmarshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐWrappedScalar(ctx context.Context, v interface{}) (WrappedScalar, error) { - tmp, err := graphql.UnmarshalString(v) - return WrappedScalar(tmp), graphql.WrapErrorWithInputPath(ctx, err) + var res WrappedScalar + err := res.UnmarshalGQL(v) + return res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐWrappedScalar(ctx context.Context, sel ast.SelectionSet, v WrappedScalar) graphql.Marshaler { - in := v - res := graphql.MarshalString(string(in)) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - } - return res + return v } func (ec *executionContext) marshalNWrappedSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐWrappedSlice(ctx context.Context, sel ast.SelectionSet, v WrappedSlice) graphql.Marshaler { diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index 9b0e2e584ee..d96bcaca0cf 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -263,10 +263,6 @@ func (r *queryResolver) ScalarSlice(ctx context.Context) ([]byte, error) { panic("not implemented") } -func (r *queryResolver) Fallback(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) { - panic("not implemented") -} - func (r *queryResolver) OptionalUnion(ctx context.Context) (TestUnion, error) { panic("not implemented") } diff --git a/codegen/testserver/stub.go b/codegen/testserver/stub.go index b8580350bbf..db82863779e 100644 --- a/codegen/testserver/stub.go +++ b/codegen/testserver/stub.go @@ -92,7 +92,6 @@ type Stub struct { DefaultScalar func(ctx context.Context, arg string) (string, error) Slices func(ctx context.Context) (*Slices, error) ScalarSlice func(ctx context.Context) ([]byte, error) - Fallback func(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) OptionalUnion func(ctx context.Context) (TestUnion, error) ValidType func(ctx context.Context) (*ValidType, error) WrappedStruct func(ctx context.Context) (*WrappedStruct, error) @@ -381,9 +380,6 @@ func (r *stubQuery) Slices(ctx context.Context) (*Slices, error) { func (r *stubQuery) ScalarSlice(ctx context.Context) ([]byte, error) { return r.QueryResolver.ScalarSlice(ctx) } -func (r *stubQuery) Fallback(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) { - return r.QueryResolver.Fallback(ctx, arg) -} func (r *stubQuery) OptionalUnion(ctx context.Context) (TestUnion, error) { return r.QueryResolver.OptionalUnion(ctx) } diff --git a/codegen/testserver/typefallback.graphql b/codegen/testserver/typefallback.graphql deleted file mode 100644 index e1ff1a59d7c..00000000000 --- a/codegen/testserver/typefallback.graphql +++ /dev/null @@ -1,9 +0,0 @@ -extend type Query { - fallback(arg: FallbackToStringEncoding!): FallbackToStringEncoding! -} - -enum FallbackToStringEncoding { - A - B - C -} diff --git a/codegen/testserver/typefallback_test.go b/codegen/testserver/typefallback_test.go deleted file mode 100644 index 8ebd091e9ef..00000000000 --- a/codegen/testserver/typefallback_test.go +++ /dev/null @@ -1,28 +0,0 @@ -package testserver - -import ( - "context" - "testing" - - "github.com/99designs/gqlgen/client" - "github.com/99designs/gqlgen/graphql/handler" - "github.com/stretchr/testify/require" -) - -func TestTypeFallback(t *testing.T) { - resolvers := &Stub{} - - c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))) - - resolvers.QueryResolver.Fallback = func(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) { - return arg, nil - } - - t.Run("fallback to string passthrough", func(t *testing.T) { - var resp struct { - Fallback string - } - c.MustPost(`query { fallback(arg: A) }`, &resp) - require.Equal(t, "A", resp.Fallback) - }) -} diff --git a/codegen/testserver/wrapped_type.go b/codegen/testserver/wrapped_type.go index d3aa63a79b4..bd7ea31006c 100644 --- a/codegen/testserver/wrapped_type.go +++ b/codegen/testserver/wrapped_type.go @@ -1,8 +1,28 @@ package testserver -import "github.com/99designs/gqlgen/codegen/testserver/otherpkg" +import ( + "fmt" + "io" + "strconv" + + "github.com/99designs/gqlgen/codegen/testserver/otherpkg" + "github.com/99designs/gqlgen/graphql" +) type WrappedScalar otherpkg.Scalar type WrappedStruct otherpkg.Struct type WrappedMap otherpkg.Map type WrappedSlice otherpkg.Slice + +func (e *WrappedScalar) UnmarshalGQL(v interface{}) error { + s, err := graphql.UnmarshalString(v) + if err != nil { + return err + } + *e = WrappedScalar(s) + return nil +} + +func (e WrappedScalar) MarshalGQL(w io.Writer) { + fmt.Fprint(w, strconv.Quote(string(e))) +} diff --git a/codegen/type.gotpl b/codegen/type.gotpl index f1639ea0db4..e09107c3ccd 100644 --- a/codegen/type.gotpl +++ b/codegen/type.gotpl @@ -25,10 +25,7 @@ return res, nil {{- else }} {{- if $type.Unmarshaler }} - {{- if $type.CastType }} - tmp, err := {{ $type.Unmarshaler | call }}(v) - return {{ $type.GO | ref }}(tmp), graphql.WrapErrorWithInputPath(ctx, err) - {{- else if and $type.IsTargetNilable (not $type.IsNilable) }} + {{- if and $type.IsTargetNilable (not $type.IsNilable) }} tmp, err := {{ $type.Unmarshaler | call }}(v) res := *tmp return res, graphql.WrapErrorWithInputPath(ctx, err) @@ -137,7 +134,7 @@ in := v {{- end }} {{- if $type.GQL.NonNull }} - res := {{ $type.Marshaler | call }}({{- if $type.CastType }}{{ $type.CastType | ref }}(in){{else}}in{{- end }}) + res := {{ $type.Marshaler | call }}(in) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -145,7 +142,7 @@ } return res {{- else }} - return {{ $type.Marshaler | call }}({{- if $type.CastType }}{{ $type.CastType | ref }}(in){{else}}in{{- end }}) + return {{ $type.Marshaler | call }}(in) {{- end }} {{- else }} return ec._{{$type.Definition.Name}}(ctx, sel, {{ if not $type.IsNilable}}&{{end}} v) From 9e7a83fceed16f573ca0b1a98dfaf2b417cd76f3 Mon Sep 17 00:00:00 2001 From: Luke Cawood Date: Wed, 12 Aug 2020 15:21:27 +1000 Subject: [PATCH 3/7] Linting --- codegen/testserver/resolver.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index d96bcaca0cf..c66b8b220f2 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -328,7 +328,9 @@ func (r *wrappedSliceResolver) Get(ctx context.Context, obj WrappedSlice, idx in } // BackedByInterface returns BackedByInterfaceResolver implementation. -func (r *Resolver) BackedByInterface() BackedByInterfaceResolver { return &backedByInterfaceResolver{r} } +func (r *Resolver) BackedByInterface() BackedByInterfaceResolver { + return &backedByInterfaceResolver{r} +} // Errors returns ErrorsResolver implementation. func (r *Resolver) Errors() ErrorsResolver { return &errorsResolver{r} } @@ -343,7 +345,9 @@ func (r *Resolver) ModelMethods() ModelMethodsResolver { return &modelMethodsRes func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } // OverlappingFields returns OverlappingFieldsResolver implementation. -func (r *Resolver) OverlappingFields() OverlappingFieldsResolver { return &overlappingFieldsResolver{r} } +func (r *Resolver) OverlappingFields() OverlappingFieldsResolver { + return &overlappingFieldsResolver{r} +} // Panics returns PanicsResolver implementation. func (r *Resolver) Panics() PanicsResolver { return &panicsResolver{r} } From 184ee006aa3772ca1f3f1de0711897c340ce9272 Mon Sep 17 00:00:00 2001 From: Luke Cawood Date: Thu, 13 Aug 2020 14:54:19 +1000 Subject: [PATCH 4/7] Clean up generated code --- codegen/testserver/generated.go | 154 +++++++----------- codegen/type.gotpl | 33 ++-- example/chat/generated.go | 40 ++--- example/config/generated.go | 40 ++--- example/dataloader/generated.go | 43 ++--- .../accounts/graph/generated/generated.go | 43 ++--- .../products/graph/generated/generated.go | 51 ++---- .../reviews/graph/generated/generated.go | 43 ++--- example/fileupload/generated.go | 53 +++--- example/scalars/generated.go | 67 +++----- example/selection/generated.go | 37 ++--- example/starwars/generated/exec.go | 73 +++------ example/todo/generated.go | 40 ++--- example/type-system-extension/generated.go | 37 ++--- integration/generated.go | 45 ++--- 15 files changed, 284 insertions(+), 515 deletions(-) diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 65a117a2430..510e1110ee8 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -12770,8 +12770,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - res := graphql.MarshalBoolean(in) + res := graphql.MarshalBoolean(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -12792,8 +12791,7 @@ func (ec *executionContext) marshalNBytes2ᚕbyte(ctx context.Context, sel ast.S } return graphql.Null } - in := v - res := MarshalBytes(in) + res := MarshalBytes(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -12818,8 +12816,7 @@ func (ec *executionContext) unmarshalNDefaultScalarImplementation2string(ctx con } func (ec *executionContext) marshalNDefaultScalarImplementation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -12868,8 +12865,7 @@ func (ec *executionContext) unmarshalNID2int(ctx context.Context, v interface{}) } func (ec *executionContext) marshalNID2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - in := v - res := graphql.MarshalIntID(in) + res := graphql.MarshalIntID(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -12884,8 +12880,7 @@ func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface } func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalID(in) + res := graphql.MarshalID(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -12895,9 +12890,8 @@ func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.Selec } func (ec *executionContext) unmarshalNInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(ctx context.Context, v interface{}) (*InnerDirectives, error) { - tmp, err := ec.unmarshalInputInnerDirectives(ctx, v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := ec.unmarshalInputInnerDirectives(ctx, v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) unmarshalNInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerInput(ctx context.Context, v interface{}) (InnerInput, error) { @@ -12906,9 +12900,8 @@ func (ec *executionContext) unmarshalNInnerInput2githubᚗcomᚋ99designsᚋgqlg } func (ec *executionContext) unmarshalNInnerInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerInput(ctx context.Context, v interface{}) (*InnerInput, error) { - tmp, err := ec.unmarshalInputInnerInput(ctx, v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := ec.unmarshalInputInnerInput(ctx, v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalNInnerObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerObject(ctx context.Context, sel ast.SelectionSet, v *InnerObject) graphql.Marshaler { @@ -12932,8 +12925,7 @@ func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{} } func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - in := v - res := graphql.MarshalInt(in) + res := graphql.MarshalInt(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -12948,8 +12940,7 @@ func (ec *executionContext) unmarshalNInt2int32(ctx context.Context, v interface } func (ec *executionContext) marshalNInt2int32(ctx context.Context, sel ast.SelectionSet, v int32) graphql.Marshaler { - in := v - res := graphql.MarshalInt32(in) + res := graphql.MarshalInt32(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -12964,8 +12955,7 @@ func (ec *executionContext) unmarshalNInt2int64(ctx context.Context, v interface } func (ec *executionContext) marshalNInt2int64(ctx context.Context, sel ast.SelectionSet, v int64) graphql.Marshaler { - in := v - res := graphql.MarshalInt64(in) + res := graphql.MarshalInt64(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -13035,9 +13025,8 @@ func (ec *executionContext) marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋg } func (ec *executionContext) unmarshalNNestedInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐNestedInput(ctx context.Context, v interface{}) (*NestedInput, error) { - tmp, err := ec.unmarshalInputNestedInput(ctx, v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := ec.unmarshalInputNestedInput(ctx, v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐNode(ctx context.Context, sel ast.SelectionSet, v Node) graphql.Marshaler { @@ -13158,8 +13147,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -13229,9 +13217,8 @@ func (ec *executionContext) marshalNString2ᚕᚖstring(ctx context.Context, sel } func (ec *executionContext) unmarshalNString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { - tmp, err := graphql.UnmarshalString(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalString(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalNString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { @@ -13241,8 +13228,7 @@ func (ec *executionContext) marshalNString2ᚖstring(ctx context.Context, sel as } return graphql.Null } - in := *v - res := graphql.MarshalString(in) + res := graphql.MarshalString(*v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -13257,8 +13243,7 @@ func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v in } func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - in := v - res := graphql.MarshalTime(in) + res := graphql.MarshalTime(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -13273,8 +13258,7 @@ func (ec *executionContext) unmarshalNUUID2string(ctx context.Context, v interfa } func (ec *executionContext) marshalNUUID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -13425,8 +13409,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -13599,8 +13582,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -13636,25 +13618,22 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(v) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalBoolean(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalBoolean(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(*v) } func (ec *executionContext) unmarshalOChanges2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { @@ -13762,17 +13741,15 @@ func (ec *executionContext) unmarshalODefaultScalarImplementation2ᚖstring(ctx if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalString(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalString(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalODefaultScalarImplementation2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalString(in) + return graphql.MarshalString(*v) } func (ec *executionContext) marshalOEmbeddedCase12ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐEmbeddedCase1(ctx context.Context, sel ast.SelectionSet, v *EmbeddedCase1) graphql.Marshaler { @@ -13816,52 +13793,46 @@ func (ec *executionContext) unmarshalOFloat2float64(ctx context.Context, v inter } func (ec *executionContext) marshalOFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { - in := v - return graphql.MarshalFloat(in) + return graphql.MarshalFloat(v) } func (ec *executionContext) unmarshalOInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(ctx context.Context, v interface{}) (*InnerDirectives, error) { if v == nil { return nil, nil } - tmp, err := ec.unmarshalInputInnerDirectives(ctx, v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := ec.unmarshalInputInnerDirectives(ctx, v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) unmarshalOInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputDirectives(ctx context.Context, v interface{}) (*InputDirectives, error) { if v == nil { return nil, nil } - tmp, err := ec.unmarshalInputInputDirectives(ctx, v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := ec.unmarshalInputInputDirectives(ctx, v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) unmarshalOInputWithEnumValue2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInputWithEnumValue(ctx context.Context, v interface{}) (*InputWithEnumValue, error) { if v == nil { return nil, nil } - tmp, err := ec.unmarshalInputInputWithEnumValue(ctx, v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := ec.unmarshalInputInputWithEnumValue(ctx, v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v interface{}) (*int, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalInt(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalInt(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalInt(in) + return graphql.MarshalInt(*v) } func (ec *executionContext) marshalOInvalidIdentifier2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx context.Context, sel ast.SelectionSet, v *invalid_packagename.InvalidIdentifier) graphql.Marshaler { @@ -13903,9 +13874,8 @@ func (ec *executionContext) unmarshalONestedMapInput2ᚖgithubᚗcomᚋ99designs if v == nil { return nil, nil } - tmp, err := ec.unmarshalInputNestedMapInput(ctx, v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := ec.unmarshalInputNestedMapInput(ctx, v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOObjectDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐObjectDirectives(ctx context.Context, sel ast.SelectionSet, v *ObjectDirectives) graphql.Marshaler { @@ -13974,9 +13944,8 @@ func (ec *executionContext) unmarshalOOuterInput2ᚖgithubᚗcomᚋ99designsᚋg if v == nil { return nil, nil } - tmp, err := ec.unmarshalInputOuterInput(ctx, v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := ec.unmarshalInputOuterInput(ctx, v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOOuterObject2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v [][]*OuterObject) graphql.Marshaler { @@ -14108,9 +14077,8 @@ func (ec *executionContext) unmarshalORecursiveInputSlice2ᚖgithubᚗcomᚋ99de if v == nil { return nil, nil } - tmp, err := ec.unmarshalInputRecursiveInputSlice(ctx, v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := ec.unmarshalInputRecursiveInputSlice(ctx, v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐShape(ctx context.Context, sel ast.SelectionSet, v Shape) graphql.Marshaler { @@ -14173,8 +14141,7 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - return graphql.MarshalString(in) + return graphql.MarshalString(v) } func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { @@ -14253,17 +14220,15 @@ func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v in if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalString(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalString(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalString(in) + return graphql.MarshalString(*v) } func (ec *executionContext) marshalOTestUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐTestUnion(ctx context.Context, sel ast.SelectionSet, v TestUnion) graphql.Marshaler { @@ -14277,43 +14242,38 @@ func (ec *executionContext) unmarshalOThirdParty2ᚖgithubᚗcomᚋ99designsᚋg if v == nil { return nil, nil } - tmp, err := UnmarshalThirdParty(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := UnmarshalThirdParty(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOThirdParty2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐThirdParty(ctx context.Context, sel ast.SelectionSet, v *ThirdParty) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return MarshalThirdParty(in) + return MarshalThirdParty(*v) } func (ec *executionContext) unmarshalOTime2ᚖtimeᚐTime(ctx context.Context, v interface{}) (*time.Time, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalTime(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalTime(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOTime2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalTime(in) + return graphql.MarshalTime(*v) } func (ec *executionContext) unmarshalOValidInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐValidInput(ctx context.Context, v interface{}) (*ValidInput, error) { if v == nil { return nil, nil } - tmp, err := ec.unmarshalInputValidInput(ctx, v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := ec.unmarshalInputValidInput(ctx, v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOValidType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐValidType(ctx context.Context, sel ast.SelectionSet, v *ValidType) graphql.Marshaler { diff --git a/codegen/type.gotpl b/codegen/type.gotpl index e09107c3ccd..60a87699406 100644 --- a/codegen/type.gotpl +++ b/codegen/type.gotpl @@ -25,16 +25,12 @@ return res, nil {{- else }} {{- if $type.Unmarshaler }} + res, err := {{ $type.Unmarshaler | call }}(v) {{- if and $type.IsTargetNilable (not $type.IsNilable) }} - tmp, err := {{ $type.Unmarshaler | call }}(v) - res := *tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + return *res, graphql.WrapErrorWithInputPath(ctx, err) {{- else if and (not $type.IsTargetNilable) $type.IsNilable }} - tmp, err := {{ $type.Unmarshaler | call }}(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + return &res, graphql.WrapErrorWithInputPath(ctx, err) {{- else}} - res, err := {{ $type.Unmarshaler | call }}(v) return res, graphql.WrapErrorWithInputPath(ctx, err) {{- end }} {{- else if eq ($type.GO | ref) "map[string]interface{}" }} @@ -48,16 +44,10 @@ err := res.UnmarshalGQL(v) return res, graphql.WrapErrorWithInputPath(ctx, err) {{- else }} - {{- if and $type.IsTargetNilable (not $type.IsNilable) }} - tmp, err := ec.unmarshalInput{{ $type.GQL.Name }}(ctx, v) - res := *tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) - {{- else if and (not $type.IsTargetNilable) $type.IsNilable }} - tmp, err := ec.unmarshalInput{{ $type.GQL.Name }}(ctx, v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := ec.unmarshalInput{{ $type.GQL.Name }}(ctx, v) + {{- if $type.IsNilable }} + return &res, graphql.WrapErrorWithInputPath(ctx, err) {{- else}} - res, err := ec.unmarshalInput{{ $type.GQL.Name }}(ctx, v) return res, graphql.WrapErrorWithInputPath(ctx, err) {{- end }} {{- end }} @@ -126,15 +116,14 @@ {{- if $type.IsMarshaler }} return v {{- else if $type.Marshaler }} + {{- $v := "v" }} {{- if and $type.IsTargetNilable (not $type.IsNilable) }} - in := &v + {{- $v = "&v" }} {{- else if and (not $type.IsTargetNilable) $type.IsNilable }} - in := *v - {{- else}} - in := v + {{- $v = "*v" }} {{- end }} {{- if $type.GQL.NonNull }} - res := {{ $type.Marshaler | call }}(in) + res := {{ $type.Marshaler | call }}({{ $v }}) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -142,7 +131,7 @@ } return res {{- else }} - return {{ $type.Marshaler | call }}(in) + return {{ $type.Marshaler | call }}({{ $v }}) {{- end }} {{- else }} return ec._{{$type.Definition.Name}}(ctx, sel, {{ if not $type.IsNilable}}&{{end}} v) diff --git a/example/chat/generated.go b/example/chat/generated.go index a513be1f77f..b5fd7e04150 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -2342,8 +2342,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - res := graphql.MarshalBoolean(in) + res := graphql.MarshalBoolean(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2358,8 +2357,7 @@ func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface } func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalID(in) + res := graphql.MarshalID(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2425,8 +2423,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2441,8 +2438,7 @@ func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v in } func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - in := v - res := graphql.MarshalTime(in) + res := graphql.MarshalTime(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2498,8 +2494,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2672,8 +2667,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2688,25 +2682,22 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(v) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalBoolean(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalBoolean(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(*v) } func (ec *executionContext) marshalOChatroom2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋchatᚐChatroom(ctx context.Context, sel ast.SelectionSet, v *Chatroom) graphql.Marshaler { @@ -2722,25 +2713,22 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - return graphql.MarshalString(in) + return graphql.MarshalString(v) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalString(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalString(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalString(in) + return graphql.MarshalString(*v) } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { diff --git a/example/config/generated.go b/example/config/generated.go index 45a8af78c9d..eeb0a407417 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -2214,8 +2214,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - res := graphql.MarshalBoolean(in) + res := graphql.MarshalBoolean(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2230,8 +2229,7 @@ func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface } func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalID(in) + res := graphql.MarshalID(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2246,8 +2244,7 @@ func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{} } func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - in := v - res := graphql.MarshalInt(in) + res := graphql.MarshalInt(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2267,8 +2264,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2385,8 +2381,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2559,8 +2554,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2575,25 +2569,22 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(v) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalBoolean(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalBoolean(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(*v) } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { @@ -2602,8 +2593,7 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - return graphql.MarshalString(in) + return graphql.MarshalString(v) } func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { @@ -2646,17 +2636,15 @@ func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v in if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalString(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalString(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalString(in) + return graphql.MarshalString(*v) } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index 147492a7a09..8134878b664 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -2509,8 +2509,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - res := graphql.MarshalBoolean(in) + res := graphql.MarshalBoolean(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2535,8 +2534,7 @@ func (ec *executionContext) unmarshalNFloat2float64(ctx context.Context, v inter } func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { - in := v - res := graphql.MarshalFloat(in) + res := graphql.MarshalFloat(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2551,8 +2549,7 @@ func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{} } func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - in := v - res := graphql.MarshalInt(in) + res := graphql.MarshalInt(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2587,8 +2584,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2603,8 +2599,7 @@ func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v in } func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - in := v - res := graphql.MarshalTime(in) + res := graphql.MarshalTime(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2660,8 +2655,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2834,8 +2828,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2857,25 +2850,22 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(v) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalBoolean(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalBoolean(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(*v) } func (ec *executionContext) marshalOCustomer2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v [][]*Customer) graphql.Marshaler { @@ -3116,25 +3106,22 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - return graphql.MarshalString(in) + return graphql.MarshalString(v) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalString(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalString(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalString(in) + return graphql.MarshalString(*v) } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { diff --git a/example/federation/accounts/graph/generated/generated.go b/example/federation/accounts/graph/generated/generated.go index e6751f1d816..5be65e7e97f 100644 --- a/example/federation/accounts/graph/generated/generated.go +++ b/example/federation/accounts/graph/generated/generated.go @@ -2134,8 +2134,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - res := graphql.MarshalBoolean(in) + res := graphql.MarshalBoolean(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2150,8 +2149,7 @@ func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface } func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalID(in) + res := graphql.MarshalID(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2166,8 +2164,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2202,8 +2199,7 @@ func (ec *executionContext) marshalN_Any2map(ctx context.Context, sel ast.Select } return graphql.Null } - in := v - res := graphql.MarshalMap(in) + res := graphql.MarshalMap(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2285,8 +2281,7 @@ func (ec *executionContext) unmarshalN_FieldSet2string(ctx context.Context, v in } func (ec *executionContext) marshalN_FieldSet2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2346,8 +2341,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2520,8 +2514,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2536,25 +2529,22 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(v) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalBoolean(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalBoolean(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(*v) } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { @@ -2563,25 +2553,22 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - return graphql.MarshalString(in) + return graphql.MarshalString(v) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalString(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalString(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalString(in) + return graphql.MarshalString(*v) } func (ec *executionContext) marshalOUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋaccountsᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { diff --git a/example/federation/products/graph/generated/generated.go b/example/federation/products/graph/generated/generated.go index a25fd614512..dd268c6b6fa 100644 --- a/example/federation/products/graph/generated/generated.go +++ b/example/federation/products/graph/generated/generated.go @@ -2209,8 +2209,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - res := graphql.MarshalBoolean(in) + res := graphql.MarshalBoolean(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2225,8 +2224,7 @@ func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{} } func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - in := v - res := graphql.MarshalInt(in) + res := graphql.MarshalInt(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2255,8 +2253,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2277,8 +2274,7 @@ func (ec *executionContext) marshalN_Any2map(ctx context.Context, sel ast.Select } return graphql.Null } - in := v - res := graphql.MarshalMap(in) + res := graphql.MarshalMap(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2360,8 +2356,7 @@ func (ec *executionContext) unmarshalN_FieldSet2string(ctx context.Context, v in } func (ec *executionContext) marshalN_FieldSet2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2421,8 +2416,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2595,8 +2589,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2611,42 +2604,37 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(v) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalBoolean(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalBoolean(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(*v) } func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v interface{}) (*int, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalInt(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalInt(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalInt(in) + return graphql.MarshalInt(*v) } func (ec *executionContext) marshalOProduct2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋproductsᚋgraphᚋmodelᚐProduct(ctx context.Context, sel ast.SelectionSet, v []*model.Product) graphql.Marshaler { @@ -2702,25 +2690,22 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - return graphql.MarshalString(in) + return graphql.MarshalString(v) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalString(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalString(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalString(in) + return graphql.MarshalString(*v) } func (ec *executionContext) marshalO_Entity2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v fedruntime.Entity) graphql.Marshaler { diff --git a/example/federation/reviews/graph/generated/generated.go b/example/federation/reviews/graph/generated/generated.go index def58941b6a..80bd200a98e 100644 --- a/example/federation/reviews/graph/generated/generated.go +++ b/example/federation/reviews/graph/generated/generated.go @@ -2478,8 +2478,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - res := graphql.MarshalBoolean(in) + res := graphql.MarshalBoolean(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2494,8 +2493,7 @@ func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface } func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalID(in) + res := graphql.MarshalID(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2524,8 +2522,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2560,8 +2557,7 @@ func (ec *executionContext) marshalN_Any2map(ctx context.Context, sel ast.Select } return graphql.Null } - in := v - res := graphql.MarshalMap(in) + res := graphql.MarshalMap(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2643,8 +2639,7 @@ func (ec *executionContext) unmarshalN_FieldSet2string(ctx context.Context, v in } func (ec *executionContext) marshalN_FieldSet2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2704,8 +2699,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2878,8 +2872,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2894,25 +2887,22 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(v) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalBoolean(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalBoolean(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(*v) } func (ec *executionContext) marshalOReview2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfederationᚋreviewsᚋgraphᚋmodelᚐReview(ctx context.Context, sel ast.SelectionSet, v []*model.Review) graphql.Marshaler { @@ -2968,25 +2958,22 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - return graphql.MarshalString(in) + return graphql.MarshalString(v) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalString(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalString(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalString(in) + return graphql.MarshalString(*v) } func (ec *executionContext) marshalO_Entity2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v fedruntime.Entity) graphql.Marshaler { diff --git a/example/fileupload/generated.go b/example/fileupload/generated.go index fc8a68dfac5..54ab565a842 100644 --- a/example/fileupload/generated.go +++ b/example/fileupload/generated.go @@ -2262,8 +2262,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - res := graphql.MarshalBoolean(in) + res := graphql.MarshalBoolean(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2329,8 +2328,7 @@ func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{} } func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - in := v - res := graphql.MarshalInt(in) + res := graphql.MarshalInt(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2345,8 +2343,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2361,8 +2358,7 @@ func (ec *executionContext) unmarshalNUpload2githubᚗcomᚋ99designsᚋgqlgen } func (ec *executionContext) marshalNUpload2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, sel ast.SelectionSet, v graphql.Upload) graphql.Marshaler { - in := v - res := graphql.MarshalUpload(in) + res := graphql.MarshalUpload(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2402,9 +2398,8 @@ func (ec *executionContext) marshalNUpload2ᚕᚖgithubᚗcomᚋ99designsᚋgqlg } func (ec *executionContext) unmarshalNUpload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, v interface{}) (*graphql.Upload, error) { - tmp, err := graphql.UnmarshalUpload(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalUpload(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalNUpload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, sel ast.SelectionSet, v *graphql.Upload) graphql.Marshaler { @@ -2414,8 +2409,7 @@ func (ec *executionContext) marshalNUpload2ᚖgithubᚗcomᚋ99designsᚋgqlgen } return graphql.Null } - in := *v - res := graphql.MarshalUpload(in) + res := graphql.MarshalUpload(*v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2451,9 +2445,8 @@ func (ec *executionContext) unmarshalNUploadFile2ᚕᚖgithubᚗcomᚋ99designs } func (ec *executionContext) unmarshalNUploadFile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfileuploadᚋmodelᚐUploadFile(ctx context.Context, v interface{}) (*model.UploadFile, error) { - tmp, err := ec.unmarshalInputUploadFile(ctx, v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := ec.unmarshalInputUploadFile(ctx, v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { @@ -2503,8 +2496,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2677,8 +2669,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2693,25 +2684,22 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(v) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalBoolean(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalBoolean(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(*v) } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { @@ -2720,25 +2708,22 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - return graphql.MarshalString(in) + return graphql.MarshalString(v) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalString(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalString(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalString(in) + return graphql.MarshalString(*v) } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { diff --git a/example/scalars/generated.go b/example/scalars/generated.go index de3a7f107d4..a47102b0849 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -2574,8 +2574,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - res := graphql.MarshalBoolean(in) + res := graphql.MarshalBoolean(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2596,8 +2595,7 @@ func (ec *executionContext) marshalNDarkMode2ᚖgithubᚗcomᚋ99designsᚋgqlge } return graphql.Null } - in := v - res := model.MarshalPreferences(in) + res := model.MarshalPreferences(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2612,8 +2610,7 @@ func (ec *executionContext) unmarshalNID2githubᚗcomᚋ99designsᚋgqlgenᚋexa } func (ec *executionContext) marshalNID2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋexternalᚐObjectID(ctx context.Context, sel ast.SelectionSet, v external.ObjectID) graphql.Marshaler { - in := v - res := model.MarshalID(in) + res := model.MarshalID(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2654,8 +2651,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2768,8 +2764,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2942,8 +2937,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2972,36 +2966,31 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(v) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalBoolean(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalBoolean(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(*v) } func (ec *executionContext) unmarshalODarkMode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPrefs(ctx context.Context, v interface{}) (model.Prefs, error) { - tmp, err := model.UnmarshalPreferences(v) - res := *tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := model.UnmarshalPreferences(v) + return *res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalODarkMode2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPrefs(ctx context.Context, sel ast.SelectionSet, v model.Prefs) graphql.Marshaler { - in := &v - return model.MarshalPreferences(in) + return model.MarshalPreferences(&v) } func (ec *executionContext) unmarshalODarkMode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPrefs(ctx context.Context, v interface{}) (*model.Prefs, error) { @@ -3016,8 +3005,7 @@ func (ec *executionContext) marshalODarkMode2ᚖgithubᚗcomᚋ99designsᚋgqlge if v == nil { return graphql.Null } - in := v - return model.MarshalPreferences(in) + return model.MarshalPreferences(v) } func (ec *executionContext) unmarshalOPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx context.Context, v interface{}) (*model.Point, error) { @@ -3040,9 +3028,8 @@ func (ec *executionContext) unmarshalOSearchArgs2ᚖgithubᚗcomᚋ99designsᚋg if v == nil { return nil, nil } - tmp, err := ec.unmarshalInputSearchArgs(ctx, v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := ec.unmarshalInputSearchArgs(ctx, v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { @@ -3051,25 +3038,22 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - return graphql.MarshalString(in) + return graphql.MarshalString(v) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalString(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalString(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalString(in) + return graphql.MarshalString(*v) } func (ec *executionContext) unmarshalOTier2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐTier(ctx context.Context, v interface{}) (model.Tier, error) { @@ -3088,25 +3072,22 @@ func (ec *executionContext) unmarshalOTimestamp2timeᚐTime(ctx context.Context, } func (ec *executionContext) marshalOTimestamp2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - in := v - return model.MarshalTimestamp(in) + return model.MarshalTimestamp(v) } func (ec *executionContext) unmarshalOTimestamp2ᚖtimeᚐTime(ctx context.Context, v interface{}) (*time.Time, error) { if v == nil { return nil, nil } - tmp, err := model.UnmarshalTimestamp(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := model.UnmarshalTimestamp(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOTimestamp2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return model.MarshalTimestamp(in) + return model.MarshalTimestamp(*v) } func (ec *executionContext) marshalOUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { diff --git a/example/selection/generated.go b/example/selection/generated.go index 6af73bcb0ad..1823dff85ae 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -2088,8 +2088,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - res := graphql.MarshalBoolean(in) + res := graphql.MarshalBoolean(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2114,8 +2113,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2130,8 +2128,7 @@ func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v in } func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - in := v - res := graphql.MarshalTime(in) + res := graphql.MarshalTime(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2187,8 +2184,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2361,8 +2357,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2377,25 +2372,22 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(v) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalBoolean(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalBoolean(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(*v) } func (ec *executionContext) marshalOEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋselectionᚐEventᚄ(ctx context.Context, sel ast.SelectionSet, v []Event) graphql.Marshaler { @@ -2444,8 +2436,7 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - return graphql.MarshalString(in) + return graphql.MarshalString(v) } func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { @@ -2488,17 +2479,15 @@ func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v in if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalString(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalString(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalString(in) + return graphql.MarshalString(*v) } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { diff --git a/example/starwars/generated/exec.go b/example/starwars/generated/exec.go index 053347ed683..8955f60b196 100644 --- a/example/starwars/generated/exec.go +++ b/example/starwars/generated/exec.go @@ -4245,8 +4245,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - res := graphql.MarshalBoolean(in) + res := graphql.MarshalBoolean(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -4339,8 +4338,7 @@ func (ec *executionContext) unmarshalNFloat2float64(ctx context.Context, v inter } func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { - in := v - res := graphql.MarshalFloat(in) + res := graphql.MarshalFloat(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -4379,8 +4377,7 @@ func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface } func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalID(in) + res := graphql.MarshalID(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -4395,8 +4392,7 @@ func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{} } func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - in := v - res := graphql.MarshalInt(in) + res := graphql.MarshalInt(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -4584,8 +4580,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -4641,8 +4636,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -4815,8 +4809,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -4831,25 +4824,22 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(v) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalBoolean(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalBoolean(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(*v) } func (ec *executionContext) marshalOCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v models.Character) graphql.Marshaler { @@ -4928,8 +4918,7 @@ func (ec *executionContext) unmarshalOFloat2float64(ctx context.Context, v inter } func (ec *executionContext) marshalOFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { - in := v - return graphql.MarshalFloat(in) + return graphql.MarshalFloat(v) } func (ec *executionContext) marshalOFriendsEdge2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐFriendsEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.FriendsEdge) graphql.Marshaler { @@ -4983,34 +4972,30 @@ func (ec *executionContext) unmarshalOID2ᚖstring(ctx context.Context, v interf if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalID(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalID(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOID2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalID(in) + return graphql.MarshalID(*v) } func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v interface{}) (*int, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalInt(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalInt(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalInt(in) + return graphql.MarshalInt(*v) } func (ec *executionContext) unmarshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐLengthUnit(ctx context.Context, v interface{}) (models.LengthUnit, error) { @@ -5099,25 +5084,22 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - return graphql.MarshalString(in) + return graphql.MarshalString(v) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalString(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalString(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalString(in) + return graphql.MarshalString(*v) } func (ec *executionContext) unmarshalOTime2timeᚐTime(ctx context.Context, v interface{}) (time.Time, error) { @@ -5126,25 +5108,22 @@ func (ec *executionContext) unmarshalOTime2timeᚐTime(ctx context.Context, v in } func (ec *executionContext) marshalOTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { - in := v - return graphql.MarshalTime(in) + return graphql.MarshalTime(v) } func (ec *executionContext) unmarshalOTime2ᚖtimeᚐTime(ctx context.Context, v interface{}) (*time.Time, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalTime(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalTime(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOTime2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalTime(in) + return graphql.MarshalTime(*v) } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { diff --git a/example/todo/generated.go b/example/todo/generated.go index ebba2f2e925..47a3e313f63 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -2235,8 +2235,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - res := graphql.MarshalBoolean(in) + res := graphql.MarshalBoolean(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2251,8 +2250,7 @@ func (ec *executionContext) unmarshalNID2int(ctx context.Context, v interface{}) } func (ec *executionContext) marshalNID2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - in := v - res := graphql.MarshalIntID(in) + res := graphql.MarshalIntID(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2273,8 +2271,7 @@ func (ec *executionContext) marshalNMap2map(ctx context.Context, sel ast.Selecti } return graphql.Null } - in := v - res := graphql.MarshalMap(in) + res := graphql.MarshalMap(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2299,8 +2296,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2412,8 +2408,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2586,8 +2581,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2602,25 +2596,22 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(v) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalBoolean(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalBoolean(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(*v) } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { @@ -2629,25 +2620,22 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - return graphql.MarshalString(in) + return graphql.MarshalString(v) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalString(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalString(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalString(in) + return graphql.MarshalString(*v) } func (ec *executionContext) marshalOTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index 99abb9f9692..ad9c52e7fe8 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -2210,8 +2210,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - res := graphql.MarshalBoolean(in) + res := graphql.MarshalBoolean(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2226,8 +2225,7 @@ func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface } func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalID(in) + res := graphql.MarshalID(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2252,8 +2250,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2365,8 +2362,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2539,8 +2535,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2555,25 +2550,22 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(v) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalBoolean(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalBoolean(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(*v) } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { @@ -2582,25 +2574,22 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - return graphql.MarshalString(in) + return graphql.MarshalString(v) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalString(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalString(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalString(in) + return graphql.MarshalString(*v) } func (ec *executionContext) marshalOTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { diff --git a/integration/generated.go b/integration/generated.go index e11f85e097e..41fbb30242f 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -2501,8 +2501,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - res := graphql.MarshalBoolean(in) + res := graphql.MarshalBoolean(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2536,8 +2535,7 @@ func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{} } func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - in := v - res := graphql.MarshalInt(in) + res := graphql.MarshalInt(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2552,8 +2550,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v inter } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2639,8 +2636,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2813,8 +2809,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v i } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - res := graphql.MarshalString(in) + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -2829,8 +2824,7 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interf } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { - in := v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(v) } func (ec *executionContext) unmarshalOBoolean2ᚕboolᚄ(ctx context.Context, v interface{}) ([]bool, error) { @@ -2873,17 +2867,15 @@ func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v int if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalBoolean(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalBoolean(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalBoolean(in) + return graphql.MarshalBoolean(*v) } func (ec *executionContext) unmarshalODATE_FILTER_OP2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋmodelsᚑgoᚐDateFilterOp(ctx context.Context, v interface{}) (*models.DateFilterOp, error) { @@ -2969,17 +2961,15 @@ func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v interfac if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalInt(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalInt(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalInt(in) + return graphql.MarshalInt(*v) } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { @@ -2988,25 +2978,22 @@ func (ec *executionContext) unmarshalOString2string(ctx context.Context, v inter } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - in := v - return graphql.MarshalString(in) + return graphql.MarshalString(v) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } - tmp, err := graphql.UnmarshalString(v) - res := &tmp - return res, graphql.WrapErrorWithInputPath(ctx, err) + res, err := graphql.UnmarshalString(v) + return &res, graphql.WrapErrorWithInputPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } - in := *v - return graphql.MarshalString(in) + return graphql.MarshalString(*v) } func (ec *executionContext) marshalOUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋremote_apiᚐUser(ctx context.Context, sel ast.SelectionSet, v *remote_api.User) graphql.Marshaler { From dfec9444b93923e643084153da85826cbfd24bcf Mon Sep 17 00:00:00 2001 From: Luke Cawood Date: Thu, 13 Aug 2020 15:03:58 +1000 Subject: [PATCH 5/7] Replace awkward loop in buildTypes with recursion --- codegen/type.go | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/codegen/type.go b/codegen/type.go index a18de31ae87..06b370be7f2 100644 --- a/codegen/type.go +++ b/codegen/type.go @@ -8,29 +8,25 @@ import ( func (b *builder) buildTypes() map[string]*config.TypeReference { ret := map[string]*config.TypeReference{} - var key string - var existing *config.TypeReference - var found bool - for _, ref := range b.Binder.References { - for ref != nil { - key = ref.UniquenessKey() - if existing, found = ret[key]; found { - // Simplistic check of content which is obviously different. - existingGQL := fmt.Sprintf("%v", existing.GQL) - newGQL := fmt.Sprintf("%v", ref.GQL) - if existingGQL != newGQL { - panic(fmt.Sprintf("non-unique key \"%s\", trying to replace %s with %s", key, existingGQL, newGQL)) - } - } - ret[key] = ref + processType(ret, ref) + } + return ret +} - if ref.IsSlice() { - ref = ref.Elem() - } else { - break - } +func processType(ret map[string]*config.TypeReference, ref *config.TypeReference) { + key := ref.UniquenessKey() + if existing, found := ret[key]; found { + // Simplistic check of content which is obviously different. + existingGQL := fmt.Sprintf("%v", existing.GQL) + newGQL := fmt.Sprintf("%v", ref.GQL) + if existingGQL != newGQL { + panic(fmt.Sprintf("non-unique key \"%s\", trying to replace %s with %s", key, existingGQL, newGQL)) } } - return ret + ret[key] = ref + + if ref.IsSlice() { + processType(ret, ref.Elem()) + } } From ea1b9d40c3462c8db6011c5d87a629db7a58b888 Mon Sep 17 00:00:00 2001 From: Luke Cawood Date: Thu, 13 Aug 2020 16:01:52 +1000 Subject: [PATCH 6/7] Reintroduce special cast case for string enums This reverts commit c5b01934bfd67678d867a42e09ffedf02a68ddf6. --- codegen/config/binder.go | 41 ++++- codegen/testserver/generated.go | 190 ++++++++++++++++++++++-- codegen/testserver/otherpkg/model.go | 3 +- codegen/testserver/resolver.go | 7 +- codegen/testserver/stub.go | 9 +- codegen/testserver/typefallback.graphql | 9 ++ codegen/testserver/typefallback_test.go | 28 ++++ codegen/testserver/wrapped_type.go | 24 +-- codegen/testserver/wrapped_type.graphql | 2 +- codegen/type.gotpl | 17 ++- 10 files changed, 283 insertions(+), 47 deletions(-) create mode 100644 codegen/testserver/typefallback.graphql create mode 100644 codegen/testserver/typefallback_test.go diff --git a/codegen/config/binder.go b/codegen/config/binder.go index a4f84fed808..514ccc6742e 100644 --- a/codegen/config/binder.go +++ b/codegen/config/binder.go @@ -151,6 +151,7 @@ func (b *Binder) PointerTo(ref *TypeReference) *TypeReference { newRef := &TypeReference{ GO: types.NewPointer(ref.GO), GQL: ref.GQL, + CastType: ref.CastType, Definition: ref.Definition, Unmarshaler: ref.Unmarshaler, Marshaler: ref.Marshaler, @@ -167,6 +168,7 @@ type TypeReference struct { GQL *ast.Type GO types.Type Target types.Type + CastType types.Type // Before calling marshalling functions cast from/to this base type Marshaler *types.Func // When using external marshalling functions this will point to the Marshal function Unmarshaler *types.Func // When using external marshalling functions this will point to the Unmarshal function IsMarshaler bool // Does the type implement graphql.Marshaler and graphql.Unmarshaler @@ -178,6 +180,7 @@ func (ref *TypeReference) Elem() *TypeReference { GO: p.Elem(), Target: ref.Target, GQL: ref.GQL, + CastType: ref.CastType, Definition: ref.Definition, Unmarshaler: ref.Unmarshaler, Marshaler: ref.Marshaler, @@ -190,6 +193,7 @@ func (ref *TypeReference) Elem() *TypeReference { GO: ref.GO.(*types.Slice).Elem(), Target: ref.Target, GQL: ref.GQL.Elem, + CastType: ref.CastType, Definition: ref.Definition, Unmarshaler: ref.Unmarshaler, Marshaler: ref.Marshaler, @@ -345,16 +349,27 @@ func (b *Binder) TypeReference(schemaType *ast.Type, bindTarget types.Type) (ret return nil, err } - fun, isFunc := obj.(*types.Func) - switch { - case isFunc: + if fun, isFunc := obj.(*types.Func); isFunc { ref.GO = fun.Type().(*types.Signature).Params().At(0).Type() ref.Marshaler = fun ref.Unmarshaler = types.NewFunc(0, fun.Pkg(), "Unmarshal"+typeName, nil) - case hasMethod(obj.Type(), "MarshalGQL") && hasMethod(obj.Type(), "UnmarshalGQL"): + } else if hasMethod(obj.Type(), "MarshalGQL") && hasMethod(obj.Type(), "UnmarshalGQL") { ref.GO = obj.Type() ref.IsMarshaler = true - default: + } else if underlying := basicUnderlying(obj.Type()); def.IsLeafType() && underlying != nil && underlying.Kind() == types.String { + // Special case for named types wrapping strings. Used by default enum implementations. + + ref.GO = obj.Type() + ref.CastType = underlying + + underlyingRef, err := b.TypeReference(&ast.Type{NamedType: "String"}, nil) + if err != nil { + return nil, err + } + + ref.Marshaler = underlyingRef.Marshaler + ref.Unmarshaler = underlyingRef.Unmarshaler + } else { ref.GO = obj.Type() } @@ -431,3 +446,19 @@ func hasMethod(it types.Type, name string) bool { } return false } + +func basicUnderlying(it types.Type) *types.Basic { + if ptr, isPtr := it.(*types.Pointer); isPtr { + it = ptr.Elem() + } + namedType, ok := it.(*types.Named) + if !ok { + return nil + } + + if basic, ok := namedType.Underlying().(*types.Basic); ok { + return basic + } + + return nil +} diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 510e1110ee8..f6e52787a91 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -15,6 +15,7 @@ import ( introspection1 "github.com/99designs/gqlgen/codegen/testserver/introspection" invalid_packagename "github.com/99designs/gqlgen/codegen/testserver/invalid-packagename" + "github.com/99designs/gqlgen/codegen/testserver/otherpkg" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" gqlparser "github.com/vektah/gqlparser/v2" @@ -277,6 +278,7 @@ type ComplexityRoot struct { EnumInInput func(childComplexity int, input *InputWithEnumValue) int ErrorBubble func(childComplexity int) int Errors func(childComplexity int) int + Fallback func(childComplexity int, arg FallbackToStringEncoding) int InputNullableSlice func(childComplexity int, arg []string) int InputSlice func(childComplexity int, arg []string) int InvalidIdentifier func(childComplexity int) int @@ -357,6 +359,7 @@ type ComplexityRoot struct { } WrappedStruct struct { + Desc func(childComplexity int) int Name func(childComplexity int) int } @@ -461,10 +464,11 @@ type QueryResolver interface { DefaultScalar(ctx context.Context, arg string) (string, error) Slices(ctx context.Context) (*Slices, error) ScalarSlice(ctx context.Context) ([]byte, error) + Fallback(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) OptionalUnion(ctx context.Context) (TestUnion, error) ValidType(ctx context.Context) (*ValidType, error) WrappedStruct(ctx context.Context) (*WrappedStruct, error) - WrappedScalar(ctx context.Context) (WrappedScalar, error) + WrappedScalar(ctx context.Context) (otherpkg.Scalar, error) WrappedMap(ctx context.Context) (WrappedMap, error) WrappedSlice(ctx context.Context) (WrappedSlice, error) } @@ -1201,6 +1205,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Errors(childComplexity), true + case "Query.fallback": + if e.complexity.Query.Fallback == nil { + break + } + + args, err := ec.field_Query_fallback_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Fallback(childComplexity, args["arg"].(FallbackToStringEncoding)), true + case "Query.inputNullableSlice": if e.complexity.Query.InputNullableSlice == nil { break @@ -1668,6 +1684,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.WrappedSlice.Get(childComplexity, args["idx"].(int)), true + case "WrappedStruct.desc": + if e.complexity.WrappedStruct.Desc == nil { + break + } + + return e.complexity.WrappedStruct.Desc(childComplexity), true + case "WrappedStruct.name": if e.complexity.WrappedStruct.Name == nil { break @@ -2186,6 +2209,16 @@ type Slices { } scalar Bytes +`, BuiltIn: false}, + {Name: "typefallback.graphql", Input: `extend type Query { + fallback(arg: FallbackToStringEncoding!): FallbackToStringEncoding! +} + +enum FallbackToStringEncoding { + A + B + C +} `, BuiltIn: false}, {Name: "useptr.graphql", Input: `type A { id: ID! @@ -2298,7 +2331,7 @@ extend type Query { wrappedSlice: WrappedSlice! } -type WrappedStruct { name: String! } +type WrappedStruct { name: WrappedScalar!, desc: WrappedScalar } scalar WrappedScalar type WrappedMap { get(key: String!): String! } type WrappedSlice { get(idx: Int!): String! } @@ -2688,6 +2721,21 @@ func (ec *executionContext) field_Query_enumInInput_args(ctx context.Context, ra return args, nil } +func (ec *executionContext) field_Query_fallback_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 FallbackToStringEncoding + if tmp, ok := rawArgs["arg"]; ok { + ctx := graphql.WithFieldInputContext(ctx, graphql.NewFieldInputWithField("arg")) + arg0, err = ec.unmarshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐFallbackToStringEncoding(ctx, tmp) + if err != nil { + return nil, err + } + } + args["arg"] = arg0 + return args, nil +} + func (ec *executionContext) field_Query_inputNullableSlice_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -7271,6 +7319,44 @@ func (ec *executionContext) _Query_scalarSlice(ctx context.Context, field graphq return ec.marshalNBytes2ᚕbyte(ctx, field.Selections, res) } +func (ec *executionContext) _Query_fallback(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, + } + + ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Query_fallback_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Fallback(rctx, args["arg"].(FallbackToStringEncoding)) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(FallbackToStringEncoding) + fc.Result = res + return ec.marshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐFallbackToStringEncoding(ctx, field.Selections, res) +} + func (ec *executionContext) _Query_optionalUnion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { @@ -7384,9 +7470,9 @@ func (ec *executionContext) _Query_wrappedScalar(ctx context.Context, field grap } return graphql.Null } - res := resTmp.(WrappedScalar) + res := resTmp.(otherpkg.Scalar) fc.Result = res - return ec.marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐWrappedScalar(ctx, field.Selections, res) + return ec.marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋotherpkgᚐScalar(ctx, field.Selections, res) } func (ec *executionContext) _Query_wrappedMap(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { @@ -8409,9 +8495,37 @@ func (ec *executionContext) _WrappedStruct_name(ctx context.Context, field graph } return graphql.Null } - res := resTmp.(string) + res := resTmp.(otherpkg.Scalar) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋotherpkgᚐScalar(ctx, field.Selections, res) +} + +func (ec *executionContext) _WrappedStruct_desc(ctx context.Context, field graphql.CollectedField, obj *WrappedStruct) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "WrappedStruct", + Field: field, + Args: nil, + IsMethod: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Desc, nil + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*otherpkg.Scalar) + fc.Result = res + return ec.marshalOWrappedScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋotherpkgᚐScalar(ctx, field.Selections, res) } func (ec *executionContext) _XXIt_id(ctx context.Context, field graphql.CollectedField, obj *XXIt) (ret graphql.Marshaler) { @@ -12033,6 +12147,20 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } return res }) + case "fallback": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_fallback(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } + return res + }) case "optionalUnion": field := field out.Concurrently(i, func() (res graphql.Marshaler) { @@ -12400,6 +12528,8 @@ func (ec *executionContext) _WrappedStruct(ctx context.Context, sel ast.Selectio if out.Values[i] == graphql.Null { invalids++ } + case "desc": + out.Values[i] = ec._WrappedStruct_desc(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -12859,6 +12989,22 @@ func (ec *executionContext) marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgen return ec._Error(ctx, sel, v) } +func (ec *executionContext) unmarshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐFallbackToStringEncoding(ctx context.Context, v interface{}) (FallbackToStringEncoding, error) { + tmp, err := graphql.UnmarshalString(v) + res := FallbackToStringEncoding(tmp) + return res, graphql.WrapErrorWithInputPath(ctx, err) +} + +func (ec *executionContext) marshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐFallbackToStringEncoding(ctx context.Context, sel ast.SelectionSet, v FallbackToStringEncoding) graphql.Marshaler { + res := graphql.MarshalString(string(v)) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + } + return res +} + func (ec *executionContext) unmarshalNID2int(ctx context.Context, v interface{}) (int, error) { res, err := graphql.UnmarshalIntID(v) return res, graphql.WrapErrorWithInputPath(ctx, err) @@ -13328,14 +13474,20 @@ func (ec *executionContext) marshalNWrappedMap2githubᚗcomᚋ99designsᚋgqlgen return ec._WrappedMap(ctx, sel, v) } -func (ec *executionContext) unmarshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐWrappedScalar(ctx context.Context, v interface{}) (WrappedScalar, error) { - var res WrappedScalar - err := res.UnmarshalGQL(v) +func (ec *executionContext) unmarshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋotherpkgᚐScalar(ctx context.Context, v interface{}) (otherpkg.Scalar, error) { + tmp, err := graphql.UnmarshalString(v) + res := otherpkg.Scalar(tmp) return res, graphql.WrapErrorWithInputPath(ctx, err) } -func (ec *executionContext) marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐWrappedScalar(ctx context.Context, sel ast.SelectionSet, v WrappedScalar) graphql.Marshaler { - return v +func (ec *executionContext) marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋotherpkgᚐScalar(ctx context.Context, sel ast.SelectionSet, v otherpkg.Scalar) graphql.Marshaler { + res := graphql.MarshalString(string(v)) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + } + return res } func (ec *executionContext) marshalNWrappedSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐWrappedSlice(ctx context.Context, sel ast.SelectionSet, v WrappedSlice) graphql.Marshaler { @@ -14283,6 +14435,22 @@ func (ec *executionContext) marshalOValidType2ᚖgithubᚗcomᚋ99designsᚋgqlg return ec._ValidType(ctx, sel, v) } +func (ec *executionContext) unmarshalOWrappedScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋotherpkgᚐScalar(ctx context.Context, v interface{}) (*otherpkg.Scalar, error) { + if v == nil { + return nil, nil + } + tmp, err := graphql.UnmarshalString(v) + res := otherpkg.Scalar(tmp) + return &res, graphql.WrapErrorWithInputPath(ctx, err) +} + +func (ec *executionContext) marshalOWrappedScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋotherpkgᚐScalar(ctx context.Context, sel ast.SelectionSet, v *otherpkg.Scalar) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return graphql.MarshalString(string(*v)) +} + func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/codegen/testserver/otherpkg/model.go b/codegen/testserver/otherpkg/model.go index 01f59d8be21..f2cc202ede0 100644 --- a/codegen/testserver/otherpkg/model.go +++ b/codegen/testserver/otherpkg/model.go @@ -7,5 +7,6 @@ type ( ) type Struct struct { - Name string + Name Scalar + Desc *Scalar } diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index c66b8b220f2..952d20943e8 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -7,6 +7,7 @@ import ( introspection1 "github.com/99designs/gqlgen/codegen/testserver/introspection" invalid_packagename "github.com/99designs/gqlgen/codegen/testserver/invalid-packagename" + "github.com/99designs/gqlgen/codegen/testserver/otherpkg" ) type Resolver struct{} @@ -263,6 +264,10 @@ func (r *queryResolver) ScalarSlice(ctx context.Context) ([]byte, error) { panic("not implemented") } +func (r *queryResolver) Fallback(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) { + panic("not implemented") +} + func (r *queryResolver) OptionalUnion(ctx context.Context) (TestUnion, error) { panic("not implemented") } @@ -275,7 +280,7 @@ func (r *queryResolver) WrappedStruct(ctx context.Context) (*WrappedStruct, erro panic("not implemented") } -func (r *queryResolver) WrappedScalar(ctx context.Context) (WrappedScalar, error) { +func (r *queryResolver) WrappedScalar(ctx context.Context) (otherpkg.Scalar, error) { panic("not implemented") } diff --git a/codegen/testserver/stub.go b/codegen/testserver/stub.go index db82863779e..daf4052ea08 100644 --- a/codegen/testserver/stub.go +++ b/codegen/testserver/stub.go @@ -7,6 +7,7 @@ import ( introspection1 "github.com/99designs/gqlgen/codegen/testserver/introspection" invalid_packagename "github.com/99designs/gqlgen/codegen/testserver/invalid-packagename" + "github.com/99designs/gqlgen/codegen/testserver/otherpkg" ) type Stub struct { @@ -92,10 +93,11 @@ type Stub struct { DefaultScalar func(ctx context.Context, arg string) (string, error) Slices func(ctx context.Context) (*Slices, error) ScalarSlice func(ctx context.Context) ([]byte, error) + Fallback func(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) OptionalUnion func(ctx context.Context) (TestUnion, error) ValidType func(ctx context.Context) (*ValidType, error) WrappedStruct func(ctx context.Context) (*WrappedStruct, error) - WrappedScalar func(ctx context.Context) (WrappedScalar, error) + WrappedScalar func(ctx context.Context) (otherpkg.Scalar, error) WrappedMap func(ctx context.Context) (WrappedMap, error) WrappedSlice func(ctx context.Context) (WrappedSlice, error) } @@ -380,6 +382,9 @@ func (r *stubQuery) Slices(ctx context.Context) (*Slices, error) { func (r *stubQuery) ScalarSlice(ctx context.Context) ([]byte, error) { return r.QueryResolver.ScalarSlice(ctx) } +func (r *stubQuery) Fallback(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) { + return r.QueryResolver.Fallback(ctx, arg) +} func (r *stubQuery) OptionalUnion(ctx context.Context) (TestUnion, error) { return r.QueryResolver.OptionalUnion(ctx) } @@ -389,7 +394,7 @@ func (r *stubQuery) ValidType(ctx context.Context) (*ValidType, error) { func (r *stubQuery) WrappedStruct(ctx context.Context) (*WrappedStruct, error) { return r.QueryResolver.WrappedStruct(ctx) } -func (r *stubQuery) WrappedScalar(ctx context.Context) (WrappedScalar, error) { +func (r *stubQuery) WrappedScalar(ctx context.Context) (otherpkg.Scalar, error) { return r.QueryResolver.WrappedScalar(ctx) } func (r *stubQuery) WrappedMap(ctx context.Context) (WrappedMap, error) { diff --git a/codegen/testserver/typefallback.graphql b/codegen/testserver/typefallback.graphql new file mode 100644 index 00000000000..e1ff1a59d7c --- /dev/null +++ b/codegen/testserver/typefallback.graphql @@ -0,0 +1,9 @@ +extend type Query { + fallback(arg: FallbackToStringEncoding!): FallbackToStringEncoding! +} + +enum FallbackToStringEncoding { + A + B + C +} diff --git a/codegen/testserver/typefallback_test.go b/codegen/testserver/typefallback_test.go new file mode 100644 index 00000000000..8ebd091e9ef --- /dev/null +++ b/codegen/testserver/typefallback_test.go @@ -0,0 +1,28 @@ +package testserver + +import ( + "context" + "testing" + + "github.com/99designs/gqlgen/client" + "github.com/99designs/gqlgen/graphql/handler" + "github.com/stretchr/testify/require" +) + +func TestTypeFallback(t *testing.T) { + resolvers := &Stub{} + + c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers}))) + + resolvers.QueryResolver.Fallback = func(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) { + return arg, nil + } + + t.Run("fallback to string passthrough", func(t *testing.T) { + var resp struct { + Fallback string + } + c.MustPost(`query { fallback(arg: A) }`, &resp) + require.Equal(t, "A", resp.Fallback) + }) +} diff --git a/codegen/testserver/wrapped_type.go b/codegen/testserver/wrapped_type.go index bd7ea31006c..d17436045b6 100644 --- a/codegen/testserver/wrapped_type.go +++ b/codegen/testserver/wrapped_type.go @@ -1,28 +1,8 @@ package testserver -import ( - "fmt" - "io" - "strconv" +import "github.com/99designs/gqlgen/codegen/testserver/otherpkg" - "github.com/99designs/gqlgen/codegen/testserver/otherpkg" - "github.com/99designs/gqlgen/graphql" -) - -type WrappedScalar otherpkg.Scalar +type WrappedScalar = otherpkg.Scalar type WrappedStruct otherpkg.Struct type WrappedMap otherpkg.Map type WrappedSlice otherpkg.Slice - -func (e *WrappedScalar) UnmarshalGQL(v interface{}) error { - s, err := graphql.UnmarshalString(v) - if err != nil { - return err - } - *e = WrappedScalar(s) - return nil -} - -func (e WrappedScalar) MarshalGQL(w io.Writer) { - fmt.Fprint(w, strconv.Quote(string(e))) -} diff --git a/codegen/testserver/wrapped_type.graphql b/codegen/testserver/wrapped_type.graphql index 4f7df84a755..116147432cb 100644 --- a/codegen/testserver/wrapped_type.graphql +++ b/codegen/testserver/wrapped_type.graphql @@ -7,7 +7,7 @@ extend type Query { wrappedSlice: WrappedSlice! } -type WrappedStruct { name: String! } +type WrappedStruct { name: WrappedScalar!, desc: WrappedScalar } scalar WrappedScalar type WrappedMap { get(key: String!): String! } type WrappedSlice { get(idx: Int!): String! } diff --git a/codegen/type.gotpl b/codegen/type.gotpl index 60a87699406..2bd0c1943a1 100644 --- a/codegen/type.gotpl +++ b/codegen/type.gotpl @@ -25,7 +25,16 @@ return res, nil {{- else }} {{- if $type.Unmarshaler }} - res, err := {{ $type.Unmarshaler | call }}(v) + {{- if $type.CastType }} + tmp, err := {{ $type.Unmarshaler | call }}(v) + {{- if $type.IsNilable }} + res := {{ $type.Elem.GO | ref }}(tmp) + {{- else}} + res := {{ $type.GO | ref }}(tmp) + {{- end }} + {{- else}} + res, err := {{ $type.Unmarshaler | call }}(v) + {{- end }} {{- if and $type.IsTargetNilable (not $type.IsNilable) }} return *res, graphql.WrapErrorWithInputPath(ctx, err) {{- else if and (not $type.IsTargetNilable) $type.IsNilable }} @@ -36,7 +45,7 @@ {{- else if eq ($type.GO | ref) "map[string]interface{}" }} return v.(map[string]interface{}), nil {{- else if $type.IsMarshaler }} - {{- if $type.IsNilable }} + {{- if $type.IsNilable }} var res = new({{ $type.Elem.GO | ref }}) {{- else}} var res {{ $type.GO | ref }} @@ -123,7 +132,7 @@ {{- $v = "*v" }} {{- end }} {{- if $type.GQL.NonNull }} - res := {{ $type.Marshaler | call }}({{ $v }}) + res := {{ $type.Marshaler | call }}({{- if $type.CastType }}{{ $type.CastType | ref }}({{ $v }}){{else}}{{ $v }}{{- end }}) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") @@ -131,7 +140,7 @@ } return res {{- else }} - return {{ $type.Marshaler | call }}({{ $v }}) + return {{ $type.Marshaler | call }}({{- if $type.CastType }}{{ $type.CastType | ref }}({{ $v }}){{else}}{{ $v }}{{- end }}) {{- end }} {{- else }} return ec._{{$type.Definition.Name}}(ctx, sel, {{ if not $type.IsNilable}}&{{end}} v) From 843c54da36e0f9ecedf2152d4e6231f82e48bcf5 Mon Sep 17 00:00:00 2001 From: Luke Cawood Date: Thu, 13 Aug 2020 17:26:49 +1000 Subject: [PATCH 7/7] Add comments and docs for pointer scalars --- codegen/config/binder.go | 6 +++--- docs/content/reference/scalars.md | 12 +++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/codegen/config/binder.go b/codegen/config/binder.go index 514ccc6742e..2be7b7bdd6b 100644 --- a/codegen/config/binder.go +++ b/codegen/config/binder.go @@ -166,8 +166,8 @@ func (b *Binder) PointerTo(ref *TypeReference) *TypeReference { type TypeReference struct { Definition *ast.Definition GQL *ast.Type - GO types.Type - Target types.Type + GO types.Type // Type of the field being bound. Could be a pointer or a value type of Target. + Target types.Type // The actual type that we know how to bind to. May require pointer juggling when traversing to fields. CastType types.Type // Before calling marshalling functions cast from/to this base type Marshaler *types.Func // When using external marshalling functions this will point to the Marshal function Unmarshaler *types.Func // When using external marshalling functions this will point to the Unmarshal function @@ -357,7 +357,7 @@ func (b *Binder) TypeReference(schemaType *ast.Type, bindTarget types.Type) (ret ref.GO = obj.Type() ref.IsMarshaler = true } else if underlying := basicUnderlying(obj.Type()); def.IsLeafType() && underlying != nil && underlying.Kind() == types.String { - // Special case for named types wrapping strings. Used by default enum implementations. + // TODO delete before v1. Backwards compatibility case for named types wrapping strings (see #595) ref.GO = obj.Type() ref.CastType = underlying diff --git a/docs/content/reference/scalars.md b/docs/content/reference/scalars.md index eff8b8cf3b0..9bda307f553 100644 --- a/docs/content/reference/scalars.md +++ b/docs/content/reference/scalars.md @@ -60,7 +60,6 @@ package mypkg import ( "fmt" "io" - "strings" ) type YesNo bool @@ -69,7 +68,7 @@ type YesNo bool func (y *YesNo) UnmarshalGQL(v interface{}) error { yes, ok := v.(string) if !ok { - return fmt.Errorf("points must be strings") + return fmt.Errorf("YesNo must be a string") } if yes == "yes" { @@ -90,7 +89,7 @@ func (y YesNo) MarshalGQL(w io.Writer) { } ``` -and then in .gqlgen.yml point to the name without the Marshal|Unmarshal in front: +and then wire up the type in .gqlgen.yml or via directives like normal: ```yaml models: @@ -100,8 +99,8 @@ models: ## Custom scalars with third party types -Sometimes you cant add methods to a type because its in another repo, part of the standard -library (eg string or time.Time). To do this we can build an external marshaler: +Sometimes you are unable to add add methods to a type - perhaps you don't own the type, or it is part of the standard +library (eg string or time.Time). To support this we can build an external marshaler: ```go package mypkg @@ -147,6 +146,9 @@ models: model: github.com/me/mypkg.MyCustomBooleanScalar ``` +**Note:** you also can un/marshal to pointer types via this approach, simply accept a pointer in your +`Marshal...` func and return one in your `Unmarshal...` func. + See the [example/scalars](https://github.com/99designs/gqlgen/tree/master/example/scalars) package for more examples. ## Unmarshaling Errors