From 2380f4843ef6c2b570732f640e431cfae6fab93b Mon Sep 17 00:00:00 2001 From: eiixy <990656271@qq.com> Date: Thu, 10 Oct 2024 15:21:04 +0800 Subject: [PATCH 1/3] add nodes to connection --- entgql/template/pagination.tmpl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/entgql/template/pagination.tmpl b/entgql/template/pagination.tmpl index 5a9869199..fc36a2257 100644 --- a/entgql/template/pagination.tmpl +++ b/entgql/template/pagination.tmpl @@ -138,6 +138,7 @@ type {{ $edge }} struct { // {{ $conn }} is the connection containing edges to {{ $name }}. type {{ $conn }} struct { Edges []*{{ $edge }} `json:"edges"` + Nodes []*{{ $name }} `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -167,6 +168,7 @@ func (c *{{ $conn }}) build(nodes []*{{ $name }}, pager *{{ $pager }}, after *Cu } } c.Edges = make([]*{{ $edge }}, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &{{ $edge }}{ From 43ddc7bcf82dec7395376bf3bcb7f925ee2c9f88 Mon Sep 17 00:00:00 2001 From: eiixy <990656271@qq.com> Date: Thu, 10 Oct 2024 16:57:50 +0800 Subject: [PATCH 2/3] add nodes field --- entgql/template.go | 5 +++++ entgql/template/pagination.tmpl | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/entgql/template.go b/entgql/template.go index 69f20dc3d..adae5e5cb 100644 --- a/entgql/template.go +++ b/entgql/template.go @@ -593,6 +593,11 @@ func (p *PaginationNames) TypeDefs() []*ast.Definition { Type: ast.ListType(ast.NamedType(p.Edge, nil), nil), Description: "A list of edges.", }, + { + Name: "nodes", + Type: ast.ListType(ast.NamedType(p.Node, nil), nil), + Description: "A list of nodes.", + }, { Name: "pageInfo", Type: ast.NonNullNamedType(RelayPageInfo, nil), diff --git a/entgql/template/pagination.tmpl b/entgql/template/pagination.tmpl index fc36a2257..3b63d776a 100644 --- a/entgql/template/pagination.tmpl +++ b/entgql/template/pagination.tmpl @@ -101,7 +101,7 @@ func hasCollectedField(ctx context.Context, path ...string) bool { } const ( - {{- range $field := list "edges" "node" "pageInfo" "totalCount" }} + {{- range $field := list "edges" "nodes" "node" "pageInfo" "totalCount" }} {{ $field }}Field = "{{ $field }}" {{- end }} ) @@ -630,7 +630,7 @@ func ({{ $r }} *{{ $name }}) ToEdge(order *{{ $order }}) *{{ $edge }} { } {{- /* Ensure the "edges" field is marshaled as "[]" in case it is empty. */}} conn := &{{ $conn }}{Edges: []*{{ $edge }}{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -660,6 +660,11 @@ func ({{ $r }} *{{ $name }}) ToEdge(order *{{ $order }}) *{{ $edge }} { return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := {{ $r }}.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } {{ $r }} = pager.applyOrder({{ $r }}) nodes, err := {{ $r }}.All(ctx) if err != nil { From dafc53d7e1a3cf207d8991da62fb1658bcd71844 Mon Sep 17 00:00:00 2001 From: eiixy <990656271@qq.com> Date: Thu, 10 Oct 2024 17:16:01 +0800 Subject: [PATCH 3/3] update entgql generate code --- entgql/internal/todo/ent.graphql | 24 + entgql/internal/todo/ent/gql_pagination.go | 82 +- entgql/internal/todo/generated.go | 714 ++++++++++++++++- entgql/internal/todofed/ent/gql_pagination.go | 19 +- .../internal/todogotype/ent/gql_pagination.go | 64 +- entgql/internal/todogotype/generated.go | 738 +++++++++++++++++- entgql/internal/todogotype/models_gen.go | 2 + .../internal/todopulid/ent/gql_pagination.go | 55 +- entgql/internal/todopulid/generated.go | 738 +++++++++++++++++- entgql/internal/todopulid/models_gen.go | 2 + .../internal/todouuid/ent/gql_pagination.go | 55 +- entgql/internal/todouuid/generated.go | 738 +++++++++++++++++- entgql/internal/todouuid/models_gen.go | 2 + 13 files changed, 3199 insertions(+), 34 deletions(-) diff --git a/entgql/internal/todo/ent.graphql b/entgql/internal/todo/ent.graphql index c1d5b1595..084560c77 100644 --- a/entgql/internal/todo/ent.graphql +++ b/entgql/internal/todo/ent.graphql @@ -150,6 +150,10 @@ type CategoryConnection { """ edges: [CategoryEdge] """ + A list of nodes. + """ + nodes: [Category] + """ Information to aid in pagination. """ pageInfo: PageInfo! @@ -358,6 +362,10 @@ type FriendshipConnection { """ edges: [FriendshipEdge] """ + A list of nodes. + """ + nodes: [Friendship] + """ Information to aid in pagination. """ pageInfo: PageInfo! @@ -454,6 +462,10 @@ type GroupConnection { """ edges: [GroupEdge] """ + A list of nodes. + """ + nodes: [Group] + """ Information to aid in pagination. """ pageInfo: PageInfo! @@ -546,6 +558,10 @@ type OneToManyConnection { """ edges: [OneToManyEdge] """ + A list of nodes. + """ + nodes: [OneToMany] + """ Information to aid in pagination. """ pageInfo: PageInfo! @@ -1017,6 +1033,10 @@ type TodoConnection { """ edges: [TodoEdge] """ + A list of nodes. + """ + nodes: [Todo] + """ Information to aid in pagination. """ pageInfo: PageInfo! @@ -1334,6 +1354,10 @@ type UserConnection { """ edges: [UserEdge] """ + A list of nodes. + """ + nodes: [User] + """ Information to aid in pagination. """ pageInfo: PageInfo! diff --git a/entgql/internal/todo/ent/gql_pagination.go b/entgql/internal/todo/ent/gql_pagination.go index 8a950a382..e145c60ba 100644 --- a/entgql/internal/todo/ent/gql_pagination.go +++ b/entgql/internal/todo/ent/gql_pagination.go @@ -105,6 +105,7 @@ func hasCollectedField(ctx context.Context, path ...string) bool { const ( edgesField = "edges" + nodesField = "nodes" nodeField = "node" pageInfoField = "pageInfo" totalCountField = "totalCount" @@ -129,6 +130,7 @@ type BillProductEdge struct { // BillProductConnection is the connection containing edges to BillProduct. type BillProductConnection struct { Edges []*BillProductEdge `json:"edges"` + Nodes []*BillProduct `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -155,6 +157,7 @@ func (c *BillProductConnection) build(nodes []*BillProduct, pager *billproductPa } } c.Edges = make([]*BillProductEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &BillProductEdge{ @@ -291,7 +294,7 @@ func (bp *BillProductQuery) Paginate( return nil, err } conn := &BillProductConnection{Edges: []*BillProductEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -319,6 +322,11 @@ func (bp *BillProductQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := bp.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } bp = pager.applyOrder(bp) nodes, err := bp.All(ctx) if err != nil { @@ -378,6 +386,7 @@ type CategoryEdge struct { // CategoryConnection is the connection containing edges to Category. type CategoryConnection struct { Edges []*CategoryEdge `json:"edges"` + Nodes []*Category `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -404,6 +413,7 @@ func (c *CategoryConnection) build(nodes []*Category, pager *categoryPager, afte } } c.Edges = make([]*CategoryEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &CategoryEdge{ @@ -589,7 +599,7 @@ func (c *CategoryQuery) Paginate( return nil, err } conn := &CategoryConnection{Edges: []*CategoryEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -617,6 +627,11 @@ func (c *CategoryQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := c.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } c = pager.applyOrder(c) nodes, err := c.All(ctx) if err != nil { @@ -818,6 +833,7 @@ type FriendshipEdge struct { // FriendshipConnection is the connection containing edges to Friendship. type FriendshipConnection struct { Edges []*FriendshipEdge `json:"edges"` + Nodes []*Friendship `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -844,6 +860,7 @@ func (c *FriendshipConnection) build(nodes []*Friendship, pager *friendshipPager } } c.Edges = make([]*FriendshipEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &FriendshipEdge{ @@ -980,7 +997,7 @@ func (f *FriendshipQuery) Paginate( return nil, err } conn := &FriendshipConnection{Edges: []*FriendshipEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -1008,6 +1025,11 @@ func (f *FriendshipQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := f.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } f = pager.applyOrder(f) nodes, err := f.All(ctx) if err != nil { @@ -1067,6 +1089,7 @@ type GroupEdge struct { // GroupConnection is the connection containing edges to Group. type GroupConnection struct { Edges []*GroupEdge `json:"edges"` + Nodes []*Group `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -1093,6 +1116,7 @@ func (c *GroupConnection) build(nodes []*Group, pager *groupPager, after *Cursor } } c.Edges = make([]*GroupEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &GroupEdge{ @@ -1265,7 +1289,7 @@ func (gr *GroupQuery) Paginate( return nil, err } conn := &GroupConnection{Edges: []*GroupEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -1293,6 +1317,11 @@ func (gr *GroupQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := gr.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } gr = pager.applyOrder(gr) nodes, err := gr.All(ctx) if err != nil { @@ -1352,6 +1381,7 @@ type OneToManyEdge struct { // OneToManyConnection is the connection containing edges to OneToMany. type OneToManyConnection struct { Edges []*OneToManyEdge `json:"edges"` + Nodes []*OneToMany `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -1378,6 +1408,7 @@ func (c *OneToManyConnection) build(nodes []*OneToMany, pager *onetomanyPager, a } } c.Edges = make([]*OneToManyEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &OneToManyEdge{ @@ -1514,7 +1545,7 @@ func (otm *OneToManyQuery) Paginate( return nil, err } conn := &OneToManyConnection{Edges: []*OneToManyEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -1542,6 +1573,11 @@ func (otm *OneToManyQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := otm.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } otm = pager.applyOrder(otm) nodes, err := otm.All(ctx) if err != nil { @@ -1648,6 +1684,7 @@ type ProjectEdge struct { // ProjectConnection is the connection containing edges to Project. type ProjectConnection struct { Edges []*ProjectEdge `json:"edges"` + Nodes []*Project `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -1674,6 +1711,7 @@ func (c *ProjectConnection) build(nodes []*Project, pager *projectPager, after * } } c.Edges = make([]*ProjectEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &ProjectEdge{ @@ -1810,7 +1848,7 @@ func (pr *ProjectQuery) Paginate( return nil, err } conn := &ProjectConnection{Edges: []*ProjectEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -1838,6 +1876,11 @@ func (pr *ProjectQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := pr.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } pr = pager.applyOrder(pr) nodes, err := pr.All(ctx) if err != nil { @@ -1897,6 +1940,7 @@ type TodoEdge struct { // TodoConnection is the connection containing edges to Todo. type TodoConnection struct { Edges []*TodoEdge `json:"edges"` + Nodes []*Todo `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -1923,6 +1967,7 @@ func (c *TodoConnection) build(nodes []*Todo, pager *todoPager, after *Cursor, f } } c.Edges = make([]*TodoEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &TodoEdge{ @@ -2108,7 +2153,7 @@ func (t *TodoQuery) Paginate( return nil, err } conn := &TodoConnection{Edges: []*TodoEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -2136,6 +2181,11 @@ func (t *TodoQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := t.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } t = pager.applyOrder(t) nodes, err := t.All(ctx) if err != nil { @@ -2367,6 +2417,7 @@ type UserEdge struct { // UserConnection is the connection containing edges to User. type UserConnection struct { Edges []*UserEdge `json:"edges"` + Nodes []*User `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -2393,6 +2444,7 @@ func (c *UserConnection) build(nodes []*User, pager *userPager, after *Cursor, f } } c.Edges = make([]*UserEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &UserEdge{ @@ -2538,7 +2590,7 @@ func (u *UserQuery) Paginate( return nil, err } conn := &UserConnection{Edges: []*UserEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -2566,6 +2618,11 @@ func (u *UserQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := u.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } u = pager.applyOrder(u) nodes, err := u.All(ctx) if err != nil { @@ -2680,6 +2737,7 @@ type OrganizationEdge struct { // OrganizationConnection is the connection containing edges to Organization. type OrganizationConnection struct { Edges []*OrganizationEdge `json:"edges"` + Nodes []*Organization `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -2706,6 +2764,7 @@ func (c *OrganizationConnection) build(nodes []*Organization, pager *organizatio } } c.Edges = make([]*OrganizationEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &OrganizationEdge{ @@ -2842,7 +2901,7 @@ func (w *WorkspaceQuery) Paginate( return nil, err } conn := &OrganizationConnection{Edges: []*OrganizationEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -2870,6 +2929,11 @@ func (w *WorkspaceQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := w.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } w = pager.applyOrder(w) nodes, err := w.All(ctx) if err != nil { diff --git a/entgql/internal/todo/generated.go b/entgql/internal/todo/generated.go index 16e714989..b88a18356 100644 --- a/entgql/internal/todo/generated.go +++ b/entgql/internal/todo/generated.go @@ -88,6 +88,7 @@ type ComplexityRoot struct { CategoryConnection struct { Edges func(childComplexity int) int + Nodes func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } @@ -116,6 +117,7 @@ type ComplexityRoot struct { FriendshipConnection struct { Edges func(childComplexity int) int + Nodes func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } @@ -133,6 +135,7 @@ type ComplexityRoot struct { GroupConnection struct { Edges func(childComplexity int) int + Nodes func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } @@ -160,6 +163,7 @@ type ComplexityRoot struct { OneToManyConnection struct { Edges func(childComplexity int) int + Nodes func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } @@ -217,6 +221,7 @@ type ComplexityRoot struct { TodoConnection struct { Edges func(childComplexity int) int + Nodes func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } @@ -239,6 +244,7 @@ type ComplexityRoot struct { UserConnection struct { Edges func(childComplexity int) int + Nodes func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } @@ -430,6 +436,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.CategoryConnection.Edges(childComplexity), true + case "CategoryConnection.nodes": + if e.complexity.CategoryConnection.Nodes == nil { + break + } + + return e.complexity.CategoryConnection.Nodes(childComplexity), true + case "CategoryConnection.pageInfo": if e.complexity.CategoryConnection.PageInfo == nil { break @@ -521,6 +534,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.FriendshipConnection.Edges(childComplexity), true + case "FriendshipConnection.nodes": + if e.complexity.FriendshipConnection.Nodes == nil { + break + } + + return e.complexity.FriendshipConnection.Nodes(childComplexity), true + case "FriendshipConnection.pageInfo": if e.complexity.FriendshipConnection.PageInfo == nil { break @@ -582,6 +602,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.GroupConnection.Edges(childComplexity), true + case "GroupConnection.nodes": + if e.complexity.GroupConnection.Nodes == nil { + break + } + + return e.complexity.GroupConnection.Nodes(childComplexity), true + case "GroupConnection.pageInfo": if e.complexity.GroupConnection.PageInfo == nil { break @@ -707,6 +734,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.OneToManyConnection.Edges(childComplexity), true + case "OneToManyConnection.nodes": + if e.complexity.OneToManyConnection.Nodes == nil { + break + } + + return e.complexity.OneToManyConnection.Nodes(childComplexity), true + case "OneToManyConnection.pageInfo": if e.complexity.OneToManyConnection.PageInfo == nil { break @@ -1009,6 +1043,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.TodoConnection.Edges(childComplexity), true + case "TodoConnection.nodes": + if e.complexity.TodoConnection.Nodes == nil { + break + } + + return e.complexity.TodoConnection.Nodes(childComplexity), true + case "TodoConnection.pageInfo": if e.complexity.TodoConnection.PageInfo == nil { break @@ -1115,6 +1156,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.UserConnection.Edges(childComplexity), true + case "UserConnection.nodes": + if e.complexity.UserConnection.Nodes == nil { + break + } + + return e.complexity.UserConnection.Nodes(childComplexity), true + case "UserConnection.pageInfo": if e.complexity.UserConnection.PageInfo == nil { break @@ -2841,6 +2889,8 @@ func (ec *executionContext) fieldContext_Category_todos(ctx context.Context, fie switch field.Name { case "edges": return ec.fieldContext_TodoConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_TodoConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_TodoConnection_pageInfo(ctx, field) case "totalCount": @@ -2904,6 +2954,8 @@ func (ec *executionContext) fieldContext_Category_subCategories(ctx context.Cont switch field.Name { case "edges": return ec.fieldContext_CategoryConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_CategoryConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_CategoryConnection_pageInfo(ctx, field) case "totalCount": @@ -3055,6 +3107,71 @@ func (ec *executionContext) fieldContext_CategoryConnection_edges(_ context.Cont return fc, nil } +func (ec *executionContext) _CategoryConnection_nodes(ctx context.Context, field graphql.CollectedField, obj *ent.CategoryConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CategoryConnection_nodes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Nodes, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.Category) + fc.Result = res + return ec.marshalOCategory2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐCategory(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CategoryConnection_nodes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CategoryConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Category_id(ctx, field) + case "text": + return ec.fieldContext_Category_text(ctx, field) + case "status": + return ec.fieldContext_Category_status(ctx, field) + case "config": + return ec.fieldContext_Category_config(ctx, field) + case "types": + return ec.fieldContext_Category_types(ctx, field) + case "duration": + return ec.fieldContext_Category_duration(ctx, field) + case "count": + return ec.fieldContext_Category_count(ctx, field) + case "strings": + return ec.fieldContext_Category_strings(ctx, field) + case "todos": + return ec.fieldContext_Category_todos(ctx, field) + case "subCategories": + return ec.fieldContext_Category_subCategories(ctx, field) + case "todosCount": + return ec.fieldContext_Category_todosCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Category", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _CategoryConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.CategoryConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_CategoryConnection_pageInfo(ctx, field) if err != nil { @@ -3694,6 +3811,61 @@ func (ec *executionContext) fieldContext_FriendshipConnection_edges(_ context.Co return fc, nil } +func (ec *executionContext) _FriendshipConnection_nodes(ctx context.Context, field graphql.CollectedField, obj *ent.FriendshipConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_FriendshipConnection_nodes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Nodes, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.Friendship) + fc.Result = res + return ec.marshalOFriendship2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐFriendship(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_FriendshipConnection_nodes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "FriendshipConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Friendship_id(ctx, field) + case "createdAt": + return ec.fieldContext_Friendship_createdAt(ctx, field) + case "userID": + return ec.fieldContext_Friendship_userID(ctx, field) + case "friendID": + return ec.fieldContext_Friendship_friendID(ctx, field) + case "user": + return ec.fieldContext_Friendship_user(ctx, field) + case "friend": + return ec.fieldContext_Friendship_friend(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Friendship", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _FriendshipConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.FriendshipConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_FriendshipConnection_pageInfo(ctx, field) if err != nil { @@ -4020,6 +4192,8 @@ func (ec *executionContext) fieldContext_Group_users(ctx context.Context, field switch field.Name { case "edges": return ec.fieldContext_UserConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_UserConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_UserConnection_pageInfo(ctx, field) case "totalCount": @@ -4089,6 +4263,79 @@ func (ec *executionContext) fieldContext_GroupConnection_edges(_ context.Context return fc, nil } +func (ec *executionContext) _GroupConnection_nodes(ctx context.Context, field graphql.CollectedField, obj *ent.GroupConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_GroupConnection_nodes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Nodes, nil + } + directive1 := func(ctx context.Context) (interface{}, error) { + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []interface{}{"ADMIN", "MODERATOR"}) + if err != nil { + return nil, err + } + if ec.directives.HasPermissions == nil { + return nil, errors.New("directive hasPermissions is not implemented") + } + return ec.directives.HasPermissions(ctx, obj, directive0, permissions) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*ent.Group); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*entgo.io/contrib/entgql/internal/todo/ent.Group`, tmp) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.Group) + fc.Result = res + return ec.marshalOGroup2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐGroup(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_GroupConnection_nodes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "GroupConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Group_id(ctx, field) + case "name": + return ec.fieldContext_Group_name(ctx, field) + case "users": + return ec.fieldContext_Group_users(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Group", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _GroupConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.GroupConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_GroupConnection_pageInfo(ctx, field) if err != nil { @@ -4952,6 +5199,59 @@ func (ec *executionContext) fieldContext_OneToManyConnection_edges(_ context.Con return fc, nil } +func (ec *executionContext) _OneToManyConnection_nodes(ctx context.Context, field graphql.CollectedField, obj *ent.OneToManyConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_OneToManyConnection_nodes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Nodes, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.OneToMany) + fc.Result = res + return ec.marshalOOneToMany2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐOneToMany(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_OneToManyConnection_nodes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "OneToManyConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_OneToMany_id(ctx, field) + case "name": + return ec.fieldContext_OneToMany_name(ctx, field) + case "field2": + return ec.fieldContext_OneToMany_field2(ctx, field) + case "parent": + return ec.fieldContext_OneToMany_parent(ctx, field) + case "children": + return ec.fieldContext_OneToMany_children(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type OneToMany", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _OneToManyConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.OneToManyConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_OneToManyConnection_pageInfo(ctx, field) if err != nil { @@ -5490,6 +5790,8 @@ func (ec *executionContext) fieldContext_Project_todos(ctx context.Context, fiel switch field.Name { case "edges": return ec.fieldContext_TodoConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_TodoConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_TodoConnection_pageInfo(ctx, field) case "totalCount": @@ -5714,6 +6016,8 @@ func (ec *executionContext) fieldContext_Query_categories(ctx context.Context, f switch field.Name { case "edges": return ec.fieldContext_CategoryConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_CategoryConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_CategoryConnection_pageInfo(ctx, field) case "totalCount": @@ -5777,6 +6081,8 @@ func (ec *executionContext) fieldContext_Query_groups(ctx context.Context, field switch field.Name { case "edges": return ec.fieldContext_GroupConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_GroupConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_GroupConnection_pageInfo(ctx, field) case "totalCount": @@ -5840,6 +6146,8 @@ func (ec *executionContext) fieldContext_Query_oneToMany(ctx context.Context, fi switch field.Name { case "edges": return ec.fieldContext_OneToManyConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_OneToManyConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_OneToManyConnection_pageInfo(ctx, field) case "totalCount": @@ -5903,6 +6211,8 @@ func (ec *executionContext) fieldContext_Query_todos(ctx context.Context, field switch field.Name { case "edges": return ec.fieldContext_TodoConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_TodoConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_TodoConnection_pageInfo(ctx, field) case "totalCount": @@ -5966,6 +6276,8 @@ func (ec *executionContext) fieldContext_Query_users(ctx context.Context, field switch field.Name { case "edges": return ec.fieldContext_UserConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_UserConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_UserConnection_pageInfo(ctx, field) case "totalCount": @@ -6073,6 +6385,8 @@ func (ec *executionContext) fieldContext_Query_todosWithJoins(ctx context.Contex switch field.Name { case "edges": return ec.fieldContext_TodoConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_TodoConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_TodoConnection_pageInfo(ctx, field) case "totalCount": @@ -6812,6 +7126,8 @@ func (ec *executionContext) fieldContext_Todo_children(ctx context.Context, fiel switch field.Name { case "edges": return ec.fieldContext_TodoConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_TodoConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_TodoConnection_pageInfo(ctx, field) case "totalCount": @@ -6987,6 +7303,79 @@ func (ec *executionContext) fieldContext_TodoConnection_edges(_ context.Context, return fc, nil } +func (ec *executionContext) _TodoConnection_nodes(ctx context.Context, field graphql.CollectedField, obj *ent.TodoConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TodoConnection_nodes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Nodes, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.Todo) + fc.Result = res + return ec.marshalOTodo2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_TodoConnection_nodes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "TodoConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Todo_id(ctx, field) + case "createdAt": + return ec.fieldContext_Todo_createdAt(ctx, field) + case "status": + return ec.fieldContext_Todo_status(ctx, field) + case "priorityOrder": + return ec.fieldContext_Todo_priorityOrder(ctx, field) + case "text": + return ec.fieldContext_Todo_text(ctx, field) + case "categoryID": + return ec.fieldContext_Todo_categoryID(ctx, field) + case "category_id": + return ec.fieldContext_Todo_category_id(ctx, field) + case "categoryX": + return ec.fieldContext_Todo_categoryX(ctx, field) + case "init": + return ec.fieldContext_Todo_init(ctx, field) + case "custom": + return ec.fieldContext_Todo_custom(ctx, field) + case "customp": + return ec.fieldContext_Todo_customp(ctx, field) + case "parent": + return ec.fieldContext_Todo_parent(ctx, field) + case "children": + return ec.fieldContext_Todo_children(ctx, field) + case "category": + return ec.fieldContext_Todo_category(ctx, field) + case "extendedField": + return ec.fieldContext_Todo_extendedField(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _TodoConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TodoConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_TodoConnection_pageInfo(ctx, field) if err != nil { @@ -7460,6 +7849,8 @@ func (ec *executionContext) fieldContext_User_groups(ctx context.Context, field switch field.Name { case "edges": return ec.fieldContext_GroupConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_GroupConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_GroupConnection_pageInfo(ctx, field) case "totalCount": @@ -7523,6 +7914,8 @@ func (ec *executionContext) fieldContext_User_friends(ctx context.Context, field switch field.Name { case "edges": return ec.fieldContext_UserConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_UserConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_UserConnection_pageInfo(ctx, field) case "totalCount": @@ -7586,6 +7979,8 @@ func (ec *executionContext) fieldContext_User_friendships(ctx context.Context, f switch field.Name { case "edges": return ec.fieldContext_FriendshipConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_FriendshipConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_FriendshipConnection_pageInfo(ctx, field) case "totalCount": @@ -7649,7 +8044,66 @@ func (ec *executionContext) fieldContext_UserConnection_edges(_ context.Context, case "cursor": return ec.fieldContext_UserEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type UserEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _UserConnection_nodes(ctx context.Context, field graphql.CollectedField, obj *ent.UserConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserConnection_nodes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Nodes, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.User) + fc.Result = res + return ec.marshalOUser2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_UserConnection_nodes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "UserConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "username": + return ec.fieldContext_User_username(ctx, field) + case "requiredMetadata": + return ec.fieldContext_User_requiredMetadata(ctx, field) + case "metadata": + return ec.fieldContext_User_metadata(ctx, field) + case "groups": + return ec.fieldContext_User_groups(ctx, field) + case "friends": + return ec.fieldContext_User_friends(ctx, field) + case "friendships": + return ec.fieldContext_User_friendships(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil @@ -13295,6 +13749,8 @@ func (ec *executionContext) _CategoryConnection(ctx context.Context, sel ast.Sel out.Values[i] = graphql.MarshalString("CategoryConnection") case "edges": out.Values[i] = ec._CategoryConnection_edges(ctx, field, obj) + case "nodes": + out.Values[i] = ec._CategoryConnection_nodes(ctx, field, obj) case "pageInfo": out.Values[i] = ec._CategoryConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -13583,6 +14039,8 @@ func (ec *executionContext) _FriendshipConnection(ctx context.Context, sel ast.S out.Values[i] = graphql.MarshalString("FriendshipConnection") case "edges": out.Values[i] = ec._FriendshipConnection_edges(ctx, field, obj) + case "nodes": + out.Values[i] = ec._FriendshipConnection_nodes(ctx, field, obj) case "pageInfo": out.Values[i] = ec._FriendshipConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -13750,6 +14208,8 @@ func (ec *executionContext) _GroupConnection(ctx context.Context, sel ast.Select out.Values[i] = graphql.MarshalString("GroupConnection") case "edges": out.Values[i] = ec._GroupConnection_edges(ctx, field, obj) + case "nodes": + out.Values[i] = ec._GroupConnection_nodes(ctx, field, obj) case "pageInfo": out.Values[i] = ec._GroupConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -14026,6 +14486,8 @@ func (ec *executionContext) _OneToManyConnection(ctx context.Context, sel ast.Se out.Values[i] = graphql.MarshalString("OneToManyConnection") case "edges": out.Values[i] = ec._OneToManyConnection_edges(ctx, field, obj) + case "nodes": + out.Values[i] = ec._OneToManyConnection_nodes(ctx, field, obj) case "pageInfo": out.Values[i] = ec._OneToManyConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -14753,6 +15215,8 @@ func (ec *executionContext) _TodoConnection(ctx context.Context, sel ast.Selecti out.Values[i] = graphql.MarshalString("TodoConnection") case "edges": out.Values[i] = ec._TodoConnection_edges(ctx, field, obj) + case "nodes": + out.Values[i] = ec._TodoConnection_nodes(ctx, field, obj) case "pageInfo": out.Values[i] = ec._TodoConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -15004,6 +15468,8 @@ func (ec *executionContext) _UserConnection(ctx context.Context, sel ast.Selecti out.Values[i] = graphql.MarshalString("UserConnection") case "edges": out.Values[i] = ec._UserConnection_edges(ctx, field, obj) + case "nodes": + out.Values[i] = ec._UserConnection_nodes(ctx, field, obj) case "pageInfo": out.Values[i] = ec._UserConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -16347,6 +16813,47 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast return res } +func (ec *executionContext) marshalOCategory2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐCategory(ctx context.Context, sel ast.SelectionSet, v []*ent.Category) 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.marshalOCategory2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐCategory(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalOCategory2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐCategory(ctx context.Context, sel ast.SelectionSet, v *ent.Category) graphql.Marshaler { if v == nil { return graphql.Null @@ -16778,6 +17285,47 @@ func (ec *executionContext) marshalODuration2ᚖtimeᚐDuration(ctx context.Cont return res } +func (ec *executionContext) marshalOFriendship2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐFriendship(ctx context.Context, sel ast.SelectionSet, v []*ent.Friendship) 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.marshalOFriendship2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐFriendship(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalOFriendship2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐFriendship(ctx context.Context, sel ast.SelectionSet, v *ent.Friendship) graphql.Marshaler { if v == nil { return graphql.Null @@ -16861,6 +17409,47 @@ func (ec *executionContext) unmarshalOFriendshipWhereInput2ᚖentgoᚗioᚋcontr return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOGroup2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐGroup(ctx context.Context, sel ast.SelectionSet, v []*ent.Group) 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.marshalOGroup2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐGroup(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalOGroup2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐGroup(ctx context.Context, sel ast.SelectionSet, v *ent.Group) graphql.Marshaler { if v == nil { return graphql.Null @@ -17095,6 +17684,47 @@ func (ec *executionContext) marshalONode2entgoᚗioᚋcontribᚋentgqlᚋinterna return ec._Node(ctx, sel, v) } +func (ec *executionContext) marshalOOneToMany2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐOneToMany(ctx context.Context, sel ast.SelectionSet, v []*ent.OneToMany) 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.marshalOOneToMany2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐOneToMany(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalOOneToMany2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐOneToManyᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.OneToMany) graphql.Marshaler { if v == nil { return graphql.Null @@ -17407,6 +18037,47 @@ func (ec *executionContext) marshalOTime2ᚖtimeᚐTime(ctx context.Context, sel return res } +func (ec *executionContext) marshalOTodo2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodo(ctx context.Context, sel ast.SelectionSet, v []*ent.Todo) 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.marshalOTodo2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodo(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalOTodo2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐTodo(ctx context.Context, sel ast.SelectionSet, v *ent.Todo) graphql.Marshaler { if v == nil { return graphql.Null @@ -17711,6 +18382,47 @@ func (ec *executionContext) marshalOUint642ᚖuint64(ctx context.Context, sel as return res } +func (ec *executionContext) marshalOUser2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐUser(ctx context.Context, sel ast.SelectionSet, v []*ent.User) 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.marshalOUser2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐUser(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalOUser2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodoᚋentᚐUser(ctx context.Context, sel ast.SelectionSet, v *ent.User) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/entgql/internal/todofed/ent/gql_pagination.go b/entgql/internal/todofed/ent/gql_pagination.go index 6db8d185c..9f1dde76f 100644 --- a/entgql/internal/todofed/ent/gql_pagination.go +++ b/entgql/internal/todofed/ent/gql_pagination.go @@ -98,6 +98,7 @@ func hasCollectedField(ctx context.Context, path ...string) bool { const ( edgesField = "edges" + nodesField = "nodes" nodeField = "node" pageInfoField = "pageInfo" totalCountField = "totalCount" @@ -122,6 +123,7 @@ type CategoryEdge struct { // CategoryConnection is the connection containing edges to Category. type CategoryConnection struct { Edges []*CategoryEdge `json:"edges"` + Nodes []*Category `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -148,6 +150,7 @@ func (c *CategoryConnection) build(nodes []*Category, pager *categoryPager, afte } } c.Edges = make([]*CategoryEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &CategoryEdge{ @@ -284,7 +287,7 @@ func (c *CategoryQuery) Paginate( return nil, err } conn := &CategoryConnection{Edges: []*CategoryEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -312,6 +315,11 @@ func (c *CategoryQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := c.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } c = pager.applyOrder(c) nodes, err := c.All(ctx) if err != nil { @@ -436,6 +444,7 @@ type TodoEdge struct { // TodoConnection is the connection containing edges to Todo. type TodoConnection struct { Edges []*TodoEdge `json:"edges"` + Nodes []*Todo `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -462,6 +471,7 @@ func (c *TodoConnection) build(nodes []*Todo, pager *todoPager, after *Cursor, f } } c.Edges = make([]*TodoEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &TodoEdge{ @@ -598,7 +608,7 @@ func (t *TodoQuery) Paginate( return nil, err } conn := &TodoConnection{Edges: []*TodoEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -626,6 +636,11 @@ func (t *TodoQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := t.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } t = pager.applyOrder(t) nodes, err := t.All(ctx) if err != nil { diff --git a/entgql/internal/todogotype/ent/gql_pagination.go b/entgql/internal/todogotype/ent/gql_pagination.go index 0aebdc670..f2d45fb32 100644 --- a/entgql/internal/todogotype/ent/gql_pagination.go +++ b/entgql/internal/todogotype/ent/gql_pagination.go @@ -103,6 +103,7 @@ func hasCollectedField(ctx context.Context, path ...string) bool { const ( edgesField = "edges" + nodesField = "nodes" nodeField = "node" pageInfoField = "pageInfo" totalCountField = "totalCount" @@ -127,6 +128,7 @@ type BillProductEdge struct { // BillProductConnection is the connection containing edges to BillProduct. type BillProductConnection struct { Edges []*BillProductEdge `json:"edges"` + Nodes []*BillProduct `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -153,6 +155,7 @@ func (c *BillProductConnection) build(nodes []*BillProduct, pager *billproductPa } } c.Edges = make([]*BillProductEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &BillProductEdge{ @@ -289,7 +292,7 @@ func (bp *BillProductQuery) Paginate( return nil, err } conn := &BillProductConnection{Edges: []*BillProductEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -317,6 +320,11 @@ func (bp *BillProductQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := bp.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } bp = pager.applyOrder(bp) nodes, err := bp.All(ctx) if err != nil { @@ -376,6 +384,7 @@ type CategoryEdge struct { // CategoryConnection is the connection containing edges to Category. type CategoryConnection struct { Edges []*CategoryEdge `json:"edges"` + Nodes []*Category `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -402,6 +411,7 @@ func (c *CategoryConnection) build(nodes []*Category, pager *categoryPager, afte } } c.Edges = make([]*CategoryEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &CategoryEdge{ @@ -587,7 +597,7 @@ func (c *CategoryQuery) Paginate( return nil, err } conn := &CategoryConnection{Edges: []*CategoryEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -615,6 +625,11 @@ func (c *CategoryQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := c.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } c = pager.applyOrder(c) nodes, err := c.All(ctx) if err != nil { @@ -798,6 +813,7 @@ type FriendshipEdge struct { // FriendshipConnection is the connection containing edges to Friendship. type FriendshipConnection struct { Edges []*FriendshipEdge `json:"edges"` + Nodes []*Friendship `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -824,6 +840,7 @@ func (c *FriendshipConnection) build(nodes []*Friendship, pager *friendshipPager } } c.Edges = make([]*FriendshipEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &FriendshipEdge{ @@ -960,7 +977,7 @@ func (f *FriendshipQuery) Paginate( return nil, err } conn := &FriendshipConnection{Edges: []*FriendshipEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -988,6 +1005,11 @@ func (f *FriendshipQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := f.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } f = pager.applyOrder(f) nodes, err := f.All(ctx) if err != nil { @@ -1047,6 +1069,7 @@ type GroupEdge struct { // GroupConnection is the connection containing edges to Group. type GroupConnection struct { Edges []*GroupEdge `json:"edges"` + Nodes []*Group `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -1073,6 +1096,7 @@ func (c *GroupConnection) build(nodes []*Group, pager *groupPager, after *Cursor } } c.Edges = make([]*GroupEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &GroupEdge{ @@ -1209,7 +1233,7 @@ func (gr *GroupQuery) Paginate( return nil, err } conn := &GroupConnection{Edges: []*GroupEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -1237,6 +1261,11 @@ func (gr *GroupQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := gr.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } gr = pager.applyOrder(gr) nodes, err := gr.All(ctx) if err != nil { @@ -1296,6 +1325,7 @@ type PetEdge struct { // PetConnection is the connection containing edges to Pet. type PetConnection struct { Edges []*PetEdge `json:"edges"` + Nodes []*Pet `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -1322,6 +1352,7 @@ func (c *PetConnection) build(nodes []*Pet, pager *petPager, after *Cursor, firs } } c.Edges = make([]*PetEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &PetEdge{ @@ -1458,7 +1489,7 @@ func (pe *PetQuery) Paginate( return nil, err } conn := &PetConnection{Edges: []*PetEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -1486,6 +1517,11 @@ func (pe *PetQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := pe.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } pe = pager.applyOrder(pe) nodes, err := pe.All(ctx) if err != nil { @@ -1545,6 +1581,7 @@ type TodoEdge struct { // TodoConnection is the connection containing edges to Todo. type TodoConnection struct { Edges []*TodoEdge `json:"edges"` + Nodes []*Todo `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -1571,6 +1608,7 @@ func (c *TodoConnection) build(nodes []*Todo, pager *todoPager, after *Cursor, f } } c.Edges = make([]*TodoEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &TodoEdge{ @@ -1756,7 +1794,7 @@ func (t *TodoQuery) Paginate( return nil, err } conn := &TodoConnection{Edges: []*TodoEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -1784,6 +1822,11 @@ func (t *TodoQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := t.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } t = pager.applyOrder(t) nodes, err := t.All(ctx) if err != nil { @@ -2015,6 +2058,7 @@ type UserEdge struct { // UserConnection is the connection containing edges to User. type UserConnection struct { Edges []*UserEdge `json:"edges"` + Nodes []*User `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -2041,6 +2085,7 @@ func (c *UserConnection) build(nodes []*User, pager *userPager, after *Cursor, f } } c.Edges = make([]*UserEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &UserEdge{ @@ -2186,7 +2231,7 @@ func (u *UserQuery) Paginate( return nil, err } conn := &UserConnection{Edges: []*UserEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -2214,6 +2259,11 @@ func (u *UserQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := u.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } u = pager.applyOrder(u) nodes, err := u.All(ctx) if err != nil { diff --git a/entgql/internal/todogotype/generated.go b/entgql/internal/todogotype/generated.go index 1296acb99..c9ccf757f 100644 --- a/entgql/internal/todogotype/generated.go +++ b/entgql/internal/todogotype/generated.go @@ -93,6 +93,7 @@ type ComplexityRoot struct { CategoryConnection struct { Edges func(childComplexity int) int + Nodes func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } @@ -121,6 +122,7 @@ type ComplexityRoot struct { FriendshipConnection struct { Edges func(childComplexity int) int + Nodes func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } @@ -138,6 +140,7 @@ type ComplexityRoot struct { GroupConnection struct { Edges func(childComplexity int) int + Nodes func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } @@ -165,6 +168,7 @@ type ComplexityRoot struct { OneToManyConnection struct { Edges func(childComplexity int) int + Nodes func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } @@ -222,6 +226,7 @@ type ComplexityRoot struct { TodoConnection struct { Edges func(childComplexity int) int + Nodes func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } @@ -244,6 +249,7 @@ type ComplexityRoot struct { UserConnection struct { Edges func(childComplexity int) int + Nodes func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } @@ -476,6 +482,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.CategoryConnection.Edges(childComplexity), true + case "CategoryConnection.nodes": + if e.complexity.CategoryConnection.Nodes == nil { + break + } + + return e.complexity.CategoryConnection.Nodes(childComplexity), true + case "CategoryConnection.pageInfo": if e.complexity.CategoryConnection.PageInfo == nil { break @@ -567,6 +580,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.FriendshipConnection.Edges(childComplexity), true + case "FriendshipConnection.nodes": + if e.complexity.FriendshipConnection.Nodes == nil { + break + } + + return e.complexity.FriendshipConnection.Nodes(childComplexity), true + case "FriendshipConnection.pageInfo": if e.complexity.FriendshipConnection.PageInfo == nil { break @@ -628,6 +648,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.GroupConnection.Edges(childComplexity), true + case "GroupConnection.nodes": + if e.complexity.GroupConnection.Nodes == nil { + break + } + + return e.complexity.GroupConnection.Nodes(childComplexity), true + case "GroupConnection.pageInfo": if e.complexity.GroupConnection.PageInfo == nil { break @@ -753,6 +780,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.OneToManyConnection.Edges(childComplexity), true + case "OneToManyConnection.nodes": + if e.complexity.OneToManyConnection.Nodes == nil { + break + } + + return e.complexity.OneToManyConnection.Nodes(childComplexity), true + case "OneToManyConnection.pageInfo": if e.complexity.OneToManyConnection.PageInfo == nil { break @@ -1055,6 +1089,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.TodoConnection.Edges(childComplexity), true + case "TodoConnection.nodes": + if e.complexity.TodoConnection.Nodes == nil { + break + } + + return e.complexity.TodoConnection.Nodes(childComplexity), true + case "TodoConnection.pageInfo": if e.complexity.TodoConnection.PageInfo == nil { break @@ -1161,6 +1202,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.UserConnection.Edges(childComplexity), true + case "UserConnection.nodes": + if e.complexity.UserConnection.Nodes == nil { + break + } + + return e.complexity.UserConnection.Nodes(childComplexity), true + case "UserConnection.pageInfo": if e.complexity.UserConnection.PageInfo == nil { break @@ -1551,6 +1599,10 @@ type CategoryConnection { """ edges: [CategoryEdge] """ + A list of nodes. + """ + nodes: [Category] + """ Information to aid in pagination. """ pageInfo: PageInfo! @@ -1759,6 +1811,10 @@ type FriendshipConnection { """ edges: [FriendshipEdge] """ + A list of nodes. + """ + nodes: [Friendship] + """ Information to aid in pagination. """ pageInfo: PageInfo! @@ -1855,6 +1911,10 @@ type GroupConnection { """ edges: [GroupEdge] """ + A list of nodes. + """ + nodes: [Group] + """ Information to aid in pagination. """ pageInfo: PageInfo! @@ -1947,6 +2007,10 @@ type OneToManyConnection { """ edges: [OneToManyEdge] """ + A list of nodes. + """ + nodes: [OneToMany] + """ Information to aid in pagination. """ pageInfo: PageInfo! @@ -2418,6 +2482,10 @@ type TodoConnection { """ edges: [TodoEdge] """ + A list of nodes. + """ + nodes: [Todo] + """ Information to aid in pagination. """ pageInfo: PageInfo! @@ -2735,6 +2803,10 @@ type UserConnection { """ edges: [UserEdge] """ + A list of nodes. + """ + nodes: [User] + """ Information to aid in pagination. """ pageInfo: PageInfo! @@ -4396,6 +4468,8 @@ func (ec *executionContext) fieldContext_Category_todos(ctx context.Context, fie switch field.Name { case "edges": return ec.fieldContext_TodoConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_TodoConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_TodoConnection_pageInfo(ctx, field) case "totalCount": @@ -4459,6 +4533,8 @@ func (ec *executionContext) fieldContext_Category_subCategories(ctx context.Cont switch field.Name { case "edges": return ec.fieldContext_CategoryConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_CategoryConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_CategoryConnection_pageInfo(ctx, field) case "totalCount": @@ -4610,6 +4686,71 @@ func (ec *executionContext) fieldContext_CategoryConnection_edges(_ context.Cont return fc, nil } +func (ec *executionContext) _CategoryConnection_nodes(ctx context.Context, field graphql.CollectedField, obj *ent.CategoryConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CategoryConnection_nodes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Nodes, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.Category) + fc.Result = res + return ec.marshalOCategory2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐCategory(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CategoryConnection_nodes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CategoryConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Category_id(ctx, field) + case "text": + return ec.fieldContext_Category_text(ctx, field) + case "status": + return ec.fieldContext_Category_status(ctx, field) + case "config": + return ec.fieldContext_Category_config(ctx, field) + case "types": + return ec.fieldContext_Category_types(ctx, field) + case "duration": + return ec.fieldContext_Category_duration(ctx, field) + case "count": + return ec.fieldContext_Category_count(ctx, field) + case "strings": + return ec.fieldContext_Category_strings(ctx, field) + case "todos": + return ec.fieldContext_Category_todos(ctx, field) + case "subCategories": + return ec.fieldContext_Category_subCategories(ctx, field) + case "todosCount": + return ec.fieldContext_Category_todosCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Category", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _CategoryConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.CategoryConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_CategoryConnection_pageInfo(ctx, field) if err != nil { @@ -5249,6 +5390,61 @@ func (ec *executionContext) fieldContext_FriendshipConnection_edges(_ context.Co return fc, nil } +func (ec *executionContext) _FriendshipConnection_nodes(ctx context.Context, field graphql.CollectedField, obj *ent.FriendshipConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_FriendshipConnection_nodes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Nodes, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.Friendship) + fc.Result = res + return ec.marshalOFriendship2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐFriendship(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_FriendshipConnection_nodes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "FriendshipConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Friendship_id(ctx, field) + case "createdAt": + return ec.fieldContext_Friendship_createdAt(ctx, field) + case "userID": + return ec.fieldContext_Friendship_userID(ctx, field) + case "friendID": + return ec.fieldContext_Friendship_friendID(ctx, field) + case "user": + return ec.fieldContext_Friendship_user(ctx, field) + case "friend": + return ec.fieldContext_Friendship_friend(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Friendship", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _FriendshipConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.FriendshipConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_FriendshipConnection_pageInfo(ctx, field) if err != nil { @@ -5575,6 +5771,8 @@ func (ec *executionContext) fieldContext_Group_users(ctx context.Context, field switch field.Name { case "edges": return ec.fieldContext_UserConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_UserConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_UserConnection_pageInfo(ctx, field) case "totalCount": @@ -5644,6 +5842,79 @@ func (ec *executionContext) fieldContext_GroupConnection_edges(_ context.Context return fc, nil } +func (ec *executionContext) _GroupConnection_nodes(ctx context.Context, field graphql.CollectedField, obj *ent.GroupConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_GroupConnection_nodes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Nodes, nil + } + directive1 := func(ctx context.Context) (interface{}, error) { + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []interface{}{"ADMIN", "MODERATOR"}) + if err != nil { + return nil, err + } + if ec.directives.HasPermissions == nil { + return nil, errors.New("directive hasPermissions is not implemented") + } + return ec.directives.HasPermissions(ctx, obj, directive0, permissions) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*ent.Group); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*entgo.io/contrib/entgql/internal/todogotype/ent.Group`, tmp) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.Group) + fc.Result = res + return ec.marshalOGroup2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐGroup(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_GroupConnection_nodes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "GroupConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Group_id(ctx, field) + case "name": + return ec.fieldContext_Group_name(ctx, field) + case "users": + return ec.fieldContext_Group_users(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Group", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _GroupConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.GroupConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_GroupConnection_pageInfo(ctx, field) if err != nil { @@ -6507,6 +6778,59 @@ func (ec *executionContext) fieldContext_OneToManyConnection_edges(_ context.Con return fc, nil } +func (ec *executionContext) _OneToManyConnection_nodes(ctx context.Context, field graphql.CollectedField, obj *OneToManyConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_OneToManyConnection_nodes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Nodes, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*OneToMany) + fc.Result = res + return ec.marshalOOneToMany2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐOneToMany(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_OneToManyConnection_nodes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "OneToManyConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_OneToMany_id(ctx, field) + case "name": + return ec.fieldContext_OneToMany_name(ctx, field) + case "field2": + return ec.fieldContext_OneToMany_field2(ctx, field) + case "parent": + return ec.fieldContext_OneToMany_parent(ctx, field) + case "children": + return ec.fieldContext_OneToMany_children(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type OneToMany", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _OneToManyConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *OneToManyConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_OneToManyConnection_pageInfo(ctx, field) if err != nil { @@ -7045,6 +7369,8 @@ func (ec *executionContext) fieldContext_Project_todos(ctx context.Context, fiel switch field.Name { case "edges": return ec.fieldContext_TodoConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_TodoConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_TodoConnection_pageInfo(ctx, field) case "totalCount": @@ -7269,6 +7595,8 @@ func (ec *executionContext) fieldContext_Query_categories(ctx context.Context, f switch field.Name { case "edges": return ec.fieldContext_CategoryConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_CategoryConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_CategoryConnection_pageInfo(ctx, field) case "totalCount": @@ -7332,6 +7660,8 @@ func (ec *executionContext) fieldContext_Query_groups(ctx context.Context, field switch field.Name { case "edges": return ec.fieldContext_GroupConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_GroupConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_GroupConnection_pageInfo(ctx, field) case "totalCount": @@ -7395,6 +7725,8 @@ func (ec *executionContext) fieldContext_Query_oneToMany(ctx context.Context, fi switch field.Name { case "edges": return ec.fieldContext_OneToManyConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_OneToManyConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_OneToManyConnection_pageInfo(ctx, field) case "totalCount": @@ -7458,6 +7790,8 @@ func (ec *executionContext) fieldContext_Query_todos(ctx context.Context, field switch field.Name { case "edges": return ec.fieldContext_TodoConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_TodoConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_TodoConnection_pageInfo(ctx, field) case "totalCount": @@ -7521,6 +7855,8 @@ func (ec *executionContext) fieldContext_Query_users(ctx context.Context, field switch field.Name { case "edges": return ec.fieldContext_UserConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_UserConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_UserConnection_pageInfo(ctx, field) case "totalCount": @@ -7628,6 +7964,8 @@ func (ec *executionContext) fieldContext_Query_todosWithJoins(ctx context.Contex switch field.Name { case "edges": return ec.fieldContext_TodoConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_TodoConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_TodoConnection_pageInfo(ctx, field) case "totalCount": @@ -8367,6 +8705,8 @@ func (ec *executionContext) fieldContext_Todo_children(ctx context.Context, fiel switch field.Name { case "edges": return ec.fieldContext_TodoConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_TodoConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_TodoConnection_pageInfo(ctx, field) case "totalCount": @@ -8542,6 +8882,79 @@ func (ec *executionContext) fieldContext_TodoConnection_edges(_ context.Context, return fc, nil } +func (ec *executionContext) _TodoConnection_nodes(ctx context.Context, field graphql.CollectedField, obj *ent.TodoConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TodoConnection_nodes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Nodes, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.Todo) + fc.Result = res + return ec.marshalOTodo2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_TodoConnection_nodes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "TodoConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Todo_id(ctx, field) + case "createdAt": + return ec.fieldContext_Todo_createdAt(ctx, field) + case "status": + return ec.fieldContext_Todo_status(ctx, field) + case "priorityOrder": + return ec.fieldContext_Todo_priorityOrder(ctx, field) + case "text": + return ec.fieldContext_Todo_text(ctx, field) + case "categoryID": + return ec.fieldContext_Todo_categoryID(ctx, field) + case "category_id": + return ec.fieldContext_Todo_category_id(ctx, field) + case "categoryX": + return ec.fieldContext_Todo_categoryX(ctx, field) + case "init": + return ec.fieldContext_Todo_init(ctx, field) + case "custom": + return ec.fieldContext_Todo_custom(ctx, field) + case "customp": + return ec.fieldContext_Todo_customp(ctx, field) + case "parent": + return ec.fieldContext_Todo_parent(ctx, field) + case "children": + return ec.fieldContext_Todo_children(ctx, field) + case "category": + return ec.fieldContext_Todo_category(ctx, field) + case "extendedField": + return ec.fieldContext_Todo_extendedField(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _TodoConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TodoConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_TodoConnection_pageInfo(ctx, field) if err != nil { @@ -9015,6 +9428,8 @@ func (ec *executionContext) fieldContext_User_groups(ctx context.Context, field switch field.Name { case "edges": return ec.fieldContext_GroupConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_GroupConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_GroupConnection_pageInfo(ctx, field) case "totalCount": @@ -9078,6 +9493,8 @@ func (ec *executionContext) fieldContext_User_friends(ctx context.Context, field switch field.Name { case "edges": return ec.fieldContext_UserConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_UserConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_UserConnection_pageInfo(ctx, field) case "totalCount": @@ -9141,6 +9558,8 @@ func (ec *executionContext) fieldContext_User_friendships(ctx context.Context, f switch field.Name { case "edges": return ec.fieldContext_FriendshipConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_FriendshipConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_FriendshipConnection_pageInfo(ctx, field) case "totalCount": @@ -9204,7 +9623,66 @@ func (ec *executionContext) fieldContext_UserConnection_edges(_ context.Context, case "cursor": return ec.fieldContext_UserEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type UserEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _UserConnection_nodes(ctx context.Context, field graphql.CollectedField, obj *ent.UserConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserConnection_nodes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Nodes, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.User) + fc.Result = res + return ec.marshalOUser2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_UserConnection_nodes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "UserConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "username": + return ec.fieldContext_User_username(ctx, field) + case "requiredMetadata": + return ec.fieldContext_User_requiredMetadata(ctx, field) + case "metadata": + return ec.fieldContext_User_metadata(ctx, field) + case "groups": + return ec.fieldContext_User_groups(ctx, field) + case "friends": + return ec.fieldContext_User_friends(ctx, field) + case "friendships": + return ec.fieldContext_User_friendships(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil @@ -14917,6 +15395,8 @@ func (ec *executionContext) _CategoryConnection(ctx context.Context, sel ast.Sel out.Values[i] = graphql.MarshalString("CategoryConnection") case "edges": out.Values[i] = ec._CategoryConnection_edges(ctx, field, obj) + case "nodes": + out.Values[i] = ec._CategoryConnection_nodes(ctx, field, obj) case "pageInfo": out.Values[i] = ec._CategoryConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -15205,6 +15685,8 @@ func (ec *executionContext) _FriendshipConnection(ctx context.Context, sel ast.S out.Values[i] = graphql.MarshalString("FriendshipConnection") case "edges": out.Values[i] = ec._FriendshipConnection_edges(ctx, field, obj) + case "nodes": + out.Values[i] = ec._FriendshipConnection_nodes(ctx, field, obj) case "pageInfo": out.Values[i] = ec._FriendshipConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -15372,6 +15854,8 @@ func (ec *executionContext) _GroupConnection(ctx context.Context, sel ast.Select out.Values[i] = graphql.MarshalString("GroupConnection") case "edges": out.Values[i] = ec._GroupConnection_edges(ctx, field, obj) + case "nodes": + out.Values[i] = ec._GroupConnection_nodes(ctx, field, obj) case "pageInfo": out.Values[i] = ec._GroupConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -15586,6 +16070,8 @@ func (ec *executionContext) _OneToManyConnection(ctx context.Context, sel ast.Se out.Values[i] = graphql.MarshalString("OneToManyConnection") case "edges": out.Values[i] = ec._OneToManyConnection_edges(ctx, field, obj) + case "nodes": + out.Values[i] = ec._OneToManyConnection_nodes(ctx, field, obj) case "pageInfo": out.Values[i] = ec._OneToManyConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -16344,6 +16830,8 @@ func (ec *executionContext) _TodoConnection(ctx context.Context, sel ast.Selecti out.Values[i] = graphql.MarshalString("TodoConnection") case "edges": out.Values[i] = ec._TodoConnection_edges(ctx, field, obj) + case "nodes": + out.Values[i] = ec._TodoConnection_nodes(ctx, field, obj) case "pageInfo": out.Values[i] = ec._TodoConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -16688,6 +17176,8 @@ func (ec *executionContext) _UserConnection(ctx context.Context, sel ast.Selecti out.Values[i] = graphql.MarshalString("UserConnection") case "edges": out.Values[i] = ec._UserConnection_edges(ctx, field, obj) + case "nodes": + out.Values[i] = ec._UserConnection_nodes(ctx, field, obj) case "pageInfo": out.Values[i] = ec._UserConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -18049,6 +18539,47 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast return res } +func (ec *executionContext) marshalOCategory2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐCategory(ctx context.Context, sel ast.SelectionSet, v []*ent.Category) 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.marshalOCategory2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐCategory(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalOCategory2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐCategory(ctx context.Context, sel ast.SelectionSet, v *ent.Category) graphql.Marshaler { if v == nil { return graphql.Null @@ -18480,6 +19011,47 @@ func (ec *executionContext) marshalODuration2ᚖtimeᚐDuration(ctx context.Cont return res } +func (ec *executionContext) marshalOFriendship2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐFriendship(ctx context.Context, sel ast.SelectionSet, v []*ent.Friendship) 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.marshalOFriendship2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐFriendship(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalOFriendship2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐFriendship(ctx context.Context, sel ast.SelectionSet, v *ent.Friendship) graphql.Marshaler { if v == nil { return graphql.Null @@ -18563,6 +19135,47 @@ func (ec *executionContext) unmarshalOFriendshipWhereInput2ᚖentgoᚗioᚋcontr return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOGroup2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐGroup(ctx context.Context, sel ast.SelectionSet, v []*ent.Group) 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.marshalOGroup2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐGroup(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalOGroup2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐGroup(ctx context.Context, sel ast.SelectionSet, v *ent.Group) graphql.Marshaler { if v == nil { return graphql.Null @@ -18851,6 +19464,47 @@ func (ec *executionContext) marshalONode2entgoᚗioᚋcontribᚋentgqlᚋinterna return ec._Node(ctx, sel, v) } +func (ec *executionContext) marshalOOneToMany2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐOneToMany(ctx context.Context, sel ast.SelectionSet, v []*OneToMany) 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.marshalOOneToMany2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐOneToMany(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalOOneToMany2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚐOneToManyᚄ(ctx context.Context, sel ast.SelectionSet, v []*OneToMany) graphql.Marshaler { if v == nil { return graphql.Null @@ -19153,6 +19807,47 @@ func (ec *executionContext) marshalOTime2ᚖtimeᚐTime(ctx context.Context, sel return res } +func (ec *executionContext) marshalOTodo2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodo(ctx context.Context, sel ast.SelectionSet, v []*ent.Todo) 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.marshalOTodo2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodo(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalOTodo2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐTodo(ctx context.Context, sel ast.SelectionSet, v *ent.Todo) graphql.Marshaler { if v == nil { return graphql.Null @@ -19457,6 +20152,47 @@ func (ec *executionContext) marshalOUint642ᚖuint64(ctx context.Context, sel as return res } +func (ec *executionContext) marshalOUser2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐUser(ctx context.Context, sel ast.SelectionSet, v []*ent.User) 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.marshalOUser2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐUser(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalOUser2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodogotypeᚋentᚐUser(ctx context.Context, sel ast.SelectionSet, v *ent.User) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/entgql/internal/todogotype/models_gen.go b/entgql/internal/todogotype/models_gen.go index 53370528e..449bd0ad6 100644 --- a/entgql/internal/todogotype/models_gen.go +++ b/entgql/internal/todogotype/models_gen.go @@ -50,6 +50,8 @@ func (OneToMany) IsNode() {} type OneToManyConnection struct { // A list of edges. Edges []*OneToManyEdge `json:"edges,omitempty"` + // A list of nodes. + Nodes []*OneToMany `json:"nodes,omitempty"` // Information to aid in pagination. PageInfo *entgql.PageInfo[string] `json:"pageInfo"` // Identifies the total count of items in the connection. diff --git a/entgql/internal/todopulid/ent/gql_pagination.go b/entgql/internal/todopulid/ent/gql_pagination.go index 1455f3a82..5d1e384f1 100644 --- a/entgql/internal/todopulid/ent/gql_pagination.go +++ b/entgql/internal/todopulid/ent/gql_pagination.go @@ -103,6 +103,7 @@ func hasCollectedField(ctx context.Context, path ...string) bool { const ( edgesField = "edges" + nodesField = "nodes" nodeField = "node" pageInfoField = "pageInfo" totalCountField = "totalCount" @@ -127,6 +128,7 @@ type BillProductEdge struct { // BillProductConnection is the connection containing edges to BillProduct. type BillProductConnection struct { Edges []*BillProductEdge `json:"edges"` + Nodes []*BillProduct `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -153,6 +155,7 @@ func (c *BillProductConnection) build(nodes []*BillProduct, pager *billproductPa } } c.Edges = make([]*BillProductEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &BillProductEdge{ @@ -289,7 +292,7 @@ func (bp *BillProductQuery) Paginate( return nil, err } conn := &BillProductConnection{Edges: []*BillProductEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -317,6 +320,11 @@ func (bp *BillProductQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := bp.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } bp = pager.applyOrder(bp) nodes, err := bp.All(ctx) if err != nil { @@ -376,6 +384,7 @@ type CategoryEdge struct { // CategoryConnection is the connection containing edges to Category. type CategoryConnection struct { Edges []*CategoryEdge `json:"edges"` + Nodes []*Category `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -402,6 +411,7 @@ func (c *CategoryConnection) build(nodes []*Category, pager *categoryPager, afte } } c.Edges = make([]*CategoryEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &CategoryEdge{ @@ -587,7 +597,7 @@ func (c *CategoryQuery) Paginate( return nil, err } conn := &CategoryConnection{Edges: []*CategoryEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -615,6 +625,11 @@ func (c *CategoryQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := c.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } c = pager.applyOrder(c) nodes, err := c.All(ctx) if err != nil { @@ -798,6 +813,7 @@ type FriendshipEdge struct { // FriendshipConnection is the connection containing edges to Friendship. type FriendshipConnection struct { Edges []*FriendshipEdge `json:"edges"` + Nodes []*Friendship `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -824,6 +840,7 @@ func (c *FriendshipConnection) build(nodes []*Friendship, pager *friendshipPager } } c.Edges = make([]*FriendshipEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &FriendshipEdge{ @@ -960,7 +977,7 @@ func (f *FriendshipQuery) Paginate( return nil, err } conn := &FriendshipConnection{Edges: []*FriendshipEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -988,6 +1005,11 @@ func (f *FriendshipQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := f.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } f = pager.applyOrder(f) nodes, err := f.All(ctx) if err != nil { @@ -1047,6 +1069,7 @@ type GroupEdge struct { // GroupConnection is the connection containing edges to Group. type GroupConnection struct { Edges []*GroupEdge `json:"edges"` + Nodes []*Group `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -1073,6 +1096,7 @@ func (c *GroupConnection) build(nodes []*Group, pager *groupPager, after *Cursor } } c.Edges = make([]*GroupEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &GroupEdge{ @@ -1245,7 +1269,7 @@ func (gr *GroupQuery) Paginate( return nil, err } conn := &GroupConnection{Edges: []*GroupEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -1273,6 +1297,11 @@ func (gr *GroupQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := gr.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } gr = pager.applyOrder(gr) nodes, err := gr.All(ctx) if err != nil { @@ -1332,6 +1361,7 @@ type TodoEdge struct { // TodoConnection is the connection containing edges to Todo. type TodoConnection struct { Edges []*TodoEdge `json:"edges"` + Nodes []*Todo `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -1358,6 +1388,7 @@ func (c *TodoConnection) build(nodes []*Todo, pager *todoPager, after *Cursor, f } } c.Edges = make([]*TodoEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &TodoEdge{ @@ -1543,7 +1574,7 @@ func (t *TodoQuery) Paginate( return nil, err } conn := &TodoConnection{Edges: []*TodoEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -1571,6 +1602,11 @@ func (t *TodoQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := t.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } t = pager.applyOrder(t) nodes, err := t.All(ctx) if err != nil { @@ -1802,6 +1838,7 @@ type UserEdge struct { // UserConnection is the connection containing edges to User. type UserConnection struct { Edges []*UserEdge `json:"edges"` + Nodes []*User `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -1828,6 +1865,7 @@ func (c *UserConnection) build(nodes []*User, pager *userPager, after *Cursor, f } } c.Edges = make([]*UserEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &UserEdge{ @@ -1973,7 +2011,7 @@ func (u *UserQuery) Paginate( return nil, err } conn := &UserConnection{Edges: []*UserEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -2001,6 +2039,11 @@ func (u *UserQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := u.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } u = pager.applyOrder(u) nodes, err := u.All(ctx) if err != nil { diff --git a/entgql/internal/todopulid/generated.go b/entgql/internal/todopulid/generated.go index dc1e44ad7..e35367d8c 100644 --- a/entgql/internal/todopulid/generated.go +++ b/entgql/internal/todopulid/generated.go @@ -95,6 +95,7 @@ type ComplexityRoot struct { CategoryConnection struct { Edges func(childComplexity int) int + Nodes func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } @@ -123,6 +124,7 @@ type ComplexityRoot struct { FriendshipConnection struct { Edges func(childComplexity int) int + Nodes func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } @@ -140,6 +142,7 @@ type ComplexityRoot struct { GroupConnection struct { Edges func(childComplexity int) int + Nodes func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } @@ -167,6 +170,7 @@ type ComplexityRoot struct { OneToManyConnection struct { Edges func(childComplexity int) int + Nodes func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } @@ -224,6 +228,7 @@ type ComplexityRoot struct { TodoConnection struct { Edges func(childComplexity int) int + Nodes func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } @@ -246,6 +251,7 @@ type ComplexityRoot struct { UserConnection struct { Edges func(childComplexity int) int + Nodes func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } @@ -482,6 +488,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.CategoryConnection.Edges(childComplexity), true + case "CategoryConnection.nodes": + if e.complexity.CategoryConnection.Nodes == nil { + break + } + + return e.complexity.CategoryConnection.Nodes(childComplexity), true + case "CategoryConnection.pageInfo": if e.complexity.CategoryConnection.PageInfo == nil { break @@ -573,6 +586,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.FriendshipConnection.Edges(childComplexity), true + case "FriendshipConnection.nodes": + if e.complexity.FriendshipConnection.Nodes == nil { + break + } + + return e.complexity.FriendshipConnection.Nodes(childComplexity), true + case "FriendshipConnection.pageInfo": if e.complexity.FriendshipConnection.PageInfo == nil { break @@ -634,6 +654,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.GroupConnection.Edges(childComplexity), true + case "GroupConnection.nodes": + if e.complexity.GroupConnection.Nodes == nil { + break + } + + return e.complexity.GroupConnection.Nodes(childComplexity), true + case "GroupConnection.pageInfo": if e.complexity.GroupConnection.PageInfo == nil { break @@ -759,6 +786,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.OneToManyConnection.Edges(childComplexity), true + case "OneToManyConnection.nodes": + if e.complexity.OneToManyConnection.Nodes == nil { + break + } + + return e.complexity.OneToManyConnection.Nodes(childComplexity), true + case "OneToManyConnection.pageInfo": if e.complexity.OneToManyConnection.PageInfo == nil { break @@ -1061,6 +1095,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.TodoConnection.Edges(childComplexity), true + case "TodoConnection.nodes": + if e.complexity.TodoConnection.Nodes == nil { + break + } + + return e.complexity.TodoConnection.Nodes(childComplexity), true + case "TodoConnection.pageInfo": if e.complexity.TodoConnection.PageInfo == nil { break @@ -1167,6 +1208,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.UserConnection.Edges(childComplexity), true + case "UserConnection.nodes": + if e.complexity.UserConnection.Nodes == nil { + break + } + + return e.complexity.UserConnection.Nodes(childComplexity), true + case "UserConnection.pageInfo": if e.complexity.UserConnection.PageInfo == nil { break @@ -1557,6 +1605,10 @@ type CategoryConnection { """ edges: [CategoryEdge] """ + A list of nodes. + """ + nodes: [Category] + """ Information to aid in pagination. """ pageInfo: PageInfo! @@ -1765,6 +1817,10 @@ type FriendshipConnection { """ edges: [FriendshipEdge] """ + A list of nodes. + """ + nodes: [Friendship] + """ Information to aid in pagination. """ pageInfo: PageInfo! @@ -1861,6 +1917,10 @@ type GroupConnection { """ edges: [GroupEdge] """ + A list of nodes. + """ + nodes: [Group] + """ Information to aid in pagination. """ pageInfo: PageInfo! @@ -1953,6 +2013,10 @@ type OneToManyConnection { """ edges: [OneToManyEdge] """ + A list of nodes. + """ + nodes: [OneToMany] + """ Information to aid in pagination. """ pageInfo: PageInfo! @@ -2424,6 +2488,10 @@ type TodoConnection { """ edges: [TodoEdge] """ + A list of nodes. + """ + nodes: [Todo] + """ Information to aid in pagination. """ pageInfo: PageInfo! @@ -2741,6 +2809,10 @@ type UserConnection { """ edges: [UserEdge] """ + A list of nodes. + """ + nodes: [User] + """ Information to aid in pagination. """ pageInfo: PageInfo! @@ -4402,6 +4474,8 @@ func (ec *executionContext) fieldContext_Category_todos(ctx context.Context, fie switch field.Name { case "edges": return ec.fieldContext_TodoConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_TodoConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_TodoConnection_pageInfo(ctx, field) case "totalCount": @@ -4465,6 +4539,8 @@ func (ec *executionContext) fieldContext_Category_subCategories(ctx context.Cont switch field.Name { case "edges": return ec.fieldContext_CategoryConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_CategoryConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_CategoryConnection_pageInfo(ctx, field) case "totalCount": @@ -4616,6 +4692,71 @@ func (ec *executionContext) fieldContext_CategoryConnection_edges(_ context.Cont return fc, nil } +func (ec *executionContext) _CategoryConnection_nodes(ctx context.Context, field graphql.CollectedField, obj *ent.CategoryConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CategoryConnection_nodes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Nodes, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.Category) + fc.Result = res + return ec.marshalOCategory2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐCategory(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CategoryConnection_nodes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CategoryConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Category_id(ctx, field) + case "text": + return ec.fieldContext_Category_text(ctx, field) + case "status": + return ec.fieldContext_Category_status(ctx, field) + case "config": + return ec.fieldContext_Category_config(ctx, field) + case "types": + return ec.fieldContext_Category_types(ctx, field) + case "duration": + return ec.fieldContext_Category_duration(ctx, field) + case "count": + return ec.fieldContext_Category_count(ctx, field) + case "strings": + return ec.fieldContext_Category_strings(ctx, field) + case "todos": + return ec.fieldContext_Category_todos(ctx, field) + case "subCategories": + return ec.fieldContext_Category_subCategories(ctx, field) + case "todosCount": + return ec.fieldContext_Category_todosCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Category", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _CategoryConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.CategoryConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_CategoryConnection_pageInfo(ctx, field) if err != nil { @@ -5255,6 +5396,61 @@ func (ec *executionContext) fieldContext_FriendshipConnection_edges(_ context.Co return fc, nil } +func (ec *executionContext) _FriendshipConnection_nodes(ctx context.Context, field graphql.CollectedField, obj *ent.FriendshipConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_FriendshipConnection_nodes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Nodes, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.Friendship) + fc.Result = res + return ec.marshalOFriendship2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐFriendship(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_FriendshipConnection_nodes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "FriendshipConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Friendship_id(ctx, field) + case "createdAt": + return ec.fieldContext_Friendship_createdAt(ctx, field) + case "userID": + return ec.fieldContext_Friendship_userID(ctx, field) + case "friendID": + return ec.fieldContext_Friendship_friendID(ctx, field) + case "user": + return ec.fieldContext_Friendship_user(ctx, field) + case "friend": + return ec.fieldContext_Friendship_friend(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Friendship", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _FriendshipConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.FriendshipConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_FriendshipConnection_pageInfo(ctx, field) if err != nil { @@ -5581,6 +5777,8 @@ func (ec *executionContext) fieldContext_Group_users(ctx context.Context, field switch field.Name { case "edges": return ec.fieldContext_UserConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_UserConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_UserConnection_pageInfo(ctx, field) case "totalCount": @@ -5650,6 +5848,79 @@ func (ec *executionContext) fieldContext_GroupConnection_edges(_ context.Context return fc, nil } +func (ec *executionContext) _GroupConnection_nodes(ctx context.Context, field graphql.CollectedField, obj *ent.GroupConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_GroupConnection_nodes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Nodes, nil + } + directive1 := func(ctx context.Context) (interface{}, error) { + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []interface{}{"ADMIN", "MODERATOR"}) + if err != nil { + return nil, err + } + if ec.directives.HasPermissions == nil { + return nil, errors.New("directive hasPermissions is not implemented") + } + return ec.directives.HasPermissions(ctx, obj, directive0, permissions) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*ent.Group); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*entgo.io/contrib/entgql/internal/todopulid/ent.Group`, tmp) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.Group) + fc.Result = res + return ec.marshalOGroup2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐGroup(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_GroupConnection_nodes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "GroupConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Group_id(ctx, field) + case "name": + return ec.fieldContext_Group_name(ctx, field) + case "users": + return ec.fieldContext_Group_users(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Group", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _GroupConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.GroupConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_GroupConnection_pageInfo(ctx, field) if err != nil { @@ -6513,6 +6784,59 @@ func (ec *executionContext) fieldContext_OneToManyConnection_edges(_ context.Con return fc, nil } +func (ec *executionContext) _OneToManyConnection_nodes(ctx context.Context, field graphql.CollectedField, obj *OneToManyConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_OneToManyConnection_nodes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Nodes, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*OneToMany) + fc.Result = res + return ec.marshalOOneToMany2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐOneToMany(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_OneToManyConnection_nodes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "OneToManyConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_OneToMany_id(ctx, field) + case "name": + return ec.fieldContext_OneToMany_name(ctx, field) + case "field2": + return ec.fieldContext_OneToMany_field2(ctx, field) + case "parent": + return ec.fieldContext_OneToMany_parent(ctx, field) + case "children": + return ec.fieldContext_OneToMany_children(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type OneToMany", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _OneToManyConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *OneToManyConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_OneToManyConnection_pageInfo(ctx, field) if err != nil { @@ -7051,6 +7375,8 @@ func (ec *executionContext) fieldContext_Project_todos(ctx context.Context, fiel switch field.Name { case "edges": return ec.fieldContext_TodoConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_TodoConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_TodoConnection_pageInfo(ctx, field) case "totalCount": @@ -7275,6 +7601,8 @@ func (ec *executionContext) fieldContext_Query_categories(ctx context.Context, f switch field.Name { case "edges": return ec.fieldContext_CategoryConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_CategoryConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_CategoryConnection_pageInfo(ctx, field) case "totalCount": @@ -7338,6 +7666,8 @@ func (ec *executionContext) fieldContext_Query_groups(ctx context.Context, field switch field.Name { case "edges": return ec.fieldContext_GroupConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_GroupConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_GroupConnection_pageInfo(ctx, field) case "totalCount": @@ -7401,6 +7731,8 @@ func (ec *executionContext) fieldContext_Query_oneToMany(ctx context.Context, fi switch field.Name { case "edges": return ec.fieldContext_OneToManyConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_OneToManyConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_OneToManyConnection_pageInfo(ctx, field) case "totalCount": @@ -7464,6 +7796,8 @@ func (ec *executionContext) fieldContext_Query_todos(ctx context.Context, field switch field.Name { case "edges": return ec.fieldContext_TodoConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_TodoConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_TodoConnection_pageInfo(ctx, field) case "totalCount": @@ -7527,6 +7861,8 @@ func (ec *executionContext) fieldContext_Query_users(ctx context.Context, field switch field.Name { case "edges": return ec.fieldContext_UserConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_UserConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_UserConnection_pageInfo(ctx, field) case "totalCount": @@ -7634,6 +7970,8 @@ func (ec *executionContext) fieldContext_Query_todosWithJoins(ctx context.Contex switch field.Name { case "edges": return ec.fieldContext_TodoConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_TodoConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_TodoConnection_pageInfo(ctx, field) case "totalCount": @@ -8373,6 +8711,8 @@ func (ec *executionContext) fieldContext_Todo_children(ctx context.Context, fiel switch field.Name { case "edges": return ec.fieldContext_TodoConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_TodoConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_TodoConnection_pageInfo(ctx, field) case "totalCount": @@ -8548,6 +8888,79 @@ func (ec *executionContext) fieldContext_TodoConnection_edges(_ context.Context, return fc, nil } +func (ec *executionContext) _TodoConnection_nodes(ctx context.Context, field graphql.CollectedField, obj *ent.TodoConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TodoConnection_nodes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Nodes, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.Todo) + fc.Result = res + return ec.marshalOTodo2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_TodoConnection_nodes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "TodoConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Todo_id(ctx, field) + case "createdAt": + return ec.fieldContext_Todo_createdAt(ctx, field) + case "status": + return ec.fieldContext_Todo_status(ctx, field) + case "priorityOrder": + return ec.fieldContext_Todo_priorityOrder(ctx, field) + case "text": + return ec.fieldContext_Todo_text(ctx, field) + case "categoryID": + return ec.fieldContext_Todo_categoryID(ctx, field) + case "category_id": + return ec.fieldContext_Todo_category_id(ctx, field) + case "categoryX": + return ec.fieldContext_Todo_categoryX(ctx, field) + case "init": + return ec.fieldContext_Todo_init(ctx, field) + case "custom": + return ec.fieldContext_Todo_custom(ctx, field) + case "customp": + return ec.fieldContext_Todo_customp(ctx, field) + case "parent": + return ec.fieldContext_Todo_parent(ctx, field) + case "children": + return ec.fieldContext_Todo_children(ctx, field) + case "category": + return ec.fieldContext_Todo_category(ctx, field) + case "extendedField": + return ec.fieldContext_Todo_extendedField(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _TodoConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TodoConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_TodoConnection_pageInfo(ctx, field) if err != nil { @@ -9021,6 +9434,8 @@ func (ec *executionContext) fieldContext_User_groups(ctx context.Context, field switch field.Name { case "edges": return ec.fieldContext_GroupConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_GroupConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_GroupConnection_pageInfo(ctx, field) case "totalCount": @@ -9084,6 +9499,8 @@ func (ec *executionContext) fieldContext_User_friends(ctx context.Context, field switch field.Name { case "edges": return ec.fieldContext_UserConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_UserConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_UserConnection_pageInfo(ctx, field) case "totalCount": @@ -9147,6 +9564,8 @@ func (ec *executionContext) fieldContext_User_friendships(ctx context.Context, f switch field.Name { case "edges": return ec.fieldContext_FriendshipConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_FriendshipConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_FriendshipConnection_pageInfo(ctx, field) case "totalCount": @@ -9210,7 +9629,66 @@ func (ec *executionContext) fieldContext_UserConnection_edges(_ context.Context, case "cursor": return ec.fieldContext_UserEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type UserEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _UserConnection_nodes(ctx context.Context, field graphql.CollectedField, obj *ent.UserConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserConnection_nodes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Nodes, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.User) + fc.Result = res + return ec.marshalOUser2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_UserConnection_nodes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "UserConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "username": + return ec.fieldContext_User_username(ctx, field) + case "requiredMetadata": + return ec.fieldContext_User_requiredMetadata(ctx, field) + case "metadata": + return ec.fieldContext_User_metadata(ctx, field) + case "groups": + return ec.fieldContext_User_groups(ctx, field) + case "friends": + return ec.fieldContext_User_friends(ctx, field) + case "friendships": + return ec.fieldContext_User_friendships(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil @@ -14927,6 +15405,8 @@ func (ec *executionContext) _CategoryConnection(ctx context.Context, sel ast.Sel out.Values[i] = graphql.MarshalString("CategoryConnection") case "edges": out.Values[i] = ec._CategoryConnection_edges(ctx, field, obj) + case "nodes": + out.Values[i] = ec._CategoryConnection_nodes(ctx, field, obj) case "pageInfo": out.Values[i] = ec._CategoryConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -15215,6 +15695,8 @@ func (ec *executionContext) _FriendshipConnection(ctx context.Context, sel ast.S out.Values[i] = graphql.MarshalString("FriendshipConnection") case "edges": out.Values[i] = ec._FriendshipConnection_edges(ctx, field, obj) + case "nodes": + out.Values[i] = ec._FriendshipConnection_nodes(ctx, field, obj) case "pageInfo": out.Values[i] = ec._FriendshipConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -15382,6 +15864,8 @@ func (ec *executionContext) _GroupConnection(ctx context.Context, sel ast.Select out.Values[i] = graphql.MarshalString("GroupConnection") case "edges": out.Values[i] = ec._GroupConnection_edges(ctx, field, obj) + case "nodes": + out.Values[i] = ec._GroupConnection_nodes(ctx, field, obj) case "pageInfo": out.Values[i] = ec._GroupConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -15596,6 +16080,8 @@ func (ec *executionContext) _OneToManyConnection(ctx context.Context, sel ast.Se out.Values[i] = graphql.MarshalString("OneToManyConnection") case "edges": out.Values[i] = ec._OneToManyConnection_edges(ctx, field, obj) + case "nodes": + out.Values[i] = ec._OneToManyConnection_nodes(ctx, field, obj) case "pageInfo": out.Values[i] = ec._OneToManyConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -16354,6 +16840,8 @@ func (ec *executionContext) _TodoConnection(ctx context.Context, sel ast.Selecti out.Values[i] = graphql.MarshalString("TodoConnection") case "edges": out.Values[i] = ec._TodoConnection_edges(ctx, field, obj) + case "nodes": + out.Values[i] = ec._TodoConnection_nodes(ctx, field, obj) case "pageInfo": out.Values[i] = ec._TodoConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -16636,6 +17124,8 @@ func (ec *executionContext) _UserConnection(ctx context.Context, sel ast.Selecti out.Values[i] = graphql.MarshalString("UserConnection") case "edges": out.Values[i] = ec._UserConnection_edges(ctx, field, obj) + case "nodes": + out.Values[i] = ec._UserConnection_nodes(ctx, field, obj) case "pageInfo": out.Values[i] = ec._UserConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -17982,6 +18472,47 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast return res } +func (ec *executionContext) marshalOCategory2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐCategory(ctx context.Context, sel ast.SelectionSet, v []*ent.Category) 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.marshalOCategory2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐCategory(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalOCategory2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐCategory(ctx context.Context, sel ast.SelectionSet, v *ent.Category) graphql.Marshaler { if v == nil { return graphql.Null @@ -18413,6 +18944,47 @@ func (ec *executionContext) marshalODuration2ᚖtimeᚐDuration(ctx context.Cont return res } +func (ec *executionContext) marshalOFriendship2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐFriendship(ctx context.Context, sel ast.SelectionSet, v []*ent.Friendship) 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.marshalOFriendship2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐFriendship(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalOFriendship2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐFriendship(ctx context.Context, sel ast.SelectionSet, v *ent.Friendship) graphql.Marshaler { if v == nil { return graphql.Null @@ -18496,6 +19068,47 @@ func (ec *executionContext) unmarshalOFriendshipWhereInput2ᚖentgoᚗioᚋcontr return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOGroup2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐGroup(ctx context.Context, sel ast.SelectionSet, v []*ent.Group) 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.marshalOGroup2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐGroup(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalOGroup2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐGroup(ctx context.Context, sel ast.SelectionSet, v *ent.Group) graphql.Marshaler { if v == nil { return graphql.Null @@ -18730,6 +19343,47 @@ func (ec *executionContext) marshalONode2entgoᚗioᚋcontribᚋentgqlᚋinterna return ec._Node(ctx, sel, v) } +func (ec *executionContext) marshalOOneToMany2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐOneToMany(ctx context.Context, sel ast.SelectionSet, v []*OneToMany) 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.marshalOOneToMany2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐOneToMany(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalOOneToMany2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚐOneToManyᚄ(ctx context.Context, sel ast.SelectionSet, v []*OneToMany) graphql.Marshaler { if v == nil { return graphql.Null @@ -19032,6 +19686,47 @@ func (ec *executionContext) marshalOTime2ᚖtimeᚐTime(ctx context.Context, sel return res } +func (ec *executionContext) marshalOTodo2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodo(ctx context.Context, sel ast.SelectionSet, v []*ent.Todo) 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.marshalOTodo2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodo(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalOTodo2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐTodo(ctx context.Context, sel ast.SelectionSet, v *ent.Todo) graphql.Marshaler { if v == nil { return graphql.Null @@ -19336,6 +20031,47 @@ func (ec *executionContext) marshalOUint642ᚖuint64(ctx context.Context, sel as return res } +func (ec *executionContext) marshalOUser2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐUser(ctx context.Context, sel ast.SelectionSet, v []*ent.User) 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.marshalOUser2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐUser(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalOUser2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodopulidᚋentᚐUser(ctx context.Context, sel ast.SelectionSet, v *ent.User) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/entgql/internal/todopulid/models_gen.go b/entgql/internal/todopulid/models_gen.go index bfaee0f16..badf57059 100644 --- a/entgql/internal/todopulid/models_gen.go +++ b/entgql/internal/todopulid/models_gen.go @@ -39,6 +39,8 @@ func (OneToMany) IsNode() {} type OneToManyConnection struct { // A list of edges. Edges []*OneToManyEdge `json:"edges,omitempty"` + // A list of nodes. + Nodes []*OneToMany `json:"nodes,omitempty"` // Information to aid in pagination. PageInfo *entgql.PageInfo[pulid.ID] `json:"pageInfo"` // Identifies the total count of items in the connection. diff --git a/entgql/internal/todouuid/ent/gql_pagination.go b/entgql/internal/todouuid/ent/gql_pagination.go index 4b1756f64..cc45a5ad8 100644 --- a/entgql/internal/todouuid/ent/gql_pagination.go +++ b/entgql/internal/todouuid/ent/gql_pagination.go @@ -103,6 +103,7 @@ func hasCollectedField(ctx context.Context, path ...string) bool { const ( edgesField = "edges" + nodesField = "nodes" nodeField = "node" pageInfoField = "pageInfo" totalCountField = "totalCount" @@ -127,6 +128,7 @@ type BillProductEdge struct { // BillProductConnection is the connection containing edges to BillProduct. type BillProductConnection struct { Edges []*BillProductEdge `json:"edges"` + Nodes []*BillProduct `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -153,6 +155,7 @@ func (c *BillProductConnection) build(nodes []*BillProduct, pager *billproductPa } } c.Edges = make([]*BillProductEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &BillProductEdge{ @@ -289,7 +292,7 @@ func (bp *BillProductQuery) Paginate( return nil, err } conn := &BillProductConnection{Edges: []*BillProductEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -317,6 +320,11 @@ func (bp *BillProductQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := bp.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } bp = pager.applyOrder(bp) nodes, err := bp.All(ctx) if err != nil { @@ -376,6 +384,7 @@ type CategoryEdge struct { // CategoryConnection is the connection containing edges to Category. type CategoryConnection struct { Edges []*CategoryEdge `json:"edges"` + Nodes []*Category `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -402,6 +411,7 @@ func (c *CategoryConnection) build(nodes []*Category, pager *categoryPager, afte } } c.Edges = make([]*CategoryEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &CategoryEdge{ @@ -587,7 +597,7 @@ func (c *CategoryQuery) Paginate( return nil, err } conn := &CategoryConnection{Edges: []*CategoryEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -615,6 +625,11 @@ func (c *CategoryQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := c.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } c = pager.applyOrder(c) nodes, err := c.All(ctx) if err != nil { @@ -798,6 +813,7 @@ type FriendshipEdge struct { // FriendshipConnection is the connection containing edges to Friendship. type FriendshipConnection struct { Edges []*FriendshipEdge `json:"edges"` + Nodes []*Friendship `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -824,6 +840,7 @@ func (c *FriendshipConnection) build(nodes []*Friendship, pager *friendshipPager } } c.Edges = make([]*FriendshipEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &FriendshipEdge{ @@ -960,7 +977,7 @@ func (f *FriendshipQuery) Paginate( return nil, err } conn := &FriendshipConnection{Edges: []*FriendshipEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -988,6 +1005,11 @@ func (f *FriendshipQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := f.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } f = pager.applyOrder(f) nodes, err := f.All(ctx) if err != nil { @@ -1047,6 +1069,7 @@ type GroupEdge struct { // GroupConnection is the connection containing edges to Group. type GroupConnection struct { Edges []*GroupEdge `json:"edges"` + Nodes []*Group `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -1073,6 +1096,7 @@ func (c *GroupConnection) build(nodes []*Group, pager *groupPager, after *Cursor } } c.Edges = make([]*GroupEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &GroupEdge{ @@ -1245,7 +1269,7 @@ func (gr *GroupQuery) Paginate( return nil, err } conn := &GroupConnection{Edges: []*GroupEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -1273,6 +1297,11 @@ func (gr *GroupQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := gr.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } gr = pager.applyOrder(gr) nodes, err := gr.All(ctx) if err != nil { @@ -1332,6 +1361,7 @@ type TodoEdge struct { // TodoConnection is the connection containing edges to Todo. type TodoConnection struct { Edges []*TodoEdge `json:"edges"` + Nodes []*Todo `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -1358,6 +1388,7 @@ func (c *TodoConnection) build(nodes []*Todo, pager *todoPager, after *Cursor, f } } c.Edges = make([]*TodoEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &TodoEdge{ @@ -1543,7 +1574,7 @@ func (t *TodoQuery) Paginate( return nil, err } conn := &TodoConnection{Edges: []*TodoEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -1571,6 +1602,11 @@ func (t *TodoQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := t.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } t = pager.applyOrder(t) nodes, err := t.All(ctx) if err != nil { @@ -1802,6 +1838,7 @@ type UserEdge struct { // UserConnection is the connection containing edges to User. type UserConnection struct { Edges []*UserEdge `json:"edges"` + Nodes []*User `json:"nodes"` PageInfo PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } @@ -1828,6 +1865,7 @@ func (c *UserConnection) build(nodes []*User, pager *userPager, after *Cursor, f } } c.Edges = make([]*UserEdge, len(nodes)) + c.Nodes = nodes for i := range nodes { node := nodeAt(i) c.Edges[i] = &UserEdge{ @@ -1973,7 +2011,7 @@ func (u *UserQuery) Paginate( return nil, err } conn := &UserConnection{Edges: []*UserEdge{}} - ignoredEdges := !hasCollectedField(ctx, edgesField) + ignoredEdges := !hasCollectedField(ctx, edgesField) && !hasCollectedField(ctx, nodesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { @@ -2001,6 +2039,11 @@ func (u *UserQuery) Paginate( return nil, err } } + if field := collectedField(ctx, nodesField); field != nil { + if err := u.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{nodesField}); err != nil { + return nil, err + } + } u = pager.applyOrder(u) nodes, err := u.All(ctx) if err != nil { diff --git a/entgql/internal/todouuid/generated.go b/entgql/internal/todouuid/generated.go index 92795d3d6..6f2969d31 100644 --- a/entgql/internal/todouuid/generated.go +++ b/entgql/internal/todouuid/generated.go @@ -96,6 +96,7 @@ type ComplexityRoot struct { CategoryConnection struct { Edges func(childComplexity int) int + Nodes func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } @@ -124,6 +125,7 @@ type ComplexityRoot struct { FriendshipConnection struct { Edges func(childComplexity int) int + Nodes func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } @@ -141,6 +143,7 @@ type ComplexityRoot struct { GroupConnection struct { Edges func(childComplexity int) int + Nodes func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } @@ -168,6 +171,7 @@ type ComplexityRoot struct { OneToManyConnection struct { Edges func(childComplexity int) int + Nodes func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } @@ -225,6 +229,7 @@ type ComplexityRoot struct { TodoConnection struct { Edges func(childComplexity int) int + Nodes func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } @@ -247,6 +252,7 @@ type ComplexityRoot struct { UserConnection struct { Edges func(childComplexity int) int + Nodes func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } @@ -483,6 +489,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.CategoryConnection.Edges(childComplexity), true + case "CategoryConnection.nodes": + if e.complexity.CategoryConnection.Nodes == nil { + break + } + + return e.complexity.CategoryConnection.Nodes(childComplexity), true + case "CategoryConnection.pageInfo": if e.complexity.CategoryConnection.PageInfo == nil { break @@ -574,6 +587,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.FriendshipConnection.Edges(childComplexity), true + case "FriendshipConnection.nodes": + if e.complexity.FriendshipConnection.Nodes == nil { + break + } + + return e.complexity.FriendshipConnection.Nodes(childComplexity), true + case "FriendshipConnection.pageInfo": if e.complexity.FriendshipConnection.PageInfo == nil { break @@ -635,6 +655,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.GroupConnection.Edges(childComplexity), true + case "GroupConnection.nodes": + if e.complexity.GroupConnection.Nodes == nil { + break + } + + return e.complexity.GroupConnection.Nodes(childComplexity), true + case "GroupConnection.pageInfo": if e.complexity.GroupConnection.PageInfo == nil { break @@ -760,6 +787,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.OneToManyConnection.Edges(childComplexity), true + case "OneToManyConnection.nodes": + if e.complexity.OneToManyConnection.Nodes == nil { + break + } + + return e.complexity.OneToManyConnection.Nodes(childComplexity), true + case "OneToManyConnection.pageInfo": if e.complexity.OneToManyConnection.PageInfo == nil { break @@ -1062,6 +1096,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.TodoConnection.Edges(childComplexity), true + case "TodoConnection.nodes": + if e.complexity.TodoConnection.Nodes == nil { + break + } + + return e.complexity.TodoConnection.Nodes(childComplexity), true + case "TodoConnection.pageInfo": if e.complexity.TodoConnection.PageInfo == nil { break @@ -1168,6 +1209,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.UserConnection.Edges(childComplexity), true + case "UserConnection.nodes": + if e.complexity.UserConnection.Nodes == nil { + break + } + + return e.complexity.UserConnection.Nodes(childComplexity), true + case "UserConnection.pageInfo": if e.complexity.UserConnection.PageInfo == nil { break @@ -1558,6 +1606,10 @@ type CategoryConnection { """ edges: [CategoryEdge] """ + A list of nodes. + """ + nodes: [Category] + """ Information to aid in pagination. """ pageInfo: PageInfo! @@ -1766,6 +1818,10 @@ type FriendshipConnection { """ edges: [FriendshipEdge] """ + A list of nodes. + """ + nodes: [Friendship] + """ Information to aid in pagination. """ pageInfo: PageInfo! @@ -1862,6 +1918,10 @@ type GroupConnection { """ edges: [GroupEdge] """ + A list of nodes. + """ + nodes: [Group] + """ Information to aid in pagination. """ pageInfo: PageInfo! @@ -1954,6 +2014,10 @@ type OneToManyConnection { """ edges: [OneToManyEdge] """ + A list of nodes. + """ + nodes: [OneToMany] + """ Information to aid in pagination. """ pageInfo: PageInfo! @@ -2425,6 +2489,10 @@ type TodoConnection { """ edges: [TodoEdge] """ + A list of nodes. + """ + nodes: [Todo] + """ Information to aid in pagination. """ pageInfo: PageInfo! @@ -2742,6 +2810,10 @@ type UserConnection { """ edges: [UserEdge] """ + A list of nodes. + """ + nodes: [User] + """ Information to aid in pagination. """ pageInfo: PageInfo! @@ -4403,6 +4475,8 @@ func (ec *executionContext) fieldContext_Category_todos(ctx context.Context, fie switch field.Name { case "edges": return ec.fieldContext_TodoConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_TodoConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_TodoConnection_pageInfo(ctx, field) case "totalCount": @@ -4466,6 +4540,8 @@ func (ec *executionContext) fieldContext_Category_subCategories(ctx context.Cont switch field.Name { case "edges": return ec.fieldContext_CategoryConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_CategoryConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_CategoryConnection_pageInfo(ctx, field) case "totalCount": @@ -4617,6 +4693,71 @@ func (ec *executionContext) fieldContext_CategoryConnection_edges(_ context.Cont return fc, nil } +func (ec *executionContext) _CategoryConnection_nodes(ctx context.Context, field graphql.CollectedField, obj *ent.CategoryConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CategoryConnection_nodes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Nodes, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.Category) + fc.Result = res + return ec.marshalOCategory2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐCategory(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CategoryConnection_nodes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CategoryConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Category_id(ctx, field) + case "text": + return ec.fieldContext_Category_text(ctx, field) + case "status": + return ec.fieldContext_Category_status(ctx, field) + case "config": + return ec.fieldContext_Category_config(ctx, field) + case "types": + return ec.fieldContext_Category_types(ctx, field) + case "duration": + return ec.fieldContext_Category_duration(ctx, field) + case "count": + return ec.fieldContext_Category_count(ctx, field) + case "strings": + return ec.fieldContext_Category_strings(ctx, field) + case "todos": + return ec.fieldContext_Category_todos(ctx, field) + case "subCategories": + return ec.fieldContext_Category_subCategories(ctx, field) + case "todosCount": + return ec.fieldContext_Category_todosCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Category", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _CategoryConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.CategoryConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_CategoryConnection_pageInfo(ctx, field) if err != nil { @@ -5256,6 +5397,61 @@ func (ec *executionContext) fieldContext_FriendshipConnection_edges(_ context.Co return fc, nil } +func (ec *executionContext) _FriendshipConnection_nodes(ctx context.Context, field graphql.CollectedField, obj *ent.FriendshipConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_FriendshipConnection_nodes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Nodes, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.Friendship) + fc.Result = res + return ec.marshalOFriendship2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐFriendship(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_FriendshipConnection_nodes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "FriendshipConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Friendship_id(ctx, field) + case "createdAt": + return ec.fieldContext_Friendship_createdAt(ctx, field) + case "userID": + return ec.fieldContext_Friendship_userID(ctx, field) + case "friendID": + return ec.fieldContext_Friendship_friendID(ctx, field) + case "user": + return ec.fieldContext_Friendship_user(ctx, field) + case "friend": + return ec.fieldContext_Friendship_friend(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Friendship", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _FriendshipConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.FriendshipConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_FriendshipConnection_pageInfo(ctx, field) if err != nil { @@ -5582,6 +5778,8 @@ func (ec *executionContext) fieldContext_Group_users(ctx context.Context, field switch field.Name { case "edges": return ec.fieldContext_UserConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_UserConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_UserConnection_pageInfo(ctx, field) case "totalCount": @@ -5651,6 +5849,79 @@ func (ec *executionContext) fieldContext_GroupConnection_edges(_ context.Context return fc, nil } +func (ec *executionContext) _GroupConnection_nodes(ctx context.Context, field graphql.CollectedField, obj *ent.GroupConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_GroupConnection_nodes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Nodes, nil + } + directive1 := func(ctx context.Context) (interface{}, error) { + permissions, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []interface{}{"ADMIN", "MODERATOR"}) + if err != nil { + return nil, err + } + if ec.directives.HasPermissions == nil { + return nil, errors.New("directive hasPermissions is not implemented") + } + return ec.directives.HasPermissions(ctx, obj, directive0, permissions) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*ent.Group); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*entgo.io/contrib/entgql/internal/todouuid/ent.Group`, tmp) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.Group) + fc.Result = res + return ec.marshalOGroup2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐGroup(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_GroupConnection_nodes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "GroupConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Group_id(ctx, field) + case "name": + return ec.fieldContext_Group_name(ctx, field) + case "users": + return ec.fieldContext_Group_users(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Group", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _GroupConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.GroupConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_GroupConnection_pageInfo(ctx, field) if err != nil { @@ -6514,6 +6785,59 @@ func (ec *executionContext) fieldContext_OneToManyConnection_edges(_ context.Con return fc, nil } +func (ec *executionContext) _OneToManyConnection_nodes(ctx context.Context, field graphql.CollectedField, obj *OneToManyConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_OneToManyConnection_nodes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Nodes, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*OneToMany) + fc.Result = res + return ec.marshalOOneToMany2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐOneToMany(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_OneToManyConnection_nodes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "OneToManyConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_OneToMany_id(ctx, field) + case "name": + return ec.fieldContext_OneToMany_name(ctx, field) + case "field2": + return ec.fieldContext_OneToMany_field2(ctx, field) + case "parent": + return ec.fieldContext_OneToMany_parent(ctx, field) + case "children": + return ec.fieldContext_OneToMany_children(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type OneToMany", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _OneToManyConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *OneToManyConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_OneToManyConnection_pageInfo(ctx, field) if err != nil { @@ -7052,6 +7376,8 @@ func (ec *executionContext) fieldContext_Project_todos(ctx context.Context, fiel switch field.Name { case "edges": return ec.fieldContext_TodoConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_TodoConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_TodoConnection_pageInfo(ctx, field) case "totalCount": @@ -7276,6 +7602,8 @@ func (ec *executionContext) fieldContext_Query_categories(ctx context.Context, f switch field.Name { case "edges": return ec.fieldContext_CategoryConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_CategoryConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_CategoryConnection_pageInfo(ctx, field) case "totalCount": @@ -7339,6 +7667,8 @@ func (ec *executionContext) fieldContext_Query_groups(ctx context.Context, field switch field.Name { case "edges": return ec.fieldContext_GroupConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_GroupConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_GroupConnection_pageInfo(ctx, field) case "totalCount": @@ -7402,6 +7732,8 @@ func (ec *executionContext) fieldContext_Query_oneToMany(ctx context.Context, fi switch field.Name { case "edges": return ec.fieldContext_OneToManyConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_OneToManyConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_OneToManyConnection_pageInfo(ctx, field) case "totalCount": @@ -7465,6 +7797,8 @@ func (ec *executionContext) fieldContext_Query_todos(ctx context.Context, field switch field.Name { case "edges": return ec.fieldContext_TodoConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_TodoConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_TodoConnection_pageInfo(ctx, field) case "totalCount": @@ -7528,6 +7862,8 @@ func (ec *executionContext) fieldContext_Query_users(ctx context.Context, field switch field.Name { case "edges": return ec.fieldContext_UserConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_UserConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_UserConnection_pageInfo(ctx, field) case "totalCount": @@ -7635,6 +7971,8 @@ func (ec *executionContext) fieldContext_Query_todosWithJoins(ctx context.Contex switch field.Name { case "edges": return ec.fieldContext_TodoConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_TodoConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_TodoConnection_pageInfo(ctx, field) case "totalCount": @@ -8374,6 +8712,8 @@ func (ec *executionContext) fieldContext_Todo_children(ctx context.Context, fiel switch field.Name { case "edges": return ec.fieldContext_TodoConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_TodoConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_TodoConnection_pageInfo(ctx, field) case "totalCount": @@ -8549,6 +8889,79 @@ func (ec *executionContext) fieldContext_TodoConnection_edges(_ context.Context, return fc, nil } +func (ec *executionContext) _TodoConnection_nodes(ctx context.Context, field graphql.CollectedField, obj *ent.TodoConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TodoConnection_nodes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Nodes, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.Todo) + fc.Result = res + return ec.marshalOTodo2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_TodoConnection_nodes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "TodoConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Todo_id(ctx, field) + case "createdAt": + return ec.fieldContext_Todo_createdAt(ctx, field) + case "status": + return ec.fieldContext_Todo_status(ctx, field) + case "priorityOrder": + return ec.fieldContext_Todo_priorityOrder(ctx, field) + case "text": + return ec.fieldContext_Todo_text(ctx, field) + case "categoryID": + return ec.fieldContext_Todo_categoryID(ctx, field) + case "category_id": + return ec.fieldContext_Todo_category_id(ctx, field) + case "categoryX": + return ec.fieldContext_Todo_categoryX(ctx, field) + case "init": + return ec.fieldContext_Todo_init(ctx, field) + case "custom": + return ec.fieldContext_Todo_custom(ctx, field) + case "customp": + return ec.fieldContext_Todo_customp(ctx, field) + case "parent": + return ec.fieldContext_Todo_parent(ctx, field) + case "children": + return ec.fieldContext_Todo_children(ctx, field) + case "category": + return ec.fieldContext_Todo_category(ctx, field) + case "extendedField": + return ec.fieldContext_Todo_extendedField(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _TodoConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TodoConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_TodoConnection_pageInfo(ctx, field) if err != nil { @@ -9022,6 +9435,8 @@ func (ec *executionContext) fieldContext_User_groups(ctx context.Context, field switch field.Name { case "edges": return ec.fieldContext_GroupConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_GroupConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_GroupConnection_pageInfo(ctx, field) case "totalCount": @@ -9085,6 +9500,8 @@ func (ec *executionContext) fieldContext_User_friends(ctx context.Context, field switch field.Name { case "edges": return ec.fieldContext_UserConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_UserConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_UserConnection_pageInfo(ctx, field) case "totalCount": @@ -9148,6 +9565,8 @@ func (ec *executionContext) fieldContext_User_friendships(ctx context.Context, f switch field.Name { case "edges": return ec.fieldContext_FriendshipConnection_edges(ctx, field) + case "nodes": + return ec.fieldContext_FriendshipConnection_nodes(ctx, field) case "pageInfo": return ec.fieldContext_FriendshipConnection_pageInfo(ctx, field) case "totalCount": @@ -9211,7 +9630,66 @@ func (ec *executionContext) fieldContext_UserConnection_edges(_ context.Context, case "cursor": return ec.fieldContext_UserEdge_cursor(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type UserEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type UserEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _UserConnection_nodes(ctx context.Context, field graphql.CollectedField, obj *ent.UserConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_UserConnection_nodes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Nodes, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.User) + fc.Result = res + return ec.marshalOUser2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_UserConnection_nodes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "UserConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "username": + return ec.fieldContext_User_username(ctx, field) + case "requiredMetadata": + return ec.fieldContext_User_requiredMetadata(ctx, field) + case "metadata": + return ec.fieldContext_User_metadata(ctx, field) + case "groups": + return ec.fieldContext_User_groups(ctx, field) + case "friends": + return ec.fieldContext_User_friends(ctx, field) + case "friendships": + return ec.fieldContext_User_friendships(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil @@ -14928,6 +15406,8 @@ func (ec *executionContext) _CategoryConnection(ctx context.Context, sel ast.Sel out.Values[i] = graphql.MarshalString("CategoryConnection") case "edges": out.Values[i] = ec._CategoryConnection_edges(ctx, field, obj) + case "nodes": + out.Values[i] = ec._CategoryConnection_nodes(ctx, field, obj) case "pageInfo": out.Values[i] = ec._CategoryConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -15216,6 +15696,8 @@ func (ec *executionContext) _FriendshipConnection(ctx context.Context, sel ast.S out.Values[i] = graphql.MarshalString("FriendshipConnection") case "edges": out.Values[i] = ec._FriendshipConnection_edges(ctx, field, obj) + case "nodes": + out.Values[i] = ec._FriendshipConnection_nodes(ctx, field, obj) case "pageInfo": out.Values[i] = ec._FriendshipConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -15383,6 +15865,8 @@ func (ec *executionContext) _GroupConnection(ctx context.Context, sel ast.Select out.Values[i] = graphql.MarshalString("GroupConnection") case "edges": out.Values[i] = ec._GroupConnection_edges(ctx, field, obj) + case "nodes": + out.Values[i] = ec._GroupConnection_nodes(ctx, field, obj) case "pageInfo": out.Values[i] = ec._GroupConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -15597,6 +16081,8 @@ func (ec *executionContext) _OneToManyConnection(ctx context.Context, sel ast.Se out.Values[i] = graphql.MarshalString("OneToManyConnection") case "edges": out.Values[i] = ec._OneToManyConnection_edges(ctx, field, obj) + case "nodes": + out.Values[i] = ec._OneToManyConnection_nodes(ctx, field, obj) case "pageInfo": out.Values[i] = ec._OneToManyConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -16355,6 +16841,8 @@ func (ec *executionContext) _TodoConnection(ctx context.Context, sel ast.Selecti out.Values[i] = graphql.MarshalString("TodoConnection") case "edges": out.Values[i] = ec._TodoConnection_edges(ctx, field, obj) + case "nodes": + out.Values[i] = ec._TodoConnection_nodes(ctx, field, obj) case "pageInfo": out.Values[i] = ec._TodoConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -16637,6 +17125,8 @@ func (ec *executionContext) _UserConnection(ctx context.Context, sel ast.Selecti out.Values[i] = graphql.MarshalString("UserConnection") case "edges": out.Values[i] = ec._UserConnection_edges(ctx, field, obj) + case "nodes": + out.Values[i] = ec._UserConnection_nodes(ctx, field, obj) case "pageInfo": out.Values[i] = ec._UserConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -17988,6 +18478,47 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast return res } +func (ec *executionContext) marshalOCategory2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐCategory(ctx context.Context, sel ast.SelectionSet, v []*ent.Category) 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.marshalOCategory2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐCategory(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalOCategory2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐCategory(ctx context.Context, sel ast.SelectionSet, v *ent.Category) graphql.Marshaler { if v == nil { return graphql.Null @@ -18419,6 +18950,47 @@ func (ec *executionContext) marshalODuration2ᚖtimeᚐDuration(ctx context.Cont return res } +func (ec *executionContext) marshalOFriendship2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐFriendship(ctx context.Context, sel ast.SelectionSet, v []*ent.Friendship) 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.marshalOFriendship2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐFriendship(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalOFriendship2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐFriendship(ctx context.Context, sel ast.SelectionSet, v *ent.Friendship) graphql.Marshaler { if v == nil { return graphql.Null @@ -18502,6 +19074,47 @@ func (ec *executionContext) unmarshalOFriendshipWhereInput2ᚖentgoᚗioᚋcontr return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOGroup2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐGroup(ctx context.Context, sel ast.SelectionSet, v []*ent.Group) 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.marshalOGroup2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐGroup(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalOGroup2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐGroup(ctx context.Context, sel ast.SelectionSet, v *ent.Group) graphql.Marshaler { if v == nil { return graphql.Null @@ -18736,6 +19349,47 @@ func (ec *executionContext) marshalONode2entgoᚗioᚋcontribᚋentgqlᚋinterna return ec._Node(ctx, sel, v) } +func (ec *executionContext) marshalOOneToMany2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐOneToMany(ctx context.Context, sel ast.SelectionSet, v []*OneToMany) 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.marshalOOneToMany2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐOneToMany(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalOOneToMany2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚐOneToManyᚄ(ctx context.Context, sel ast.SelectionSet, v []*OneToMany) graphql.Marshaler { if v == nil { return graphql.Null @@ -19038,6 +19692,47 @@ func (ec *executionContext) marshalOTime2ᚖtimeᚐTime(ctx context.Context, sel return res } +func (ec *executionContext) marshalOTodo2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodo(ctx context.Context, sel ast.SelectionSet, v []*ent.Todo) 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.marshalOTodo2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodo(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalOTodo2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐTodo(ctx context.Context, sel ast.SelectionSet, v *ent.Todo) graphql.Marshaler { if v == nil { return graphql.Null @@ -19342,6 +20037,47 @@ func (ec *executionContext) marshalOUint642ᚖuint64(ctx context.Context, sel as return res } +func (ec *executionContext) marshalOUser2ᚕᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐUser(ctx context.Context, sel ast.SelectionSet, v []*ent.User) 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.marshalOUser2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐUser(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + func (ec *executionContext) marshalOUser2ᚖentgoᚗioᚋcontribᚋentgqlᚋinternalᚋtodouuidᚋentᚐUser(ctx context.Context, sel ast.SelectionSet, v *ent.User) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/entgql/internal/todouuid/models_gen.go b/entgql/internal/todouuid/models_gen.go index 91247fbee..087900fb0 100644 --- a/entgql/internal/todouuid/models_gen.go +++ b/entgql/internal/todouuid/models_gen.go @@ -39,6 +39,8 @@ func (OneToMany) IsNode() {} type OneToManyConnection struct { // A list of edges. Edges []*OneToManyEdge `json:"edges,omitempty"` + // A list of nodes. + Nodes []*OneToMany `json:"nodes,omitempty"` // Information to aid in pagination. PageInfo *entgql.PageInfo[uuid.UUID] `json:"pageInfo"` // Identifies the total count of items in the connection.