Skip to content

Cookie banner cookies data schema changes#1079

Merged
codenem merged 4 commits intomainfrom
cookie-banner-cookies-data-schema-changes
Apr 21, 2026
Merged

Cookie banner cookies data schema changes#1079
codenem merged 4 commits intomainfrom
cookie-banner-cookies-data-schema-changes

Conversation

@codenem
Copy link
Copy Markdown
Contributor

@codenem codenem commented Apr 21, 2026

Relates to ENG-266

Summary by cubic

Moves cookie data to a dedicated cookies table and GraphQL model with full CRUD, replacing the embedded array on categories. The console UI now uses Relay connections so creating, editing, deleting, and moving cookies updates lists instantly without reloads. Also fixes update operations to return “not found” when no rows are affected.

  • New Features

    • DB: adds cookies table with unique name per banner; drops cookie_categories.cookies.
    • Core: new pkg/coredata/cookie.go and CookieOrderField; service methods to create/get/update/delete/list/count cookies; draft versions update on cookie changes; updates use Exec and check RowsAffected() for not-found.
    • API: new Cookie type and CookieConnection on CookieCategory.cookies; adds createCookie, updateCookie, deleteCookie; moveCookieToCategory now takes cookieId and returns the moved cookie.
    • Auth: adds cookie actions to policies (core:cookie:*).
    • UI: CategorySection uses Relay @connection with filters: [], @appendEdge/@deleteEdge, and an updater for moves; CookieDialog calls createCookie; EditCookieRow reads a fragment; improved duplicate-name error handling.
    • Docs: updates contrib/claude/coredata.md (use Exec, check RowsAffected) and contrib/claude/relay.md (connection filters: [], store updates).
  • Migration

    • Run DB migrations.
    • Update GraphQL:
      • CookieCategory.cookies is now a connection; query edges { node { id name duration description } } and __id if you update the list.
      • Remove cookies from CreateCookieCategoryInput and UpdateCookieCategoryInput.
      • MoveCookieToCategoryInput now uses cookieId and targetCookieCategoryId; payload returns cookie and cookieBanner.
      • Use new createCookie, updateCookie, and deleteCookie mutations and handle CONFLICT errors for duplicate names.
    • Behavior change: deleting a category moves its cookies to the “Uncategorised” category automatically.

Written for commit 82748f8. Summary will update on new commits.

codenem added 3 commits April 21, 2026 14:18
Signed-off-by: Émile Ré <emile@getprobo.com>
The create, delete, and move cookie mutations were not updating
the Relay store connections, so the UI only reflected changes
after a page reload. Add @connection and @appendEdge/@deleteEdge
directives, and a store updater for the move mutation.

Also document mutation store update rules in contrib/claude/relay.md.

Signed-off-by: Émile Ré <emile@getprobo.com>
ConnectionHandler.getConnection could not find the cookies
connection because orderBy was implicitly treated as a filter.
Add filters: [] to the @connection directive and document the
filters rule in contrib/claude/relay.md.

Signed-off-by: Émile Ré <emile@getprobo.com>
@codenem codenem force-pushed the cookie-banner-cookies-data-schema-changes branch from d2586dc to 8dfed9f Compare April 21, 2026 10:18
@codenem codenem marked this pull request as ready for review April 21, 2026 10:24
@codenem codenem requested a review from a team April 21, 2026 10:35
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 19 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="contrib/claude/coredata.md">

<violation number="1" location="contrib/claude/coredata.md:132">
P2: Don’t discard the Exec command tag here; UPDATE/DELETE callers need RowsAffected() to preserve ErrResourceNotFound semantics.</violation>
</file>

<file name="contrib/claude/relay.md">

<violation number="1" location="contrib/claude/relay.md:344">
P3: Don't make `__id` mandatory here. Relay can also derive the connection ID with `ConnectionHandler.getConnectionID`, so mutations don't need to select `__id` in every fragment.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread contrib/claude/coredata.md Outdated
Comment thread contrib/claude/relay.md Outdated
Address PR review comments: capture Exec result and check
RowsAffected() == 0 to return ErrResourceNotFound in
Cookie.Update, CookieCategory.Update, and CookieCategory.UpdateRank.
Also update coredata and relay contributor docs accordingly.

Signed-off-by: Émile Ré <emile@getprobo.com>
Copy link
Copy Markdown
Contributor

@SachaProbo SachaProbo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

cookie_banner_id TEXT NOT NULL REFERENCES cookie_banners(id) ON DELETE CASCADE,
cookie_category_id TEXT NOT NULL REFERENCES cookie_categories(id) ON DELETE CASCADE,
name TEXT NOT NULL,
duration TEXT NOT NULL,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use interval type ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be "session" when no max age or expires is set. Seems to be just text on other banner systems too

@codenem codenem merged commit 82748f8 into main Apr 21, 2026
18 checks passed
@codenem codenem deleted the cookie-banner-cookies-data-schema-changes branch April 21, 2026 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants