Search code examples
wordpressgraphqladvanced-custom-fieldscustom-post-type

Why does GraphQL only query 10 entries when using Custom Post Types?


Not sure if this is a silly question but I am trying to query Custom Post Types from WordPress using GraphQL, there Custom Post Types also contain Advanced Custom Fields.

As you can see here I have published 17 in total:

enter image description here

My query to graphQL looks like this:

const GET_ALL_MEDIA = gql`
  query MyQuery {
    slumpMedias {
      edges {
        node {
          title
          slumpMeta {
            image {
              mediaItemUrl
            }
            audio1 {
              mediaItemUrl
            }
          }
        }
      }
    }
  }
`;

For whatever reason I only get 10 entries that return, the most recent ones that I have published:

enter image description here

10 entries only appear as well when using the GraphQL IDE.

Anyone know what I'm doing wrong here? I've checked the settings on WordPress and everything seems normal.

Using:

Custom Post Type UI, WP GraphQL, WPGraphQL for Advanced Custom Fields, Advanced Custom Fields as plugins


Solution

  • By default, it only pulls through the first 10, specify the limit of how much you want in the query

        {  
          slumpMedias (first:100)  {
              edges  {
                node {
                  title
                  slumpMeta {
                    image {
                      mediaItemUrl
                    }
                    audio1 {
                      mediaItemUrl
                    }
                  }
                }
              }
            }
        }