feat(wabe): support connection arguments#303
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughConnection arguments (where, offset, first, order) are now supported on relation fields in GraphQL queries, enabling filtering, pagination, and ordering of related objects. The feature spans schema configuration, variable resolution, database query construction, and comprehensive test coverage. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant GraphQL Parser
participant Field Resolver
participant Database Controller
participant Database
Client->>GraphQL Parser: Query with variables<br/>(first, offset, order, where on relation)
GraphQL Parser->>Field Resolver: Parse and extract fields<br/>(include _args from arguments)
Field Resolver->>Field Resolver: Resolve variable values<br/>into _args property
Field Resolver->>Database Controller: _resolveRelationField<br/>(with _args parameters)
Database Controller->>Database Controller: Build composite where<br/>(relationIds + args.where)
Database Controller->>Database Controller: Construct order object<br/>(from args.order)
Database Controller->>Database: getObjects<br/>(where, offset, first, order)
Database-->>Database Controller: Related objects
Database Controller->>Database Controller: Compute totalCount<br/>(count query if filtering applied,<br/>else use object length)
Database Controller-->>Field Resolver: Resolved relation with edges<br/>and totalCount
Field Resolver-->>Client: GraphQL response
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes The changes introduce distributed logic across multiple files with varying concerns: query parameter threading, schema configuration, variable resolution, and database query construction. Heterogeneous modifications spanning schema, resolver, and database layers require careful verification of integration points and ordering/filtering semantics. Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/wabe/src/database/DatabaseController.ts`:
- Around line 707-714: The truthy check determining totalCount incorrectly
treats args.first === 0 or args.offset === 0 as "no count", causing totalCount
to be 0; update the condition that decides whether to call this.count to
explicitly check for undefined (e.g., args.offset !== undefined || args.first
!== undefined || args.where) so that zero values still trigger the count call
and fall back to relationObjects.length only when all three are undefined;
ensure you pass currentClassName, where, and context into this.count as before.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Summary by CodeRabbit
Release Notes
New Features
Tests