Search code examples
githubgraphqlgithub-apigit-fork

GitHub GraphQL: Get all forks of a repository


I would like to get a list of all the forks (with timestamp) of a specific repository. When I try the following on explorer

{
  repository(name: "tensorflow", owner: "tensorflow") {
    forkCount
    forks(first: 100) {
      totalCount
    }
  }
}

It returns the forkCount correctly and as displayed on the webpage, but unexplainably there are over 15,000 fewer repositories in the "forks" list as displayed on the webpage and forkCount. Consequently, I am missing the timestamp for these repositories.

{
  "data": {
    "repository": {
      "forkCount": 86841,
      "forks": {
        "totalCount": 70082
      }
    }
  }
}

Does anyone have an explanation for this? How do you get the other repositories?

The visibility of a fork repository cannot be changed.

Thank you in advance!


Solution

  • forks.totalCount shows the number of direct forks of this repository. forkCount also includes forks of forks and this number may be bigger

    Credit for the answer goes here: https://github.com/orgs/community/discussions/33375#discussioncomment-3671593