Skip to content

feat(wabe): support connection arguments#303

Merged
coratgerl merged 2 commits intomainfrom
support-connection-argument
Feb 21, 2026
Merged

feat(wabe): support connection arguments#303
coratgerl merged 2 commits intomainfrom
support-connection-argument

Conversation

@coratgerl
Copy link
Collaborator

@coratgerl coratgerl commented Feb 21, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Relation fields now support filtering, pagination, and ordering through connection arguments (where, offset, first, order).
  • Tests

    • Added tests validating connection argument behavior on related object queries across multiple scenarios.

@coratgerl coratgerl self-assigned this Feb 21, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 21, 2026

Important

Review skipped

Auto reviews are disabled on this repository. 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.

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
📝 Walkthrough

Walkthrough

Connection 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

Cohort / File(s) Summary
Database Query Logic
packages/wabe/src/database/DatabaseController.ts
Implements pagination, filtering, and ordering for related objects in _resolveRelationField. Extracts args from query, builds composite where clauses, constructs order objects from both enum and object formats, and computes totalCount conditionally based on applied pagination/filtering.
GraphQL Schema Configuration
packages/wabe/src/graphql/parser.ts
Adds args field to GraphQL configuration for relation fields of type Object, defining where, offset, first, and order arguments to support filtering and pagination on relations.
Field Resolution & Variables
packages/wabe/src/graphql/resolvers.ts
Threads GraphQL variable values through field extraction via updated extractFieldsFromSetNode signature. Populates _args property on fields with argument values resolved using variables.
Test Coverage
packages/wabe/src/graphql/GraphQLSchema.test.ts
Adds two new integration tests validating connection arguments (first, offset, order, where) on relation queries with multiple parent objects, covering pagination, ordering, and filtering scenarios.

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
Loading

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

🐰 A rabbit's ode to connected relations:

Through fields we hop with order and grace,
Filtering whiskers, pagination's pace,
First and offset now dance in the night,
Relations aligned, our queries take flight! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat(wabe): support connection arguments' directly and accurately summarizes the main change: adding support for connection arguments (first, offset, order, where) to relation fields in the wabe GraphQL framework.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch support-connection-argument

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

@coratgerl
Copy link
Collaborator Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 21, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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 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>
@coratgerl coratgerl merged commit 392497b into main Feb 21, 2026
3 checks passed
@coratgerl coratgerl deleted the support-connection-argument branch February 21, 2026 11:15
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.

1 participant