Closed sladyn98 closed 3 years ago
One of the queries I tried running to get repositories is
{
viewer {
repositories(first: 100) {
totalCount
nodes {
nameWithOwner
}
pageInfo {
endCursor
hasNextPage
}
}
}
}
This is one query I used to get all repos under jordans username
{
user(login: "ljharb") {
repositories(first: 50, isFork: false) {
nodes {
name
url
}
}
}
}
You can get the default branch name by adding a defaultBranchRef
{
user(login: "ljharb") {
repositories(first: 50, isFork: false) {
nodes {
name
url
defaultBranchRef {
name
}
}
}
}
}
{
user(login: "ljharb") {
repositories(first: 50, isFork: false) {
nodes {
name
url
defaultBranchRef {
name
branchProtectionRule {
isAdminEnforced
requiresStatusChecks
allowsForcePushes
}
}
}
}
}
}
This returns data in this format. We can then parse this information about default branch name and group it
{
"data": {
"user": {
"repositories": {
"nodes": [
{
"name": "compat-table",
"url": "https://github.com/kangax/compat-table",
"defaultBranchRef": {
"name": "gh-pages",
"branchProtectionRule": null
}
},
{
"name": "nvm",
"url": "https://github.com/nvm-sh/nvm",
"defaultBranchRef": {
"name": "master",
"branchProtectionRule": null
}
},
{
"name": "forms",
"url": "https://github.com/caolan/forms",
"defaultBranchRef": {
"name": "master",
"branchProtectionRule": null
}
},
{
"name": "testling",
"url": "https://github.com/substack/testling",
"defaultBranchRef": {
"name": "master",
"branchProtectionRule": null
}
},
{
"name": "isitteatimeyet",
"url": "https://github.com/attaboy/isitteatimeyet",
"defaultBranchRef": {
"name": "master",
"branchProtectionRule": null
}
},
{
"name": "travis-cookbooks",
"url": "https://github.com/travis-ci/travis-cookbooks",
"defaultBranchRef": {
"name": "master",
"branchProtectionRule": null
}
},
{
"name": "resolve",
"url": "https://github.com/browserify/resolve",
"defaultBranchRef": {
"name": "master",
"branchProtectionRule": null
}
},
{
"name": "TcoExpand",
"url": "https://github.com/ljharb/TcoExpand",
"defaultBranchRef": {
"name": "master",
"branchProtectionRule": null
}
},
{
"name": "is",
"url": "https://github.com/enricomarino/is",
"defaultBranchRef": {
"name": "master",
"branchProtectionRule": null
}
},
Here's the one I used:
query {
viewer {
repositories(
first: 100
affiliations: [OWNER, ORGANIZATION_MEMBER, COLLABORATOR]
${endCursor ? `after: "${endCursor}"` : ""}
) {
totalCount
pageInfo {
endCursor
hasNextPage
}
nodes {
name
owner {
login
}
isPrivate
defaultBranchRef {
name
}
viewerPermission
}
}
}
rateLimit {
cost
remaining
}
}
Some sample outputs I got with the feature I pushed here
This looks great! A few thoughts:
We can close this since we have already initial research
We could search for all of the repositories owned by a user and then list out the parameters we would require to query a) Default Branch b) Pull Requests c) Default Permissions d) Branch Protection