graphqlgithub-apigithub-graphql

GitHub GraphQL fetch repositories that are not archived


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
        }
      }
    }
  }
}

Solution

  • 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