【问题标题】:Github GraphQL Search with Filtering带有过滤的 Github GraphQL 搜索
【发布时间】:2018-08-26 22:04:32
【问题描述】:

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

是否可以在Github GraphQL 的过滤条件下进行搜索,

  • 星星 > 10
  • 叉子 > 3
  • 总提交 >= 5
  • 问题总数 >= 1
  • 未解决的问题
  • 尺寸 > 2k
  • 分数 > 5
  • 最后一次更新在一年内

即过滤将所有上述条件。有可能吗?

【问题讨论】:

标签: search github graphql github-api github-graphql


【解决方案1】:

这不是一个答案,而是我迄今为止收集的内容的更新。

  • 根据“Select * for Github GraphQL Search”,并非所有上述条件都适用于存储库边缘。即,“总提交”、“未解决的问题”和“分数”可能不可用。

  • 问题的目的显然是找到有价值的存储库并清除低质量的存储库。我已经collected 所有可能有助于此类评估的可用字段here

截至 2018-03-18 的副本:

query SearchMostTop10Star($queryString: String!, $number_of_repos:Int!) {
  search(query: $queryString, type: REPOSITORY, first: $number_of_repos) {
    repositoryCount
    edges {
      node {
        ... on Repository {
          name
          url
          description
#         shortDescriptionHTML
          repositoryTopics(first: 12) {nodes {topic {name}}}
          primaryLanguage {name}
          languages(first: 3) { nodes {name} }
          releases {totalCount}
          forkCount
          pullRequests {totalCount}
          stargazers {totalCount}
          issues {totalCount}
          createdAt
          pushedAt
          updatedAt
        }
      }
    }
  }
}
variables {
  "queryString": "language:JavaScript stars:>10000", 
  "number_of_repos": 3 
}

任何人都可以尝试as per here

【讨论】:

  • fwiw,您可以将过滤器应用于问题字段以仅获取未解决的问题:issues(states:[OPEN])
  • 感谢@DanielRearden,我已经updated my gist
【解决方案2】:

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

  • 星星数
  • 分叉数
  • 尺寸
  • 上次更新

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

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

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

这是 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
          #     }
          #   }
          # }
        }
      }
    }
  }
}

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

【讨论】:

  • 太棒了!谢谢!!
猜你喜欢
  • 2019-04-10
  • 1970-01-01
  • 2018-08-27
  • 2021-10-08
  • 2014-11-25
  • 2015-12-14
  • 2015-01-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多