Here is the pagination query I have. As you can see it calculates the amount of pages & current page based on the provided LIMIT.
const bots = await strapi.services.bot.find(ctx.query, []);
const count = await strapi.services.bot.count(ctx.query); // total items
const current_page = Math.ceil((ctx.query._start - 1) / ctx.query._limit) + 1;
const total_pages = Math.ceil(count/ctx.query._limit);
let response = bots.map(bot => sanitizeEntity(bot, { model: strapi.models.bot }));
return {
count: count,
bots: response,
pages: total_pages,
current: current_page
};
When I use Graphql to fetch this data I get
"message": "Expected Iterable, but did not find one for field \"Query.bots\"."
. I get that it expects an iterable entity but I am sending something like
{
count: 30,
bots: [...],
pages: 3,
current: 1
}
Is there any way to make it work?