graphQL pagination

Highlighted
New Member
1 0 0

Hi guys,

I'm trying to get results with pagination. I did the query below, it kind of works but it's not exactly what I need. This works if I want to go page by page
I need to jump to page number, lets say I need to go directly to page 5, in order to do so, I need to view page 4 and get the last cursor which I do not always have.

Any advice would be greatly appreciated. Cheers

 

{
  products(query:"title:*", first:5, after:"eyJsYXN0X2lkIjo0MzkyNzI2MzMxNDQ3LCJsYXN0X3ZhbHVlIjoiNDM5MjcyNjMzMTQ0NyJ9") {
    edges {
      cursor
      node {
        id
        title
      }
    }
    pageInfo {
      hasNextPage
      hasPreviousPage
    }
  }
}

 

0 Likes