Github Graphql 按里程碑过滤问题 [英] Github Graphql Filter issues by Milestone

查看:36
本文介绍了Github Graphql 按里程碑过滤问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力使用 Github 的 graphql api(在学习 graphql 时)试图让它列出某个里程碑中的所有问题.我无法从 API 文档中弄清楚如何做到这一点.

I'm wrestling with Github's graphql api (while learning graphql) trying to get it to list all issues in a certain milestone. I can't figure out how to do that from the API docs.

我可以查询问题并查看它们处于哪个里程碑(抱歉,名称已删除):

I can query issues and see what milestone they're in (sorry, names redacted):

query {
    repository(owner:"me", name:"repo") {
        issues(last:10) {
            nodes {
                milestone {
                    id
                    title
                }
            }
         }
    }
}

我希望有一种方法可以说像issues(milestoneID:"xyz"),或者如果Issue 将定义一个 MilestoneConnection(似乎不存在).

I wish there was a way to say something like issues(milestoneID:"xyz"), or perhaps if Issue would define a MilestoneConnection (doesn't appear to exist).

到目前为止,在我对 GraphQL 的阅读/学习中,如果架构中未定义显式参数,我还没有找到构建任意字段过滤器的方法(我的说法正确吗?).

In my reading / learning about GraphQL thus far, I haven't found a way to build arbitrary filters of fields if an explicit parameter is not defined in the schema (am I right about that?).

我想我可以查询存储库中的所有问题并对 JSON 响应进行后处理以过滤掉我想要的里程碑,但是有没有更好的方法来使用 github + graphql 来做到这一点?

I guess I can query all of issues in the repository and post-process the JSON response to filter out the milestone I want, but is there a better way to do this with github + graphql?

推荐答案

GitHub 最近添加了查看与给定里程碑相关的所有问题的功能.您应该能够使用类似于以下内容的查询来获取它:

GitHub recently added the ability to see all issues that are associated with a given milestone. You should be able to fetch it with a query similar to:

query($id:ID!) {
  node(id:$id) {
    ... on Milestone {
      issues(last:10) {
        edges {
          node {
            title
            author {
              login
            }
          }
        }
      }
    }
  }
}

或者,如果您不知道节点 ID,您可以执行以下操作:

Or if you don't know the node ID, you could do something like:

query($owner:String!,$name:String!,$milestoneNumber:Int!) {
  repository(owner:$owner,name:$name) {
    milestone(number:$milestoneNumber) {
      issues(last:10) {
        edges {
          node {
            title
            author {
              login
            }
          }
        }
      }
    }
  }
}

这篇关于Github Graphql 按里程碑过滤问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆