From f892156622766311d04b0dc4ba908d1e0321e3dd Mon Sep 17 00:00:00 2001 From: Mikhail Swift Date: Tue, 11 Oct 2022 18:44:53 -0400 Subject: [PATCH] feat: add filtering and pagination to subjects --- ent.graphql | 49 ++- ent.resolvers.go | 18 + ent/gql_collection.go | 93 ++++- ent/gql_edge.go | 79 +++- ent/schema/statement.go | 3 +- ent/schema/subject.go | 9 + generated.go | 771 ++++++++++++++++++++++++++++++++++++---- 7 files changed, 943 insertions(+), 79 deletions(-) diff --git a/ent.graphql b/ent.graphql index 52fef015..97dbcdd8 100644 --- a/ent.graphql +++ b/ent.graphql @@ -279,6 +279,22 @@ type Query { """Filtering options for Dsses returned from the connection.""" where: DsseWhereInput ): DsseConnection! + subjects( + """Returns the elements in the list that come after the specified cursor.""" + after: Cursor + + """Returns the first _n_ elements from the list.""" + first: Int + + """Returns the elements in the list that come before the specified cursor.""" + before: Cursor + + """Returns the last _n_ elements from the list.""" + last: Int + + """Filtering options for Subjects returned from the connection.""" + where: SubjectWhereInput + ): SubjectConnection! } type Signature implements Node { id: ID! @@ -338,7 +354,22 @@ input SignatureWhereInput { type Statement implements Node { id: ID! predicate: String! - subjects: [Subject!] + subjects( + """Returns the elements in the list that come after the specified cursor.""" + after: Cursor + + """Returns the first _n_ elements from the list.""" + first: Int + + """Returns the elements in the list that come before the specified cursor.""" + before: Cursor + + """Returns the last _n_ elements from the list.""" + last: Int + + """Filtering options for Subjects returned from the connection.""" + where: SubjectWhereInput + ): SubjectConnection! attestationCollections: AttestationCollection dsse: [Dsse!] } @@ -389,6 +420,15 @@ type Subject implements Node { subjectDigests: [SubjectDigest!] statement: Statement } +"""A connection to a list of items.""" +type SubjectConnection { + """A list of edges.""" + edges: [SubjectEdge] + """Information to aid in pagination.""" + pageInfo: PageInfo! + """Identifies the total count of items in the connection.""" + totalCount: Int! +} type SubjectDigest implements Node { id: ID! algorithm: String! @@ -444,6 +484,13 @@ input SubjectDigestWhereInput { hasSubject: Boolean hasSubjectWith: [SubjectWhereInput!] } +"""An edge in a connection.""" +type SubjectEdge { + """The item at the end of the edge.""" + node: Subject + """A cursor for use in pagination.""" + cursor: Cursor! +} """ SubjectWhereInput is used for filtering Subject objects. Input was generated by ent. diff --git a/ent.resolvers.go b/ent.resolvers.go index 64b8ca92..cb5abe21 100644 --- a/ent.resolvers.go +++ b/ent.resolvers.go @@ -1,3 +1,17 @@ +// Copyright 2022 The Archivist Contributors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package archivist // This file will be automatically regenerated based on the schema, any resolver implementations @@ -21,6 +35,10 @@ func (r *queryResolver) Dsses(ctx context.Context, after *ent.Cursor, first *int return r.client.Dsse.Query().Paginate(ctx, after, first, before, last, ent.WithDsseFilter(where.Filter)) } +func (r *queryResolver) Subjects(ctx context.Context, after *ent.Cursor, first *int, before *ent.Cursor, last *int, where *ent.SubjectWhereInput) (*ent.SubjectConnection, error) { + return r.client.Subject.Query().Paginate(ctx, after, first, before, last, ent.WithSubjectFilter(where.Filter)) +} + // Query returns QueryResolver implementation. func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } diff --git a/ent/gql_collection.go b/ent/gql_collection.go index c37e9fad..e41981af 100644 --- a/ent/gql_collection.go +++ b/ent/gql_collection.go @@ -4,9 +4,12 @@ package ent import ( "context" + "database/sql/driver" + "fmt" "entgo.io/ent/dialect/sql" "github.com/99designs/gqlgen/graphql" + "github.com/testifysec/archivist/ent/statement" ) // CollectFields tells the query-builder to eagerly load connected nodes by resolver context. @@ -352,9 +355,97 @@ func (s *StatementQuery) collectField(ctx context.Context, op *graphql.Operation path = append(path, field.Name) query = &SubjectQuery{config: s.config} ) - if err := query.collectField(ctx, op, field, path, satisfies...); err != nil { + args := newSubjectPaginateArgs(fieldArgs(ctx, new(SubjectWhereInput), path...)) + if err := validateFirstLast(args.first, args.last); err != nil { + return fmt.Errorf("validate first and last in path %q: %w", path, err) + } + pager, err := newSubjectPager(args.opts) + if err != nil { + return fmt.Errorf("create new pager in path %q: %w", path, err) + } + if query, err = pager.applyFilter(query); err != nil { return err } + if !hasCollectedField(ctx, append(path, edgesField)...) || args.first != nil && *args.first == 0 || args.last != nil && *args.last == 0 { + if hasCollectedField(ctx, append(path, totalCountField)...) || hasCollectedField(ctx, append(path, pageInfoField)...) { + query := query.Clone() + s.loadTotal = append(s.loadTotal, func(ctx context.Context, nodes []*Statement) error { + ids := make([]driver.Value, len(nodes)) + for i := range nodes { + ids[i] = nodes[i].ID + } + var v []struct { + NodeID int `sql:"statement_subjects"` + Count int `sql:"count"` + } + query.Where(func(s *sql.Selector) { + s.Where(sql.InValues(statement.SubjectsColumn, ids...)) + }) + if err := query.GroupBy(statement.SubjectsColumn).Aggregate(Count()).Scan(ctx, &v); err != nil { + return err + } + m := make(map[int]int, len(v)) + for i := range v { + m[v[i].NodeID] = v[i].Count + } + for i := range nodes { + n := m[nodes[i].ID] + nodes[i].Edges.totalCount[0] = &n + } + return nil + }) + } + continue + } + if (args.after != nil || args.first != nil || args.before != nil || args.last != nil) && hasCollectedField(ctx, append(path, totalCountField)...) { + query := query.Clone() + s.loadTotal = append(s.loadTotal, func(ctx context.Context, nodes []*Statement) error { + ids := make([]driver.Value, len(nodes)) + for i := range nodes { + ids[i] = nodes[i].ID + } + var v []struct { + NodeID int `sql:"statement_subjects"` + Count int `sql:"count"` + } + query.Where(func(s *sql.Selector) { + s.Where(sql.InValues(statement.SubjectsColumn, ids...)) + }) + if err := query.GroupBy(statement.SubjectsColumn).Aggregate(Count()).Scan(ctx, &v); err != nil { + return err + } + m := make(map[int]int, len(v)) + for i := range v { + m[v[i].NodeID] = v[i].Count + } + for i := range nodes { + n := m[nodes[i].ID] + nodes[i].Edges.totalCount[0] = &n + } + return nil + }) + } else { + s.loadTotal = append(s.loadTotal, func(_ context.Context, nodes []*Statement) error { + for i := range nodes { + n := len(nodes[i].Edges.Subjects) + nodes[i].Edges.totalCount[0] = &n + } + return nil + }) + } + query = pager.applyCursors(query, args.after, args.before) + if limit := paginateLimit(args.first, args.last); limit > 0 { + modify := limitRows(statement.SubjectsColumn, limit, pager.orderExpr(args.last != nil)) + query.modifiers = append(query.modifiers, modify) + } else { + query = pager.applyOrder(query, args.last != nil) + } + path = append(path, edgesField, nodeField) + if field := collectedField(ctx, path...); field != nil { + if err := query.collectField(ctx, op, *field, path, satisfies...); err != nil { + return err + } + } s.withSubjects = query case "attestationCollections", "attestation_collections": var ( diff --git a/ent/gql_edge.go b/ent/gql_edge.go index 8a2c20e3..02d65442 100644 --- a/ent/gql_edge.go +++ b/ent/gql_edge.go @@ -2,7 +2,11 @@ package ent -import "context" +import ( + "context" + + "github.com/99designs/gqlgen/graphql" +) func (a *Attestation) AttestationCollection(ctx context.Context) (*AttestationCollection, error) { result, err := a.Edges.AttestationCollectionOrErr() @@ -68,12 +72,75 @@ func (s *Signature) Dsse(ctx context.Context) (*Dsse, error) { return result, MaskNotFound(err) } -func (s *Statement) Subjects(ctx context.Context) ([]*Subject, error) { - result, err := s.Edges.SubjectsOrErr() - if IsNotLoaded(err) { - result, err = s.QuerySubjects().All(ctx) +func (s *Statement) Subjects( + ctx context.Context, after *Cursor, first *int, before *Cursor, last *int, where *SubjectWhereInput, +) (*SubjectConnection, error) { + opts := []SubjectPaginateOption{ + WithSubjectFilter(where.Filter), } - return result, err + totalCount := s.Edges.totalCount[0] + if nodes, err := s.Edges.SubjectsOrErr(); err == nil || totalCount != nil { + conn := &SubjectConnection{Edges: []*SubjectEdge{}} + if totalCount != nil { + conn.TotalCount = *totalCount + } + pager, err := newSubjectPager(opts) + if err != nil { + return nil, err + } + conn.build(nodes, pager, after, first, before, last) + return conn, nil + } + query := s.QuerySubjects() + if err := validateFirstLast(first, last); err != nil { + return nil, err + } + pager, err := newSubjectPager(opts) + if err != nil { + return nil, err + } + if query, err = pager.applyFilter(query); err != nil { + return nil, err + } + conn := &SubjectConnection{Edges: []*SubjectEdge{}} + if !hasCollectedField(ctx, edgesField) || first != nil && *first == 0 || last != nil && *last == 0 { + if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { + if totalCount != nil { + conn.TotalCount = *totalCount + } else if conn.TotalCount, err = query.Count(ctx); err != nil { + return nil, err + } + conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 + conn.PageInfo.HasPreviousPage = last != nil && conn.TotalCount > 0 + } + return conn, nil + } + + if (after != nil || first != nil || before != nil || last != nil) && hasCollectedField(ctx, totalCountField) { + count, err := query.Clone().Count(ctx) + if err != nil { + return nil, err + } + conn.TotalCount = count + } + + query = pager.applyCursors(query, after, before) + query = pager.applyOrder(query, last != nil) + if limit := paginateLimit(first, last); limit != 0 { + query.Limit(limit) + } + if field := collectedField(ctx, edgesField, nodeField); field != nil { + if err := query.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + return nil, err + } + } + + nodes, err := query.All(ctx) + if err != nil || len(nodes) == 0 { + return conn, err + } + conn.build(nodes, pager, after, first, before, last) + return conn, nil } func (s *Statement) AttestationCollections(ctx context.Context) (*AttestationCollection, error) { diff --git a/ent/schema/statement.go b/ent/schema/statement.go index 0c59280d..2977b806 100644 --- a/ent/schema/statement.go +++ b/ent/schema/statement.go @@ -15,6 +15,7 @@ package schema import ( + "entgo.io/contrib/entgql" "entgo.io/ent" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" @@ -36,7 +37,7 @@ func (Statement) Fields() []ent.Field { // Edges of the Statement. func (Statement) Edges() []ent.Edge { return []ent.Edge{ - edge.To("subjects", Subject.Type), + edge.To("subjects", Subject.Type).Annotations(entgql.RelayConnection()), edge.To("attestation_collections", AttestationCollection.Type).Unique(), edge.From("dsse", Dsse.Type).Ref("statement"), diff --git a/ent/schema/subject.go b/ent/schema/subject.go index 34e8e002..f8245059 100644 --- a/ent/schema/subject.go +++ b/ent/schema/subject.go @@ -15,7 +15,9 @@ package schema import ( + "entgo.io/contrib/entgql" "entgo.io/ent" + "entgo.io/ent/schema" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" @@ -49,3 +51,10 @@ func (Subject) Indexes() []ent.Index { index.Fields("name"), } } + +func (Subject) Annotations() []schema.Annotation { + return []schema.Annotation{ + entgql.RelayConnection(), + entgql.QueryField(), + } +} diff --git a/generated.go b/generated.go index 2d7d8088..da5eba10 100644 --- a/generated.go +++ b/generated.go @@ -91,9 +91,10 @@ type ComplexityRoot struct { } Query struct { - Dsses func(childComplexity int, after *ent.Cursor, first *int, before *ent.Cursor, last *int, where *ent.DsseWhereInput) int - Node func(childComplexity int, id int) int - Nodes func(childComplexity int, ids []int) int + Dsses func(childComplexity int, after *ent.Cursor, first *int, before *ent.Cursor, last *int, where *ent.DsseWhereInput) int + Node func(childComplexity int, id int) int + Nodes func(childComplexity int, ids []int) int + Subjects func(childComplexity int, after *ent.Cursor, first *int, before *ent.Cursor, last *int, where *ent.SubjectWhereInput) int } Signature struct { @@ -108,7 +109,7 @@ type ComplexityRoot struct { Dsse func(childComplexity int) int ID func(childComplexity int) int Predicate func(childComplexity int) int - Subjects func(childComplexity int) int + Subjects func(childComplexity int, after *ent.Cursor, first *int, before *ent.Cursor, last *int, where *ent.SubjectWhereInput) int } Subject struct { @@ -118,18 +119,30 @@ type ComplexityRoot struct { SubjectDigests func(childComplexity int) int } + SubjectConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + SubjectDigest struct { Algorithm func(childComplexity int) int ID func(childComplexity int) int Subject func(childComplexity int) int Value func(childComplexity int) int } + + SubjectEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } } type QueryResolver interface { Node(ctx context.Context, id int) (ent.Noder, error) Nodes(ctx context.Context, ids []int) ([]ent.Noder, error) Dsses(ctx context.Context, after *ent.Cursor, first *int, before *ent.Cursor, last *int, where *ent.DsseWhereInput) (*ent.DsseConnection, error) + Subjects(ctx context.Context, after *ent.Cursor, first *int, before *ent.Cursor, last *int, where *ent.SubjectWhereInput) (*ent.SubjectConnection, error) } type executableSchema struct { @@ -365,6 +378,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Nodes(childComplexity, args["ids"].([]int)), true + case "Query.subjects": + if e.complexity.Query.Subjects == nil { + break + } + + args, err := ec.field_Query_subjects_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Subjects(childComplexity, args["after"].(*ent.Cursor), args["first"].(*int), args["before"].(*ent.Cursor), args["last"].(*int), args["where"].(*ent.SubjectWhereInput)), true + case "Signature.dsse": if e.complexity.Signature.Dsse == nil { break @@ -426,7 +451,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - return e.complexity.Statement.Subjects(childComplexity), true + args, err := ec.field_Statement_subjects_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Statement.Subjects(childComplexity, args["after"].(*ent.Cursor), args["first"].(*int), args["before"].(*ent.Cursor), args["last"].(*int), args["where"].(*ent.SubjectWhereInput)), true case "Subject.id": if e.complexity.Subject.ID == nil { @@ -456,6 +486,27 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Subject.SubjectDigests(childComplexity), true + case "SubjectConnection.edges": + if e.complexity.SubjectConnection.Edges == nil { + break + } + + return e.complexity.SubjectConnection.Edges(childComplexity), true + + case "SubjectConnection.pageInfo": + if e.complexity.SubjectConnection.PageInfo == nil { + break + } + + return e.complexity.SubjectConnection.PageInfo(childComplexity), true + + case "SubjectConnection.totalCount": + if e.complexity.SubjectConnection.TotalCount == nil { + break + } + + return e.complexity.SubjectConnection.TotalCount(childComplexity), true + case "SubjectDigest.algorithm": if e.complexity.SubjectDigest.Algorithm == nil { break @@ -484,6 +535,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.SubjectDigest.Value(childComplexity), true + case "SubjectEdge.cursor": + if e.complexity.SubjectEdge.Cursor == nil { + break + } + + return e.complexity.SubjectEdge.Cursor(childComplexity), true + + case "SubjectEdge.node": + if e.complexity.SubjectEdge.Node == nil { + break + } + + return e.complexity.SubjectEdge.Node(childComplexity), true + } return 0, false } @@ -826,6 +891,22 @@ type Query { """Filtering options for Dsses returned from the connection.""" where: DsseWhereInput ): DsseConnection! + subjects( + """Returns the elements in the list that come after the specified cursor.""" + after: Cursor + + """Returns the first _n_ elements from the list.""" + first: Int + + """Returns the elements in the list that come before the specified cursor.""" + before: Cursor + + """Returns the last _n_ elements from the list.""" + last: Int + + """Filtering options for Subjects returned from the connection.""" + where: SubjectWhereInput + ): SubjectConnection! } type Signature implements Node { id: ID! @@ -885,7 +966,22 @@ input SignatureWhereInput { type Statement implements Node { id: ID! predicate: String! - subjects: [Subject!] + subjects( + """Returns the elements in the list that come after the specified cursor.""" + after: Cursor + + """Returns the first _n_ elements from the list.""" + first: Int + + """Returns the elements in the list that come before the specified cursor.""" + before: Cursor + + """Returns the last _n_ elements from the list.""" + last: Int + + """Filtering options for Subjects returned from the connection.""" + where: SubjectWhereInput + ): SubjectConnection! attestationCollections: AttestationCollection dsse: [Dsse!] } @@ -936,6 +1032,15 @@ type Subject implements Node { subjectDigests: [SubjectDigest!] statement: Statement } +"""A connection to a list of items.""" +type SubjectConnection { + """A list of edges.""" + edges: [SubjectEdge] + """Information to aid in pagination.""" + pageInfo: PageInfo! + """Identifies the total count of items in the connection.""" + totalCount: Int! +} type SubjectDigest implements Node { id: ID! algorithm: String! @@ -991,6 +1096,13 @@ input SubjectDigestWhereInput { hasSubject: Boolean hasSubjectWith: [SubjectWhereInput!] } +"""An edge in a connection.""" +type SubjectEdge { + """The item at the end of the edge.""" + node: Subject + """A cursor for use in pagination.""" + cursor: Cursor! +} """ SubjectWhereInput is used for filtering Subject objects. Input was generated by ent. @@ -1133,6 +1245,108 @@ func (ec *executionContext) field_Query_nodes_args(ctx context.Context, rawArgs return args, nil } +func (ec *executionContext) field_Query_subjects_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 *ent.Cursor + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg0, err = ec.unmarshalOCursor2ᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐCursor(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg0 + var arg1 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg1, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg1 + var arg2 *ent.Cursor + if tmp, ok := rawArgs["before"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("before")) + arg2, err = ec.unmarshalOCursor2ᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐCursor(ctx, tmp) + if err != nil { + return nil, err + } + } + args["before"] = arg2 + var arg3 *int + if tmp, ok := rawArgs["last"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("last")) + arg3, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["last"] = arg3 + var arg4 *ent.SubjectWhereInput + if tmp, ok := rawArgs["where"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("where")) + arg4, err = ec.unmarshalOSubjectWhereInput2ᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubjectWhereInput(ctx, tmp) + if err != nil { + return nil, err + } + } + args["where"] = arg4 + return args, nil +} + +func (ec *executionContext) field_Statement_subjects_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 *ent.Cursor + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg0, err = ec.unmarshalOCursor2ᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐCursor(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg0 + var arg1 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg1, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg1 + var arg2 *ent.Cursor + if tmp, ok := rawArgs["before"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("before")) + arg2, err = ec.unmarshalOCursor2ᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐCursor(ctx, tmp) + if err != nil { + return nil, err + } + } + args["before"] = arg2 + var arg3 *int + if tmp, ok := rawArgs["last"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("last")) + arg3, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["last"] = arg3 + var arg4 *ent.SubjectWhereInput + if tmp, ok := rawArgs["where"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("where")) + arg4, err = ec.unmarshalOSubjectWhereInput2ᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubjectWhereInput(ctx, tmp) + if err != nil { + return nil, err + } + } + args["where"] = arg4 + return args, nil +} + func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -2564,6 +2778,69 @@ func (ec *executionContext) fieldContext_Query_dsses(ctx context.Context, field return fc, nil } +func (ec *executionContext) _Query_subjects(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_subjects(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 ec.resolvers.Query().Subjects(rctx, fc.Args["after"].(*ent.Cursor), fc.Args["first"].(*int), fc.Args["before"].(*ent.Cursor), fc.Args["last"].(*int), fc.Args["where"].(*ent.SubjectWhereInput)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*ent.SubjectConnection) + fc.Result = res + return ec.marshalNSubjectConnection2ᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubjectConnection(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_subjects(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "edges": + return ec.fieldContext_SubjectConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_SubjectConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_SubjectConnection_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type SubjectConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_subjects_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return + } + return fc, nil +} + func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Query___type(ctx, field) if err != nil { @@ -2982,18 +3259,21 @@ func (ec *executionContext) _Statement_subjects(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Subjects(ctx) + return obj.Subjects(ctx, fc.Args["after"].(*ent.Cursor), fc.Args["first"].(*int), fc.Args["before"].(*ent.Cursor), fc.Args["last"].(*int), fc.Args["where"].(*ent.SubjectWhereInput)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]*ent.Subject) + res := resTmp.(*ent.SubjectConnection) fc.Result = res - return ec.marshalOSubject2ᚕᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubjectᚄ(ctx, field.Selections, res) + return ec.marshalNSubjectConnection2ᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubjectConnection(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Statement_subjects(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -3004,18 +3284,27 @@ func (ec *executionContext) fieldContext_Statement_subjects(ctx context.Context, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Subject_id(ctx, field) - case "name": - return ec.fieldContext_Subject_name(ctx, field) - case "subjectDigests": - return ec.fieldContext_Subject_subjectDigests(ctx, field) - case "statement": - return ec.fieldContext_Subject_statement(ctx, field) + case "edges": + return ec.fieldContext_SubjectConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_SubjectConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_SubjectConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Subject", field.Name) + return nil, fmt.Errorf("no field named %q was found under type SubjectConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Statement_subjects_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return + } return fc, nil } @@ -3299,19 +3588,164 @@ func (ec *executionContext) fieldContext_Subject_statement(ctx context.Context, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Statement_id(ctx, field) - case "predicate": - return ec.fieldContext_Statement_predicate(ctx, field) - case "subjects": - return ec.fieldContext_Statement_subjects(ctx, field) - case "attestationCollections": - return ec.fieldContext_Statement_attestationCollections(ctx, field) - case "dsse": - return ec.fieldContext_Statement_dsse(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Statement", field.Name) + switch field.Name { + case "id": + return ec.fieldContext_Statement_id(ctx, field) + case "predicate": + return ec.fieldContext_Statement_predicate(ctx, field) + case "subjects": + return ec.fieldContext_Statement_subjects(ctx, field) + case "attestationCollections": + return ec.fieldContext_Statement_attestationCollections(ctx, field) + case "dsse": + return ec.fieldContext_Statement_dsse(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Statement", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _SubjectConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.SubjectConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SubjectConnection_edges(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.Edges, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.SubjectEdge) + fc.Result = res + return ec.marshalOSubjectEdge2ᚕᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubjectEdge(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SubjectConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "SubjectConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "node": + return ec.fieldContext_SubjectEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_SubjectEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type SubjectEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _SubjectConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.SubjectConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SubjectConnection_pageInfo(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.PageInfo, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(ent.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2githubᚗcomᚋtestifysecᚋarchivistᚋentᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SubjectConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "SubjectConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _SubjectConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.SubjectConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SubjectConnection_totalCount(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.TotalCount, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SubjectConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "SubjectConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil @@ -3500,6 +3934,101 @@ func (ec *executionContext) fieldContext_SubjectDigest_subject(ctx context.Conte return fc, nil } +func (ec *executionContext) _SubjectEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.SubjectEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SubjectEdge_node(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.Node, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*ent.Subject) + fc.Result = res + return ec.marshalOSubject2ᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubject(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SubjectEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "SubjectEdge", + 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_Subject_id(ctx, field) + case "name": + return ec.fieldContext_Subject_name(ctx, field) + case "subjectDigests": + return ec.fieldContext_Subject_subjectDigests(ctx, field) + case "statement": + return ec.fieldContext_Subject_statement(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Subject", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _SubjectEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.SubjectEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SubjectEdge_cursor(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.Cursor, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(ent.Cursor) + fc.Result = res + return ec.marshalNCursor2githubᚗcomᚋtestifysecᚋarchivistᚋentᚐCursor(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SubjectEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "SubjectEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Cursor does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { fc, err := ec.fieldContext___Directive_name(ctx, field) if err != nil { @@ -8101,6 +8630,29 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) } + out.Concurrently(i, func() graphql.Marshaler { + return rrm(innerCtx) + }) + case "subjects": + field := field + + innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_subjects(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + } + out.Concurrently(i, func() graphql.Marshaler { return rrm(innerCtx) }) @@ -8220,6 +8772,9 @@ func (ec *executionContext) _Statement(ctx context.Context, sel ast.SelectionSet } }() res = ec._Statement_subjects(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } return res } @@ -8341,6 +8896,45 @@ func (ec *executionContext) _Subject(ctx context.Context, sel ast.SelectionSet, return out } +var subjectConnectionImplementors = []string{"SubjectConnection"} + +func (ec *executionContext) _SubjectConnection(ctx context.Context, sel ast.SelectionSet, obj *ent.SubjectConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, subjectConnectionImplementors) + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("SubjectConnection") + case "edges": + + out.Values[i] = ec._SubjectConnection_edges(ctx, field, obj) + + case "pageInfo": + + out.Values[i] = ec._SubjectConnection_pageInfo(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "totalCount": + + out.Values[i] = ec._SubjectConnection_totalCount(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + var subjectDigestImplementors = []string{"SubjectDigest", "Node"} func (ec *executionContext) _SubjectDigest(ctx context.Context, sel ast.SelectionSet, obj *ent.SubjectDigest) graphql.Marshaler { @@ -8400,6 +8994,38 @@ func (ec *executionContext) _SubjectDigest(ctx context.Context, sel ast.Selectio return out } +var subjectEdgeImplementors = []string{"SubjectEdge"} + +func (ec *executionContext) _SubjectEdge(ctx context.Context, sel ast.SelectionSet, obj *ent.SubjectEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, subjectEdgeImplementors) + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("SubjectEdge") + case "node": + + out.Values[i] = ec._SubjectEdge_node(ctx, field, obj) + + case "cursor": + + out.Values[i] = ec._SubjectEdge_cursor(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { @@ -8966,14 +9592,18 @@ func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.S return res } -func (ec *executionContext) marshalNSubject2ᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubject(ctx context.Context, sel ast.SelectionSet, v *ent.Subject) graphql.Marshaler { +func (ec *executionContext) marshalNSubjectConnection2githubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubjectConnection(ctx context.Context, sel ast.SelectionSet, v ent.SubjectConnection) graphql.Marshaler { + return ec._SubjectConnection(ctx, sel, &v) +} + +func (ec *executionContext) marshalNSubjectConnection2ᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubjectConnection(ctx context.Context, sel ast.SelectionSet, v *ent.SubjectConnection) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } - return ec._Subject(ctx, sel, v) + return ec._SubjectConnection(ctx, sel, v) } func (ec *executionContext) marshalNSubjectDigest2ᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubjectDigest(ctx context.Context, sel ast.SelectionSet, v *ent.SubjectDigest) graphql.Marshaler { @@ -9847,7 +10477,14 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as return res } -func (ec *executionContext) marshalOSubject2ᚕᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubjectᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.Subject) graphql.Marshaler { +func (ec *executionContext) marshalOSubject2ᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubject(ctx context.Context, sel ast.SelectionSet, v *ent.Subject) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Subject(ctx, sel, v) +} + +func (ec *executionContext) marshalOSubjectDigest2ᚕᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubjectDigestᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.SubjectDigest) graphql.Marshaler { if v == nil { return graphql.Null } @@ -9874,7 +10511,7 @@ func (ec *executionContext) marshalOSubject2ᚕᚖgithubᚗcomᚋtestifysecᚋar if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNSubject2ᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubject(ctx, sel, v[i]) + ret[i] = ec.marshalNSubjectDigest2ᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubjectDigest(ctx, sel, v[i]) } if isLen1 { f(i) @@ -9894,14 +10531,35 @@ func (ec *executionContext) marshalOSubject2ᚕᚖgithubᚗcomᚋtestifysecᚋar return ret } -func (ec *executionContext) marshalOSubject2ᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubject(ctx context.Context, sel ast.SelectionSet, v *ent.Subject) graphql.Marshaler { +func (ec *executionContext) unmarshalOSubjectDigestWhereInput2ᚕᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubjectDigestWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.SubjectDigestWhereInput, error) { if v == nil { - return graphql.Null + return nil, nil } - return ec._Subject(ctx, sel, v) + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*ent.SubjectDigestWhereInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNSubjectDigestWhereInput2ᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubjectDigestWhereInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil } -func (ec *executionContext) marshalOSubjectDigest2ᚕᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubjectDigestᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.SubjectDigest) graphql.Marshaler { +func (ec *executionContext) unmarshalOSubjectDigestWhereInput2ᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubjectDigestWhereInput(ctx context.Context, v interface{}) (*ent.SubjectDigestWhereInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputSubjectDigestWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOSubjectEdge2ᚕᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubjectEdge(ctx context.Context, sel ast.SelectionSet, v []*ent.SubjectEdge) graphql.Marshaler { if v == nil { return graphql.Null } @@ -9928,7 +10586,7 @@ func (ec *executionContext) marshalOSubjectDigest2ᚕᚖgithubᚗcomᚋtestifyse if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNSubjectDigest2ᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubjectDigest(ctx, sel, v[i]) + ret[i] = ec.marshalOSubjectEdge2ᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubjectEdge(ctx, sel, v[i]) } if isLen1 { f(i) @@ -9939,41 +10597,14 @@ func (ec *executionContext) marshalOSubjectDigest2ᚕᚖgithubᚗcomᚋtestifyse } wg.Wait() - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - return ret } -func (ec *executionContext) unmarshalOSubjectDigestWhereInput2ᚕᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubjectDigestWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.SubjectDigestWhereInput, error) { - if v == nil { - return nil, nil - } - var vSlice []interface{} - if v != nil { - vSlice = graphql.CoerceList(v) - } - var err error - res := make([]*ent.SubjectDigestWhereInput, len(vSlice)) - for i := range vSlice { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNSubjectDigestWhereInput2ᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubjectDigestWhereInput(ctx, vSlice[i]) - if err != nil { - return nil, err - } - } - return res, nil -} - -func (ec *executionContext) unmarshalOSubjectDigestWhereInput2ᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubjectDigestWhereInput(ctx context.Context, v interface{}) (*ent.SubjectDigestWhereInput, error) { +func (ec *executionContext) marshalOSubjectEdge2ᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubjectEdge(ctx context.Context, sel ast.SelectionSet, v *ent.SubjectEdge) graphql.Marshaler { if v == nil { - return nil, nil + return graphql.Null } - res, err := ec.unmarshalInputSubjectDigestWhereInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) + return ec._SubjectEdge(ctx, sel, v) } func (ec *executionContext) unmarshalOSubjectWhereInput2ᚕᚖgithubᚗcomᚋtestifysecᚋarchivistᚋentᚐSubjectWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.SubjectWhereInput, error) {