Github Graphql筛选器问题(按里程碑) [英] Github Graphql Filter issues by Milestone

查看:84
本文介绍了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"),或者如果问题将定义一个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天全站免登陆