Why are some repos' releases not being returned via GraphQL?

Let’s say I want to access a repo’s releases. My code is more complex than this in reality but here’s the simplest reproduction I can make: 

query($owner: String!, $name: String!) {
      repository(owner:$owner, name:$name) {
        id
        releases(first: 3) {
          totalCount
        }
      }
    }

This works on most projects just fine, but on some (such as https://github.com/discourse/discourse) it returns zero releases despite that project having many releases: https://github.com/discourse/discourse/releases

Any ideas?

1 Like

I also note this seems to be true using the REST API too:

https://api.github.com/repos/discourse/discourse/releases

While I’m busy attempting to answer my own question, does this relate to the idea that tags can be shown as releases but are not technically first class “releases” in the GitHub sense? If so, that may explain this issue. If this is the case, could someone help clarify if on projects without true “releases”, every tag essentially becomes a “release” on the project’s /releases page?

I am seeing this same problem with https://github.com/django/django/releases.

I second this question. A little explanation would be nice.

I am calling the Github API v4 with the following query:

{
  repository(owner: "django", name: "django") {
    release(tagName: "1.11") {
      name
      tagName
      createdAt
    }
  }
}

I am getting the response:

{
  "data": {
    "repository": {
      "release": null
    }
  }
}

And when calling the REST API, it is also empty https://api.github.com/repos/django/django/releases.

This seems to be the case.

This answer on StackOverflow seems to address what the issue is. Apparently, the repository owner is not actually “creating” a release in the Github sense. All that they seem to be doing is tagging their repository. By tagging the repository, Github then creates (in their UI) an automatic link to the tag (e.g. a “pointer”). However, that is not a “release” in the Github sense.

The author of the Github repository has to explicitly create a release through the UI or the API for a release to be created.

Here’s a related thread on this forum.

Agreed. I came to that conclusion at the time but didn’t get any confirmation so it’s good to see someone did basically confirm it :slight_smile:

For reference and in case it helps anyone else, I now include the latest tags in my queries as well so I can determine what the latest “release” is client side. The relevant part of the query is:

releases(first: 3, orderBy: {field: CREATED_AT, direction: DESC}) {

          totalCount

          edges {

            node {

              tag {

                name

              }

              createdAt

            }

          }

        }

        refs(refPrefix: “refs/tags/”, first: 2, orderBy: {field: TAG_COMMIT_DATE, direction: DESC}) {

          nodes {

            name

            target {

              … on Tag {

                target {

                  … on Commit {

                    authoredDate

                  }

                }

              }

            }

          }

        }