Last active
March 19, 2022 20:54
-
-
Save johndevs/8bfd1c5338be0e753e56a3794fb0cc3a to your computer and use it in GitHub Desktop.
Github GraphQL - Get all file contents in repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Provide $query as a variable. | |
# The query is the same as you would enter into the search field e.g. "org:johndevs in:name feedreader" | |
query GetFilesQuery($branch: GitObjectID, $query: String!) { | |
search(first: 1, type: REPOSITORY, query: $query) { | |
edges { | |
node { | |
... on Repository { | |
object(expression: "master:", oid: $branch) { | |
... on Tree { | |
entries { | |
name | |
object { | |
... on Blob { | |
text | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} |
How would one grab the updated date or committedDate for each of these TreeEntries?
I tried using Commit
instead of Blob
and that didn't work. Got all empty objects. {}
object {
... on Commit {
committedDate
authoredDate
}
}
I couldn't figure it out either. Put a stackoverflow question on it:
https://stackoverflow.com/questions/71499519/getting-commit-data-on-file-list-github-graphql-api
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't use
master:
butHEAD:
Not every repo has
master:
as the default branch