Search code examples
reactjsnext.jsgraphqlhygraph

Headless CMS GraphQL NextJS Project Post Limit Issue


I have a Headless cms project I created using GraphQl, NextJS and Hygraph. I'm also using NPM Graphql-request. I'm having issues "receiving" more than 10 posts on my project. So far I had less then 10 posts on my site, but now that I posted more, I'm simply not receiving the extra ones. I did some research but I can't seem to find the solution!

Here's what I got:

const QUERY = gql`
  {
    posts {
      title
      id
      slug
      datePublished
      mobileCoverPhoto {
        url
      }
      coverPhoto {
        id
        url
      }
      category
      imageAtlTag
      author {
        id
        name
        avatar {
          url
        }
      }
      content {
        text
        html
      }
    }
  }
`;

Everything works fine until post #10 only. Thanks everyone for helping!


Solution

  • 10 is the default number of fetched posts. If you want to specify the number of posts you need to do it like this:

     posts(first: 10) {
       nodes {
         title
        slug
       }
      }