Github GraphQL 搜索与过滤

xpt*_*xpt 9 search github github-api graphql github-graphql

根据我有限的搜索,GraphQL 似乎只能支持等值过滤。所以,

是否可以使用以下过滤条件进行Github GraphQL搜索:

  • 星星 > 10
  • 货叉 > 3
  • 总提交 >= 5
  • 总问题 >= 1
  • 未决问题 <= 60
  • 尺寸 > 2k
  • 分数 > 5
  • 上次更新是在一年内

即对以上所有条件进行过滤。是否可以?

Igo*_*man 9

查询存储库时,您可以仅对列表中的特定数量的字段应用过滤器:

  • 星星数量
  • 货叉数量
  • 尺寸
  • 最后更新

尽管您无法在查询过滤器中指定它们,但您可以在查询中包含其他字段并验证客户端应用程序中的值:

  • 问题总数
  • 未解决问题的数量

虽然从理论上讲,您还可以应用特定参数参数来查询提交次数,但该查询会返回服务器错误,但很可能会超时。因此,这些行被注释掉了。

这是 GraphQL 查询:

query {
  search(
    type:REPOSITORY, 
    query: """
      stars:>10
      forks:>3
      size:>2000
      pushed:>=2018-08-08
    """,
    last: 100
  ) {
    repos: edges {
      repo: node {
        ... on Repository {
          url

          allIssues: issues {
            totalCount
          }
          openIssues: issues(states:OPEN) {
            totalCount
          }

          # commitsCount: object(expression: "master") {
          #   ... on Commit {
          #      history {
          #       totalCount
          #     }
          #   }
          # }
        }
      }
    }
  }
}

Run Code Online (Sandbox Code Playgroud)

存储库查询的规范可以在这里找到: https: //help.github.com/en/articles/searching-for-repositories#search-by-repository-size