-
Notifications
You must be signed in to change notification settings - Fork 89
Description
Hi,
I'm trying to fetch all of the branches in a selected repository, as well as their last commit date. I use the commit date in order to programmatically sort the branches in a descending chronological order. The repository currently has more than 300 branches.
I've tried multiple solutions and queries, but I cannot fetch more than 100 branches, even when using multiple requests, and the hasNextPage flag is set to false once the 100th ref is reached.
When the first variable is set to a number lower than 100, the pagination seems to work, but still stops at 100 branches. For example, if first is set to 20, then 5 pages will be fetched with 100 branches in total.
I've also tried using https://github.com/octokit/plugin-paginate-graphql.js but I got the same results.
Here is the query I'm currently using:
query branches(
$owner: String = "github_user",
$repositoryName: String!,
$prefix: String = "refs/heads/",
$refQuery: String = "",
) {
repository(name: $repositoryName, owner: $owner) {
defaultBranchRef {
name
}
refs(first: 100, query: $refQuery, refPrefix: $prefix, after: $endCursor) {
edges {
node {
name,
ref: target {
... on Commit {
oid,
authors(first: 1) {
nodes {
date
}
}
}
}
}
cursor
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
Thanks in advance!
Metadata
Metadata
Assignees
Labels
Type
Projects
Status