I have a little web app called RepoSweeper (https://reposweeper.com/) which I built after my coding bootcamp. It's purpose is to bulk delete unused repos from GitHub.
A while back GitHub changed the way you access repos via the API and Private repos stopped showing up in the results. So I had a freelancer modify the code to use GraphQL to make the request.
Now all the repos show up (hooray!) but there are a huge number of repos that don't exist in my Repositories on Github. My first thought was that they are archived, but the isArchived flag is false in the response data.
This is the GraphQL query:
export const REPO_INFO_QUERY = gql`
query ($ghLogin: String!, $after: String) {
user(login: $ghLogin) {
id
name
login
avatarUrl
bioHTML
repositories(first: 100, after: $after, ownerAffiliations: [OWNER, ORGANIZATION_MEMBER, COLLABORATOR]) {
totalCount
pageInfo {
endCursor
hasNextPage
__typename
}
nodes {
id
viewerCanAdminister
name
description
isFork
isPrivate
isArchived
updatedAt
createdAt
url
parent {
nameWithOwner
url
__typename
}
owner {
login
url
__typename
}
__typename
}
__typename
}
__typename
}
}
`;
This is the request:
const endpoint = `https://api.github.com/graphql`
const graphQLClient = new GraphQLClient(endpoint, {
headers: {
authorization: `Bearer ${token}`,
},
})
const variables = {ghLogin: user, archived: true, isArchived: true}
return graphQLClient.request(REPO_INFO_QUERY, variables).then(data => {
debugger
return data
})
.catch(err => {
Popup.alert('Error: '+ err)
return false
}
)
And this is what the non-existent repo data looks like:
Love to hear what you guys think. Thank you!
