Skip to content

New: Add queryHook for role-agnostic query filtering - #106

Merged
taylortom merged 1 commit into
masterfrom
feature/query-hook
Jun 15, 2026
Merged

New: Add queryHook for role-agnostic query filtering#106
taylortom merged 1 commit into
masterfrom
feature/query-hook

Conversation

@taylortom

Copy link
Copy Markdown
Collaborator

New

  • Add queryHook, a mutable hook invoked in queryHandler for every user (after requestHook, before pagination), letting observers merge user-driven filter clauses into req.apiData.query.

This complements accessQueryHook (#103), which is deliberately skipped for super users so they see unfiltered results. That bypass is correct for access filtering ("what may this user see") but silently breaks user-driven list filters ("what did this user ask to see") — e.g. projects-dashboard filters sourced from another collection — which must apply regardless of role. Such filters previously had no role-agnostic seam to attach to; queryHook is that seam. Running before pagination keeps counts and the Link header accurate.

Testing

  1. Tap queryHook from a module and merge a clause into req.apiData.query.
  2. As a super admin, hit a list/query endpoint and confirm the clause is applied (whereas an accessQueryHook clause is not).
  3. As a non-super user, confirm both hooks still apply and pagination counts remain correct.

accessQueryHook is skipped for super users (access filtering), which
silently breaks user-driven list filters that must apply to every role.
queryHook runs in queryHandler for all users, after requestHook and
before pagination, so filter clauses merge into req.apiData.query without
affecting counts or the Link header.
@taylortom
taylortom merged commit 51dc367 into master Jun 15, 2026
2 checks passed
@taylortom
taylortom deleted the feature/query-hook branch June 15, 2026 18:38
github-actions Bot pushed a commit that referenced this pull request Jun 15, 2026
# [3.9.0](v3.8.0...v3.9.0) (2026-06-15)

### New

* Add queryHook for role-agnostic query filtering (#106) ([51dc367](51dc367)), closes [#106](#106)
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 3.9.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant