GitHub GraphQL获取未归档的存储库

时间:2018-12-28 00:47:38

标签: graphql github-api github-graphql

是否有一种方法可以仅提取未归档的存储库?

{
  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 个答案:

答案 0 :(得分:1)

除了使用archived search parameter进行用户查询外,您还可以使用搜索查询。还可以使用fork:true来包含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 :(得分:0)

您应该能够将过滤器添加到查询的存储库部分:

repositories(first: 100, isArchived: false) { # fetch only the repos that are not archived
  ...
}

The docs they have some examplesnameowner过滤器。