Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.
enter image description here

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
                  }
                }
              }
            }
        }
    }
  }
`

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The documentation for Strapi v4 is available here.

Could you try with:

const REVIEWS = gql`
  query GetReviews {
    reviews (sort: "createdAt:desc", pagination: { start: 1, 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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading