[英]Github Graphql Filter issues by Milestone
I'm wrestling with Github's graphql api (while learning graphql) trying to get it to list all issues in a certain milestone. 我正在与Github的graphql api(同时学习graphql)进行摔跤,试图让它列出某个里程碑中的所有问题。 I can't figure out how to do that from the API docs. 我无法弄清楚如何从API文档中做到这一点。
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
}
}
}
}
}
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). 我希望有一种方法可以说出类似issues(milestoneID:"xyz")
,或者如果问题定义了MilestoneConnection
(似乎不存在)。
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?). 到目前为止,在我阅读/学习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? 我想我可以查询存储库中的所有问题并对JSON响应进行后处理以过滤掉我想要的里程碑,但有没有更好的方法来使用github + graphql?
You can use a search query with milestone
filter : 您可以将搜索查询与milestone
过滤器一起使用:
{
search(first: 100, type: ISSUE, query: "user:callemall repo:material-ui milestone:v1.0.0-prerelease state:open") {
issueCount
pageInfo {
hasNextPage
endCursor
}
edges {
node {
... on Issue {
createdAt
title
url
}
}
}
}
}
GitHub recently added the ability to see all issues that are associated with a given milestone. GitHub最近添加了查看与给定里程碑相关的所有问题的功能。 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
}
}
}
}
}
}
}
Or if you don't know the node ID, you could do something like: 或者,如果您不知道节点ID,您可以执行以下操作:
query($owner:String!,$name:String!,$milestoneNumber:Int!) {
repository(owner:$owner,name:$name) {
milestone(number:$milestoneNumber) {
issues(last:10) {
edges {
node {
title
author {
login
}
}
}
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.