Get releases (including tags)


#1

Hello there,

I’m playing around with GraphQL API and I’m trying to bend my head around getting all of the releases in repo shown. I understand how the UI works (details are shown here).

Basically I want to get all the information that is shown on the releases page. A good example is the Erlang Repository. The minor updates are marked as a release whereas the patch updates are “only” tags.

I want to get both in one query. I know how to get releases and tags but not both at once.

I imagine I have to query all tags and then somehow “join” the releases based on the tag id but I have no way if and how that works.

I would greatly appreciate some help on that.


#2

Well, I think you can.
But in fact you can retrieve them with one http request.

I used that query few months ago to retrieve all information:

{
  repository(owner: "rails", name: "rails") {
    tags: refs(refPrefix: "refs/tags/", first: 5, direction: DESC) {
      edges {
        tag: node {
          name
          target {
            ... on Commit {
              message
              author {
                name
                date
              }
            }
            ... on Tag {
              message
              tagger {
                name
                date
              }
            }
          }
        }
      }
    }
    releases(last: 5) {
      nodes {
        id
        name
        description
        publishedAt
        tag {
          name
        }
      }
    }
  }
}

You’ll get both information but you’ll have to merge them manually.


#3

Thank you!

Not quite what I’m looking for. I’d like to already have it reduced to only tags (with optional release information).

I saw that the id field of tag: node matches the id of release -> tag -> id. So if a subquery was possible, that would give me exactly what I want


Release Count Does Not Match What Is Shown On Repository Page