Closed be90728 closed 2 years ago
Good catch @be90728, but seems we must do it a bit different to cover also GQL. Anyway will follow your snippets :)
Fix has been released as part of v2.0.5
@cyp3rius seems that the pagination[withCount]
is not workig. The idea is to load x
comments and then if there are more, show a "load more" button, however, pagination[withCount]=true
does not have any effect on the response and I can't see how much comments are there 🤔
Let me check that @Tragio
@cyp3rius here it goes my request 😃
/comments/content:1/flat?pagination[page]=1&pagination[pageSize]=10&pagination[withCount]=true&sort[0]=createdAt:desc
@Tragio released as part of v2.0.6
. Release notes: https://github.com/VirtusLab-Open-Source/strapi-plugin-comments/releases/tag/v2.0.6
I'm using version 2.0.8 and I still can get the pagination to work. This is my graphQL request :
query commentsApi($apiAndId: String!) { findAllFlat(pagination: {page: 1, pageSize: 10}, relation: $apiAndId, filters: { blocked: { ne: true } }) { data { blocked id author { name } content } meta { pagination { page pageSize pageCount total } } } }
And my response :
{
"data": {
"findAllFlat": {
"data": [
{
"blocked": false,
"id": 15,
"author": {
"name": "Test"
},
"content": "test"
}
],
"meta": {
"pagination": {
"page": 1,
"pageSize": 10,
"pageCount": null,
"total": null
}
}
}
}
}
The total is always null
Hello @Kaherdin , right I've checked the pagination type for GQL in Strapi and it doesn't allow to use withCount
as for REST API. Let me drop this fix in next version.
@Kaherdin should be fixed in version v2.0.9
Wow great thanks ! You are so reactive, it works now, but I will need to do some more test, because with it's get me the total of entry, including the blocked comments. So it's not accurate for pagination.
You must filter out blocked
comments if you want to. By default only removed
are filtered out on the client endpoints.
Most of consumers handles comments which are blocked
by special visualization.
For total
, the same conditions are used.
@cyp3rius doesn't pagination works if you are not using flat? I am getting Undefined attribute level operator page
@cyp3rius doesn't pagination works if you are not using flat? I am getting Undefined attribute level operator page
Yes, you need to use flat. Not sure if that will change.
@cyp3rius doesn't pagination works if you are not using flat? I am getting Undefined attribute level operator page
Yes, you need to use flat. Not sure if that will change.
I see, its just hard to group child comments together when using it.
Its indeed tricky case and I'm analyzing couple possibilities here. Happy to work with you folks to get it done as community expect :)
I can't use pagination in query
{{host}}/api/comments/api::post.post:1/flat?pagination[pageSize]=1
Always got errorUndefined attribute level operator pageSize
I looked at the source code and I found the function
findAllFlat
inserver/controllers/client.js
and found thatsort and pagination
definitely does not exist in ctx.So i changed
const { params = {}, query, sort, pagination } = ctx;
toconst { params = {}, query } = ctx;
And add
const { sort, pagination } = query;
before call servicefindAllFlat
Also i go to
server/services/common.js
add code in functionfindAllFlat
like thisPlugin version: 2.0.4 & 2.0.3