diff --git a/pkg/server/api/console/v1/cookie_banner_resolvers.go b/pkg/server/api/console/v1/cookie_banner_resolvers.go index 56298c3a8..bf0d7f832 100644 --- a/pkg/server/api/console/v1/cookie_banner_resolvers.go +++ b/pkg/server/api/console/v1/cookie_banner_resolvers.go @@ -222,9 +222,11 @@ func (r *cookieBannerResolver) TrackerPatterns(ctx context.Context, obj *types.C r.logger.ErrorCtx(ctx, "cannot resolve common third party tracker patterns", log.Error(err)) return nil, gqlutils.Internal(ctx) } + if ids == nil { ids = []gid.GID{} } + coredataFilter = coredataFilter.WithCommonTrackerPatternIDs(ids) default: return nil, gqlutils.Invalidf(ctx, "thirdPartyId must reference a ThirdParty or CommonThirdParty") @@ -276,19 +278,24 @@ func (r *cookieBannerResolver) LinkedThirdParties(ctx context.Context, obj *type if len(thirdPartyIDs) > 0 { tps, loadErr := loaders.ThirdParty.LoadAll(ctx, thirdPartyIDs) + var loadErrs dataloadgen.ErrorSlice if loadErr != nil && !errors.As(loadErr, &loadErrs) { r.logger.ErrorCtx(ctx, "cannot get third parties", log.Error(loadErr)) return nil, gqlutils.Internal(ctx) } + for i, tp := range tps { if loadErrs != nil && loadErrs[i] != nil { if errors.Is(loadErrs[i], coredata.ErrResourceNotFound) || errors.Is(loadErrs[i], dataloadgen.ErrNotFound) { continue } + r.logger.ErrorCtx(ctx, "cannot get third party", log.Error(loadErrs[i])) + return nil, gqlutils.Internal(ctx) } + out = append(out, types.NewThirdParty(tp)) } } @@ -306,14 +313,17 @@ func (r *cookieBannerResolver) LinkedThirdParties(ctx context.Context, obj *type } seen := make(map[gid.GID]struct{}, len(patterns)) + commonThirdPartyIDs := make([]gid.GID, 0, len(patterns)) for _, p := range patterns { if p.CommonThirdPartyID == nil { continue } + if _, ok := seen[*p.CommonThirdPartyID]; ok { continue } + seen[*p.CommonThirdPartyID] = struct{}{} commonThirdPartyIDs = append(commonThirdPartyIDs, *p.CommonThirdPartyID) } @@ -324,6 +334,7 @@ func (r *cookieBannerResolver) LinkedThirdParties(ctx context.Context, obj *type r.logger.ErrorCtx(ctx, "cannot get common third parties", log.Error(err)) return nil, gqlutils.Internal(ctx) } + for _, p := range parties { out = append(out, types.NewCommonThirdParty(p)) } diff --git a/pkg/server/api/mcp/v1/schema.resolvers.go b/pkg/server/api/mcp/v1/schema.resolvers.go index c04693db2..7768f965d 100644 --- a/pkg/server/api/mcp/v1/schema.resolvers.go +++ b/pkg/server/api/mcp/v1/schema.resolvers.go @@ -5567,6 +5567,7 @@ func (r *Resolver) ListCookieCategoriesTool(ctx context.Context, req *mcp.CallTo if err != nil { return nil, types.ListCookieCategoriesOutput{}, err } + cursor := types.NewCursor(input.Size, input.Cursor, page.OrderBy[coredata.CookieCategoryOrderField]{Field: coredata.CookieCategoryOrderFieldRank, Direction: page.OrderDirectionAsc}) categories, err := r.cookieBanner.ListCategoriesForBanner(ctx, scope, input.CookieBannerID, cursor, coredata.NewCookieCategoryFilter(new(coredata.CookieCategoryKindUncategorised))) @@ -5680,6 +5681,7 @@ func (r *Resolver) ListTrackerPatternsTool(ctx context.Context, req *mcp.CallToo if err != nil { return nil, types.ListTrackerPatternsOutput{}, err } + cursor := types.NewCursor(input.Size, input.Cursor, page.OrderBy[coredata.TrackerPatternOrderField]{Field: coredata.TrackerPatternOrderFieldCreatedAt, Direction: page.OrderDirectionAsc}) patterns, err := r.cookieBanner.ListTrackerPatternsForCategory(ctx, scope, input.CookieCategoryID, cursor) @@ -5805,6 +5807,7 @@ func (r *Resolver) ListCookieBannerVersionsTool(ctx context.Context, req *mcp.Ca if err != nil { return nil, types.ListCookieBannerVersionsOutput{}, err } + cursor := types.NewCursor(input.Size, input.Cursor, page.OrderBy[coredata.CookieBannerVersionOrderField]{Field: coredata.CookieBannerVersionOrderFieldCreatedAt, Direction: page.OrderDirectionDesc}) versions, err := r.cookieBanner.ListCookieBannerVersionsForBanner(ctx, scope, input.CookieBannerID, cursor) @@ -5840,6 +5843,7 @@ func (r *Resolver) ListCookieConsentRecordsTool(ctx context.Context, req *mcp.Ca if err != nil { return nil, types.ListCookieConsentRecordsOutput{}, err } + cursor := types.NewCursor(input.Size, input.Cursor, page.OrderBy[coredata.CookieConsentRecordOrderField]{Field: coredata.CookieConsentRecordOrderFieldCreatedAt, Direction: page.OrderDirectionDesc}) var action *coredata.CookieConsentAction @@ -6064,6 +6068,7 @@ func (r *Resolver) ListTrackerResourcesTool(ctx context.Context, req *mcp.CallTo if err != nil { return nil, types.ListTrackerResourcesOutput{}, err } + cursor := types.NewCursor(input.Size, input.Cursor, page.OrderBy[coredata.TrackerResourceOrderField]{Field: coredata.TrackerResourceOrderFieldCreatedAt, Direction: page.OrderDirectionAsc}) resources, err := r.cookieBanner.ListTrackerResourcesForCategory(ctx, scope, input.CookieCategoryID, cursor)