'GraphQL - retrieves only maximum 10 items from Strapi
I am using React with Strapi and GrapqQL in order to retreive my data from Strapi.
Seems that my query retrieves only maximum 10 items. The API is changed with this new version and I am not allowed to use first:100
in the query.
This link 1 is obsolete. I don't know if this is a policy from Strapi's or GraphQL's new version. 1 https://graphql.org/learn/pagination/
const REVIEWS = gql`
query GetReviews {
reviews (sort: "createdAt:desc") {
data{
id
attributes{
title
rating
body
createdAt
categories{
data{
id
attributes
{
name
}
}
}
}
}
}
}
`
Solution 1:[1]
The documentation for Strapi v4 is available here.
Could you try with:
const REVIEWS = gql`
query GetReviews {
reviews (sort: "createdAt:desc", pagination: { limit: 100 }) {
data{
id
attributes{
title
rating
body
createdAt
categories{
data{
id
attributes
{
name
}
}
}
}
}
}
}
`
The default and maximum values for pagination[limit]
can be configured in the ./config/plugins.js
file with the graphql.config.defaultLimit
and graphql.config.maxLimit
keys.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | idmean |