Skip to content

🎨 Used NQL $all operator for member label is-all-of filters#28596

Closed
rob-ghost wants to merge 1 commit into
codex/ber-3664-member-label-is-allfrom
feat/ber-3664-nql-all-of-operator
Closed

🎨 Used NQL $all operator for member label is-all-of filters#28596
rob-ghost wants to merge 1 commit into
codex/ber-3664-member-label-is-allfrom
feat/ber-3664-nql-all-of-operator

Conversation

@rob-ghost

@rob-ghost rob-ghost commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Problem

Member filtering supports an "is all of" mode for labels, where a member must carry every selected label. Until now the admin serialized this intent by hand-rolling a parenthesised group of separate clauses (one clause per label, ANDed together). That workaround was brittle: it duplicated NQL's grouping semantics in the admin, made outer-grouping detection fiddly (especially for quoted label values), and drifted from how the rest of the filter pipeline expresses queries.

Solution

This change replaces the parentheses-grouping workaround with first-class support for NQL's native "all of" operator, so an "is all of" label filter is now expressed as a single clause that lists every required label. The admin's filter codecs, query core, and member filter query all serialize and parse this form directly, and the field config drives whether a field is eligible for all-of handling rather than special-casing it in the query builder.

An end-to-end test drives the Members admin API over HTTP to prove the round trip: members are created with overlapping labels, and an "all of" filter returns only the member carrying every label, while the comma list still returns members carrying either.

This depends on the "all of" operator landing in NQL (TryGhost/NQL#156). While that is in review it is consumed as a prerelease published to npm under the next dist-tag (@tryghost/nql@0.13.1-pr156.0, @tryghost/nql-lang@0.6.6-pr156.0). The catalog points at those versions and a workspace override forces them onto transitive consumers too (the filter-to-SQL path lives in a transitive dependency). Once NQL#156 is released to latest, the catalog and override get bumped to the stable versions and the override can be dropped.

This PR is stacked on #27945.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c919f013-9c7c-4e43-a79d-709eebcd5c24

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: implementing NQL $all operator for member label is-all-of filters, which aligns with the primary objective of replacing the parentheses-grouping workaround with native operator support.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description clearly explains the problem (brittle hand-rolled parenthesis grouping), the solution (native NQL $all operator support), and implementation details (filter codecs, query core changes, and temporary workspace overrides).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/ber-3664-nql-all-of-operator

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud

nx-cloud Bot commented Jun 15, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit fe218a0

Command Status Duration Result
nx build @tryghost/portal ✅ Succeeded <1s View ↗
nx build @tryghost/comments-ui ✅ Succeeded <1s View ↗
nx build @tryghost/announcement-bar ✅ Succeeded <1s View ↗
nx build @tryghost/activitypub ✅ Succeeded 1s View ↗
nx build @tryghost/signup-form ✅ Succeeded <1s View ↗
nx build @tryghost/admin-toolbar ✅ Succeeded 1s View ↗
nx build @tryghost/sodo-search ✅ Succeeded <1s View ↗
nx run @tryghost/admin-x-settings:test:acceptance ✅ Succeeded 10m 7s View ↗
Additional runs (15) ✅ Succeeded ... View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-06-15 12:52:40 UTC

@rob-ghost rob-ghost requested a review from kevinansfield June 15, 2026 11:36

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm-workspace.yaml`:
- Around line 135-140: Replace the non-portable local link overrides for
`@tryghost/nql` and `@tryghost/nql-lang` on lines 139-140 with catalog-pinned
versions. Add both dependencies to the catalog section of pnpm-workspace.yaml
with their published version numbers (or a documented temporary release tag),
then update the dependency declarations to reference them using the catalog:
syntax instead of link:../NQL paths. This ensures dependency resolution remains
reproducible across CI environments and contributor machines while respecting
the workspace's catalog-pinning workflow.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 727326e4-568c-4189-a02a-012a4f02cd21

📥 Commits

Reviewing files that changed from the base of the PR and between 76410ae and 81ddf5e.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (11)
  • apps/posts/src/views/filters/filter-codecs.test.ts
  • apps/posts/src/views/filters/filter-codecs.ts
  • apps/posts/src/views/filters/filter-query-core.test.ts
  • apps/posts/src/views/filters/filter-query-core.ts
  • apps/posts/src/views/filters/filter-types.ts
  • apps/posts/src/views/filters/resolve-field.test.ts
  • apps/posts/src/views/filters/resolve-field.ts
  • apps/posts/src/views/members/member-filter-query.test.ts
  • apps/posts/src/views/members/member-filter-query.ts
  • ghost/core/test/e2e-api/admin/members.test.js
  • pnpm-workspace.yaml
💤 Files with no reviewable changes (1)
  • apps/posts/src/views/filters/filter-query-core.ts

Comment thread pnpm-workspace.yaml Outdated
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (codex/ber-3664-member-label-is-all@4884ed7). Learn more about missing BASE report.

Additional details and impacted files
@@                          Coverage Diff                          @@
##             codex/ber-3664-member-label-is-all   #28596   +/-   ##
=====================================================================
  Coverage                                      ?   73.94%           
=====================================================================
  Files                                         ?     1541           
  Lines                                         ?   132388           
  Branches                                      ?    15903           
=====================================================================
  Hits                                          ?    97892           
  Misses                                        ?    33532           
  Partials                                      ?      964           
Flag Coverage Δ
admin-tests 54.89% <ø> (?)
e2e-tests 76.10% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rob-ghost rob-ghost force-pushed the codex/ber-3664-member-label-is-all branch from 76410ae to 4884ed7 Compare June 15, 2026 12:34
Replaced the parenthesised-grouping workaround for "is all of" label
filters with NQL's native all-of operator. The admin codecs and member
filter query now serialize and parse the $all form directly, dropping
the outer-grouping probe and the bespoke all-of extraction.

Consumes the operator from a prerelease published under the `next`
dist-tag (TryGhost/NQL#156) via the catalog plus an override that forces
it onto transitive consumers like @tryghost/bookshelf-filter. Bump to the
released versions once #156 merges to latest.
@rob-ghost rob-ghost force-pushed the feat/ber-3664-nql-all-of-operator branch from d6f633d to fe218a0 Compare June 15, 2026 12:38

@coderabbitai coderabbitai Bot left a comment

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.

♻️ Duplicate comments (1)
pnpm-workspace.yaml (1)

137-143: ⚠️ Potential issue | 🟠 Major

Replace concrete versions in overrides with catalog references to maintain a single source of truth.

Lines 142-143 duplicate versions already pinned in the catalog (lines 63-64). With catalogMode: strict enabled, these should reference the catalog directly using 'catalog:' syntax, consistent with the pattern already used in line 145 for '@tryghost/logging'.

Suggested fix
 overrides:
@@
-  '`@tryghost/nql`': 0.13.1-pr156.0
-  '`@tryghost/nql-lang`': 0.6.6-pr156.0
+  '`@tryghost/nql`': 'catalog:'
+  '`@tryghost/nql-lang`': 'catalog:'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pnpm-workspace.yaml` around lines 137 - 143, Replace the concrete version
numbers for '`@tryghost/nql`' and '`@tryghost/nql-lang`' in the overrides section
with catalog references using the 'catalog:' syntax, matching the pattern
already established for '`@tryghost/logging`'. This eliminates duplication since
these versions are already defined in the catalog and ensures a single source of
truth for version management when catalogMode is set to strict.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@pnpm-workspace.yaml`:
- Around line 137-143: Replace the concrete version numbers for '`@tryghost/nql`'
and '`@tryghost/nql-lang`' in the overrides section with catalog references using
the 'catalog:' syntax, matching the pattern already established for
'`@tryghost/logging`'. This eliminates duplication since these versions are
already defined in the catalog and ensures a single source of truth for version
management when catalogMode is set to strict.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ae60d459-9e13-4273-a8fc-5f02a729c7b5

📥 Commits

Reviewing files that changed from the base of the PR and between 81ddf5e and fe218a0.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • apps/posts/src/views/filters/filter-codecs.test.ts
  • apps/posts/src/views/filters/filter-codecs.ts
  • apps/posts/src/views/filters/filter-types.ts
  • apps/posts/src/views/filters/resolve-field.test.ts
  • apps/posts/src/views/filters/resolve-field.ts
  • apps/posts/src/views/members/member-filter-query.test.ts
  • ghost/core/test/e2e-api/admin/members.test.js
  • pnpm-workspace.yaml
✅ Files skipped from review due to trivial changes (1)
  • ghost/core/test/e2e-api/admin/members.test.js
🚧 Files skipped from review as they are similar to previous changes (6)
  • apps/posts/src/views/filters/filter-types.ts
  • apps/posts/src/views/filters/resolve-field.test.ts
  • apps/posts/src/views/filters/resolve-field.ts
  • apps/posts/src/views/members/member-filter-query.test.ts
  • apps/posts/src/views/filters/filter-codecs.ts
  • apps/posts/src/views/filters/filter-codecs.test.ts

@rob-ghost rob-ghost marked this pull request as ready for review June 15, 2026 13:02
@rob-ghost rob-ghost closed this Jun 16, 2026
@rob-ghost rob-ghost deleted the feat/ber-3664-nql-all-of-operator branch June 16, 2026 13:08
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