Skip to content

Conversation

@elitexp
Copy link

@elitexp elitexp commented Jan 20, 2026

Support negative first argument to disable pagination limits, improving query efficiency over large arbitrary limit workarounds.

Resolves #2734

Changes
Introduced a simple NegativePerPageLengthAwarePaginator

  • Not worked on simplePaginator & Scout Builder
image

Support negative `first` argument to disable pagination limits,
improving query efficiency over large arbitrary limit workarounds.
Copy link
Collaborator

@spawnia spawnia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can not even begin to consider inclusion due to the total lack of tests. Before you write any, let's discuss the issue of null vs negative values for first.

Comment on lines 1 to 3
<?php

declare(strict_types=1);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting is off here and messed up in other places.

? 'simplePaginate'
: 'paginate';

if ($methodName == 'paginate' && $this->first < 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first: null seems much cleaner to me. Negative values could be the result of unchecked arithmetic errors, whereas null is much more explicit and discrete.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For support of first: null, We need to modify in PaginationManipulator from first: Int! to first: Int. I am not sure, if that breaks other already deployed.

Sorry that I am new to php-cs-fixer and I am trying that.
image
image

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Also found this Unit Test for checking if first is Int!.

So, I am pretty much confused.

Support null `first` argument to disable pagination limits,
improving query efficiency over large arbitrary limit workarounds.
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.

Support pagination with unlimited results

2 participants