Skip to content

feat: add shouldCount option to skip count queries - #652

Merged
pPeterle merged 3 commits into
mainfrom
feat/optional-shouldCount-connection
Mar 30, 2026
Merged

pPeterle merged 3 commits into
mainfrom
feat/optional-shouldCount-connection

Conversation

@pPeterle

Copy link
Copy Markdown
Contributor

Summary

  • Add shouldCount?: boolean (default false) to both connectionFromMongoCursor and connectionFromMongoAggregate
  • When shouldCount is false, the count query (countDocuments / aggregate $count) is skipped entirely, eliminating an expensive DB round-trip
  • hasNextPage is inferred from edges.length >= limit when count is unavailable, matching the pattern in @woovi/graphql/src/connection

Test plan

  • All 15 existing vitest tests pass with updated snapshots
  • Verify downstream consumers (graphql-mongo-helpers, woovi-webhook) work correctly with count: null

🤖 Generated with Claude Code

By default, connectionFromMongoCursor and connectionFromMongoAggregate
no longer run count queries (countDocuments / aggregate $count). Callers
can opt in with shouldCount: true. When count is skipped, hasNextPage is
inferred from edges.length >= limit.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@pPeterle
pPeterle merged commit c1036b5 into main Mar 30, 2026
1 check failed
@pPeterle
pPeterle deleted the feat/optional-shouldCount-connection branch March 30, 2026 16:14
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