From 286c0f8e87d87fce0a1b11b629e885cf0c4b921b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 May 2024 13:21:35 +0000 Subject: [PATCH] Bump entgo.io/contrib from 0.4.5 to 0.5.0 (#1894) * Bump entgo.io/contrib from 0.4.5 to 0.5.0 Bumps [entgo.io/contrib](https://github.com/ent/contrib) from 0.4.5 to 0.5.0. - [Release notes](https://github.com/ent/contrib/releases) - [Commits](https://github.com/ent/contrib/compare/v0.4.5...v0.5.0) --- updated-dependencies: - dependency-name: entgo.io/contrib dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * regen code Signed-off-by: pxp928 --------- Signed-off-by: dependabot[bot] Signed-off-by: pxp928 Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: pxp928 --- go.mod | 2 +- go.sum | 4 +- pkg/assembler/backends/ent/gql_collection.go | 423 ++++++++++-------- pkg/assembler/backends/ent/gql_node.go | 437 +++++++++---------- pkg/assembler/backends/ent/gql_pagination.go | 207 ++++++--- 5 files changed, 596 insertions(+), 477 deletions(-) diff --git a/go.mod b/go.mod index 5277dca46c..0600926f4b 100644 --- a/go.mod +++ b/go.mod @@ -268,7 +268,7 @@ require ( require ( deps.dev/api/v3 v3.0.0-20240503042720-6166138ce783 - entgo.io/contrib v0.4.5 + entgo.io/contrib v0.5.0 entgo.io/ent v0.13.0 github.com/99designs/gqlgen v0.17.45 github.com/CycloneDX/cyclonedx-go v0.8.0 diff --git a/go.sum b/go.sum index d6d64605ed..282083543c 100644 --- a/go.sum +++ b/go.sum @@ -21,8 +21,8 @@ dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= deps.dev/api/v3 v3.0.0-20240503042720-6166138ce783 h1:ls9MrAHgWyVrhaRw/xGuFc6/oNUR4VYKGWf2ZCAVsjo= deps.dev/api/v3 v3.0.0-20240503042720-6166138ce783/go.mod h1:DyBY3wNVqRCwvb4tLvz6LL/FupH3FMflEROyQAv2Vi0= -entgo.io/contrib v0.4.5 h1:BFaOHwFLE8WZjVJadP0XHCIaxgcC1BAtUvAyw7M/GHk= -entgo.io/contrib v0.4.5/go.mod h1:wpZyq2DJgthugFvDBlaqMXj9mV4/9ebyGEn7xlTVQqE= +entgo.io/contrib v0.5.0 h1:M4IqodImfUm327RDwNAITLNz3PsxVeC3rD4DPeVA8Gs= +entgo.io/contrib v0.5.0/go.mod h1:q8dXQCmzqpSlVdT2bWDydjgznGcy3y4zmsYmVFC9V/U= entgo.io/ent v0.13.0 h1:DclxWczaCpyiKn6ZWVcJjq1zIKtJ11iNKy+08lNYsJE= entgo.io/ent v0.13.0/go.mod h1:+oU8oGna69xy29O+g+NEz+/TM7yJDhQQGJfuOWq1pT8= github.com/99designs/gqlgen v0.17.45 h1:bH0AH67vIJo8JKNKPJP+pOPpQhZeuVRQLf53dKIpDik= diff --git a/pkg/assembler/backends/ent/gql_collection.go b/pkg/assembler/backends/ent/gql_collection.go index 6fa0cb8a7f..219eb8e622 100644 --- a/pkg/assembler/backends/ent/gql_collection.go +++ b/pkg/assembler/backends/ent/gql_collection.go @@ -5,7 +5,6 @@ package ent import ( "context" - "entgo.io/ent/dialect/sql" "github.com/99designs/gqlgen/graphql" "github.com/guacsec/guac/pkg/assembler/backends/ent/artifact" "github.com/guacsec/guac/pkg/assembler/backends/ent/billofmaterials" @@ -38,13 +37,13 @@ func (a *ArtifactQuery) CollectFields(ctx context.Context, satisfies ...string) if fc == nil { return a, nil } - if err := a.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := a.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return a, nil } -func (a *ArtifactQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (a *ArtifactQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -53,133 +52,144 @@ func (a *ArtifactQuery) collectField(ctx context.Context, opCtx *graphql.Operati ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "occurrences": var ( alias = field.Alias path = append(path, alias) query = (&OccurrenceClient{config: a.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, occurrenceImplementors)...); err != nil { return err } a.WithNamedOccurrences(alias, func(wq *OccurrenceQuery) { *wq = *query }) + case "sbom": var ( alias = field.Alias path = append(path, alias) query = (&BillOfMaterialsClient{config: a.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, billofmaterialsImplementors)...); err != nil { return err } a.WithNamedSbom(alias, func(wq *BillOfMaterialsQuery) { *wq = *query }) + case "attestations": var ( alias = field.Alias path = append(path, alias) query = (&SLSAAttestationClient{config: a.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, slsaattestationImplementors)...); err != nil { return err } a.WithNamedAttestations(alias, func(wq *SLSAAttestationQuery) { *wq = *query }) + case "attestationsSubject": var ( alias = field.Alias path = append(path, alias) query = (&SLSAAttestationClient{config: a.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, slsaattestationImplementors)...); err != nil { return err } a.WithNamedAttestationsSubject(alias, func(wq *SLSAAttestationQuery) { *wq = *query }) + case "hashEqualArtA": var ( alias = field.Alias path = append(path, alias) query = (&HashEqualClient{config: a.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, hashequalImplementors)...); err != nil { return err } a.WithNamedHashEqualArtA(alias, func(wq *HashEqualQuery) { *wq = *query }) + case "hashEqualArtB": var ( alias = field.Alias path = append(path, alias) query = (&HashEqualClient{config: a.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, hashequalImplementors)...); err != nil { return err } a.WithNamedHashEqualArtB(alias, func(wq *HashEqualQuery) { *wq = *query }) + case "vex": var ( alias = field.Alias path = append(path, alias) query = (&CertifyVexClient{config: a.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, certifyvexImplementors)...); err != nil { return err } a.WithNamedVex(alias, func(wq *CertifyVexQuery) { *wq = *query }) + case "certification": var ( alias = field.Alias path = append(path, alias) query = (&CertificationClient{config: a.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, certificationImplementors)...); err != nil { return err } a.WithNamedCertification(alias, func(wq *CertificationQuery) { *wq = *query }) + case "metadata": var ( alias = field.Alias path = append(path, alias) query = (&HasMetadataClient{config: a.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, hasmetadataImplementors)...); err != nil { return err } a.WithNamedMetadata(alias, func(wq *HasMetadataQuery) { *wq = *query }) + case "poc": var ( alias = field.Alias path = append(path, alias) query = (&PointOfContactClient{config: a.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, pointofcontactImplementors)...); err != nil { return err } a.WithNamedPoc(alias, func(wq *PointOfContactQuery) { *wq = *query }) + case "includedInSboms": var ( alias = field.Alias path = append(path, alias) query = (&BillOfMaterialsClient{config: a.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, billofmaterialsImplementors)...); err != nil { return err } a.WithNamedIncludedInSboms(alias, func(wq *BillOfMaterialsQuery) { @@ -239,13 +249,13 @@ func (bom *BillOfMaterialsQuery) CollectFields(ctx context.Context, satisfies .. if fc == nil { return bom, nil } - if err := bom.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := bom.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return bom, nil } -func (bom *BillOfMaterialsQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (bom *BillOfMaterialsQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -254,13 +264,14 @@ func (bom *BillOfMaterialsQuery) collectField(ctx context.Context, opCtx *graphq ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "package": var ( alias = field.Alias path = append(path, alias) query = (&PackageVersionClient{config: bom.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, packageversionImplementors)...); err != nil { return err } bom.withPackage = query @@ -268,13 +279,14 @@ func (bom *BillOfMaterialsQuery) collectField(ctx context.Context, opCtx *graphq selectedFields = append(selectedFields, billofmaterials.FieldPackageID) fieldSeen[billofmaterials.FieldPackageID] = struct{}{} } + case "artifact": var ( alias = field.Alias path = append(path, alias) query = (&ArtifactClient{config: bom.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, artifactImplementors)...); err != nil { return err } bom.withArtifact = query @@ -282,49 +294,53 @@ func (bom *BillOfMaterialsQuery) collectField(ctx context.Context, opCtx *graphq selectedFields = append(selectedFields, billofmaterials.FieldArtifactID) fieldSeen[billofmaterials.FieldArtifactID] = struct{}{} } + case "includedSoftwarePackages": var ( alias = field.Alias path = append(path, alias) query = (&PackageVersionClient{config: bom.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, packageversionImplementors)...); err != nil { return err } bom.WithNamedIncludedSoftwarePackages(alias, func(wq *PackageVersionQuery) { *wq = *query }) + case "includedSoftwareArtifacts": var ( alias = field.Alias path = append(path, alias) query = (&ArtifactClient{config: bom.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, artifactImplementors)...); err != nil { return err } bom.WithNamedIncludedSoftwareArtifacts(alias, func(wq *ArtifactQuery) { *wq = *query }) + case "includedDependencies": var ( alias = field.Alias path = append(path, alias) query = (&DependencyClient{config: bom.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, dependencyImplementors)...); err != nil { return err } bom.WithNamedIncludedDependencies(alias, func(wq *DependencyQuery) { *wq = *query }) + case "includedOccurrences": var ( alias = field.Alias path = append(path, alias) query = (&OccurrenceClient{config: bom.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, occurrenceImplementors)...); err != nil { return err } bom.WithNamedIncludedOccurrences(alias, func(wq *OccurrenceQuery) { @@ -444,13 +460,13 @@ func (b *BuilderQuery) CollectFields(ctx context.Context, satisfies ...string) ( if fc == nil { return b, nil } - if err := b.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := b.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return b, nil } -func (b *BuilderQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (b *BuilderQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -459,13 +475,14 @@ func (b *BuilderQuery) collectField(ctx context.Context, opCtx *graphql.Operatio ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "slsaAttestations": var ( alias = field.Alias path = append(path, alias) query = (&SLSAAttestationClient{config: b.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, slsaattestationImplementors)...); err != nil { return err } b.WithNamedSlsaAttestations(alias, func(wq *SLSAAttestationQuery) { @@ -520,13 +537,13 @@ func (c *CertificationQuery) CollectFields(ctx context.Context, satisfies ...str if fc == nil { return c, nil } - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := c.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return c, nil } -func (c *CertificationQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (c *CertificationQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -535,13 +552,14 @@ func (c *CertificationQuery) collectField(ctx context.Context, opCtx *graphql.Op ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "source": var ( alias = field.Alias path = append(path, alias) query = (&SourceNameClient{config: c.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, sourcenameImplementors)...); err != nil { return err } c.withSource = query @@ -549,13 +567,14 @@ func (c *CertificationQuery) collectField(ctx context.Context, opCtx *graphql.Op selectedFields = append(selectedFields, certification.FieldSourceID) fieldSeen[certification.FieldSourceID] = struct{}{} } + case "packageVersion": var ( alias = field.Alias path = append(path, alias) query = (&PackageVersionClient{config: c.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, packageversionImplementors)...); err != nil { return err } c.withPackageVersion = query @@ -563,13 +582,14 @@ func (c *CertificationQuery) collectField(ctx context.Context, opCtx *graphql.Op selectedFields = append(selectedFields, certification.FieldPackageVersionID) fieldSeen[certification.FieldPackageVersionID] = struct{}{} } + case "allVersions": var ( alias = field.Alias path = append(path, alias) query = (&PackageNameClient{config: c.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, packagenameImplementors)...); err != nil { return err } c.withAllVersions = query @@ -577,13 +597,14 @@ func (c *CertificationQuery) collectField(ctx context.Context, opCtx *graphql.Op selectedFields = append(selectedFields, certification.FieldPackageNameID) fieldSeen[certification.FieldPackageNameID] = struct{}{} } + case "artifact": var ( alias = field.Alias path = append(path, alias) query = (&ArtifactClient{config: c.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, artifactImplementors)...); err != nil { return err } c.withArtifact = query @@ -685,13 +706,13 @@ func (cl *CertifyLegalQuery) CollectFields(ctx context.Context, satisfies ...str if fc == nil { return cl, nil } - if err := cl.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := cl.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return cl, nil } -func (cl *CertifyLegalQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (cl *CertifyLegalQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -700,13 +721,14 @@ func (cl *CertifyLegalQuery) collectField(ctx context.Context, opCtx *graphql.Op ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "package": var ( alias = field.Alias path = append(path, alias) query = (&PackageVersionClient{config: cl.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, packageversionImplementors)...); err != nil { return err } cl.withPackage = query @@ -714,13 +736,14 @@ func (cl *CertifyLegalQuery) collectField(ctx context.Context, opCtx *graphql.Op selectedFields = append(selectedFields, certifylegal.FieldPackageID) fieldSeen[certifylegal.FieldPackageID] = struct{}{} } + case "source": var ( alias = field.Alias path = append(path, alias) query = (&SourceNameClient{config: cl.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, sourcenameImplementors)...); err != nil { return err } cl.withSource = query @@ -728,25 +751,27 @@ func (cl *CertifyLegalQuery) collectField(ctx context.Context, opCtx *graphql.Op selectedFields = append(selectedFields, certifylegal.FieldSourceID) fieldSeen[certifylegal.FieldSourceID] = struct{}{} } + case "declaredLicenses": var ( alias = field.Alias path = append(path, alias) query = (&LicenseClient{config: cl.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, licenseImplementors)...); err != nil { return err } cl.WithNamedDeclaredLicenses(alias, func(wq *LicenseQuery) { *wq = *query }) + case "discoveredLicenses": var ( alias = field.Alias path = append(path, alias) query = (&LicenseClient{config: cl.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, licenseImplementors)...); err != nil { return err } cl.WithNamedDiscoveredLicenses(alias, func(wq *LicenseQuery) { @@ -856,13 +881,13 @@ func (cs *CertifyScorecardQuery) CollectFields(ctx context.Context, satisfies .. if fc == nil { return cs, nil } - if err := cs.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := cs.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return cs, nil } -func (cs *CertifyScorecardQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (cs *CertifyScorecardQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -871,13 +896,14 @@ func (cs *CertifyScorecardQuery) collectField(ctx context.Context, opCtx *graphq ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "source": var ( alias = field.Alias path = append(path, alias) query = (&SourceNameClient{config: cs.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, sourcenameImplementors)...); err != nil { return err } cs.withSource = query @@ -979,13 +1005,13 @@ func (cv *CertifyVexQuery) CollectFields(ctx context.Context, satisfies ...strin if fc == nil { return cv, nil } - if err := cv.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := cv.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return cv, nil } -func (cv *CertifyVexQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (cv *CertifyVexQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -994,13 +1020,14 @@ func (cv *CertifyVexQuery) collectField(ctx context.Context, opCtx *graphql.Oper ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "package": var ( alias = field.Alias path = append(path, alias) query = (&PackageVersionClient{config: cv.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, packageversionImplementors)...); err != nil { return err } cv.withPackage = query @@ -1008,13 +1035,14 @@ func (cv *CertifyVexQuery) collectField(ctx context.Context, opCtx *graphql.Oper selectedFields = append(selectedFields, certifyvex.FieldPackageID) fieldSeen[certifyvex.FieldPackageID] = struct{}{} } + case "artifact": var ( alias = field.Alias path = append(path, alias) query = (&ArtifactClient{config: cv.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, artifactImplementors)...); err != nil { return err } cv.withArtifact = query @@ -1022,13 +1050,14 @@ func (cv *CertifyVexQuery) collectField(ctx context.Context, opCtx *graphql.Oper selectedFields = append(selectedFields, certifyvex.FieldArtifactID) fieldSeen[certifyvex.FieldArtifactID] = struct{}{} } + case "vulnerability": var ( alias = field.Alias path = append(path, alias) query = (&VulnerabilityIDClient{config: cv.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, vulnerabilityidImplementors)...); err != nil { return err } cv.withVulnerability = query @@ -1135,13 +1164,13 @@ func (cv *CertifyVulnQuery) CollectFields(ctx context.Context, satisfies ...stri if fc == nil { return cv, nil } - if err := cv.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := cv.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return cv, nil } -func (cv *CertifyVulnQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (cv *CertifyVulnQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -1150,13 +1179,14 @@ func (cv *CertifyVulnQuery) collectField(ctx context.Context, opCtx *graphql.Ope ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "vulnerability": var ( alias = field.Alias path = append(path, alias) query = (&VulnerabilityIDClient{config: cv.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, vulnerabilityidImplementors)...); err != nil { return err } cv.withVulnerability = query @@ -1164,13 +1194,14 @@ func (cv *CertifyVulnQuery) collectField(ctx context.Context, opCtx *graphql.Ope selectedFields = append(selectedFields, certifyvuln.FieldVulnerabilityID) fieldSeen[certifyvuln.FieldVulnerabilityID] = struct{}{} } + case "package": var ( alias = field.Alias path = append(path, alias) query = (&PackageVersionClient{config: cv.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, packageversionImplementors)...); err != nil { return err } cv.withPackage = query @@ -1272,13 +1303,13 @@ func (d *DependencyQuery) CollectFields(ctx context.Context, satisfies ...string if fc == nil { return d, nil } - if err := d.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := d.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return d, nil } -func (d *DependencyQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (d *DependencyQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -1287,13 +1318,14 @@ func (d *DependencyQuery) collectField(ctx context.Context, opCtx *graphql.Opera ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "package": var ( alias = field.Alias path = append(path, alias) query = (&PackageVersionClient{config: d.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, packageversionImplementors)...); err != nil { return err } d.withPackage = query @@ -1301,13 +1333,14 @@ func (d *DependencyQuery) collectField(ctx context.Context, opCtx *graphql.Opera selectedFields = append(selectedFields, dependency.FieldPackageID) fieldSeen[dependency.FieldPackageID] = struct{}{} } + case "dependentPackageName": var ( alias = field.Alias path = append(path, alias) query = (&PackageNameClient{config: d.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, packagenameImplementors)...); err != nil { return err } d.withDependentPackageName = query @@ -1315,13 +1348,14 @@ func (d *DependencyQuery) collectField(ctx context.Context, opCtx *graphql.Opera selectedFields = append(selectedFields, dependency.FieldDependentPackageNameID) fieldSeen[dependency.FieldDependentPackageNameID] = struct{}{} } + case "dependentPackageVersion": var ( alias = field.Alias path = append(path, alias) query = (&PackageVersionClient{config: d.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, packageversionImplementors)...); err != nil { return err } d.withDependentPackageVersion = query @@ -1329,13 +1363,14 @@ func (d *DependencyQuery) collectField(ctx context.Context, opCtx *graphql.Opera selectedFields = append(selectedFields, dependency.FieldDependentPackageVersionID) fieldSeen[dependency.FieldDependentPackageVersionID] = struct{}{} } + case "includedInSboms": var ( alias = field.Alias path = append(path, alias) query = (&BillOfMaterialsClient{config: d.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, billofmaterialsImplementors)...); err != nil { return err } d.WithNamedIncludedInSboms(alias, func(wq *BillOfMaterialsQuery) { @@ -1430,13 +1465,13 @@ func (hm *HasMetadataQuery) CollectFields(ctx context.Context, satisfies ...stri if fc == nil { return hm, nil } - if err := hm.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := hm.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return hm, nil } -func (hm *HasMetadataQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (hm *HasMetadataQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -1445,13 +1480,14 @@ func (hm *HasMetadataQuery) collectField(ctx context.Context, opCtx *graphql.Ope ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "source": var ( alias = field.Alias path = append(path, alias) query = (&SourceNameClient{config: hm.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, sourcenameImplementors)...); err != nil { return err } hm.withSource = query @@ -1459,13 +1495,14 @@ func (hm *HasMetadataQuery) collectField(ctx context.Context, opCtx *graphql.Ope selectedFields = append(selectedFields, hasmetadata.FieldSourceID) fieldSeen[hasmetadata.FieldSourceID] = struct{}{} } + case "packageVersion": var ( alias = field.Alias path = append(path, alias) query = (&PackageVersionClient{config: hm.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, packageversionImplementors)...); err != nil { return err } hm.withPackageVersion = query @@ -1473,13 +1510,14 @@ func (hm *HasMetadataQuery) collectField(ctx context.Context, opCtx *graphql.Ope selectedFields = append(selectedFields, hasmetadata.FieldPackageVersionID) fieldSeen[hasmetadata.FieldPackageVersionID] = struct{}{} } + case "allVersions": var ( alias = field.Alias path = append(path, alias) query = (&PackageNameClient{config: hm.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, packagenameImplementors)...); err != nil { return err } hm.withAllVersions = query @@ -1487,13 +1525,14 @@ func (hm *HasMetadataQuery) collectField(ctx context.Context, opCtx *graphql.Ope selectedFields = append(selectedFields, hasmetadata.FieldPackageNameID) fieldSeen[hasmetadata.FieldPackageNameID] = struct{}{} } + case "artifact": var ( alias = field.Alias path = append(path, alias) query = (&ArtifactClient{config: hm.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, artifactImplementors)...); err != nil { return err } hm.withArtifact = query @@ -1600,13 +1639,13 @@ func (hsa *HasSourceAtQuery) CollectFields(ctx context.Context, satisfies ...str if fc == nil { return hsa, nil } - if err := hsa.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := hsa.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return hsa, nil } -func (hsa *HasSourceAtQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (hsa *HasSourceAtQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -1615,13 +1654,14 @@ func (hsa *HasSourceAtQuery) collectField(ctx context.Context, opCtx *graphql.Op ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "packageVersion": var ( alias = field.Alias path = append(path, alias) query = (&PackageVersionClient{config: hsa.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, packageversionImplementors)...); err != nil { return err } hsa.withPackageVersion = query @@ -1629,13 +1669,14 @@ func (hsa *HasSourceAtQuery) collectField(ctx context.Context, opCtx *graphql.Op selectedFields = append(selectedFields, hassourceat.FieldPackageVersionID) fieldSeen[hassourceat.FieldPackageVersionID] = struct{}{} } + case "allVersions": var ( alias = field.Alias path = append(path, alias) query = (&PackageNameClient{config: hsa.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, packagenameImplementors)...); err != nil { return err } hsa.withAllVersions = query @@ -1643,13 +1684,14 @@ func (hsa *HasSourceAtQuery) collectField(ctx context.Context, opCtx *graphql.Op selectedFields = append(selectedFields, hassourceat.FieldPackageNameID) fieldSeen[hassourceat.FieldPackageNameID] = struct{}{} } + case "source": var ( alias = field.Alias path = append(path, alias) query = (&SourceNameClient{config: hsa.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, sourcenameImplementors)...); err != nil { return err } hsa.withSource = query @@ -1741,13 +1783,13 @@ func (he *HashEqualQuery) CollectFields(ctx context.Context, satisfies ...string if fc == nil { return he, nil } - if err := he.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := he.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return he, nil } -func (he *HashEqualQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (he *HashEqualQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -1756,13 +1798,14 @@ func (he *HashEqualQuery) collectField(ctx context.Context, opCtx *graphql.Opera ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "artifactA": var ( alias = field.Alias path = append(path, alias) query = (&ArtifactClient{config: he.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, artifactImplementors)...); err != nil { return err } he.withArtifactA = query @@ -1770,13 +1813,14 @@ func (he *HashEqualQuery) collectField(ctx context.Context, opCtx *graphql.Opera selectedFields = append(selectedFields, hashequal.FieldArtID) fieldSeen[hashequal.FieldArtID] = struct{}{} } + case "artifactB": var ( alias = field.Alias path = append(path, alias) query = (&ArtifactClient{config: he.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, artifactImplementors)...); err != nil { return err } he.withArtifactB = query @@ -1863,13 +1907,13 @@ func (l *LicenseQuery) CollectFields(ctx context.Context, satisfies ...string) ( if fc == nil { return l, nil } - if err := l.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := l.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return l, nil } -func (l *LicenseQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (l *LicenseQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -1878,25 +1922,27 @@ func (l *LicenseQuery) collectField(ctx context.Context, opCtx *graphql.Operatio ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "declaredInCertifyLegals": var ( alias = field.Alias path = append(path, alias) query = (&CertifyLegalClient{config: l.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, certifylegalImplementors)...); err != nil { return err } l.WithNamedDeclaredInCertifyLegals(alias, func(wq *CertifyLegalQuery) { *wq = *query }) + case "discoveredInCertifyLegals": var ( alias = field.Alias path = append(path, alias) query = (&CertifyLegalClient{config: l.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, certifylegalImplementors)...); err != nil { return err } l.WithNamedDiscoveredInCertifyLegals(alias, func(wq *CertifyLegalQuery) { @@ -1961,13 +2007,13 @@ func (o *OccurrenceQuery) CollectFields(ctx context.Context, satisfies ...string if fc == nil { return o, nil } - if err := o.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := o.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return o, nil } -func (o *OccurrenceQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (o *OccurrenceQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -1976,13 +2022,14 @@ func (o *OccurrenceQuery) collectField(ctx context.Context, opCtx *graphql.Opera ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "artifact": var ( alias = field.Alias path = append(path, alias) query = (&ArtifactClient{config: o.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, artifactImplementors)...); err != nil { return err } o.withArtifact = query @@ -1990,13 +2037,14 @@ func (o *OccurrenceQuery) collectField(ctx context.Context, opCtx *graphql.Opera selectedFields = append(selectedFields, occurrence.FieldArtifactID) fieldSeen[occurrence.FieldArtifactID] = struct{}{} } + case "package": var ( alias = field.Alias path = append(path, alias) query = (&PackageVersionClient{config: o.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, packageversionImplementors)...); err != nil { return err } o.withPackage = query @@ -2004,13 +2052,14 @@ func (o *OccurrenceQuery) collectField(ctx context.Context, opCtx *graphql.Opera selectedFields = append(selectedFields, occurrence.FieldPackageID) fieldSeen[occurrence.FieldPackageID] = struct{}{} } + case "source": var ( alias = field.Alias path = append(path, alias) query = (&SourceNameClient{config: o.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, sourcenameImplementors)...); err != nil { return err } o.withSource = query @@ -2018,13 +2067,14 @@ func (o *OccurrenceQuery) collectField(ctx context.Context, opCtx *graphql.Opera selectedFields = append(selectedFields, occurrence.FieldSourceID) fieldSeen[occurrence.FieldSourceID] = struct{}{} } + case "includedInSboms": var ( alias = field.Alias path = append(path, alias) query = (&BillOfMaterialsClient{config: o.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, billofmaterialsImplementors)...); err != nil { return err } o.WithNamedIncludedInSboms(alias, func(wq *BillOfMaterialsQuery) { @@ -2109,13 +2159,13 @@ func (pn *PackageNameQuery) CollectFields(ctx context.Context, satisfies ...stri if fc == nil { return pn, nil } - if err := pn.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := pn.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return pn, nil } -func (pn *PackageNameQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (pn *PackageNameQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -2124,73 +2174,79 @@ func (pn *PackageNameQuery) collectField(ctx context.Context, opCtx *graphql.Ope ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "versions": var ( alias = field.Alias path = append(path, alias) query = (&PackageVersionClient{config: pn.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, packageversionImplementors)...); err != nil { return err } pn.WithNamedVersions(alias, func(wq *PackageVersionQuery) { *wq = *query }) + case "hasSourceAt": var ( alias = field.Alias path = append(path, alias) query = (&HasSourceAtClient{config: pn.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, hassourceatImplementors)...); err != nil { return err } pn.WithNamedHasSourceAt(alias, func(wq *HasSourceAtQuery) { *wq = *query }) + case "dependency": var ( alias = field.Alias path = append(path, alias) query = (&DependencyClient{config: pn.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, dependencyImplementors)...); err != nil { return err } pn.WithNamedDependency(alias, func(wq *DependencyQuery) { *wq = *query }) + case "certification": var ( alias = field.Alias path = append(path, alias) query = (&CertificationClient{config: pn.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, certificationImplementors)...); err != nil { return err } pn.WithNamedCertification(alias, func(wq *CertificationQuery) { *wq = *query }) + case "metadata": var ( alias = field.Alias path = append(path, alias) query = (&HasMetadataClient{config: pn.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, hasmetadataImplementors)...); err != nil { return err } pn.WithNamedMetadata(alias, func(wq *HasMetadataQuery) { *wq = *query }) + case "poc": var ( alias = field.Alias path = append(path, alias) query = (&PointOfContactClient{config: pn.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, pointofcontactImplementors)...); err != nil { return err } pn.WithNamedPoc(alias, func(wq *PointOfContactQuery) { @@ -2255,13 +2311,13 @@ func (pv *PackageVersionQuery) CollectFields(ctx context.Context, satisfies ...s if fc == nil { return pv, nil } - if err := pv.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := pv.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return pv, nil } -func (pv *PackageVersionQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (pv *PackageVersionQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -2270,13 +2326,14 @@ func (pv *PackageVersionQuery) collectField(ctx context.Context, opCtx *graphql. ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "name": var ( alias = field.Alias path = append(path, alias) query = (&PackageNameClient{config: pv.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, packagenameImplementors)...); err != nil { return err } pv.withName = query @@ -2284,169 +2341,183 @@ func (pv *PackageVersionQuery) collectField(ctx context.Context, opCtx *graphql. selectedFields = append(selectedFields, packageversion.FieldNameID) fieldSeen[packageversion.FieldNameID] = struct{}{} } + case "occurrences": var ( alias = field.Alias path = append(path, alias) query = (&OccurrenceClient{config: pv.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, occurrenceImplementors)...); err != nil { return err } pv.WithNamedOccurrences(alias, func(wq *OccurrenceQuery) { *wq = *query }) + case "sbom": var ( alias = field.Alias path = append(path, alias) query = (&BillOfMaterialsClient{config: pv.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, billofmaterialsImplementors)...); err != nil { return err } pv.WithNamedSbom(alias, func(wq *BillOfMaterialsQuery) { *wq = *query }) + case "vuln": var ( alias = field.Alias path = append(path, alias) query = (&CertifyVulnClient{config: pv.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, certifyvulnImplementors)...); err != nil { return err } pv.WithNamedVuln(alias, func(wq *CertifyVulnQuery) { *wq = *query }) + case "vex": var ( alias = field.Alias path = append(path, alias) query = (&CertifyVexClient{config: pv.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, certifyvexImplementors)...); err != nil { return err } pv.WithNamedVex(alias, func(wq *CertifyVexQuery) { *wq = *query }) + case "hasSourceAt": var ( alias = field.Alias path = append(path, alias) query = (&HasSourceAtClient{config: pv.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, hassourceatImplementors)...); err != nil { return err } pv.WithNamedHasSourceAt(alias, func(wq *HasSourceAtQuery) { *wq = *query }) + case "certification": var ( alias = field.Alias path = append(path, alias) query = (&CertificationClient{config: pv.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, certificationImplementors)...); err != nil { return err } pv.WithNamedCertification(alias, func(wq *CertificationQuery) { *wq = *query }) + case "metadata": var ( alias = field.Alias path = append(path, alias) query = (&HasMetadataClient{config: pv.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, hasmetadataImplementors)...); err != nil { return err } pv.WithNamedMetadata(alias, func(wq *HasMetadataQuery) { *wq = *query }) + case "dependency": var ( alias = field.Alias path = append(path, alias) query = (&DependencyClient{config: pv.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, dependencyImplementors)...); err != nil { return err } pv.WithNamedDependency(alias, func(wq *DependencyQuery) { *wq = *query }) + case "dependencySubject": var ( alias = field.Alias path = append(path, alias) query = (&DependencyClient{config: pv.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, dependencyImplementors)...); err != nil { return err } pv.WithNamedDependencySubject(alias, func(wq *DependencyQuery) { *wq = *query }) + case "includedInSboms": var ( alias = field.Alias path = append(path, alias) query = (&BillOfMaterialsClient{config: pv.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, billofmaterialsImplementors)...); err != nil { return err } pv.WithNamedIncludedInSboms(alias, func(wq *BillOfMaterialsQuery) { *wq = *query }) + case "pkgEqualPkgA": var ( alias = field.Alias path = append(path, alias) query = (&PkgEqualClient{config: pv.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, pkgequalImplementors)...); err != nil { return err } pv.WithNamedPkgEqualPkgA(alias, func(wq *PkgEqualQuery) { *wq = *query }) + case "pkgEqualPkgB": var ( alias = field.Alias path = append(path, alias) query = (&PkgEqualClient{config: pv.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, pkgequalImplementors)...); err != nil { return err } pv.WithNamedPkgEqualPkgB(alias, func(wq *PkgEqualQuery) { *wq = *query }) + case "poc": var ( alias = field.Alias path = append(path, alias) query = (&PointOfContactClient{config: pv.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, pointofcontactImplementors)...); err != nil { return err } pv.WithNamedPoc(alias, func(wq *PointOfContactQuery) { *wq = *query }) + case "certifyLegal": var ( alias = field.Alias path = append(path, alias) query = (&CertifyLegalClient{config: pv.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, certifylegalImplementors)...); err != nil { return err } pv.WithNamedCertifyLegal(alias, func(wq *CertifyLegalQuery) { @@ -2521,13 +2592,13 @@ func (pe *PkgEqualQuery) CollectFields(ctx context.Context, satisfies ...string) if fc == nil { return pe, nil } - if err := pe.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := pe.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return pe, nil } -func (pe *PkgEqualQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (pe *PkgEqualQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -2536,13 +2607,14 @@ func (pe *PkgEqualQuery) collectField(ctx context.Context, opCtx *graphql.Operat ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "packageA": var ( alias = field.Alias path = append(path, alias) query = (&PackageVersionClient{config: pe.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, packageversionImplementors)...); err != nil { return err } pe.withPackageA = query @@ -2550,13 +2622,14 @@ func (pe *PkgEqualQuery) collectField(ctx context.Context, opCtx *graphql.Operat selectedFields = append(selectedFields, pkgequal.FieldPkgID) fieldSeen[pkgequal.FieldPkgID] = struct{}{} } + case "packageB": var ( alias = field.Alias path = append(path, alias) query = (&PackageVersionClient{config: pe.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, packageversionImplementors)...); err != nil { return err } pe.withPackageB = query @@ -2643,13 +2716,13 @@ func (poc *PointOfContactQuery) CollectFields(ctx context.Context, satisfies ... if fc == nil { return poc, nil } - if err := poc.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := poc.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return poc, nil } -func (poc *PointOfContactQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (poc *PointOfContactQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -2658,13 +2731,14 @@ func (poc *PointOfContactQuery) collectField(ctx context.Context, opCtx *graphql ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "source": var ( alias = field.Alias path = append(path, alias) query = (&SourceNameClient{config: poc.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, sourcenameImplementors)...); err != nil { return err } poc.withSource = query @@ -2672,13 +2746,14 @@ func (poc *PointOfContactQuery) collectField(ctx context.Context, opCtx *graphql selectedFields = append(selectedFields, pointofcontact.FieldSourceID) fieldSeen[pointofcontact.FieldSourceID] = struct{}{} } + case "packageVersion": var ( alias = field.Alias path = append(path, alias) query = (&PackageVersionClient{config: poc.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, packageversionImplementors)...); err != nil { return err } poc.withPackageVersion = query @@ -2686,13 +2761,14 @@ func (poc *PointOfContactQuery) collectField(ctx context.Context, opCtx *graphql selectedFields = append(selectedFields, pointofcontact.FieldPackageVersionID) fieldSeen[pointofcontact.FieldPackageVersionID] = struct{}{} } + case "allVersions": var ( alias = field.Alias path = append(path, alias) query = (&PackageNameClient{config: poc.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, packagenameImplementors)...); err != nil { return err } poc.withAllVersions = query @@ -2700,13 +2776,14 @@ func (poc *PointOfContactQuery) collectField(ctx context.Context, opCtx *graphql selectedFields = append(selectedFields, pointofcontact.FieldPackageNameID) fieldSeen[pointofcontact.FieldPackageNameID] = struct{}{} } + case "artifact": var ( alias = field.Alias path = append(path, alias) query = (&ArtifactClient{config: poc.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, artifactImplementors)...); err != nil { return err } poc.withArtifact = query @@ -2813,13 +2890,13 @@ func (sa *SLSAAttestationQuery) CollectFields(ctx context.Context, satisfies ... if fc == nil { return sa, nil } - if err := sa.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := sa.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return sa, nil } -func (sa *SLSAAttestationQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (sa *SLSAAttestationQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -2828,25 +2905,27 @@ func (sa *SLSAAttestationQuery) collectField(ctx context.Context, opCtx *graphql ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "builtFrom": var ( alias = field.Alias path = append(path, alias) query = (&ArtifactClient{config: sa.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, artifactImplementors)...); err != nil { return err } sa.WithNamedBuiltFrom(alias, func(wq *ArtifactQuery) { *wq = *query }) + case "builtBy": var ( alias = field.Alias path = append(path, alias) query = (&BuilderClient{config: sa.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, builderImplementors)...); err != nil { return err } sa.withBuiltBy = query @@ -2854,13 +2933,14 @@ func (sa *SLSAAttestationQuery) collectField(ctx context.Context, opCtx *graphql selectedFields = append(selectedFields, slsaattestation.FieldBuiltByID) fieldSeen[slsaattestation.FieldBuiltByID] = struct{}{} } + case "subject": var ( alias = field.Alias path = append(path, alias) query = (&ArtifactClient{config: sa.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, artifactImplementors)...); err != nil { return err } sa.withSubject = query @@ -2967,13 +3047,13 @@ func (sn *SourceNameQuery) CollectFields(ctx context.Context, satisfies ...strin if fc == nil { return sn, nil } - if err := sn.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := sn.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return sn, nil } -func (sn *SourceNameQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (sn *SourceNameQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -2982,85 +3062,92 @@ func (sn *SourceNameQuery) collectField(ctx context.Context, opCtx *graphql.Oper ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "occurrences": var ( alias = field.Alias path = append(path, alias) query = (&OccurrenceClient{config: sn.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, occurrenceImplementors)...); err != nil { return err } sn.WithNamedOccurrences(alias, func(wq *OccurrenceQuery) { *wq = *query }) + case "hasSourceAt": var ( alias = field.Alias path = append(path, alias) query = (&HasSourceAtClient{config: sn.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, hassourceatImplementors)...); err != nil { return err } sn.WithNamedHasSourceAt(alias, func(wq *HasSourceAtQuery) { *wq = *query }) + case "scorecard": var ( alias = field.Alias path = append(path, alias) query = (&CertifyScorecardClient{config: sn.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, certifyscorecardImplementors)...); err != nil { return err } sn.WithNamedScorecard(alias, func(wq *CertifyScorecardQuery) { *wq = *query }) + case "certification": var ( alias = field.Alias path = append(path, alias) query = (&CertificationClient{config: sn.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, certificationImplementors)...); err != nil { return err } sn.WithNamedCertification(alias, func(wq *CertificationQuery) { *wq = *query }) + case "metadata": var ( alias = field.Alias path = append(path, alias) query = (&HasMetadataClient{config: sn.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, hasmetadataImplementors)...); err != nil { return err } sn.WithNamedMetadata(alias, func(wq *HasMetadataQuery) { *wq = *query }) + case "poc": var ( alias = field.Alias path = append(path, alias) query = (&PointOfContactClient{config: sn.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, pointofcontactImplementors)...); err != nil { return err } sn.WithNamedPoc(alias, func(wq *PointOfContactQuery) { *wq = *query }) + case "certifyLegal": var ( alias = field.Alias path = append(path, alias) query = (&CertifyLegalClient{config: sn.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, certifylegalImplementors)...); err != nil { return err } sn.WithNamedCertifyLegal(alias, func(wq *CertifyLegalQuery) { @@ -3135,13 +3222,13 @@ func (ve *VulnEqualQuery) CollectFields(ctx context.Context, satisfies ...string if fc == nil { return ve, nil } - if err := ve.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := ve.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return ve, nil } -func (ve *VulnEqualQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (ve *VulnEqualQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -3150,13 +3237,14 @@ func (ve *VulnEqualQuery) collectField(ctx context.Context, opCtx *graphql.Opera ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "vulnerabilityA": var ( alias = field.Alias path = append(path, alias) query = (&VulnerabilityIDClient{config: ve.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, vulnerabilityidImplementors)...); err != nil { return err } ve.withVulnerabilityA = query @@ -3164,13 +3252,14 @@ func (ve *VulnEqualQuery) collectField(ctx context.Context, opCtx *graphql.Opera selectedFields = append(selectedFields, vulnequal.FieldVulnID) fieldSeen[vulnequal.FieldVulnID] = struct{}{} } + case "vulnerabilityB": var ( alias = field.Alias path = append(path, alias) query = (&VulnerabilityIDClient{config: ve.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, vulnerabilityidImplementors)...); err != nil { return err } ve.withVulnerabilityB = query @@ -3257,13 +3346,13 @@ func (vi *VulnerabilityIDQuery) CollectFields(ctx context.Context, satisfies ... if fc == nil { return vi, nil } - if err := vi.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := vi.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return vi, nil } -func (vi *VulnerabilityIDQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (vi *VulnerabilityIDQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -3272,61 +3361,66 @@ func (vi *VulnerabilityIDQuery) collectField(ctx context.Context, opCtx *graphql ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "vulnEqualVulnA": var ( alias = field.Alias path = append(path, alias) query = (&VulnEqualClient{config: vi.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, vulnequalImplementors)...); err != nil { return err } vi.WithNamedVulnEqualVulnA(alias, func(wq *VulnEqualQuery) { *wq = *query }) + case "vulnEqualVulnB": var ( alias = field.Alias path = append(path, alias) query = (&VulnEqualClient{config: vi.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, vulnequalImplementors)...); err != nil { return err } vi.WithNamedVulnEqualVulnB(alias, func(wq *VulnEqualQuery) { *wq = *query }) + case "metadata": var ( alias = field.Alias path = append(path, alias) query = (&VulnerabilityMetadataClient{config: vi.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, vulnerabilitymetadataImplementors)...); err != nil { return err } vi.WithNamedMetadata(alias, func(wq *VulnerabilityMetadataQuery) { *wq = *query }) + case "certifyVuln": var ( alias = field.Alias path = append(path, alias) query = (&CertifyVulnClient{config: vi.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, certifyvulnImplementors)...); err != nil { return err } vi.WithNamedCertifyVuln(alias, func(wq *CertifyVulnQuery) { *wq = *query }) + case "vex": var ( alias = field.Alias path = append(path, alias) query = (&CertifyVexClient{config: vi.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, false, opCtx, field, path, mayAddCondition(satisfies, certifyvexImplementors)...); err != nil { return err } vi.WithNamedVex(alias, func(wq *CertifyVexQuery) { @@ -3386,13 +3480,13 @@ func (vm *VulnerabilityMetadataQuery) CollectFields(ctx context.Context, satisfi if fc == nil { return vm, nil } - if err := vm.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := vm.collectField(ctx, false, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } return vm, nil } -func (vm *VulnerabilityMetadataQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (vm *VulnerabilityMetadataQuery) collectField(ctx context.Context, oneNode bool, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool @@ -3401,13 +3495,14 @@ func (vm *VulnerabilityMetadataQuery) collectField(ctx context.Context, opCtx *g ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { + case "vulnerabilityID": var ( alias = field.Alias path = append(path, alias) query = (&VulnerabilityIDClient{config: vm.config}).Query() ) - if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + if err := query.collectField(ctx, oneNode, opCtx, field, path, mayAddCondition(satisfies, vulnerabilityidImplementors)...); err != nil { return err } vm.withVulnerabilityID = query @@ -3540,39 +3635,17 @@ func unmarshalArgs(ctx context.Context, whereInput any, args map[string]any) map return args } -func limitRows(partitionBy string, limit int, orderBy ...sql.Querier) func(s *sql.Selector) { - return func(s *sql.Selector) { - d := sql.Dialect(s.Dialect()) - s.SetDistinct(false) - with := d.With("src_query"). - As(s.Clone()). - With("limited_query"). - As( - d.Select("*"). - AppendSelectExprAs( - sql.RowNumber().PartitionBy(partitionBy).OrderExpr(orderBy...), - "row_number", - ). - From(d.Table("src_query")), - ) - t := d.Table("limited_query").As(s.TableName()) - *s = *d.Select(s.UnqualifiedColumns()...). - From(t). - Where(sql.LTE(t.C("row_number"), limit)). - Prefix(with) - } -} - // mayAddCondition appends another type condition to the satisfies list -// if condition is enabled (Node/Nodes) and it does not exist in the list. -func mayAddCondition(satisfies []string, typeCond string) []string { - if len(satisfies) == 0 { - return satisfies - } - for _, s := range satisfies { - if typeCond == s { - return satisfies +// if it does not exist in the list. +func mayAddCondition(satisfies []string, typeCond []string) []string { +Cond: + for _, c := range typeCond { + for _, s := range satisfies { + if c == s { + continue Cond + } } + satisfies = append(satisfies, c) } - return append(satisfies, typeCond) + return satisfies } diff --git a/pkg/assembler/backends/ent/gql_node.go b/pkg/assembler/backends/ent/gql_node.go index fd0a2b65f2..f6bbe0476c 100644 --- a/pkg/assembler/backends/ent/gql_node.go +++ b/pkg/assembler/backends/ent/gql_node.go @@ -40,74 +40,120 @@ type Noder interface { IsNode() } +var artifactImplementors = []string{"Artifact", "Node"} + // IsNode implements the Node interface check for GQLGen. -func (n *Artifact) IsNode() {} +func (*Artifact) IsNode() {} + +var billofmaterialsImplementors = []string{"BillOfMaterials", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *BillOfMaterials) IsNode() {} +func (*BillOfMaterials) IsNode() {} + +var builderImplementors = []string{"Builder", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Builder) IsNode() {} +func (*Builder) IsNode() {} + +var certificationImplementors = []string{"Certification", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Certification) IsNode() {} +func (*Certification) IsNode() {} + +var certifylegalImplementors = []string{"CertifyLegal", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *CertifyLegal) IsNode() {} +func (*CertifyLegal) IsNode() {} + +var certifyscorecardImplementors = []string{"CertifyScorecard", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *CertifyScorecard) IsNode() {} +func (*CertifyScorecard) IsNode() {} + +var certifyvexImplementors = []string{"CertifyVex", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *CertifyVex) IsNode() {} +func (*CertifyVex) IsNode() {} + +var certifyvulnImplementors = []string{"CertifyVuln", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *CertifyVuln) IsNode() {} +func (*CertifyVuln) IsNode() {} + +var dependencyImplementors = []string{"Dependency", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Dependency) IsNode() {} +func (*Dependency) IsNode() {} + +var hasmetadataImplementors = []string{"HasMetadata", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *HasMetadata) IsNode() {} +func (*HasMetadata) IsNode() {} + +var hassourceatImplementors = []string{"HasSourceAt", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *HasSourceAt) IsNode() {} +func (*HasSourceAt) IsNode() {} + +var hashequalImplementors = []string{"HashEqual", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *HashEqual) IsNode() {} +func (*HashEqual) IsNode() {} + +var licenseImplementors = []string{"License", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *License) IsNode() {} +func (*License) IsNode() {} + +var occurrenceImplementors = []string{"Occurrence", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *Occurrence) IsNode() {} +func (*Occurrence) IsNode() {} + +var packagenameImplementors = []string{"PackageName", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *PackageName) IsNode() {} +func (*PackageName) IsNode() {} + +var packageversionImplementors = []string{"PackageVersion", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *PackageVersion) IsNode() {} +func (*PackageVersion) IsNode() {} + +var pkgequalImplementors = []string{"PkgEqual", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *PkgEqual) IsNode() {} +func (*PkgEqual) IsNode() {} + +var pointofcontactImplementors = []string{"PointOfContact", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *PointOfContact) IsNode() {} +func (*PointOfContact) IsNode() {} + +var slsaattestationImplementors = []string{"SLSAAttestation", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *SLSAAttestation) IsNode() {} +func (*SLSAAttestation) IsNode() {} + +var sourcenameImplementors = []string{"SourceName", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *SourceName) IsNode() {} +func (*SourceName) IsNode() {} + +var vulnequalImplementors = []string{"VulnEqual", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *VulnEqual) IsNode() {} +func (*VulnEqual) IsNode() {} + +var vulnerabilityidImplementors = []string{"VulnerabilityID", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *VulnerabilityID) IsNode() {} +func (*VulnerabilityID) IsNode() {} + +var vulnerabilitymetadataImplementors = []string{"VulnerabilityMetadata", "Node"} // IsNode implements the Node interface check for GQLGen. -func (n *VulnerabilityMetadata) IsNode() {} +func (*VulnerabilityMetadata) IsNode() {} var errNodeInvalidID = &NotFoundError{"node"} @@ -170,279 +216,210 @@ func (c *Client) noder(ctx context.Context, table string, id uuid.UUID) (Noder, case artifact.Table: query := c.Artifact.Query(). Where(artifact.ID(id)) - query, err := query.CollectFields(ctx, "Artifact") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, artifactImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case billofmaterials.Table: query := c.BillOfMaterials.Query(). Where(billofmaterials.ID(id)) - query, err := query.CollectFields(ctx, "BillOfMaterials") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, billofmaterialsImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case builder.Table: query := c.Builder.Query(). Where(builder.ID(id)) - query, err := query.CollectFields(ctx, "Builder") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, builderImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case certification.Table: query := c.Certification.Query(). Where(certification.ID(id)) - query, err := query.CollectFields(ctx, "Certification") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, certificationImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case certifylegal.Table: query := c.CertifyLegal.Query(). Where(certifylegal.ID(id)) - query, err := query.CollectFields(ctx, "CertifyLegal") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, certifylegalImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case certifyscorecard.Table: query := c.CertifyScorecard.Query(). Where(certifyscorecard.ID(id)) - query, err := query.CollectFields(ctx, "CertifyScorecard") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, certifyscorecardImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case certifyvex.Table: query := c.CertifyVex.Query(). Where(certifyvex.ID(id)) - query, err := query.CollectFields(ctx, "CertifyVex") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, certifyvexImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case certifyvuln.Table: query := c.CertifyVuln.Query(). Where(certifyvuln.ID(id)) - query, err := query.CollectFields(ctx, "CertifyVuln") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, certifyvulnImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case dependency.Table: query := c.Dependency.Query(). Where(dependency.ID(id)) - query, err := query.CollectFields(ctx, "Dependency") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, dependencyImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case hasmetadata.Table: query := c.HasMetadata.Query(). Where(hasmetadata.ID(id)) - query, err := query.CollectFields(ctx, "HasMetadata") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, hasmetadataImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case hassourceat.Table: query := c.HasSourceAt.Query(). Where(hassourceat.ID(id)) - query, err := query.CollectFields(ctx, "HasSourceAt") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, hassourceatImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case hashequal.Table: query := c.HashEqual.Query(). Where(hashequal.ID(id)) - query, err := query.CollectFields(ctx, "HashEqual") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, hashequalImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case license.Table: query := c.License.Query(). Where(license.ID(id)) - query, err := query.CollectFields(ctx, "License") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, licenseImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case occurrence.Table: query := c.Occurrence.Query(). Where(occurrence.ID(id)) - query, err := query.CollectFields(ctx, "Occurrence") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, occurrenceImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case packagename.Table: query := c.PackageName.Query(). Where(packagename.ID(id)) - query, err := query.CollectFields(ctx, "PackageName") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, packagenameImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case packageversion.Table: query := c.PackageVersion.Query(). Where(packageversion.ID(id)) - query, err := query.CollectFields(ctx, "PackageVersion") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, packageversionImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case pkgequal.Table: query := c.PkgEqual.Query(). Where(pkgequal.ID(id)) - query, err := query.CollectFields(ctx, "PkgEqual") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, pkgequalImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case pointofcontact.Table: query := c.PointOfContact.Query(). Where(pointofcontact.ID(id)) - query, err := query.CollectFields(ctx, "PointOfContact") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, pointofcontactImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case slsaattestation.Table: query := c.SLSAAttestation.Query(). Where(slsaattestation.ID(id)) - query, err := query.CollectFields(ctx, "SLSAAttestation") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, slsaattestationImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case sourcename.Table: query := c.SourceName.Query(). Where(sourcename.ID(id)) - query, err := query.CollectFields(ctx, "SourceName") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, sourcenameImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case vulnequal.Table: query := c.VulnEqual.Query(). Where(vulnequal.ID(id)) - query, err := query.CollectFields(ctx, "VulnEqual") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, vulnequalImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case vulnerabilityid.Table: query := c.VulnerabilityID.Query(). Where(vulnerabilityid.ID(id)) - query, err := query.CollectFields(ctx, "VulnerabilityID") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, vulnerabilityidImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) case vulnerabilitymetadata.Table: query := c.VulnerabilityMetadata.Query(). Where(vulnerabilitymetadata.ID(id)) - query, err := query.CollectFields(ctx, "VulnerabilityMetadata") - if err != nil { - return nil, err - } - n, err := query.Only(ctx) - if err != nil { - return nil, err + if fc := graphql.GetFieldContext(ctx); fc != nil { + if err := query.collectField(ctx, true, graphql.GetOperationContext(ctx), fc.Field, nil, vulnerabilitymetadataImplementors...); err != nil { + return nil, err + } } - return n, nil + return query.Only(ctx) default: return nil, fmt.Errorf("cannot resolve noder from table %q: %w", table, errNodeInvalidID) } @@ -519,7 +496,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case artifact.Table: query := c.Artifact.Query(). Where(artifact.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Artifact") + query, err := query.CollectFields(ctx, artifactImplementors...) if err != nil { return nil, err } @@ -535,7 +512,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case billofmaterials.Table: query := c.BillOfMaterials.Query(). Where(billofmaterials.IDIn(ids...)) - query, err := query.CollectFields(ctx, "BillOfMaterials") + query, err := query.CollectFields(ctx, billofmaterialsImplementors...) if err != nil { return nil, err } @@ -551,7 +528,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case builder.Table: query := c.Builder.Query(). Where(builder.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Builder") + query, err := query.CollectFields(ctx, builderImplementors...) if err != nil { return nil, err } @@ -567,7 +544,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case certification.Table: query := c.Certification.Query(). Where(certification.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Certification") + query, err := query.CollectFields(ctx, certificationImplementors...) if err != nil { return nil, err } @@ -583,7 +560,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case certifylegal.Table: query := c.CertifyLegal.Query(). Where(certifylegal.IDIn(ids...)) - query, err := query.CollectFields(ctx, "CertifyLegal") + query, err := query.CollectFields(ctx, certifylegalImplementors...) if err != nil { return nil, err } @@ -599,7 +576,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case certifyscorecard.Table: query := c.CertifyScorecard.Query(). Where(certifyscorecard.IDIn(ids...)) - query, err := query.CollectFields(ctx, "CertifyScorecard") + query, err := query.CollectFields(ctx, certifyscorecardImplementors...) if err != nil { return nil, err } @@ -615,7 +592,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case certifyvex.Table: query := c.CertifyVex.Query(). Where(certifyvex.IDIn(ids...)) - query, err := query.CollectFields(ctx, "CertifyVex") + query, err := query.CollectFields(ctx, certifyvexImplementors...) if err != nil { return nil, err } @@ -631,7 +608,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case certifyvuln.Table: query := c.CertifyVuln.Query(). Where(certifyvuln.IDIn(ids...)) - query, err := query.CollectFields(ctx, "CertifyVuln") + query, err := query.CollectFields(ctx, certifyvulnImplementors...) if err != nil { return nil, err } @@ -647,7 +624,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case dependency.Table: query := c.Dependency.Query(). Where(dependency.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Dependency") + query, err := query.CollectFields(ctx, dependencyImplementors...) if err != nil { return nil, err } @@ -663,7 +640,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case hasmetadata.Table: query := c.HasMetadata.Query(). Where(hasmetadata.IDIn(ids...)) - query, err := query.CollectFields(ctx, "HasMetadata") + query, err := query.CollectFields(ctx, hasmetadataImplementors...) if err != nil { return nil, err } @@ -679,7 +656,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case hassourceat.Table: query := c.HasSourceAt.Query(). Where(hassourceat.IDIn(ids...)) - query, err := query.CollectFields(ctx, "HasSourceAt") + query, err := query.CollectFields(ctx, hassourceatImplementors...) if err != nil { return nil, err } @@ -695,7 +672,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case hashequal.Table: query := c.HashEqual.Query(). Where(hashequal.IDIn(ids...)) - query, err := query.CollectFields(ctx, "HashEqual") + query, err := query.CollectFields(ctx, hashequalImplementors...) if err != nil { return nil, err } @@ -711,7 +688,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case license.Table: query := c.License.Query(). Where(license.IDIn(ids...)) - query, err := query.CollectFields(ctx, "License") + query, err := query.CollectFields(ctx, licenseImplementors...) if err != nil { return nil, err } @@ -727,7 +704,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case occurrence.Table: query := c.Occurrence.Query(). Where(occurrence.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Occurrence") + query, err := query.CollectFields(ctx, occurrenceImplementors...) if err != nil { return nil, err } @@ -743,7 +720,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case packagename.Table: query := c.PackageName.Query(). Where(packagename.IDIn(ids...)) - query, err := query.CollectFields(ctx, "PackageName") + query, err := query.CollectFields(ctx, packagenameImplementors...) if err != nil { return nil, err } @@ -759,7 +736,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case packageversion.Table: query := c.PackageVersion.Query(). Where(packageversion.IDIn(ids...)) - query, err := query.CollectFields(ctx, "PackageVersion") + query, err := query.CollectFields(ctx, packageversionImplementors...) if err != nil { return nil, err } @@ -775,7 +752,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case pkgequal.Table: query := c.PkgEqual.Query(). Where(pkgequal.IDIn(ids...)) - query, err := query.CollectFields(ctx, "PkgEqual") + query, err := query.CollectFields(ctx, pkgequalImplementors...) if err != nil { return nil, err } @@ -791,7 +768,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case pointofcontact.Table: query := c.PointOfContact.Query(). Where(pointofcontact.IDIn(ids...)) - query, err := query.CollectFields(ctx, "PointOfContact") + query, err := query.CollectFields(ctx, pointofcontactImplementors...) if err != nil { return nil, err } @@ -807,7 +784,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case slsaattestation.Table: query := c.SLSAAttestation.Query(). Where(slsaattestation.IDIn(ids...)) - query, err := query.CollectFields(ctx, "SLSAAttestation") + query, err := query.CollectFields(ctx, slsaattestationImplementors...) if err != nil { return nil, err } @@ -823,7 +800,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case sourcename.Table: query := c.SourceName.Query(). Where(sourcename.IDIn(ids...)) - query, err := query.CollectFields(ctx, "SourceName") + query, err := query.CollectFields(ctx, sourcenameImplementors...) if err != nil { return nil, err } @@ -839,7 +816,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case vulnequal.Table: query := c.VulnEqual.Query(). Where(vulnequal.IDIn(ids...)) - query, err := query.CollectFields(ctx, "VulnEqual") + query, err := query.CollectFields(ctx, vulnequalImplementors...) if err != nil { return nil, err } @@ -855,7 +832,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case vulnerabilityid.Table: query := c.VulnerabilityID.Query(). Where(vulnerabilityid.IDIn(ids...)) - query, err := query.CollectFields(ctx, "VulnerabilityID") + query, err := query.CollectFields(ctx, vulnerabilityidImplementors...) if err != nil { return nil, err } @@ -871,7 +848,7 @@ func (c *Client) noders(ctx context.Context, table string, ids []uuid.UUID) ([]N case vulnerabilitymetadata.Table: query := c.VulnerabilityMetadata.Query(). Where(vulnerabilitymetadata.IDIn(ids...)) - query, err := query.CollectFields(ctx, "VulnerabilityMetadata") + query, err := query.CollectFields(ctx, vulnerabilitymetadataImplementors...) if err != nil { return nil, err } diff --git a/pkg/assembler/backends/ent/gql_pagination.go b/pkg/assembler/backends/ent/gql_pagination.go index 35b809da5e..1bf2a74aa6 100644 --- a/pkg/assembler/backends/ent/gql_pagination.go +++ b/pkg/assembler/backends/ent/gql_pagination.go @@ -293,7 +293,9 @@ func (a *ArtifactQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = a.Clone().Count(ctx); err != nil { + c := a.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -306,11 +308,12 @@ func (a *ArtifactQuery) Paginate( if a, err = pager.applyCursors(a, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { a.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := a.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := a.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -539,7 +542,9 @@ func (bom *BillOfMaterialsQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = bom.Clone().Count(ctx); err != nil { + c := bom.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -552,11 +557,12 @@ func (bom *BillOfMaterialsQuery) Paginate( if bom, err = pager.applyCursors(bom, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { bom.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := bom.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := bom.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -785,7 +791,9 @@ func (b *BuilderQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = b.Clone().Count(ctx); err != nil { + c := b.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -798,11 +806,12 @@ func (b *BuilderQuery) Paginate( if b, err = pager.applyCursors(b, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { b.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := b.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := b.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -1031,7 +1040,9 @@ func (c *CertificationQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = c.Clone().Count(ctx); err != nil { + c := c.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1044,11 +1055,12 @@ func (c *CertificationQuery) Paginate( if c, err = pager.applyCursors(c, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { c.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := c.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := c.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -1277,7 +1289,9 @@ func (cl *CertifyLegalQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = cl.Clone().Count(ctx); err != nil { + c := cl.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1290,11 +1304,12 @@ func (cl *CertifyLegalQuery) Paginate( if cl, err = pager.applyCursors(cl, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { cl.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := cl.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := cl.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -1523,7 +1538,9 @@ func (cs *CertifyScorecardQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = cs.Clone().Count(ctx); err != nil { + c := cs.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1536,11 +1553,12 @@ func (cs *CertifyScorecardQuery) Paginate( if cs, err = pager.applyCursors(cs, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { cs.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := cs.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := cs.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -1769,7 +1787,9 @@ func (cv *CertifyVexQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = cv.Clone().Count(ctx); err != nil { + c := cv.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1782,11 +1802,12 @@ func (cv *CertifyVexQuery) Paginate( if cv, err = pager.applyCursors(cv, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { cv.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := cv.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := cv.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -2015,7 +2036,9 @@ func (cv *CertifyVulnQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = cv.Clone().Count(ctx); err != nil { + c := cv.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -2028,11 +2051,12 @@ func (cv *CertifyVulnQuery) Paginate( if cv, err = pager.applyCursors(cv, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { cv.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := cv.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := cv.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -2261,7 +2285,9 @@ func (d *DependencyQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = d.Clone().Count(ctx); err != nil { + c := d.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -2274,11 +2300,12 @@ func (d *DependencyQuery) Paginate( if d, err = pager.applyCursors(d, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { d.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := d.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := d.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -2507,7 +2534,9 @@ func (hm *HasMetadataQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = hm.Clone().Count(ctx); err != nil { + c := hm.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -2520,11 +2549,12 @@ func (hm *HasMetadataQuery) Paginate( if hm, err = pager.applyCursors(hm, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { hm.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := hm.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := hm.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -2753,7 +2783,9 @@ func (hsa *HasSourceAtQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = hsa.Clone().Count(ctx); err != nil { + c := hsa.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -2766,11 +2798,12 @@ func (hsa *HasSourceAtQuery) Paginate( if hsa, err = pager.applyCursors(hsa, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { hsa.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := hsa.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := hsa.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -2999,7 +3032,9 @@ func (he *HashEqualQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = he.Clone().Count(ctx); err != nil { + c := he.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -3012,11 +3047,12 @@ func (he *HashEqualQuery) Paginate( if he, err = pager.applyCursors(he, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { he.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := he.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := he.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -3245,7 +3281,9 @@ func (l *LicenseQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = l.Clone().Count(ctx); err != nil { + c := l.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -3258,11 +3296,12 @@ func (l *LicenseQuery) Paginate( if l, err = pager.applyCursors(l, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { l.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := l.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := l.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -3491,7 +3530,9 @@ func (o *OccurrenceQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = o.Clone().Count(ctx); err != nil { + c := o.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -3504,11 +3545,12 @@ func (o *OccurrenceQuery) Paginate( if o, err = pager.applyCursors(o, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { o.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := o.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := o.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -3737,7 +3779,9 @@ func (pn *PackageNameQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = pn.Clone().Count(ctx); err != nil { + c := pn.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -3750,11 +3794,12 @@ func (pn *PackageNameQuery) Paginate( if pn, err = pager.applyCursors(pn, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { pn.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := pn.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := pn.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -3983,7 +4028,9 @@ func (pv *PackageVersionQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = pv.Clone().Count(ctx); err != nil { + c := pv.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -3996,11 +4043,12 @@ func (pv *PackageVersionQuery) Paginate( if pv, err = pager.applyCursors(pv, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { pv.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := pv.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := pv.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -4229,7 +4277,9 @@ func (pe *PkgEqualQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = pe.Clone().Count(ctx); err != nil { + c := pe.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -4242,11 +4292,12 @@ func (pe *PkgEqualQuery) Paginate( if pe, err = pager.applyCursors(pe, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { pe.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := pe.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := pe.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -4475,7 +4526,9 @@ func (poc *PointOfContactQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = poc.Clone().Count(ctx); err != nil { + c := poc.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -4488,11 +4541,12 @@ func (poc *PointOfContactQuery) Paginate( if poc, err = pager.applyCursors(poc, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { poc.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := poc.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := poc.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -4721,7 +4775,9 @@ func (sa *SLSAAttestationQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = sa.Clone().Count(ctx); err != nil { + c := sa.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -4734,11 +4790,12 @@ func (sa *SLSAAttestationQuery) Paginate( if sa, err = pager.applyCursors(sa, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { sa.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := sa.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := sa.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -4967,7 +5024,9 @@ func (sn *SourceNameQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = sn.Clone().Count(ctx); err != nil { + c := sn.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -4980,11 +5039,12 @@ func (sn *SourceNameQuery) Paginate( if sn, err = pager.applyCursors(sn, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { sn.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := sn.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := sn.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -5213,7 +5273,9 @@ func (ve *VulnEqualQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = ve.Clone().Count(ctx); err != nil { + c := ve.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -5226,11 +5288,12 @@ func (ve *VulnEqualQuery) Paginate( if ve, err = pager.applyCursors(ve, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { ve.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := ve.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := ve.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -5459,7 +5522,9 @@ func (vi *VulnerabilityIDQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = vi.Clone().Count(ctx); err != nil { + c := vi.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -5472,11 +5537,12 @@ func (vi *VulnerabilityIDQuery) Paginate( if vi, err = pager.applyCursors(vi, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { vi.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := vi.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := vi.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } @@ -5705,7 +5771,9 @@ func (vm *VulnerabilityMetadataQuery) Paginate( if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = vm.Clone().Count(ctx); err != nil { + c := vm.Clone() + c.ctx.Fields = nil + if conn.TotalCount, err = c.Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -5718,11 +5786,12 @@ func (vm *VulnerabilityMetadataQuery) Paginate( if vm, err = pager.applyCursors(vm, after, before); err != nil { return nil, err } - if limit := paginateLimit(first, last); limit != 0 { + limit := paginateLimit(first, last) + if limit != 0 { vm.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := vm.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := vm.collectField(ctx, limit == 1, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } }