Skip to content

Add paginated query support with metadata#26

Merged
maltehuebner merged 4 commits intomainfrom
feature/paginated-query-support
Mar 14, 2026
Merged

Add paginated query support with metadata#26
maltehuebner merged 4 commits intomainfrom
feature/paginated-query-support

Conversation

@maltehuebner
Copy link
Owner

Summary

  • Adds PaginatedResult class with getData(), getPage(), getSize(), getTotalItems(), getTotalPages()
  • Adds PageParameter (0-based) as user-friendly alternative to FromParameter (?page=2&size=50 instead of ?from=100&size=50)
  • Adds paginatedQuery() method to DataQueryManagerInterface alongside the existing query() method (backward compatible)
  • Implements paginated execution for Doctrine ORM (via Doctrine\ORM\Tools\Pagination\Paginator) and Elasticsearch (via FOS Elastica paginator adapter)

Expected JSON response format

{
  "data": [ ... ],
  "meta": {
    "page": 0,
    "size": 100,
    "totalItems": 54321,
    "totalPages": 544
  }
}

Test plan

  • All 354 existing tests pass
  • PHPStan passes at level 5
  • Integration test with Doctrine ORM paginated queries
  • Integration test with Elasticsearch paginated queries

Closes #25

🤖 Generated with Claude Code

maltehuebner and others added 4 commits March 14, 2026 09:40
Introduces a result container that holds paginated data along with
metadata: page, size, totalItems, and computed totalPages.

Refs #25

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
PageParameter provides a 0-based page parameter as a user-friendly
alternative to the offset-based FromParameter. SizeParameter gains a
getter so the DataQueryManager can extract the configured page size.

Refs #25

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Doctrine ORM uses Doctrine\ORM\Tools\Pagination\Paginator for efficient
total count queries. Elasticsearch uses the FOS Elastica paginator
adapter to retrieve results and total count in a single operation.

Refs #25

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Exposes the new paginatedQuery() method on the DataQueryManagerInterface,
wires PaginatedResult into service autodiscovery, and baselines the
optional FOS Elastica createPaginatorAdapter() call in PHPStan.

Closes #25

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@maltehuebner maltehuebner added enhancement New feature or request AI-generated labels Mar 14, 2026
@maltehuebner maltehuebner merged commit 7e39512 into main Mar 14, 2026
4 checks passed
@maltehuebner maltehuebner deleted the feature/paginated-query-support branch March 14, 2026 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-generated enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add paginated query support with metadata (totalItems, totalPages)

1 participant