Pagination - page numbers less than 1 all return page 1 results
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.5k
- Forks
- 468
- Avg merge
- 3h 9m
- Merged PRs (30d)
- 2
Description
Describe the bug
When using pagination, requesting page 0 (or any negative integer page number e.g. page -31) returns page 1.
Expected behavior/Solution
When requesting a page number less than 1, you should not receive page 1.
Option 1: return requested page with empty data array.
myQueryName(first: 10, page: 0) {
data {
field1
field2
field3
}
paginatorInfo {
count
currentPage
lastPage
firstItem
lastItem
perPage
hasMorePages
total
}
}
{
"data": {
"myQueryName": {
"data": [],
"paginatorInfo": {
"count": 0,
"currentPage": 0,
"lastPage": 83,
"firstItem": null,
"lastItem": null,
"perPage": 10,
"hasMorePages": true,
"total": 83
}
}
}
}
Option 2: return an error
{
"errors": [
{
"message": "Argument 'page' must be greater than 0",
"locations": [
{
...
}
]
}
]
}
Steps to reproduce
- Query a paginated endpoint with argument
page: 0(or any negative integer) ensuring to request paginatorInfocurrentPage - Observe that the response says the
currentPageis1and the data is the first page of results
Output/Logs
N/A
Lighthouse Version
6.14
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source files or tests are named. Start by reproducing the issue with a paginated GraphQL query using page: 0 and a negative page, then trace the pagination argument handling and existing paginator tests. Done means an agreed behavior is implemented and covered for values below 1.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, laravel, php
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100