Empty array returned after the 1000th cursor


#1

Hi,

I use the graphql api to search for some specific topic such as machine learning.
Due to the graphql property, I need to maintain the last cursor in order to keep searching following repos.
But it seems that when I use the 1000th cursor to get the repos after that, the api will return an empty array.

For example: when I query by using the following where the “Y3Vyc29yOjEwMDA=” is the 1000th cursor, the result will be empty array.

query {
  search(query: "machine learning", type: REPOSITORY, first: 1, after: "Y3Vyc29yOjEwMDA=") {
    edges {
      cursor
      node {
        ...on Repository {
          name
        }
      }
    }
  }
}

The return value is an empty array.

{
  "data": {
    "search": {
      "edges": []
    }
  }
}

However, if I use the 999th cursor, and only get one repo after the 999th (“Y3Vyc29yOjk5OQ==” in this case) repo, it will work.

query {
  search(query: "machine learning", type: REPOSITORY, first: 1, after: "Y3Vyc29yOjk5OQ==") {
    edges {
      cursor
      node {
        ...on Repository {
          name
        }
      }
    }
  }
}
{
  "data": {
    "search": {
      "edges": [
        {
          "cursor": "Y3Vyc29yOjEwMDA=",
          "node": {
            "name": "machine-learning-server-docs"
          }
        }
      ]
    }
  }
}

If I change the “first” to 2, it will fail.

query {
  search(query: "machine learning", type: REPOSITORY, first:2 , after: "Y3Vyc29yOjk5OQ==") {
    edges {
      cursor
      node {
        ...on Repository {
          name
        }
      }
    }
  }
}
{
  "data": {
    "search": {
      "edges": []
    }
  }
}

It seems that the api has a limit of 1000 in this case?
Is that a limitation, or a bug? And is there another way to get the data instead? Any help will be appreciated.

Thanks.


#2

Indeed, that’s an API-wide limit that we have in place for search :confused:.

More information can be found here.