Can we compare two branches with the Github GraphQL?
From their v3 rest API, you can do:
/repos/:owner/:repo/compare/:base...:head
(docs: https://developer.github.com/v3/repos/commits/#compare-two-commits)
and this works with SHA's, branches, tags, etc.
However, I'm unable to find it's equivalent GraphQL query in the docs.
This is my attempt so far :
I'm able to get the list of commits for each branch seperately, however, the entire history is loaded and I would only like the difference between canary branch and nightly branch.
query{
repository(owner:"samridh",name:"release-generator"){
name
branch0: ref(qualifiedName: "canary"){
target{
... on Commit {
history(first:100){
...CommitFragment
}
}
}
}
branch1: ref(qualifiedName: "nightly"){
target{
... on Commit {
history(first:100){
...CommitFragment
}
}
}
}
}
}
fragment CommitFragment on CommitHistoryConnection {
totalCount
nodes {
oid
message
committedDate
author {
name
email
}
}
pageInfo {
hasNextPage
endCursor
}
}
This would have been done as :
/repos/samridh/release-generator/compare/nightly...canary
in the v3 REST API
Unfortunately, after scrolling through hours and hours of the github community page, it seems that as of this date, the API is not migrated on the v4, and must be done via v3 itself.
However, the v3 API only supports 250 commits, any commits beyond that will be ignored and not shown. This can be worked around using graphQL though.
Fire this query to get the starting and ending points:
This will give you the start and end date of the query.
Plugin these values to :
and extract all the oid, 100 at a time ( Github GraphQL only supports 100 at a time )
Finally, you can call the v3 API, likewise :