I'm struggling with the github graphql interface to get the data that I need. I want to get a list of asset urls for both tags and releases. It seems that some repos produce my desired result while others produce nothing.
query {
repository(owner:"erlang",name:"otp") {
releases(last:100) {
edges {
node {
url
releaseAssets(last:100) {
edges {
node {
downloadUrl
}
}
}
tag {
name
target {
... on Commit {
zipballUrl
tarballUrl
}
}
}
}
}
}
tags:refs(refPrefix:"refs/tags/", last:30) {
edges {
tag:node {
name
target {
sha:oid
commitResourcePath
... on Commit {
zipballUrl
tarballUrl
author {
name
email
date
}
}
}
}
}
}
}
}
That query, as is, produces my desired results(or at least some them) whereas owner:"spring-projects",name:"spring-framework" produces tags with no tarball. When I look at the spring-framework repo it obviously has assets for releases.
Why are they not showing in this query? When I look at git every release and tag has assets yet, even in my query, the results are hit or miss. What am I missing?
target is a git reference, in that case it can point to a Tag or a Commit object. When it points to a Commit, your query returns the expected result since ...on Commit is not empty. To get the Tag as well just try out with ...on Tag and extract the tagger or the commit it points to depending on what you want. Here is an example :
{
repository(owner: "spring-projects", name: "spring-framework") {
releases(last: 100) {
edges {
node {
url
releaseAssets(last: 100) {
edges {
node {
downloadUrl
}
}
}
tag {
...refInfo
}
}
}
}
tags: refs(refPrefix: "refs/tags/", last: 30) {
edges {
node {
...refInfo
}
}
}
}
}
fragment refInfo on Ref {
name
target {
sha: oid
commitResourcePath
__typename
... on Tag {
target {
... on Commit {
...commitInfo
}
}
tagger {
name
email
date
}
}
... on Commit {
...commitInfo
}
}
}
fragment commitInfo on Commit {
zipballUrl
tarballUrl
author {
name
email
date
}
}
Try it in the explorer
Note that in the example above, I've used fragments to reduce the query size & improve readibility
My guess is that in case the ref is pointing to a Tag object that's an annotated tag which can hold a message, a specific tagging date & tagger info. If it points to a Commit object, it's a lightweight tag which is just linking to a commit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With