diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index b737424dd7c..ce5a94e73a8 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -12478,9 +12478,6 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se } func (ec *executionContext) unmarshalNBytes2ᚕbyte(ctx context.Context, v interface{}) ([]byte, error) { - if v == nil { - return nil, nil - } return UnmarshalBytes(v) } @@ -12599,9 +12596,6 @@ func (ec *executionContext) unmarshalNInnerDirectives2githubᚗcomᚋ99designs } func (ec *executionContext) unmarshalNInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(ctx context.Context, v interface{}) (*InnerDirectives, error) { - if v == nil { - return nil, nil - } res, err := ec.unmarshalNInnerDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerDirectives(ctx, v) return &res, err } @@ -12611,9 +12605,6 @@ 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) { - if v == nil { - return nil, nil - } res, err := ec.unmarshalNInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐInnerInput(ctx, v) return &res, err } @@ -12716,9 +12707,6 @@ func (ec *executionContext) marshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlg } func (ec *executionContext) unmarshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanicᚄ(ctx context.Context, v interface{}) ([]MarshalPanic, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -12868,9 +12856,6 @@ func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.S } func (ec *executionContext) unmarshalNString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -12900,9 +12885,6 @@ func (ec *executionContext) marshalNString2ᚕstringᚄ(ctx context.Context, sel } func (ec *executionContext) unmarshalNString2ᚕᚖstring(ctx context.Context, v interface{}) ([]*string, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -12932,9 +12914,6 @@ func (ec *executionContext) marshalNString2ᚕᚖstring(ctx context.Context, sel } func (ec *executionContext) unmarshalNString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { - if v == nil { - return nil, nil - } res, err := ec.unmarshalNString2string(ctx, v) return &res, err } @@ -13133,9 +13112,6 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte } func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { diff --git a/codegen/type.gotpl b/codegen/type.gotpl index f283f5603a8..469c2a373d5 100644 --- a/codegen/type.gotpl +++ b/codegen/type.gotpl @@ -1,7 +1,7 @@ {{- range $type := .ReferencedTypes }} {{ with $type.UnmarshalFunc }} func (ec *executionContext) {{ . }}(ctx context.Context, v interface{}) ({{ $type.GO | ref }}, error) { - {{- if $type.IsNilable }} + {{- if and $type.IsNilable (not $type.GQL.NonNull) }} if v == nil { return nil, nil } {{- end }} {{- if $type.IsPtr }} diff --git a/example/chat/generated.go b/example/chat/generated.go index 9ed9ae91b43..f64e588ceb8 100644 --- a/example/chat/generated.go +++ b/example/chat/generated.go @@ -2490,9 +2490,6 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte } func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { diff --git a/example/config/generated.go b/example/config/generated.go index f14c0cdaa5b..4322c888bae 100644 --- a/example/config/generated.go +++ b/example/config/generated.go @@ -2381,9 +2381,6 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte } func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go index 915473b509d..ddb182fc759 100644 --- a/example/dataloader/generated.go +++ b/example/dataloader/generated.go @@ -2666,9 +2666,6 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte } func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { diff --git a/example/federation/accounts/graph/generated/generated.go b/example/federation/accounts/graph/generated/generated.go index 08286ab0bb1..d799cc01327 100644 --- a/example/federation/accounts/graph/generated/generated.go +++ b/example/federation/accounts/graph/generated/generated.go @@ -2180,9 +2180,6 @@ func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ } func (ec *executionContext) unmarshalN_Any2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { - if v == nil { - return nil, nil - } return graphql.UnmarshalMap(v) } @@ -2203,9 +2200,6 @@ func (ec *executionContext) marshalN_Any2map(ctx context.Context, sel ast.Select } func (ec *executionContext) unmarshalN_Any2ᚕmapᚄ(ctx context.Context, v interface{}) ([]map[string]interface{}, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -2345,9 +2339,6 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte } func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { diff --git a/example/federation/products/graph/generated/generated.go b/example/federation/products/graph/generated/generated.go index d6005ae532e..2fee8579f0c 100644 --- a/example/federation/products/graph/generated/generated.go +++ b/example/federation/products/graph/generated/generated.go @@ -2254,9 +2254,6 @@ func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.S } func (ec *executionContext) unmarshalN_Any2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { - if v == nil { - return nil, nil - } return graphql.UnmarshalMap(v) } @@ -2277,9 +2274,6 @@ func (ec *executionContext) marshalN_Any2map(ctx context.Context, sel ast.Select } func (ec *executionContext) unmarshalN_Any2ᚕmapᚄ(ctx context.Context, v interface{}) ([]map[string]interface{}, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -2419,9 +2413,6 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte } func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { diff --git a/example/federation/reviews/graph/generated/generated.go b/example/federation/reviews/graph/generated/generated.go index 9326171535a..3b702da6402 100644 --- a/example/federation/reviews/graph/generated/generated.go +++ b/example/federation/reviews/graph/generated/generated.go @@ -2537,9 +2537,6 @@ func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ } func (ec *executionContext) unmarshalN_Any2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { - if v == nil { - return nil, nil - } return graphql.UnmarshalMap(v) } @@ -2560,9 +2557,6 @@ func (ec *executionContext) marshalN_Any2map(ctx context.Context, sel ast.Select } func (ec *executionContext) unmarshalN_Any2ᚕmapᚄ(ctx context.Context, v interface{}) ([]map[string]interface{}, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -2702,9 +2696,6 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte } func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { diff --git a/example/fileupload/generated.go b/example/fileupload/generated.go index 630055caccf..517cbb1fca7 100644 --- a/example/fileupload/generated.go +++ b/example/fileupload/generated.go @@ -2353,9 +2353,6 @@ func (ec *executionContext) marshalNUpload2githubᚗcomᚋ99designsᚋgqlgenᚋg } func (ec *executionContext) unmarshalNUpload2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUploadᚄ(ctx context.Context, v interface{}) ([]*graphql.Upload, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -2385,9 +2382,6 @@ 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) { - if v == nil { - return nil, nil - } res, err := ec.unmarshalNUpload2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx, v) return &res, err } @@ -2407,9 +2401,6 @@ func (ec *executionContext) unmarshalNUploadFile2githubᚗcomᚋ99designsᚋgqlg } func (ec *executionContext) unmarshalNUploadFile2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfileuploadᚋmodelᚐUploadFileᚄ(ctx context.Context, v interface{}) ([]*model.UploadFile, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -2430,9 +2421,6 @@ 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) { - if v == nil { - return nil, nil - } res, err := ec.unmarshalNUploadFile2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋfileuploadᚋmodelᚐUploadFile(ctx, v) return &res, err } @@ -2493,9 +2481,6 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte } func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { diff --git a/example/scalars/generated.go b/example/scalars/generated.go index 54544c72e90..95c630adcfa 100644 --- a/example/scalars/generated.go +++ b/example/scalars/generated.go @@ -2373,9 +2373,6 @@ 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) { - if v == nil { - return nil, nil - } res, err := ec.unmarshalNPoint2githubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋscalarsᚋmodelᚐPoint(ctx, v) return &res, err } @@ -2511,9 +2508,6 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte } func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { diff --git a/example/selection/generated.go b/example/selection/generated.go index 266c97d41ce..f25e924fbb7 100644 --- a/example/selection/generated.go +++ b/example/selection/generated.go @@ -2187,9 +2187,6 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte } func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { diff --git a/example/starwars/generated/exec.go b/example/starwars/generated/exec.go index 150c1a1ec94..35644f0ba0b 100644 --- a/example/starwars/generated/exec.go +++ b/example/starwars/generated/exec.go @@ -4248,9 +4248,6 @@ func (ec *executionContext) marshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋ } func (ec *executionContext) unmarshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋexampleᚋstarwarsᚋmodelsᚐEpisodeᚄ(ctx context.Context, v interface{}) ([]models.Episode, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -4378,9 +4375,6 @@ func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.Selecti } func (ec *executionContext) unmarshalNInt2ᚕintᚄ(ctx context.Context, v interface{}) ([]int, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -4410,9 +4404,6 @@ func (ec *executionContext) marshalNInt2ᚕintᚄ(ctx context.Context, sel ast.S } func (ec *executionContext) unmarshalNInt2ᚕᚕintᚄ(ctx context.Context, v interface{}) ([][]int, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -4631,9 +4622,6 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte } func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { diff --git a/example/todo/generated.go b/example/todo/generated.go index 93c819a01b4..cb9b3b617ec 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -2245,9 +2245,6 @@ func (ec *executionContext) marshalNID2int(ctx context.Context, sel ast.Selectio } func (ec *executionContext) unmarshalNMap2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { - if v == nil { - return nil, nil - } return graphql.UnmarshalMap(v) } @@ -2401,9 +2398,6 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte } func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go index 0d63ac02aa9..318ff3baec1 100644 --- a/example/type-system-extension/generated.go +++ b/example/type-system-extension/generated.go @@ -2359,9 +2359,6 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte } func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { diff --git a/integration/generated.go b/integration/generated.go index edf4d1a9046..ee0a66a4da4 100644 --- a/integration/generated.go +++ b/integration/generated.go @@ -2543,9 +2543,6 @@ func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.S } func (ec *executionContext) unmarshalNString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { @@ -2630,9 +2627,6 @@ func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Conte } func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { - if v == nil { - return nil, nil - } var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok {