From 792f3f55b36e1b63f488770d0d028cbfcb8a5295 Mon Sep 17 00:00:00 2001 From: Andrei Aaron Date: Fri, 24 Feb 2023 22:22:01 +0200 Subject: [PATCH] feat(graphql): Image() call now returns a non-nullable ImageSummary (#1216) This is for consistency with the other calls, and should help in making all ZUI handling of ZOT errors consistent Signed-off-by: Andrei Aaron --- pkg/extensions/search/gql_generated/generated.go | 14 ++++++++++++-- pkg/extensions/search/schema.graphql | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/pkg/extensions/search/gql_generated/generated.go b/pkg/extensions/search/gql_generated/generated.go index 3166b0cb..7e2eccba 100644 --- a/pkg/extensions/search/gql_generated/generated.go +++ b/pkg/extensions/search/gql_generated/generated.go @@ -1575,7 +1575,7 @@ type Query { Image( "Image name in the format ` + "`" + `repository:tag` + "`" + `" image: String! - ): ImageSummary + ): ImageSummary! """ Returns a list of descriptors of an image or artifact manifest that are found in a and have a subject field of @@ -5200,11 +5200,14 @@ func (ec *executionContext) _Query_Image(ctx context.Context, field graphql.Coll return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } res := resTmp.(*ImageSummary) fc.Result = res - return ec.marshalOImageSummary2ᚖzotregistryᚗioᚋzotᚋpkgᚋextensionsᚋsearchᚋgql_generatedᚐImageSummary(ctx, field.Selections, res) + return ec.marshalNImageSummary2ᚖzotregistryᚗioᚋzotᚋpkgᚋextensionsᚋsearchᚋgql_generatedᚐImageSummary(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Query_Image(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -9002,6 +9005,9 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } }() res = ec._Query_Image(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } return res } @@ -9595,6 +9601,10 @@ func (ec *executionContext) marshalNGlobalSearchResult2ᚖzotregistryᚗioᚋzot return ec._GlobalSearchResult(ctx, sel, v) } +func (ec *executionContext) marshalNImageSummary2zotregistryᚗioᚋzotᚋpkgᚋextensionsᚋsearchᚋgql_generatedᚐImageSummary(ctx context.Context, sel ast.SelectionSet, v ImageSummary) graphql.Marshaler { + return ec._ImageSummary(ctx, sel, &v) +} + func (ec *executionContext) marshalNImageSummary2ᚕᚖzotregistryᚗioᚋzotᚋpkgᚋextensionsᚋsearchᚋgql_generatedᚐImageSummaryᚄ(ctx context.Context, sel ast.SelectionSet, v []*ImageSummary) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup diff --git a/pkg/extensions/search/schema.graphql b/pkg/extensions/search/schema.graphql index 2445ebf2..802a778d 100644 --- a/pkg/extensions/search/schema.graphql +++ b/pkg/extensions/search/schema.graphql @@ -626,7 +626,7 @@ type Query { Image( "Image name in the format `repository:tag`" image: String! - ): ImageSummary + ): ImageSummary! """ Returns a list of descriptors of an image or artifact manifest that are found in a and have a subject field of