Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

How can I display n items in GraphQL?

Avatar

Level 2

I want to get only n results of a query in GraphiQL Explorer.
The GraphQL documentation says that I can use first, but when I try to use it in GraphiQL Explorer, I get an error.

 

 query allEventsTest {
   eventsTestList(first:10) {
    items {
      _path
    }
  }
}
1 Reply

Avatar

Level 7

You can use limit and offset. Let's say you need 10 pages only. This will fetch 10 blog posts starting from the 1st record.

query { blogPosts(limit: 10, offset: 0) { title author { name authorImage } } }

For second page, use limit: 10, offset: 10, This will fetch 10 records starting from the 11th record and so on.

Avatar

Level 2

Hi HeenaMadan,

I tried the following query in GraphiQL Explorer and got an error "Unknown argument "limit" on field "QueryType.eventList"".

 query {
   eventsTestList(limit: 10, offset: 0) {
    items {
      _path
    }
  }
}

 

From the answers to the following questions, it appears that Paging/Sorting is not yet supported.

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/aem-headless-graphql-sort/...