feat(ensapi): operator-based filter inputs for events and permissions#2126
Conversation
🦋 Changeset detectedLatest commit: 49305ae The changes in this PR will be included in the next version bump. This PR includes changesets to release 24 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
3 Skipped Deployments
|
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughRefactors omnigraph API event and permission filtering from flat field structures to operator-based input objects. Event filters use set membership ( ChangesEvent and Permission Filter Operator-Based Refactoring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Pull request overview
This PR updates the Omnigraph GraphQL API to use operator-based filter input objects for events and permissions, aligning multiple fields with the existing @oneOf filter approach and adding a timestamp range filter with zod refinements. It rewires resolver SQL where-building to support { eq | in } set-membership filters and { gt/gte/lt/lte } timestamp ranges, regenerates the SDL, and updates integration tests accordingly.
Changes:
- Introduces per-field
@oneOfset filters (eq/in) for event selector/from/sender and domain-permissions user filtering, plus a refined timestamp range filter. - Refactors
find-events-resolverto use sharedsetFilterCondition/rangeFilterConditionhelpers (including empty-in: []short-circuit semantics). - Updates GraphQL schema wiring (imports, new inputs) and integration tests; adds a Changeset entry.
Reviewed changes
Copilot reviewed 13 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/enssdk/src/omnigraph/generated/schema.graphql | Regenerated SDL reflecting new operator-based filter input shapes and argument rename(s). |
| apps/ensapi/src/omnigraph-api/schema/resolver.ts | Switches EventsWhereInput import to the new event-inputs module. |
| apps/ensapi/src/omnigraph-api/schema/permissions.ts | Switches EventsWhereInput import to the new event-inputs module. |
| apps/ensapi/src/omnigraph-api/schema/permissions.integration.test.ts | Updates event-filter queries to new shapes; adds Domain.permissions user in test. |
| apps/ensapi/src/omnigraph-api/schema/event.ts | Removes event-related input definitions (leaving EventRef). |
| apps/ensapi/src/omnigraph-api/schema/event-inputs.ts | Adds new event filter inputs and zod refinements; defines EventsWhereInput / AccountEventsWhereInput. |
| apps/ensapi/src/omnigraph-api/schema/domain.ts | Updates Domain.permissions resolver to support `{ eq |
| apps/ensapi/src/omnigraph-api/schema/domain.integration.test.ts | Updates event-filter queries to the new where shapes. |
| apps/ensapi/src/omnigraph-api/schema/domain-inputs.ts | Adds DomainPermissionsUserFilter and updates DomainPermissionsWhereInput.user to use it. |
| apps/ensapi/src/omnigraph-api/schema/account.ts | Updates Account.events sender filter shape; renames Account.permissions arg to where and adds AccountPermissionsWhereInput. |
| apps/ensapi/src/omnigraph-api/schema/account.integration.test.ts | Updates Account.events filter tests to new operator-based input shapes. |
| apps/ensapi/src/omnigraph-api/lib/find-events/find-events-resolver.ts | Refactors event WHERE building to generic helpers; implements empty-in short-circuit and range filters. |
| apps/ensapi/src/omnigraph-api/lib/find-domains/layers/filter-by-name-in.ts | Minor comment adjustment; preserves empty-inArray([]) short-circuit semantics. |
| .changeset/events-filters-oneof.md | Declares a minor release note describing the breaking Omnigraph filter shape changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Greptile SummaryThis PR extends ENSapi's Omnigraph filter layer from a single
Confidence Score: 5/5All changed code paths are well-scoped to the ENSapi Omnigraph schema layer with no in-repo downstream consumers affected; the logic is internally consistent and thoroughly tested. The filter helpers are straightforward and correct, Zod refines use <= for the inverted-range check, the empty-in short-circuit is consistent, and integration tests cover all validation paths including pin-point equal bounds. No files require special attention. Important Files Changed
Reviews (10): Last reviewed commit: "test(ensapi): EventsTimestampFilter vali..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/ensapi/src/omnigraph-api/schema/account.integration.test.ts (1)
234-313: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick winAdd negative integration cases for timestamp filter validation.
This block only asserts valid timestamp paths. Please also assert rejection for invalid
EventsTimestampFiltercombinations ({},{ gt, gte },{ lt, lte }, and inverted ranges) so schema/refine regressions are caught at the API boundary.🤖 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 `@apps/ensapi/src/omnigraph-api/schema/account.integration.test.ts` around lines 234 - 313, Add negative integration tests in the same test suite (near the existing "filters by timestamp ..." cases) that call the GraphQL query symbol AccountEventsFiltered via request<AccountEventsResult> with invalid EventsTimestampFilter combinations and assert the API rejects them: test an empty timestamp object (where: { timestamp: {} }), conflicting bounds ({ timestamp: { gt: midTs, gte: midTs } } and { timestamp: { lt: midTs, lte: midTs } }), and inverted ranges ({ timestamp: { gte: highTs, lte: lowTs } }); locate the helpers in this file (request, AccountEventsFiltered, allEvents) and for each invalid input assert the request returns GraphQL errors or throws (e.g. result.errors?.length > 0 or expect(request(...)).rejects.toThrow()), ensuring the API surface validation fails these inputs.
🤖 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 @.changeset/events-filters-oneof.md:
- Line 5: Refactor the long single-line breaking-change description in
.changeset/events-filters-oneof.md into a structured, readable format: split the
changes into bullet points or short paragraphs and list each API change
separately (referencing EventsWhereInput / AccountEventsWhereInput and the
selector_in → selector change, timestamp_gte/timestamp_lte → timestamp with
{gt,gte,lt,lte}, from/sender → {eq|in}, DomainPermissionsWhereInput.user →
{eq|in}, and the Account.permissions signature change to
Account.permissions(where: { contract: AccountIdInput })), and add a distinct
constraints section that calls out the set-membership in cap (10 items) and the
timestamp range rules (require ≥1 bound; disallow gt+gte and lt+lte and inverted
bounds) so downstream consumers can scan each change and constraint easily.
In `@apps/ensapi/src/omnigraph-api/lib/find-events/find-events-resolver.ts`:
- Around line 32-49: The two filter declarations use interface syntax but should
be type aliases per the coding guideline; replace the interface declarations for
SetFilter<T> and RangeFilter<T> with equivalent type aliases (e.g., "type
SetFilter<T> = { ... }" and "type RangeFilter<T> = { ... }") preserving the same
properties and optional/null annotations and the JSDoc comments, and keep the
generic parameter names and member names (SetFilter, RangeFilter, eq, in, gt,
gte, lt, lte) unchanged so downstream code continues to type-check.
---
Outside diff comments:
In `@apps/ensapi/src/omnigraph-api/schema/account.integration.test.ts`:
- Around line 234-313: Add negative integration tests in the same test suite
(near the existing "filters by timestamp ..." cases) that call the GraphQL query
symbol AccountEventsFiltered via request<AccountEventsResult> with invalid
EventsTimestampFilter combinations and assert the API rejects them: test an
empty timestamp object (where: { timestamp: {} }), conflicting bounds ({
timestamp: { gt: midTs, gte: midTs } } and { timestamp: { lt: midTs, lte: midTs
} }), and inverted ranges ({ timestamp: { gte: highTs, lte: lowTs } }); locate
the helpers in this file (request, AccountEventsFiltered, allEvents) and for
each invalid input assert the request returns GraphQL errors or throws (e.g.
result.errors?.length > 0 or expect(request(...)).rejects.toThrow()), ensuring
the API surface validation fails these inputs.
🪄 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: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 3b0a8b22-d829-4dcd-bdcd-12be295b9274
⛔ Files ignored due to path filters (2)
packages/enssdk/src/omnigraph/generated/introspection.tsis excluded by!**/generated/**packages/enssdk/src/omnigraph/generated/schema.graphqlis excluded by!**/generated/**
📒 Files selected for processing (13)
.changeset/events-filters-oneof.mdapps/ensapi/src/omnigraph-api/lib/find-domains/layers/filter-by-name-in.tsapps/ensapi/src/omnigraph-api/lib/find-events/find-events-resolver.tsapps/ensapi/src/omnigraph-api/schema/account.integration.test.tsapps/ensapi/src/omnigraph-api/schema/account.tsapps/ensapi/src/omnigraph-api/schema/domain-inputs.tsapps/ensapi/src/omnigraph-api/schema/domain.integration.test.tsapps/ensapi/src/omnigraph-api/schema/domain.tsapps/ensapi/src/omnigraph-api/schema/event-inputs.tsapps/ensapi/src/omnigraph-api/schema/event.tsapps/ensapi/src/omnigraph-api/schema/permissions.integration.test.tsapps/ensapi/src/omnigraph-api/schema/permissions.tsapps/ensapi/src/omnigraph-api/schema/resolver.ts
💤 Files with no reviewable changes (1)
- apps/ensapi/src/omnigraph-api/schema/event.ts
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@greptile review |
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@greptile review |
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@greptile review |
Add integration tests for EventsTimestampFilter refines: empty bounds, gt+gte, lt+lte, inverted range, and equal bounds. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@greptile review |
lightwalker-eth
left a comment
There was a problem hiding this comment.
@shrugs Looks super! Nice work 🚀 Please merge when ready 👍
Reviewer Focus
find-events-resolver.tsset/range helpers + emptyin: []→ no matches (mirrorsfilter-by-name-in.ts).EventsTimestampFilterzod refines (≥1 bound;gt/gtemutex;lt/ltemutex; inverted-range rejected) — not expressible via@oneOf.Problem & Motivation
extends the
@oneOfoperator pattern fromDomain.nameto the rest of Omnigraph's filter args where multiple operators have a real use case today. tight scope; expand on demand.What Changed
@oneOf { eq, in }filters (in: max 10):EventsSelectorFilter,EventsFromFilter,EventsSenderFilter,DomainPermissionsUserFilter.EventsTimestampFilter { gt?, gte?, lt?, lte? }.EventsWhereInput/AccountEventsWhereInput/DomainPermissionsWhereInputreshaped to use them.Account.permissions(in: AccountIdInput)→Account.permissions(where: { contract }).event-inputs.ts.Design
set-membership =
@oneOf { eq, in }; range = flat (bounds combine, can't be@oneOf). per-field-named inputs (no shared generics). emptyin: []matches nothing rather than 400 — matchesDomainsNameFilterprecedent + search-page consumer DX.Self-Review
minLength: 1onin:that would have forced consumers to special-case empty UI state.Domain.permissionsuserScope to mirrorsetFilterCondition'sin ?? [eq]pattern.event-inputs.tsfor symmetry withdomain-inputs.ts.Cross-Codebase Alignment
grepped
selector_in,timestamp_gte/_lte,EventsWhereInput,AccountEventsWhereInput,DomainPermissionsWhereInput,permissions(in:. no live references inapps/ensadmin,packages/ensnode-sdk,packages/ensnode-react,docs/ensnode.io,examples/. subgraph API intentionally untouched (compat).Downstream Impact
breaking Omnigraph schema. SDL regenerated. no in-repo consumers affected. changeset added (minor, ensapi only).
Testing
typecheck clean, lint clean, 98 unit + 295 integration pass.
gap: timestamp cross-field refines not asserted by integration tests (zod-layer behavior).
Scope Reductions
no
eq/infor timestamp, no negation, no version-filter extension, no shared generic filter types. open on demand.Risk
pre-1.0 API. blast radius: ensapi GraphQL clients. rollback = revert.
named owner: @shrugs.
Pre-Review Checklist