mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 07:03:38 +00:00
fix: negative limit without maxLimit (graphql)
This commit is contained in:
parent
3e5cea0cbc
commit
73e5b672fd
@ -26,7 +26,7 @@ const withMaxLimit = (limit, maxLimit = -1) => {
|
||||
// Ensure minimum page & pageSize values (page >= 1, pageSize >= 0, start >= 0, limit >= 0)
|
||||
const ensureMinValues = ({ start, limit }) => ({
|
||||
start: Math.max(start, 0),
|
||||
limit: Math.max(limit, 1),
|
||||
limit: limit === -1 ? limit : Math.max(limit, 1),
|
||||
});
|
||||
|
||||
const ensureMaxValues = (maxLimit = -1) => ({ start, limit }) => ({
|
||||
|
||||
@ -25,9 +25,9 @@ module.exports = ({ strapi }) => {
|
||||
const { start, limit } = args;
|
||||
|
||||
const total = await strapi.entityService.count(resourceUID, args);
|
||||
const pageSize = limit;
|
||||
const pageCount = limit === 0 ? 0 : Math.ceil(total / limit);
|
||||
const page = limit === 0 ? 1 : Math.floor(start / limit) + 1;
|
||||
const pageSize = limit === -1 ? total : limit;
|
||||
const pageCount = limit === -1 ? 1 : Math.ceil(total / limit);
|
||||
const page = limit === -1 ? 1 : Math.floor(start / limit) + 1;
|
||||
|
||||
return { total, page, pageSize, pageCount };
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user