GraphQL pagination response, probably displays wrong results in V4

I think the response I got from my paginated query might be wrong.
This is my query:

query($language: String!, $endCursor: String, $numberOfRepos: Int){
  search(query: $language, type: REPOSITORY, first: $numberOfRepos, after: $endCursor) {
    pageInfo {
      startCursor
      hasNextPage
      endCursor
    }
    edges {
      node {
        ... on Repository {
          nameWithOwner
          isArchived
          stargazers{
              totalCount
          }
        }
      }
    }
  }
}

And those are my input variables

{
	"language": "stars:>=500 sort:stars",
	"endCursor": "Y3Vyc29yOjk5OQ==",
	"numberOfRepos": 1
}

And finally this is the response I got:

{
    "data": {
        "search": {
            "pageInfo": {
                "startCursor": "Y3Vyc29yOjEwMDA=",
                "hasNextPage": false,
                "endCursor": "Y3Vyc29yOjEwMDA="
            },
            "edges": [
                {
                    "node": {
                        "nameWithOwner": "foreversd/forever",
                        "isArchived": false,
                        "stargazers": {
                            "totalCount": 12813
                        }
                    }
                }
            ]
        }
    }
}

Now as you can see this repo has about 12k stars and I got hasNextPage false.
I believe that this is not correct, I cannot believe that there are no more repositories with more than 500 stars after this one D=.

Am I missing something? Is my query wrong?

I want to get all the repositories with stars count bigger than 500 and ordered by starts count from big to small.

Any idea? 
Thanks

Hi Matteo,

Both the REST API and GraphQL API cap the  number of returned results at 1000 and the after argument in your query is pointing to the very last result that can be returned (as the API currently uses base64 to encode these values, we can confirm that “Y3Vyc29yOjEwMDA=” is " cursor:999"). Because there’s no more results we can return,   hasNextPage: false is expected here.

If you wanted to work around the 1000 result limit, I’d suggest trying to further narrow your search. You can use ranges (such as stars:500…600) but as this is searching all repositories on GitHub, you might find you need to filter those results further. Here’s an example that also filters by language:

query {
  search(query: "stars:500..600 language:ruby sort:stars", type: REPOSITORY, first: 20) {
    pageInfo {
      startCursor
      hasNextPage
      endCursor
    }
    repositoryCount
    edges {
      node {
        ... on Repository {
          nameWithOwner
          isArchived
          stargazers{
              totalCount
          }
        }
      }
    }
  }
}

Note that I’ve included repositoryCount too which allows us to confirm the total number of results we’re working with.

I hope this helps!