I’m trying to create a custom resolver that handle pagination, I’m getting my data correctly but I miss the “meta data” of pagination. I don’t know how to extract meta data of pagination using the strapi service.
I am in urgent need of this solution.
Cant get meta data from entityService.findMany and entityService.findPage ignores start and limit properties.
help please.
Note sure if this is relevant, but since you seem stuck perhaps this custom REST API controller could give you some insights. I use it with the following query: /api/lists/library?pagination[page]=1&pagination[pageSize]=15
If not, I would recommend looking into the core service package and cherry-pick the individual functions needed.
we can’t rely on this forum, can we? very bad.
Agree 100 %. The Community (slack and forum) are the worst part of Strapi, and probably their biggest weakness in the long run. I’m just waiting for an equally robust alternative and I’m gone.
Thank you brother, I finallly found a solution by looking in strapi repository directly.
The “meta” object which contains pagination details is handled by strapi it self using a resolver and it need us to provide resourceUID , start and limit. So we don’t need to use findPage method findMany is enough.
Posting this, as it took a little bit to get a working solution still, create a custom resolver in /src/api/index.js
pages: {
resolve: async (obj, options, ctx) => {
const { toEntityResponseCollection } = strapi.service(
"plugin::graphql.format"
).returnTypes;
const data = await strapi.service(
"api::page.page"
).find(options);
const start = options.start || 0;
const limit = options.limit || 100;
const response = toEntityResponseCollection(data.results, {
args: { start, limit },
resourceUID: "api::page.page",
})
return response;
},
},```
This is using the find service, which you can edit or extend. With this resolver you can pass in logic to that service and also get the meta data and pagination.