Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 3

graphql search last fails

Hi, I'm having an issue when searching for Users. 
Getting first results, and pagination with cursor workas as expected, but when querying the las page search with last param only, it returns the first results anyway. page info hasNextPage is also true

Captura de pantalla 2018-12-21 a la(s) 22.13.17.png

 

The query:

query ($query: String!) {
  search(query: $query, last: 10, type: USER) {
    userCount
    pageInfo {
      hasNextPage
    }
    edges {
      node {
        ... on User {
          name
        }
      }
    }
  }
}

 

Am I missing something? It works with every other search pagination option:
go to firstpage, go to previous page, got to next page

Thanks!

2 Replies
Community Manager
Message 2 of 3

Re: graphql search last fails

Hi @flakolefluk,

 

Thanks for being here! I think the issue here is with the differences between offset vs cursor based pagination, the REST API allows to fetch multiple pages of results in parallel thanks to offset. That is not possible with GraphQL. 

 

Here is a really great external blog detailing: "Offset pagination contains page numbers in addition to next and previous links. But due to the highly dynamic nature of the data, we can’t provide page numbers for cursor based pagination".

 

I'd love for someone else to chime in here as they might have more experience here.

Mark helpful posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great content!

Copilot Lvl 2
Message 3 of 3

Re: graphql search last fails

Thanks for the reply. Perhaps i shouldn’t have used the ‘page’ word. So if understand correctly there’s no way to get the latest 10 items of a Query using the GraphQL api.