diff --git a/entgql/internal/todo/ent.graphql b/entgql/internal/todo/ent.graphql index 03c085a81..a87de7b0d 100644 --- a/entgql/internal/todo/ent.graphql +++ b/entgql/internal/todo/ent.graphql @@ -73,11 +73,11 @@ type Category implements Node { id: ID! text: String! status: CategoryStatus! - config: CategoryConfig - types: CategoryTypes - duration: Duration - count: Uint64 - strings: [String!] @deprecated(reason: "use `string` instead") + config: CategoryConfig! + types: CategoryTypes! + duration: Duration! + count: Uint64! + strings: [String!]! @deprecated(reason: "use `string` instead") todos( """ Returns the elements in the list that come after the specified cursor. @@ -534,7 +534,7 @@ interface Node @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent.Noder" type OneToMany implements Node { id: ID! name: String! - field2: String + field2: String! parent: OneToMany children: [OneToMany!] } @@ -969,12 +969,12 @@ type Todo implements Node { status: TodoStatus! priorityOrder: Int! @goField(name: "Priority", forceResolver: false) text: String! - categoryID: ID - category_id: ID - categoryX: ID @goField(name: "CategoryID", forceResolver: false) - init: Map - custom: [Custom!] - customp: [Custom] + categoryID: ID! + category_id: ID! + categoryX: ID! @goField(name: "CategoryID", forceResolver: false) + init: Map! + custom: [Custom!]! + customp: [Custom]! value: Int! parent: Todo children( @@ -1254,7 +1254,7 @@ type User implements Node { name: String! username: UUID! requiredMetadata: Map! - metadata: Map + metadata: Map! groups( """ Returns the elements in the list that come after the specified cursor. diff --git a/entgql/internal/todo/generated.go b/entgql/internal/todo/generated.go index d929674ac..750de0c4d 100644 --- a/entgql/internal/todo/generated.go +++ b/entgql/internal/todo/generated.go @@ -3950,11 +3950,14 @@ func (ec *executionContext) _Category_config(ctx context.Context, field graphql. return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(*schematype.CategoryConfig) fc.Result = res - return ec.marshalOCategoryConfig2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, field.Selections, res) + return ec.marshalNCategoryConfig2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Category_config(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -3995,11 +3998,14 @@ func (ec *executionContext) _Category_types(ctx context.Context, field graphql.C return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(*schematype.CategoryTypes) fc.Result = res - return ec.marshalOCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryTypes(ctx, field.Selections, res) + return ec.marshalNCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryTypes(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Category_types(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -4040,11 +4046,14 @@ func (ec *executionContext) _Category_duration(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(time.Duration) fc.Result = res - return ec.marshalODuration2timeᚐDuration(ctx, field.Selections, res) + return ec.marshalNDuration2timeᚐDuration(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Category_duration(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -4081,11 +4090,14 @@ func (ec *executionContext) _Category_count(ctx context.Context, field graphql.C return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(uint64) fc.Result = res - return ec.marshalOUint642uint64(ctx, field.Selections, res) + return ec.marshalNUint642uint64(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Category_count(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -4122,11 +4134,14 @@ func (ec *executionContext) _Category_strings(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.([]string) fc.Result = res - return ec.marshalOString2ᚕstringᚄ(ctx, field.Selections, res) + return ec.marshalNString2ᚕstringᚄ(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Category_strings(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -6128,11 +6143,14 @@ func (ec *executionContext) _OneToMany_field2(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(string) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_OneToMany_field2(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -7816,11 +7834,14 @@ func (ec *executionContext) _Todo_categoryID(ctx context.Context, field graphql. return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(int) fc.Result = res - return ec.marshalOID2int(ctx, field.Selections, res) + return ec.marshalNID2int(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_categoryID(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -7857,11 +7878,14 @@ func (ec *executionContext) _Todo_category_id(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(int) fc.Result = res - return ec.marshalOID2int(ctx, field.Selections, res) + return ec.marshalNID2int(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_category_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -7898,11 +7922,14 @@ func (ec *executionContext) _Todo_categoryX(ctx context.Context, field graphql.C return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(int) fc.Result = res - return ec.marshalOID2int(ctx, field.Selections, res) + return ec.marshalNID2int(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_categoryX(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -7939,11 +7966,14 @@ func (ec *executionContext) _Todo_init(ctx context.Context, field graphql.Collec return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(map[string]interface{}) fc.Result = res - return ec.marshalOMap2map(ctx, field.Selections, res) + return ec.marshalNMap2map(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_init(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -7980,11 +8010,14 @@ func (ec *executionContext) _Todo_custom(ctx context.Context, field graphql.Coll return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.([]customstruct.Custom) fc.Result = res - return ec.marshalOCustom2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustomᚄ(ctx, field.Selections, res) + return ec.marshalNCustom2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustomᚄ(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_custom(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -8025,11 +8058,14 @@ func (ec *executionContext) _Todo_customp(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.([]*customstruct.Custom) fc.Result = res - return ec.marshalOCustom2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx, field.Selections, res) + return ec.marshalNCustom2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_customp(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -8798,11 +8834,14 @@ func (ec *executionContext) _User_metadata(ctx context.Context, field graphql.Co return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(map[string]interface{}) fc.Result = res - return ec.marshalOMap2map(ctx, field.Selections, res) + return ec.marshalNMap2map(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_User_metadata(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -14757,14 +14796,29 @@ func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, } case "config": out.Values[i] = ec._Category_config(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "types": out.Values[i] = ec._Category_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "duration": out.Values[i] = ec._Category_duration(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "count": out.Values[i] = ec._Category_count(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "strings": out.Values[i] = ec._Category_strings(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "todos": field := field @@ -15571,6 +15625,9 @@ func (ec *executionContext) _OneToMany(ctx context.Context, sel ast.SelectionSet } case "field2": out.Values[i] = ec._OneToMany_field2(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "parent": field := field @@ -16219,16 +16276,34 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj } case "categoryID": out.Values[i] = ec._Todo_categoryID(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "category_id": out.Values[i] = ec._Todo_category_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "categoryX": out.Values[i] = ec._Todo_categoryX(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "init": out.Values[i] = ec._Todo_init(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "custom": out.Values[i] = ec._Todo_custom(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "customp": out.Values[i] = ec._Todo_customp(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "value": out.Values[i] = ec._Todo_value(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -16512,6 +16587,9 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj } case "metadata": out.Values[i] = ec._User_metadata(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "groups": field := field @@ -17153,6 +17231,16 @@ func (ec *executionContext) marshalNCategory2ᚖentgoᚗioᚋcontribᚋentgqlᚋ return ec._Category(ctx, sel, v) } +func (ec *executionContext) marshalNCategoryConfig2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx context.Context, sel ast.SelectionSet, v *schematype.CategoryConfig) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._CategoryConfig(ctx, sel, v) +} + func (ec *executionContext) unmarshalNCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx context.Context, v any) (*schematype.CategoryConfig, error) { res, err := ec.unmarshalInputCategoryConfigInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) @@ -17203,6 +17291,16 @@ func (ec *executionContext) marshalNCategoryStatus2entgoᚗioᚋcontribᚋentgql return v } +func (ec *executionContext) marshalNCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryTypes(ctx context.Context, sel ast.SelectionSet, v *schematype.CategoryTypes) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._CategoryTypes(ctx, sel, v) +} + func (ec *executionContext) unmarshalNCategoryWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐCategoryWhereInput(ctx context.Context, v any) (*ent.CategoryWhereInput, error) { res, err := ec.unmarshalInputCategoryWhereInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) @@ -17237,6 +17335,88 @@ func (ec *executionContext) marshalNCustom2entgoᚗioᚋcontribᚋentgqlᚋinter return ec._Custom(ctx, sel, &v) } +func (ec *executionContext) marshalNCustom2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustomᚄ(ctx context.Context, sel ast.SelectionSet, v []customstruct.Custom) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNCustom2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNCustom2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx context.Context, sel ast.SelectionSet, v []*customstruct.Custom) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalOCustom2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) unmarshalNDuration2timeᚐDuration(ctx context.Context, v any) (time.Duration, error) { res, err := durationgql.UnmarshalDuration(v) return res, graphql.ErrorOnPath(ctx, err) @@ -18007,13 +18187,6 @@ func (ec *executionContext) marshalOCategory2ᚖentgoᚗioᚋcontribᚋentgqlᚋ return ec._Category(ctx, sel, v) } -func (ec *executionContext) marshalOCategoryConfig2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx context.Context, sel ast.SelectionSet, v *schematype.CategoryConfig) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._CategoryConfig(ctx, sel, v) -} - func (ec *executionContext) unmarshalOCategoryConfigInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfigᚄ(ctx context.Context, v any) ([]*schematype.CategoryConfig, error) { if v == nil { return nil, nil @@ -18187,13 +18360,6 @@ func (ec *executionContext) marshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋent return v } -func (ec *executionContext) marshalOCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryTypes(ctx context.Context, sel ast.SelectionSet, v *schematype.CategoryTypes) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._CategoryTypes(ctx, sel, v) -} - func (ec *executionContext) unmarshalOCategoryTypesInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryTypes(ctx context.Context, v any) (*schematype.CategoryTypes, error) { if v == nil { return nil, nil @@ -18262,94 +18428,6 @@ func (ec *executionContext) marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCu return v } -func (ec *executionContext) marshalOCustom2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustomᚄ(ctx context.Context, sel ast.SelectionSet, v []customstruct.Custom) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNCustom2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalOCustom2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx context.Context, sel ast.SelectionSet, v []*customstruct.Custom) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalOCustom2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - return ret -} - func (ec *executionContext) marshalOCustom2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx context.Context, sel ast.SelectionSet, v *customstruct.Custom) graphql.Marshaler { if v == nil { return graphql.Null @@ -18357,16 +18435,6 @@ func (ec *executionContext) marshalOCustom2ᚖentgoᚗioᚋcontribᚋentgqlᚋin return ec._Custom(ctx, sel, v) } -func (ec *executionContext) unmarshalODuration2timeᚐDuration(ctx context.Context, v any) (time.Duration, error) { - res, err := durationgql.UnmarshalDuration(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalODuration2timeᚐDuration(ctx context.Context, sel ast.SelectionSet, v time.Duration) graphql.Marshaler { - res := durationgql.MarshalDuration(v) - return res -} - func (ec *executionContext) unmarshalODuration2ᚕtimeᚐDurationᚄ(ctx context.Context, v any) ([]time.Duration, error) { if v == nil { return nil, nil @@ -18581,16 +18649,6 @@ func (ec *executionContext) unmarshalOGroupWhereInput2ᚖentgoᚗioᚋcontribᚋ return &res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) unmarshalOID2int(ctx context.Context, v any) (int, error) { - res, err := graphql.UnmarshalIntID(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOID2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - res := graphql.MarshalIntID(v) - return res -} - func (ec *executionContext) unmarshalOID2ᚕintᚄ(ctx context.Context, v any) ([]int, error) { if v == nil { return nil, nil @@ -18916,16 +18974,6 @@ func (ec *executionContext) unmarshalOProjectWhereInput2ᚖentgoᚗioᚋcontrib return &res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) unmarshalOString2string(ctx context.Context, v any) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) - return res -} - func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v any) ([]string, error) { if v == nil { return nil, nil @@ -19262,16 +19310,6 @@ func (ec *executionContext) marshalOUUID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID( return res } -func (ec *executionContext) unmarshalOUint642uint64(ctx context.Context, v any) (uint64, error) { - res, err := graphql.UnmarshalUint64(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOUint642uint64(ctx context.Context, sel ast.SelectionSet, v uint64) graphql.Marshaler { - res := graphql.MarshalUint64(v) - return res -} - func (ec *executionContext) unmarshalOUint642ᚕuint64ᚄ(ctx context.Context, v any) ([]uint64, error) { if v == nil { return nil, nil diff --git a/entgql/internal/todoglobalid/ent.graphql b/entgql/internal/todoglobalid/ent.graphql index 8a75944e5..a247be3e6 100644 --- a/entgql/internal/todoglobalid/ent.graphql +++ b/entgql/internal/todoglobalid/ent.graphql @@ -73,11 +73,11 @@ type Category implements Node { id: ID! text: String! status: CategoryStatus! - config: CategoryConfig - types: CategoryTypes - duration: Duration - count: Uint64 - strings: [String!] @deprecated(reason: "use `string` instead") + config: CategoryConfig! + types: CategoryTypes! + duration: Duration! + count: Uint64! + strings: [String!]! @deprecated(reason: "use `string` instead") todos( """ Returns the elements in the list that come after the specified cursor. @@ -534,7 +534,7 @@ interface Node @goModel(model: "entgo.io/contrib/entgql/internal/todoglobalid/en type OneToMany implements Node { id: ID! name: String! - field2: String + field2: String! parent: OneToMany children: [OneToMany!] } @@ -969,12 +969,12 @@ type Todo implements Node { status: TodoStatus! priorityOrder: Int! @goField(name: "Priority", forceResolver: false) text: String! - categoryID: ID - category_id: ID - categoryX: ID @goField(name: "CategoryID", forceResolver: false) - init: Map - custom: [Custom!] - customp: [Custom] + categoryID: ID! + category_id: ID! + categoryX: ID! @goField(name: "CategoryID", forceResolver: false) + init: Map! + custom: [Custom!]! + customp: [Custom]! value: Int! parent: Todo children( @@ -1254,7 +1254,7 @@ type User implements Node { name: String! username: UUID! requiredMetadata: Map! - metadata: Map + metadata: Map! groups( """ Returns the elements in the list that come after the specified cursor. diff --git a/entgql/internal/todoglobalid/generated.go b/entgql/internal/todoglobalid/generated.go index ce0d7a143..f10d17889 100644 --- a/entgql/internal/todoglobalid/generated.go +++ b/entgql/internal/todoglobalid/generated.go @@ -3950,11 +3950,14 @@ func (ec *executionContext) _Category_config(ctx context.Context, field graphql. return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(*schematype.CategoryConfig) fc.Result = res - return ec.marshalOCategoryConfig2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoglobalidᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, field.Selections, res) + return ec.marshalNCategoryConfig2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoglobalidᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Category_config(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -3995,11 +3998,14 @@ func (ec *executionContext) _Category_types(ctx context.Context, field graphql.C return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(*schematype.CategoryTypes) fc.Result = res - return ec.marshalOCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoglobalidᚋentᚋschemaᚋschematypeᚐCategoryTypes(ctx, field.Selections, res) + return ec.marshalNCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoglobalidᚋentᚋschemaᚋschematypeᚐCategoryTypes(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Category_types(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -4040,11 +4046,14 @@ func (ec *executionContext) _Category_duration(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(time.Duration) fc.Result = res - return ec.marshalODuration2timeᚐDuration(ctx, field.Selections, res) + return ec.marshalNDuration2timeᚐDuration(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Category_duration(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -4081,11 +4090,14 @@ func (ec *executionContext) _Category_count(ctx context.Context, field graphql.C return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(uint64) fc.Result = res - return ec.marshalOUint642uint64(ctx, field.Selections, res) + return ec.marshalNUint642uint64(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Category_count(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -4122,11 +4134,14 @@ func (ec *executionContext) _Category_strings(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.([]string) fc.Result = res - return ec.marshalOString2ᚕstringᚄ(ctx, field.Selections, res) + return ec.marshalNString2ᚕstringᚄ(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Category_strings(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -6128,11 +6143,14 @@ func (ec *executionContext) _OneToMany_field2(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(string) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_OneToMany_field2(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -7816,11 +7834,14 @@ func (ec *executionContext) _Todo_categoryID(ctx context.Context, field graphql. return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(int) fc.Result = res - return ec.marshalOID2int(ctx, field.Selections, res) + return ec.marshalNID2int(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_categoryID(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -7857,11 +7878,14 @@ func (ec *executionContext) _Todo_category_id(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(int) fc.Result = res - return ec.marshalOID2int(ctx, field.Selections, res) + return ec.marshalNID2int(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_category_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -7898,11 +7922,14 @@ func (ec *executionContext) _Todo_categoryX(ctx context.Context, field graphql.C return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(int) fc.Result = res - return ec.marshalOID2int(ctx, field.Selections, res) + return ec.marshalNID2int(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_categoryX(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -7939,11 +7966,14 @@ func (ec *executionContext) _Todo_init(ctx context.Context, field graphql.Collec return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(map[string]interface{}) fc.Result = res - return ec.marshalOMap2map(ctx, field.Selections, res) + return ec.marshalNMap2map(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_init(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -7980,11 +8010,14 @@ func (ec *executionContext) _Todo_custom(ctx context.Context, field graphql.Coll return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.([]customstruct.Custom) fc.Result = res - return ec.marshalOCustom2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoglobalidᚋentᚋschemaᚋcustomstructᚐCustomᚄ(ctx, field.Selections, res) + return ec.marshalNCustom2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoglobalidᚋentᚋschemaᚋcustomstructᚐCustomᚄ(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_custom(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -8025,11 +8058,14 @@ func (ec *executionContext) _Todo_customp(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.([]*customstruct.Custom) fc.Result = res - return ec.marshalOCustom2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoglobalidᚋentᚋschemaᚋcustomstructᚐCustom(ctx, field.Selections, res) + return ec.marshalNCustom2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoglobalidᚋentᚋschemaᚋcustomstructᚐCustom(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_customp(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -8798,11 +8834,14 @@ func (ec *executionContext) _User_metadata(ctx context.Context, field graphql.Co return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(map[string]interface{}) fc.Result = res - return ec.marshalOMap2map(ctx, field.Selections, res) + return ec.marshalNMap2map(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_User_metadata(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -14757,14 +14796,29 @@ func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, } case "config": out.Values[i] = ec._Category_config(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "types": out.Values[i] = ec._Category_types(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "duration": out.Values[i] = ec._Category_duration(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "count": out.Values[i] = ec._Category_count(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "strings": out.Values[i] = ec._Category_strings(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "todos": field := field @@ -15571,6 +15625,9 @@ func (ec *executionContext) _OneToMany(ctx context.Context, sel ast.SelectionSet } case "field2": out.Values[i] = ec._OneToMany_field2(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "parent": field := field @@ -16219,16 +16276,34 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj } case "categoryID": out.Values[i] = ec._Todo_categoryID(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "category_id": out.Values[i] = ec._Todo_category_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "categoryX": out.Values[i] = ec._Todo_categoryX(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "init": out.Values[i] = ec._Todo_init(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "custom": out.Values[i] = ec._Todo_custom(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "customp": out.Values[i] = ec._Todo_customp(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "value": out.Values[i] = ec._Todo_value(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -16512,6 +16587,9 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj } case "metadata": out.Values[i] = ec._User_metadata(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "groups": field := field @@ -17153,6 +17231,16 @@ func (ec *executionContext) marshalNCategory2ᚖentgoᚗioᚋcontribᚋentgqlᚋ return ec._Category(ctx, sel, v) } +func (ec *executionContext) marshalNCategoryConfig2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoglobalidᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx context.Context, sel ast.SelectionSet, v *schematype.CategoryConfig) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._CategoryConfig(ctx, sel, v) +} + func (ec *executionContext) unmarshalNCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoglobalidᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx context.Context, v any) (*schematype.CategoryConfig, error) { res, err := ec.unmarshalInputCategoryConfigInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) @@ -17203,6 +17291,16 @@ func (ec *executionContext) marshalNCategoryStatus2entgoᚗioᚋcontribᚋentgql return v } +func (ec *executionContext) marshalNCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoglobalidᚋentᚋschemaᚋschematypeᚐCategoryTypes(ctx context.Context, sel ast.SelectionSet, v *schematype.CategoryTypes) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._CategoryTypes(ctx, sel, v) +} + func (ec *executionContext) unmarshalNCategoryWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoglobalidᚋentᚐCategoryWhereInput(ctx context.Context, v any) (*ent.CategoryWhereInput, error) { res, err := ec.unmarshalInputCategoryWhereInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) @@ -17237,6 +17335,88 @@ func (ec *executionContext) marshalNCustom2entgoᚗioᚋcontribᚋentgqlᚋinter return ec._Custom(ctx, sel, &v) } +func (ec *executionContext) marshalNCustom2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoglobalidᚋentᚋschemaᚋcustomstructᚐCustomᚄ(ctx context.Context, sel ast.SelectionSet, v []customstruct.Custom) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNCustom2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoglobalidᚋentᚋschemaᚋcustomstructᚐCustom(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNCustom2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoglobalidᚋentᚋschemaᚋcustomstructᚐCustom(ctx context.Context, sel ast.SelectionSet, v []*customstruct.Custom) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalOCustom2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoglobalidᚋentᚋschemaᚋcustomstructᚐCustom(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) unmarshalNDuration2timeᚐDuration(ctx context.Context, v any) (time.Duration, error) { res, err := durationgql.UnmarshalDuration(v) return res, graphql.ErrorOnPath(ctx, err) @@ -18007,13 +18187,6 @@ func (ec *executionContext) marshalOCategory2ᚖentgoᚗioᚋcontribᚋentgqlᚋ return ec._Category(ctx, sel, v) } -func (ec *executionContext) marshalOCategoryConfig2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoglobalidᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx context.Context, sel ast.SelectionSet, v *schematype.CategoryConfig) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._CategoryConfig(ctx, sel, v) -} - func (ec *executionContext) unmarshalOCategoryConfigInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoglobalidᚋentᚋschemaᚋschematypeᚐCategoryConfigᚄ(ctx context.Context, v any) ([]*schematype.CategoryConfig, error) { if v == nil { return nil, nil @@ -18187,13 +18360,6 @@ func (ec *executionContext) marshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋent return v } -func (ec *executionContext) marshalOCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoglobalidᚋentᚋschemaᚋschematypeᚐCategoryTypes(ctx context.Context, sel ast.SelectionSet, v *schematype.CategoryTypes) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._CategoryTypes(ctx, sel, v) -} - func (ec *executionContext) unmarshalOCategoryTypesInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoglobalidᚋentᚋschemaᚋschematypeᚐCategoryTypes(ctx context.Context, v any) (*schematype.CategoryTypes, error) { if v == nil { return nil, nil @@ -18262,94 +18428,6 @@ func (ec *executionContext) marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCu return v } -func (ec *executionContext) marshalOCustom2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoglobalidᚋentᚋschemaᚋcustomstructᚐCustomᚄ(ctx context.Context, sel ast.SelectionSet, v []customstruct.Custom) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNCustom2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoglobalidᚋentᚋschemaᚋcustomstructᚐCustom(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalOCustom2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoglobalidᚋentᚋschemaᚋcustomstructᚐCustom(ctx context.Context, sel ast.SelectionSet, v []*customstruct.Custom) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalOCustom2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoglobalidᚋentᚋschemaᚋcustomstructᚐCustom(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - return ret -} - func (ec *executionContext) marshalOCustom2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoglobalidᚋentᚋschemaᚋcustomstructᚐCustom(ctx context.Context, sel ast.SelectionSet, v *customstruct.Custom) graphql.Marshaler { if v == nil { return graphql.Null @@ -18357,16 +18435,6 @@ func (ec *executionContext) marshalOCustom2ᚖentgoᚗioᚋcontribᚋentgqlᚋin return ec._Custom(ctx, sel, v) } -func (ec *executionContext) unmarshalODuration2timeᚐDuration(ctx context.Context, v any) (time.Duration, error) { - res, err := durationgql.UnmarshalDuration(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalODuration2timeᚐDuration(ctx context.Context, sel ast.SelectionSet, v time.Duration) graphql.Marshaler { - res := durationgql.MarshalDuration(v) - return res -} - func (ec *executionContext) unmarshalODuration2ᚕtimeᚐDurationᚄ(ctx context.Context, v any) ([]time.Duration, error) { if v == nil { return nil, nil @@ -18581,16 +18649,6 @@ func (ec *executionContext) unmarshalOGroupWhereInput2ᚖentgoᚗioᚋcontribᚋ return &res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) unmarshalOID2int(ctx context.Context, v any) (int, error) { - res, err := graphql.UnmarshalIntID(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOID2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - res := graphql.MarshalIntID(v) - return res -} - func (ec *executionContext) unmarshalOID2ᚕintᚄ(ctx context.Context, v any) ([]int, error) { if v == nil { return nil, nil @@ -18916,16 +18974,6 @@ func (ec *executionContext) unmarshalOProjectWhereInput2ᚖentgoᚗioᚋcontrib return &res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) unmarshalOString2string(ctx context.Context, v any) (string, error) { - res, err := graphql.UnmarshalString(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) - return res -} - func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v any) ([]string, error) { if v == nil { return nil, nil @@ -19262,16 +19310,6 @@ func (ec *executionContext) marshalOUUID2ᚖgithubᚗcomᚋgoogleᚋuuidᚐUUID( return res } -func (ec *executionContext) unmarshalOUint642uint64(ctx context.Context, v any) (uint64, error) { - res, err := graphql.UnmarshalUint64(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOUint642uint64(ctx context.Context, sel ast.SelectionSet, v uint64) graphql.Marshaler { - res := graphql.MarshalUint64(v) - return res -} - func (ec *executionContext) unmarshalOUint642ᚕuint64ᚄ(ctx context.Context, v any) ([]uint64, error) { if v == nil { return nil, nil diff --git a/entgql/internal/todogotype/generated.go b/entgql/internal/todogotype/generated.go index 7b7091bad..8a421dcf5 100644 --- a/entgql/internal/todogotype/generated.go +++ b/entgql/internal/todogotype/generated.go @@ -1482,11 +1482,11 @@ type Category implements Node { id: ID! text: String! status: CategoryStatus! - config: CategoryConfig - types: CategoryTypes - duration: Duration - count: Uint64 - strings: [String!] @deprecated(reason: "use ` + "`" + `string` + "`" + ` instead") + config: CategoryConfig! + types: CategoryTypes! + duration: Duration! + count: Uint64! + strings: [String!]! @deprecated(reason: "use ` + "`" + `string` + "`" + ` instead") todos( """ Returns the elements in the list that come after the specified cursor. @@ -1943,7 +1943,7 @@ interface Node @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent.Noder" type OneToMany implements Node { id: ID! name: String! - field2: String + field2: String! parent: OneToMany children: [OneToMany!] } @@ -2378,12 +2378,12 @@ type Todo implements Node { status: TodoStatus! priorityOrder: Int! @goField(name: "Priority", forceResolver: false) text: String! - categoryID: ID - category_id: ID - categoryX: ID @goField(name: "CategoryID", forceResolver: false) - init: Map - custom: [Custom!] - customp: [Custom] + categoryID: ID! + category_id: ID! + categoryX: ID! @goField(name: "CategoryID", forceResolver: false) + init: Map! + custom: [Custom!]! + customp: [Custom]! value: Int! parent: Todo children( @@ -2663,7 +2663,7 @@ type User implements Node { name: String! username: UUID! requiredMetadata: Map! - metadata: Map + metadata: Map! groups( """ Returns the elements in the list that come after the specified cursor. @@ -5519,11 +5519,14 @@ func (ec *executionContext) _Category_config(ctx context.Context, field graphql. return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(*schematype.CategoryConfig) fc.Result = res - return ec.marshalOCategoryConfig2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, field.Selections, res) + return ec.marshalNCategoryConfig2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Category_config(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -5564,11 +5567,14 @@ func (ec *executionContext) _Category_types(ctx context.Context, field graphql.C return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(*CategoryTypes) fc.Result = res - return ec.marshalOCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐCategoryTypes(ctx, field.Selections, res) + return ec.marshalNCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐCategoryTypes(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Category_types(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -5609,11 +5615,14 @@ func (ec *executionContext) _Category_duration(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(time.Duration) fc.Result = res - return ec.marshalODuration2timeᚐDuration(ctx, field.Selections, res) + return ec.marshalNDuration2timeᚐDuration(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Category_duration(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -5650,11 +5659,14 @@ func (ec *executionContext) _Category_count(ctx context.Context, field graphql.C return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(uint64) fc.Result = res - return ec.marshalOUint642uint64(ctx, field.Selections, res) + return ec.marshalNUint642uint64(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Category_count(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -5691,11 +5703,14 @@ func (ec *executionContext) _Category_strings(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.([]string) fc.Result = res - return ec.marshalOString2ᚕstringᚄ(ctx, field.Selections, res) + return ec.marshalNString2ᚕstringᚄ(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Category_strings(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -7697,11 +7712,14 @@ func (ec *executionContext) _OneToMany_field2(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_OneToMany_field2(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -9385,11 +9403,14 @@ func (ec *executionContext) _Todo_categoryID(ctx context.Context, field graphql. return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(bigintgql.BigInt) fc.Result = res - return ec.marshalOID2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx, field.Selections, res) + return ec.marshalNID2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_categoryID(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -9426,11 +9447,14 @@ func (ec *executionContext) _Todo_category_id(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(bigintgql.BigInt) fc.Result = res - return ec.marshalOID2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx, field.Selections, res) + return ec.marshalNID2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_category_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -9467,11 +9491,14 @@ func (ec *executionContext) _Todo_categoryX(ctx context.Context, field graphql.C return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(bigintgql.BigInt) fc.Result = res - return ec.marshalOID2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx, field.Selections, res) + return ec.marshalNID2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_categoryX(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -9508,11 +9535,14 @@ func (ec *executionContext) _Todo_init(ctx context.Context, field graphql.Collec return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(map[string]interface{}) fc.Result = res - return ec.marshalOMap2map(ctx, field.Selections, res) + return ec.marshalNMap2map(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_init(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -9549,11 +9579,14 @@ func (ec *executionContext) _Todo_custom(ctx context.Context, field graphql.Coll return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.([]customstruct.Custom) fc.Result = res - return ec.marshalOCustom2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustomᚄ(ctx, field.Selections, res) + return ec.marshalNCustom2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustomᚄ(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_custom(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -9594,11 +9627,14 @@ func (ec *executionContext) _Todo_customp(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.([]*customstruct.Custom) fc.Result = res - return ec.marshalOCustom2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx, field.Selections, res) + return ec.marshalNCustom2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_customp(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -10367,11 +10403,14 @@ func (ec *executionContext) _User_metadata(ctx context.Context, field graphql.Co return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(map[string]any) fc.Result = res - return ec.marshalOMap2map(ctx, field.Selections, res) + return ec.marshalNMap2map(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_User_metadata(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -16362,16 +16401,22 @@ func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, } case "config": out.Values[i] = ec._Category_config(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "types": field := field - innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Category_types(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } return res } @@ -16397,10 +16442,19 @@ func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "duration": out.Values[i] = ec._Category_duration(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "count": out.Values[i] = ec._Category_count(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "strings": out.Values[i] = ec._Category_strings(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "todos": field := field @@ -17207,6 +17261,9 @@ func (ec *executionContext) _OneToMany(ctx context.Context, sel ast.SelectionSet } case "field2": out.Values[i] = ec._OneToMany_field2(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } case "parent": out.Values[i] = ec._OneToMany_parent(ctx, field, obj) case "children": @@ -17824,16 +17881,34 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj } case "categoryID": out.Values[i] = ec._Todo_categoryID(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "category_id": out.Values[i] = ec._Todo_category_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "categoryX": out.Values[i] = ec._Todo_categoryX(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "init": out.Values[i] = ec._Todo_init(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "custom": out.Values[i] = ec._Todo_custom(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "customp": out.Values[i] = ec._Todo_customp(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "value": out.Values[i] = ec._Todo_value(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -18180,13 +18255,16 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj case "metadata": field := field - innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._User_metadata(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } return res } @@ -18851,6 +18929,16 @@ func (ec *executionContext) marshalNCategory2ᚖentgoᚗioᚋcontribᚋentgqlᚋ return ec._Category(ctx, sel, v) } +func (ec *executionContext) marshalNCategoryConfig2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx context.Context, sel ast.SelectionSet, v *schematype.CategoryConfig) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._CategoryConfig(ctx, sel, v) +} + func (ec *executionContext) unmarshalNCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx context.Context, v any) (*schematype.CategoryConfig, error) { res, err := ec.unmarshalInputCategoryConfigInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) @@ -18901,6 +18989,20 @@ func (ec *executionContext) marshalNCategoryStatus2entgoᚗioᚋcontribᚋentgql return v } +func (ec *executionContext) marshalNCategoryTypes2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐCategoryTypes(ctx context.Context, sel ast.SelectionSet, v CategoryTypes) graphql.Marshaler { + return ec._CategoryTypes(ctx, sel, &v) +} + +func (ec *executionContext) marshalNCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐCategoryTypes(ctx context.Context, sel ast.SelectionSet, v *CategoryTypes) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._CategoryTypes(ctx, sel, v) +} + func (ec *executionContext) unmarshalNCategoryWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐCategoryWhereInput(ctx context.Context, v any) (*ent.CategoryWhereInput, error) { res, err := ec.unmarshalInputCategoryWhereInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) @@ -18935,6 +19037,88 @@ func (ec *executionContext) marshalNCustom2entgoᚗioᚋcontribᚋentgqlᚋinter return ec._Custom(ctx, sel, &v) } +func (ec *executionContext) marshalNCustom2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustomᚄ(ctx context.Context, sel ast.SelectionSet, v []customstruct.Custom) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNCustom2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNCustom2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx context.Context, sel ast.SelectionSet, v []*customstruct.Custom) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalOCustom2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) unmarshalNDuration2timeᚐDuration(ctx context.Context, v any) (time.Duration, error) { res, err := durationgql.UnmarshalDuration(v) return res, graphql.ErrorOnPath(ctx, err) @@ -19723,13 +19907,6 @@ func (ec *executionContext) marshalOCategory2ᚖentgoᚗioᚋcontribᚋentgqlᚋ return ec._Category(ctx, sel, v) } -func (ec *executionContext) marshalOCategoryConfig2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx context.Context, sel ast.SelectionSet, v *schematype.CategoryConfig) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._CategoryConfig(ctx, sel, v) -} - func (ec *executionContext) unmarshalOCategoryConfigInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfigᚄ(ctx context.Context, v any) ([]*schematype.CategoryConfig, error) { if v == nil { return nil, nil @@ -19903,13 +20080,6 @@ func (ec *executionContext) marshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋent return v } -func (ec *executionContext) marshalOCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐCategoryTypes(ctx context.Context, sel ast.SelectionSet, v *CategoryTypes) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._CategoryTypes(ctx, sel, v) -} - func (ec *executionContext) unmarshalOCategoryTypesInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐCategoryTypesInput(ctx context.Context, v any) (*CategoryTypesInput, error) { if v == nil { return nil, nil @@ -19978,94 +20148,6 @@ func (ec *executionContext) marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCu return v } -func (ec *executionContext) marshalOCustom2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustomᚄ(ctx context.Context, sel ast.SelectionSet, v []customstruct.Custom) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNCustom2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalOCustom2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx context.Context, sel ast.SelectionSet, v []*customstruct.Custom) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalOCustom2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - return ret -} - func (ec *executionContext) marshalOCustom2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx context.Context, sel ast.SelectionSet, v *customstruct.Custom) graphql.Marshaler { if v == nil { return graphql.Null @@ -20073,16 +20155,6 @@ func (ec *executionContext) marshalOCustom2ᚖentgoᚗioᚋcontribᚋentgqlᚋin return ec._Custom(ctx, sel, v) } -func (ec *executionContext) unmarshalODuration2timeᚐDuration(ctx context.Context, v any) (time.Duration, error) { - res, err := durationgql.UnmarshalDuration(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalODuration2timeᚐDuration(ctx context.Context, sel ast.SelectionSet, v time.Duration) graphql.Marshaler { - res := durationgql.MarshalDuration(v) - return res -} - func (ec *executionContext) unmarshalODuration2ᚕtimeᚐDurationᚄ(ctx context.Context, v any) ([]time.Duration, error) { if v == nil { return nil, nil @@ -20297,16 +20369,6 @@ func (ec *executionContext) unmarshalOGroupWhereInput2ᚖentgoᚗioᚋcontribᚋ return &res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) unmarshalOID2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx context.Context, v any) (bigintgql.BigInt, error) { - var res bigintgql.BigInt - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOID2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigInt(ctx context.Context, sel ast.SelectionSet, v bigintgql.BigInt) graphql.Marshaler { - return v -} - func (ec *executionContext) unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚋschemaᚋbigintgqlᚐBigIntᚄ(ctx context.Context, v any) ([]bigintgql.BigInt, error) { if v == nil { return nil, nil @@ -21020,16 +21082,6 @@ func (ec *executionContext) marshalOUUID2ᚖstring(ctx context.Context, sel ast. return res } -func (ec *executionContext) unmarshalOUint642uint64(ctx context.Context, v any) (uint64, error) { - res, err := graphql.UnmarshalUint64(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOUint642uint64(ctx context.Context, sel ast.SelectionSet, v uint64) graphql.Marshaler { - res := graphql.MarshalUint64(v) - return res -} - func (ec *executionContext) unmarshalOUint642ᚕuint64ᚄ(ctx context.Context, v any) ([]uint64, error) { if v == nil { return nil, nil diff --git a/entgql/internal/todogotype/models_gen.go b/entgql/internal/todogotype/models_gen.go index be74852ee..2e84f4d7b 100644 --- a/entgql/internal/todogotype/models_gen.go +++ b/entgql/internal/todogotype/models_gen.go @@ -39,7 +39,7 @@ type CreateUserInput struct { type OneToMany struct { ID string `json:"id"` Name string `json:"name"` - Field2 *string `json:"field2,omitempty"` + Field2 string `json:"field2"` Parent *OneToMany `json:"parent,omitempty"` Children []*OneToMany `json:"children,omitempty"` } diff --git a/entgql/internal/todopulid/generated.go b/entgql/internal/todopulid/generated.go index 356ba9d63..9ec184e14 100644 --- a/entgql/internal/todopulid/generated.go +++ b/entgql/internal/todopulid/generated.go @@ -1488,11 +1488,11 @@ type Category implements Node { id: ID! text: String! status: CategoryStatus! - config: CategoryConfig - types: CategoryTypes - duration: Duration - count: Uint64 - strings: [String!] @deprecated(reason: "use ` + "`" + `string` + "`" + ` instead") + config: CategoryConfig! + types: CategoryTypes! + duration: Duration! + count: Uint64! + strings: [String!]! @deprecated(reason: "use ` + "`" + `string` + "`" + ` instead") todos( """ Returns the elements in the list that come after the specified cursor. @@ -1949,7 +1949,7 @@ interface Node @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent.Noder" type OneToMany implements Node { id: ID! name: String! - field2: String + field2: String! parent: OneToMany children: [OneToMany!] } @@ -2384,12 +2384,12 @@ type Todo implements Node { status: TodoStatus! priorityOrder: Int! @goField(name: "Priority", forceResolver: false) text: String! - categoryID: ID - category_id: ID - categoryX: ID @goField(name: "CategoryID", forceResolver: false) - init: Map - custom: [Custom!] - customp: [Custom] + categoryID: ID! + category_id: ID! + categoryX: ID! @goField(name: "CategoryID", forceResolver: false) + init: Map! + custom: [Custom!]! + customp: [Custom]! value: Int! parent: Todo children( @@ -2669,7 +2669,7 @@ type User implements Node { name: String! username: UUID! requiredMetadata: Map! - metadata: Map + metadata: Map! groups( """ Returns the elements in the list that come after the specified cursor. @@ -5525,11 +5525,14 @@ func (ec *executionContext) _Category_config(ctx context.Context, field graphql. return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(*schematype.CategoryConfig) fc.Result = res - return ec.marshalOCategoryConfig2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, field.Selections, res) + return ec.marshalNCategoryConfig2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Category_config(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -5570,11 +5573,14 @@ func (ec *executionContext) _Category_types(ctx context.Context, field graphql.C return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(*CategoryTypes) fc.Result = res - return ec.marshalOCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐCategoryTypes(ctx, field.Selections, res) + return ec.marshalNCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐCategoryTypes(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Category_types(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -5615,11 +5621,14 @@ func (ec *executionContext) _Category_duration(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(time.Duration) fc.Result = res - return ec.marshalODuration2timeᚐDuration(ctx, field.Selections, res) + return ec.marshalNDuration2timeᚐDuration(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Category_duration(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -5656,11 +5665,14 @@ func (ec *executionContext) _Category_count(ctx context.Context, field graphql.C return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(uint64) fc.Result = res - return ec.marshalOUint642uint64(ctx, field.Selections, res) + return ec.marshalNUint642uint64(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Category_count(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -5697,11 +5709,14 @@ func (ec *executionContext) _Category_strings(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.([]string) fc.Result = res - return ec.marshalOString2ᚕstringᚄ(ctx, field.Selections, res) + return ec.marshalNString2ᚕstringᚄ(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Category_strings(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -7703,11 +7718,14 @@ func (ec *executionContext) _OneToMany_field2(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_OneToMany_field2(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -9391,11 +9409,14 @@ func (ec *executionContext) _Todo_categoryID(ctx context.Context, field graphql. return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(pulid.ID) fc.Result = res - return ec.marshalOID2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, field.Selections, res) + return ec.marshalNID2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_categoryID(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -9432,11 +9453,14 @@ func (ec *executionContext) _Todo_category_id(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(pulid.ID) fc.Result = res - return ec.marshalOID2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, field.Selections, res) + return ec.marshalNID2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_category_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -9473,11 +9497,14 @@ func (ec *executionContext) _Todo_categoryX(ctx context.Context, field graphql.C return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(pulid.ID) fc.Result = res - return ec.marshalOID2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, field.Selections, res) + return ec.marshalNID2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_categoryX(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -9514,11 +9541,14 @@ func (ec *executionContext) _Todo_init(ctx context.Context, field graphql.Collec return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(map[string]interface{}) fc.Result = res - return ec.marshalOMap2map(ctx, field.Selections, res) + return ec.marshalNMap2map(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_init(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -9555,11 +9585,14 @@ func (ec *executionContext) _Todo_custom(ctx context.Context, field graphql.Coll return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.([]customstruct.Custom) fc.Result = res - return ec.marshalOCustom2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustomᚄ(ctx, field.Selections, res) + return ec.marshalNCustom2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustomᚄ(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_custom(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -9600,11 +9633,14 @@ func (ec *executionContext) _Todo_customp(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.([]*customstruct.Custom) fc.Result = res - return ec.marshalOCustom2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx, field.Selections, res) + return ec.marshalNCustom2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_customp(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -10373,11 +10409,14 @@ func (ec *executionContext) _User_metadata(ctx context.Context, field graphql.Co return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(map[string]interface{}) fc.Result = res - return ec.marshalOMap2map(ctx, field.Selections, res) + return ec.marshalNMap2map(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_User_metadata(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -16372,16 +16411,22 @@ func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, } case "config": out.Values[i] = ec._Category_config(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "types": field := field - innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Category_types(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } return res } @@ -16407,10 +16452,19 @@ func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "duration": out.Values[i] = ec._Category_duration(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "count": out.Values[i] = ec._Category_count(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "strings": out.Values[i] = ec._Category_strings(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "todos": field := field @@ -17217,6 +17271,9 @@ func (ec *executionContext) _OneToMany(ctx context.Context, sel ast.SelectionSet } case "field2": out.Values[i] = ec._OneToMany_field2(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } case "parent": out.Values[i] = ec._OneToMany_parent(ctx, field, obj) case "children": @@ -17834,16 +17891,34 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj } case "categoryID": out.Values[i] = ec._Todo_categoryID(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "category_id": out.Values[i] = ec._Todo_category_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "categoryX": out.Values[i] = ec._Todo_categoryX(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "init": out.Values[i] = ec._Todo_init(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "custom": out.Values[i] = ec._Todo_custom(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "customp": out.Values[i] = ec._Todo_customp(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "value": out.Values[i] = ec._Todo_value(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -18158,6 +18233,9 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj } case "metadata": out.Values[i] = ec._User_metadata(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "groups": field := field @@ -18799,6 +18877,16 @@ func (ec *executionContext) marshalNCategory2ᚖentgoᚗioᚋcontribᚋentgqlᚋ return ec._Category(ctx, sel, v) } +func (ec *executionContext) marshalNCategoryConfig2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx context.Context, sel ast.SelectionSet, v *schematype.CategoryConfig) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._CategoryConfig(ctx, sel, v) +} + func (ec *executionContext) unmarshalNCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx context.Context, v any) (*schematype.CategoryConfig, error) { res, err := ec.unmarshalInputCategoryConfigInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) @@ -18849,6 +18937,20 @@ func (ec *executionContext) marshalNCategoryStatus2entgoᚗioᚋcontribᚋentgql return v } +func (ec *executionContext) marshalNCategoryTypes2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐCategoryTypes(ctx context.Context, sel ast.SelectionSet, v CategoryTypes) graphql.Marshaler { + return ec._CategoryTypes(ctx, sel, &v) +} + +func (ec *executionContext) marshalNCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐCategoryTypes(ctx context.Context, sel ast.SelectionSet, v *CategoryTypes) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._CategoryTypes(ctx, sel, v) +} + func (ec *executionContext) unmarshalNCategoryWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐCategoryWhereInput(ctx context.Context, v any) (*ent.CategoryWhereInput, error) { res, err := ec.unmarshalInputCategoryWhereInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) @@ -18883,6 +18985,88 @@ func (ec *executionContext) marshalNCustom2entgoᚗioᚋcontribᚋentgqlᚋinter return ec._Custom(ctx, sel, &v) } +func (ec *executionContext) marshalNCustom2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustomᚄ(ctx context.Context, sel ast.SelectionSet, v []customstruct.Custom) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNCustom2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNCustom2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx context.Context, sel ast.SelectionSet, v []*customstruct.Custom) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalOCustom2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) unmarshalNDuration2timeᚐDuration(ctx context.Context, v any) (time.Duration, error) { res, err := durationgql.UnmarshalDuration(v) return res, graphql.ErrorOnPath(ctx, err) @@ -19656,13 +19840,6 @@ func (ec *executionContext) marshalOCategory2ᚖentgoᚗioᚋcontribᚋentgqlᚋ return ec._Category(ctx, sel, v) } -func (ec *executionContext) marshalOCategoryConfig2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx context.Context, sel ast.SelectionSet, v *schematype.CategoryConfig) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._CategoryConfig(ctx, sel, v) -} - func (ec *executionContext) unmarshalOCategoryConfigInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfigᚄ(ctx context.Context, v any) ([]*schematype.CategoryConfig, error) { if v == nil { return nil, nil @@ -19836,13 +20013,6 @@ func (ec *executionContext) marshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋent return v } -func (ec *executionContext) marshalOCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐCategoryTypes(ctx context.Context, sel ast.SelectionSet, v *CategoryTypes) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._CategoryTypes(ctx, sel, v) -} - func (ec *executionContext) unmarshalOCategoryTypesInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐCategoryTypesInput(ctx context.Context, v any) (*CategoryTypesInput, error) { if v == nil { return nil, nil @@ -19911,94 +20081,6 @@ func (ec *executionContext) marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCu return v } -func (ec *executionContext) marshalOCustom2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustomᚄ(ctx context.Context, sel ast.SelectionSet, v []customstruct.Custom) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNCustom2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalOCustom2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx context.Context, sel ast.SelectionSet, v []*customstruct.Custom) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalOCustom2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - return ret -} - func (ec *executionContext) marshalOCustom2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx context.Context, sel ast.SelectionSet, v *customstruct.Custom) graphql.Marshaler { if v == nil { return graphql.Null @@ -20006,16 +20088,6 @@ func (ec *executionContext) marshalOCustom2ᚖentgoᚗioᚋcontribᚋentgqlᚋin return ec._Custom(ctx, sel, v) } -func (ec *executionContext) unmarshalODuration2timeᚐDuration(ctx context.Context, v any) (time.Duration, error) { - res, err := durationgql.UnmarshalDuration(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalODuration2timeᚐDuration(ctx context.Context, sel ast.SelectionSet, v time.Duration) graphql.Marshaler { - res := durationgql.MarshalDuration(v) - return res -} - func (ec *executionContext) unmarshalODuration2ᚕtimeᚐDurationᚄ(ctx context.Context, v any) ([]time.Duration, error) { if v == nil { return nil, nil @@ -20230,16 +20302,6 @@ func (ec *executionContext) unmarshalOGroupWhereInput2ᚖentgoᚗioᚋcontribᚋ return &res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) unmarshalOID2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx context.Context, v any) (pulid.ID, error) { - var res pulid.ID - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOID2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐID(ctx context.Context, sel ast.SelectionSet, v pulid.ID) graphql.Marshaler { - return v -} - func (ec *executionContext) unmarshalOID2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚋschemaᚋpulidᚐIDᚄ(ctx context.Context, v any) ([]pulid.ID, error) { if v == nil { return nil, nil @@ -20901,16 +20963,6 @@ func (ec *executionContext) marshalOUUID2ᚖstring(ctx context.Context, sel ast. return res } -func (ec *executionContext) unmarshalOUint642uint64(ctx context.Context, v any) (uint64, error) { - res, err := graphql.UnmarshalUint64(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOUint642uint64(ctx context.Context, sel ast.SelectionSet, v uint64) graphql.Marshaler { - res := graphql.MarshalUint64(v) - return res -} - func (ec *executionContext) unmarshalOUint642ᚕuint64ᚄ(ctx context.Context, v any) ([]uint64, error) { if v == nil { return nil, nil diff --git a/entgql/internal/todopulid/models_gen.go b/entgql/internal/todopulid/models_gen.go index de0adce27..90199e655 100644 --- a/entgql/internal/todopulid/models_gen.go +++ b/entgql/internal/todopulid/models_gen.go @@ -28,7 +28,7 @@ type CategoryTypesInput struct { type OneToMany struct { ID pulid.ID `json:"id"` Name string `json:"name"` - Field2 *string `json:"field2,omitempty"` + Field2 string `json:"field2"` Parent *OneToMany `json:"parent,omitempty"` Children []*OneToMany `json:"children,omitempty"` } diff --git a/entgql/internal/todouuid/generated.go b/entgql/internal/todouuid/generated.go index 8ebf13494..a1c43cd0f 100644 --- a/entgql/internal/todouuid/generated.go +++ b/entgql/internal/todouuid/generated.go @@ -1489,11 +1489,11 @@ type Category implements Node { id: ID! text: String! status: CategoryStatus! - config: CategoryConfig - types: CategoryTypes - duration: Duration - count: Uint64 - strings: [String!] @deprecated(reason: "use ` + "`" + `string` + "`" + ` instead") + config: CategoryConfig! + types: CategoryTypes! + duration: Duration! + count: Uint64! + strings: [String!]! @deprecated(reason: "use ` + "`" + `string` + "`" + ` instead") todos( """ Returns the elements in the list that come after the specified cursor. @@ -1950,7 +1950,7 @@ interface Node @goModel(model: "entgo.io/contrib/entgql/internal/todo/ent.Noder" type OneToMany implements Node { id: ID! name: String! - field2: String + field2: String! parent: OneToMany children: [OneToMany!] } @@ -2385,12 +2385,12 @@ type Todo implements Node { status: TodoStatus! priorityOrder: Int! @goField(name: "Priority", forceResolver: false) text: String! - categoryID: ID - category_id: ID - categoryX: ID @goField(name: "CategoryID", forceResolver: false) - init: Map - custom: [Custom!] - customp: [Custom] + categoryID: ID! + category_id: ID! + categoryX: ID! @goField(name: "CategoryID", forceResolver: false) + init: Map! + custom: [Custom!]! + customp: [Custom]! value: Int! parent: Todo children( @@ -2670,7 +2670,7 @@ type User implements Node { name: String! username: UUID! requiredMetadata: Map! - metadata: Map + metadata: Map! groups( """ Returns the elements in the list that come after the specified cursor. @@ -5526,11 +5526,14 @@ func (ec *executionContext) _Category_config(ctx context.Context, field graphql. return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(*schematype.CategoryConfig) fc.Result = res - return ec.marshalOCategoryConfig2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, field.Selections, res) + return ec.marshalNCategoryConfig2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Category_config(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -5571,11 +5574,14 @@ func (ec *executionContext) _Category_types(ctx context.Context, field graphql.C return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(*CategoryTypes) fc.Result = res - return ec.marshalOCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐCategoryTypes(ctx, field.Selections, res) + return ec.marshalNCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐCategoryTypes(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Category_types(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -5616,11 +5622,14 @@ func (ec *executionContext) _Category_duration(ctx context.Context, field graphq return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(time.Duration) fc.Result = res - return ec.marshalODuration2timeᚐDuration(ctx, field.Selections, res) + return ec.marshalNDuration2timeᚐDuration(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Category_duration(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -5657,11 +5666,14 @@ func (ec *executionContext) _Category_count(ctx context.Context, field graphql.C return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(uint64) fc.Result = res - return ec.marshalOUint642uint64(ctx, field.Selections, res) + return ec.marshalNUint642uint64(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Category_count(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -5698,11 +5710,14 @@ func (ec *executionContext) _Category_strings(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.([]string) fc.Result = res - return ec.marshalOString2ᚕstringᚄ(ctx, field.Selections, res) + return ec.marshalNString2ᚕstringᚄ(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Category_strings(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -7704,11 +7719,14 @@ func (ec *executionContext) _OneToMany_field2(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*string) + res := resTmp.(string) fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_OneToMany_field2(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -9392,11 +9410,14 @@ func (ec *executionContext) _Todo_categoryID(ctx context.Context, field graphql. return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(uuid.UUID) fc.Result = res - return ec.marshalOID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, field.Selections, res) + return ec.marshalNID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_categoryID(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -9433,11 +9454,14 @@ func (ec *executionContext) _Todo_category_id(ctx context.Context, field graphql return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(uuid.UUID) fc.Result = res - return ec.marshalOID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, field.Selections, res) + return ec.marshalNID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_category_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -9474,11 +9498,14 @@ func (ec *executionContext) _Todo_categoryX(ctx context.Context, field graphql.C return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(uuid.UUID) fc.Result = res - return ec.marshalOID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, field.Selections, res) + return ec.marshalNID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_categoryX(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -9515,11 +9542,14 @@ func (ec *executionContext) _Todo_init(ctx context.Context, field graphql.Collec return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(map[string]interface{}) fc.Result = res - return ec.marshalOMap2map(ctx, field.Selections, res) + return ec.marshalNMap2map(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_init(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -9556,11 +9586,14 @@ func (ec *executionContext) _Todo_custom(ctx context.Context, field graphql.Coll return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.([]customstruct.Custom) fc.Result = res - return ec.marshalOCustom2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustomᚄ(ctx, field.Selections, res) + return ec.marshalNCustom2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustomᚄ(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_custom(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -9601,11 +9634,14 @@ func (ec *executionContext) _Todo_customp(ctx context.Context, field graphql.Col return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.([]*customstruct.Custom) fc.Result = res - return ec.marshalOCustom2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx, field.Selections, res) + return ec.marshalNCustom2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_customp(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -10374,11 +10410,14 @@ func (ec *executionContext) _User_metadata(ctx context.Context, field graphql.Co return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(map[string]interface{}) fc.Result = res - return ec.marshalOMap2map(ctx, field.Selections, res) + return ec.marshalNMap2map(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_User_metadata(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -16373,16 +16412,22 @@ func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, } case "config": out.Values[i] = ec._Category_config(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "types": field := field - innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Category_types(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } return res } @@ -16408,10 +16453,19 @@ func (ec *executionContext) _Category(ctx context.Context, sel ast.SelectionSet, out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "duration": out.Values[i] = ec._Category_duration(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "count": out.Values[i] = ec._Category_count(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "strings": out.Values[i] = ec._Category_strings(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "todos": field := field @@ -17218,6 +17272,9 @@ func (ec *executionContext) _OneToMany(ctx context.Context, sel ast.SelectionSet } case "field2": out.Values[i] = ec._OneToMany_field2(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } case "parent": out.Values[i] = ec._OneToMany_parent(ctx, field, obj) case "children": @@ -17835,16 +17892,34 @@ func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj } case "categoryID": out.Values[i] = ec._Todo_categoryID(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "category_id": out.Values[i] = ec._Todo_category_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "categoryX": out.Values[i] = ec._Todo_categoryX(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "init": out.Values[i] = ec._Todo_init(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "custom": out.Values[i] = ec._Todo_custom(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "customp": out.Values[i] = ec._Todo_customp(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "value": out.Values[i] = ec._Todo_value(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -18159,6 +18234,9 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj } case "metadata": out.Values[i] = ec._User_metadata(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "groups": field := field @@ -18800,6 +18878,16 @@ func (ec *executionContext) marshalNCategory2ᚖentgoᚗioᚋcontribᚋentgqlᚋ return ec._Category(ctx, sel, v) } +func (ec *executionContext) marshalNCategoryConfig2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx context.Context, sel ast.SelectionSet, v *schematype.CategoryConfig) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._CategoryConfig(ctx, sel, v) +} + func (ec *executionContext) unmarshalNCategoryConfigInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx context.Context, v any) (*schematype.CategoryConfig, error) { res, err := ec.unmarshalInputCategoryConfigInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) @@ -18850,6 +18938,20 @@ func (ec *executionContext) marshalNCategoryStatus2entgoᚗioᚋcontribᚋentgql return v } +func (ec *executionContext) marshalNCategoryTypes2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐCategoryTypes(ctx context.Context, sel ast.SelectionSet, v CategoryTypes) graphql.Marshaler { + return ec._CategoryTypes(ctx, sel, &v) +} + +func (ec *executionContext) marshalNCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐCategoryTypes(ctx context.Context, sel ast.SelectionSet, v *CategoryTypes) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._CategoryTypes(ctx, sel, v) +} + func (ec *executionContext) unmarshalNCategoryWhereInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐCategoryWhereInput(ctx context.Context, v any) (*ent.CategoryWhereInput, error) { res, err := ec.unmarshalInputCategoryWhereInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) @@ -18884,6 +18986,88 @@ func (ec *executionContext) marshalNCustom2entgoᚗioᚋcontribᚋentgqlᚋinter return ec._Custom(ctx, sel, &v) } +func (ec *executionContext) marshalNCustom2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustomᚄ(ctx context.Context, sel ast.SelectionSet, v []customstruct.Custom) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNCustom2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNCustom2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx context.Context, sel ast.SelectionSet, v []*customstruct.Custom) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalOCustom2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) unmarshalNDuration2timeᚐDuration(ctx context.Context, v any) (time.Duration, error) { res, err := durationgql.UnmarshalDuration(v) return res, graphql.ErrorOnPath(ctx, err) @@ -19662,13 +19846,6 @@ func (ec *executionContext) marshalOCategory2ᚖentgoᚗioᚋcontribᚋentgqlᚋ return ec._Category(ctx, sel, v) } -func (ec *executionContext) marshalOCategoryConfig2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfig(ctx context.Context, sel ast.SelectionSet, v *schematype.CategoryConfig) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._CategoryConfig(ctx, sel, v) -} - func (ec *executionContext) unmarshalOCategoryConfigInput2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋschematypeᚐCategoryConfigᚄ(ctx context.Context, v any) ([]*schematype.CategoryConfig, error) { if v == nil { return nil, nil @@ -19842,13 +20019,6 @@ func (ec *executionContext) marshalOCategoryStatus2ᚖentgoᚗioᚋcontribᚋent return v } -func (ec *executionContext) marshalOCategoryTypes2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐCategoryTypes(ctx context.Context, sel ast.SelectionSet, v *CategoryTypes) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._CategoryTypes(ctx, sel, v) -} - func (ec *executionContext) unmarshalOCategoryTypesInput2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐCategoryTypesInput(ctx context.Context, v any) (*CategoryTypesInput, error) { if v == nil { return nil, nil @@ -19917,94 +20087,6 @@ func (ec *executionContext) marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCu return v } -func (ec *executionContext) marshalOCustom2ᚕentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustomᚄ(ctx context.Context, sel ast.SelectionSet, v []customstruct.Custom) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNCustom2entgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalOCustom2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx context.Context, sel ast.SelectionSet, v []*customstruct.Custom) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalOCustom2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - return ret -} - func (ec *executionContext) marshalOCustom2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚋschemaᚋcustomstructᚐCustom(ctx context.Context, sel ast.SelectionSet, v *customstruct.Custom) graphql.Marshaler { if v == nil { return graphql.Null @@ -20012,16 +20094,6 @@ func (ec *executionContext) marshalOCustom2ᚖentgoᚗioᚋcontribᚋentgqlᚋin return ec._Custom(ctx, sel, v) } -func (ec *executionContext) unmarshalODuration2timeᚐDuration(ctx context.Context, v any) (time.Duration, error) { - res, err := durationgql.UnmarshalDuration(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalODuration2timeᚐDuration(ctx context.Context, sel ast.SelectionSet, v time.Duration) graphql.Marshaler { - res := durationgql.MarshalDuration(v) - return res -} - func (ec *executionContext) unmarshalODuration2ᚕtimeᚐDurationᚄ(ctx context.Context, v any) ([]time.Duration, error) { if v == nil { return nil, nil @@ -20236,16 +20308,6 @@ func (ec *executionContext) unmarshalOGroupWhereInput2ᚖentgoᚗioᚋcontribᚋ return &res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) unmarshalOID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx context.Context, v any) (uuid.UUID, error) { - res, err := uuidgql.UnmarshalUUID(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx context.Context, sel ast.SelectionSet, v uuid.UUID) graphql.Marshaler { - res := uuidgql.MarshalUUID(v) - return res -} - func (ec *executionContext) unmarshalOID2ᚕgithubᚗcomᚋgoogleᚋuuidᚐUUIDᚄ(ctx context.Context, v any) ([]uuid.UUID, error) { if v == nil { return nil, nil @@ -20907,16 +20969,6 @@ func (ec *executionContext) marshalOUUID2ᚖstring(ctx context.Context, sel ast. return res } -func (ec *executionContext) unmarshalOUint642uint64(ctx context.Context, v any) (uint64, error) { - res, err := graphql.UnmarshalUint64(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOUint642uint64(ctx context.Context, sel ast.SelectionSet, v uint64) graphql.Marshaler { - res := graphql.MarshalUint64(v) - return res -} - func (ec *executionContext) unmarshalOUint642ᚕuint64ᚄ(ctx context.Context, v any) ([]uint64, error) { if v == nil { return nil, nil diff --git a/entgql/internal/todouuid/models_gen.go b/entgql/internal/todouuid/models_gen.go index f368391f0..741956607 100644 --- a/entgql/internal/todouuid/models_gen.go +++ b/entgql/internal/todouuid/models_gen.go @@ -28,7 +28,7 @@ type CategoryTypesInput struct { type OneToMany struct { ID uuid.UUID `json:"id"` Name string `json:"name"` - Field2 *string `json:"field2,omitempty"` + Field2 string `json:"field2"` Parent *OneToMany `json:"parent,omitempty"` Children []*OneToMany `json:"children,omitempty"` } diff --git a/entgql/schema.go b/entgql/schema.go index ddf08a8a4..8addf19f6 100644 --- a/entgql/schema.go +++ b/entgql/schema.go @@ -714,7 +714,7 @@ func (e *schemaGenerator) fieldDefinitionOp(gqlType string, f *gen.Field, ant *A func (e *schemaGenerator) typeFromField(gqlType string, f *gen.Field, ant *Annotation) (*ast.Type, error) { if scalar := e.mapScalar(gqlType, f, ant, nonInputObjectFilter); scalar != "" { - return namedType(scalar, f.Optional), nil + return namedType(scalar, f.Nillable), nil } switch t := f.Type.Type; { diff --git a/entgql/testdata/schema.graphql b/entgql/testdata/schema.graphql index 289e579b3..3a7082750 100644 --- a/entgql/testdata/schema.graphql +++ b/entgql/testdata/schema.graphql @@ -8,11 +8,11 @@ type Category { id: ID! text: String! status: CategoryStatus! - config: CategoryConfig - types: CategoryTypes - duration: Duration - count: Uint64 - strings: [String!] + config: CategoryConfig! + types: CategoryTypes! + duration: Duration! + count: Uint64! + strings: [String!]! todos: [Todo!] subCategories: [Category!] } @@ -110,7 +110,7 @@ scalar Map type OneToMany { id: ID! name: String! - field2: String + field2: String! parent: OneToMany children: [OneToMany!] } @@ -162,12 +162,12 @@ type Todo { status: TodoStatus! priorityOrder: Int! @goField(name: "Priority", forceResolver: false) text: String! - categoryID: ID - category_id: ID - categoryX: ID @goField(name: "CategoryID", forceResolver: false) - init: Map - custom: [Custom!] - customp: [Custom] + categoryID: ID! + category_id: ID! + categoryX: ID! @goField(name: "CategoryID", forceResolver: false) + init: Map! + custom: [Custom!]! + customp: [Custom]! value: Int! parent: Todo children: [Todo!] @@ -287,7 +287,7 @@ type User { name: String! username: UUID! requiredMetadata: Map! - metadata: Map + metadata: Map! """ The groups of the user """ diff --git a/entgql/testdata/schema_output.graphql b/entgql/testdata/schema_output.graphql index 289e579b3..3a7082750 100644 --- a/entgql/testdata/schema_output.graphql +++ b/entgql/testdata/schema_output.graphql @@ -8,11 +8,11 @@ type Category { id: ID! text: String! status: CategoryStatus! - config: CategoryConfig - types: CategoryTypes - duration: Duration - count: Uint64 - strings: [String!] + config: CategoryConfig! + types: CategoryTypes! + duration: Duration! + count: Uint64! + strings: [String!]! todos: [Todo!] subCategories: [Category!] } @@ -110,7 +110,7 @@ scalar Map type OneToMany { id: ID! name: String! - field2: String + field2: String! parent: OneToMany children: [OneToMany!] } @@ -162,12 +162,12 @@ type Todo { status: TodoStatus! priorityOrder: Int! @goField(name: "Priority", forceResolver: false) text: String! - categoryID: ID - category_id: ID - categoryX: ID @goField(name: "CategoryID", forceResolver: false) - init: Map - custom: [Custom!] - customp: [Custom] + categoryID: ID! + category_id: ID! + categoryX: ID! @goField(name: "CategoryID", forceResolver: false) + init: Map! + custom: [Custom!]! + customp: [Custom]! value: Int! parent: Todo children: [Todo!] @@ -287,7 +287,7 @@ type User { name: String! username: UUID! requiredMetadata: Map! - metadata: Map + metadata: Map! """ The groups of the user """ diff --git a/entgql/testdata/schema_relay.graphql b/entgql/testdata/schema_relay.graphql index 8f0d69b91..22739078b 100644 --- a/entgql/testdata/schema_relay.graphql +++ b/entgql/testdata/schema_relay.graphql @@ -71,11 +71,11 @@ type Category implements Node { id: ID! text: String! status: CategoryStatus! - config: CategoryConfig - types: CategoryTypes - duration: Duration - count: Uint64 - strings: [String!] + config: CategoryConfig! + types: CategoryTypes! + duration: Duration! + count: Uint64! + strings: [String!]! todos( """ Returns the elements in the list that come after the specified cursor. @@ -517,7 +517,7 @@ scalar Map type OneToMany implements Node { id: ID! name: String! - field2: String + field2: String! parent: OneToMany children: [OneToMany!] } @@ -917,12 +917,12 @@ type Todo implements Node { status: TodoStatus! priorityOrder: Int! @goField(name: "Priority", forceResolver: false) text: String! - categoryID: ID - category_id: ID - categoryX: ID @goField(name: "CategoryID", forceResolver: false) - init: Map - custom: [Custom!] - customp: [Custom] + categoryID: ID! + category_id: ID! + categoryX: ID! @goField(name: "CategoryID", forceResolver: false) + init: Map! + custom: [Custom!]! + customp: [Custom]! value: Int! parent: Todo children( @@ -1202,7 +1202,7 @@ type User implements Node { name: String! username: UUID! requiredMetadata: Map! - metadata: Map + metadata: Map! groups( """ Returns the elements in the list that come after the specified cursor. diff --git a/entgql/testdata/schema_relay_output.graphql b/entgql/testdata/schema_relay_output.graphql index 8f0d69b91..22739078b 100644 --- a/entgql/testdata/schema_relay_output.graphql +++ b/entgql/testdata/schema_relay_output.graphql @@ -71,11 +71,11 @@ type Category implements Node { id: ID! text: String! status: CategoryStatus! - config: CategoryConfig - types: CategoryTypes - duration: Duration - count: Uint64 - strings: [String!] + config: CategoryConfig! + types: CategoryTypes! + duration: Duration! + count: Uint64! + strings: [String!]! todos( """ Returns the elements in the list that come after the specified cursor. @@ -517,7 +517,7 @@ scalar Map type OneToMany implements Node { id: ID! name: String! - field2: String + field2: String! parent: OneToMany children: [OneToMany!] } @@ -917,12 +917,12 @@ type Todo implements Node { status: TodoStatus! priorityOrder: Int! @goField(name: "Priority", forceResolver: false) text: String! - categoryID: ID - category_id: ID - categoryX: ID @goField(name: "CategoryID", forceResolver: false) - init: Map - custom: [Custom!] - customp: [Custom] + categoryID: ID! + category_id: ID! + categoryX: ID! @goField(name: "CategoryID", forceResolver: false) + init: Map! + custom: [Custom!]! + customp: [Custom]! value: Int! parent: Todo children( @@ -1202,7 +1202,7 @@ type User implements Node { name: String! username: UUID! requiredMetadata: Map! - metadata: Map + metadata: Map! groups( """ Returns the elements in the list that come after the specified cursor.