Skip to content

Instantly share code, notes, and snippets.

@waseem
Last active July 22, 2022 17:56
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save waseem/c71fa3c8b2b2824f2cdcb34bef51dcb3 to your computer and use it in GitHub Desktop.
Save waseem/c71fa3c8b2b2824f2cdcb34bef51dcb3 to your computer and use it in GitHub Desktop.
Github GraphQL repo commit history for commits made before a certain commit.
query {
repository(owner: "rails", name:"rails") {
ref(qualifiedName:"master") {
target {
... on Commit {
id
#
# We're are requesting commits in the multiple of 5. We can assume that the page size here is 5.
# Next page/cursor should use value in next multiples of 5s. So next page will have a
# after: "05eaa07627376626902bd7acde35406edf1bb2f2 5"
# And after that
# after: "05eaa07627376626902bd7acde35406edf1bb2f2 10" (5 * 2)
# It goes on like 5 * n where n = 0, 1, 2, 3...
#
# When results reach the point upto a commit which has already been processed, the reqsests should
# be stopped.
#
history(first:5 after: "05eaa07627376626902bd7acde35406edf1bb2f2 0") {
pageInfo{
hasNextPage
startCursor
endCursor
}
edges {
node {
id
oid
message
author {
name
email
}
}
}
}
}
}
}
}
}
@sergeymasyura
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment