GitHub GraphQL fetch repositories that are not archived

GitHub GraphQL fetch repositories that are not archived


5

Is there a way to fetch only the repos that are not archived?

{
  user(login: "SrikanthBandaru") {
    id
    email
    isHireable
    name
    repositories(first: 100) { # fetch only the repos that are not archived
      edges {
        node {
          name
          isArchived
          shortDescriptionHTML
          description
          descriptionHTML
          repositoryTopics(first: 10) {
            edges {
              node {
                topic {
                  name
                }
              }
            }
          }
          homepageUrl
          url
        }
      }
    }
  }
}

2 Answers
2


8

You can use a search query in addition to user query with the archived search parameter. Also use fork:true to include forks:

{
  user: user(login: "simon04") {
    id
    email
    isHireable
    name
  }
  repos: search(query: "user:simon04 fork:true archived:false", type: REPOSITORY, first: 100) {
    repositoryCount
    edges {
      node {
        ... on Repository {
          nameWithOwner
          name
          isArchived
          shortDescriptionHTML
          description
          descriptionHTML
          repositoryTopics(first: 10) {
            edges {
              node {
                topic {
                  name
                }
              }
            }
          }
          homepageUrl
          url
        }
      }
    }
  }
}

Try it in the explorer

1

  • ahh..!! Thank you!!

    – Testaccount

    Dec 28, 2018 at 1:23


0

You can run the query below to filter out archived repository in the Github org; I used the pageInfo request to get the endcursor for paginating into the next page.

query {
  organization(login: "orgname") {
    repositories(isArchived:false, first: 100) {  # adjust this value based on your needs
      edges {
        node {
          name
          vulnerabilityAlerts(first: 100) {  # adjust this value based on your needs
            edges {
              node {
                id
                securityVulnerability {
                  package {
                    name
                    ecosystem
                  }
                  severity
                  updatedAt
                }
                vulnerableRequirements
              }
            }
          }
        }
      }
      pageInfo {
        endCursor
        hasNextPage
      } 
    }
  }
}



Leave a Reply

Your email address will not be published. Required fields are marked *