Releases totalCount using GraphQL v4 API

Hey,
I’m trying to get the total count of releases from a certain repository on GitHub.

If you go to a normal GitHub page of a repository, you can see on the right it shows the Releases box that shows total count, latest release and +remaining number of releases. When you click and explore, you notice some of those releases are tagged as pre-release, others as full release, yet others as test, etc. Doesn’t matter - it still gives you a total count. And that’s what I want to do with GraphQL.
I tried:

{
  repository(owner: "repo-owner", name: "repo-name") {
    name
    releases(first: 0) {
      totalCount
    }
  }
}

But that returns a weird number, not anyhow compatible with what I see on the GitHub page alone.
How do I do that?

1 Like

@chaubunhtha :heart_eyes: :smiling_face_with_three_hearts:

Wait… what? :slight_smile:

And I just figured it out myself.

{
  repository(owner: "repo-owner", name: "repo-name") {
    refs(refPrefix: "refs/tags/") {
      totalCount
    }
  }
}

Works like a charm. :slight_smile: