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
}
}
}
}
}
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).
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?).
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?
You can use a search query with milestone
filter :
{
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. 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:
query($owner:String!,$name:String!,$milestoneNumber:Int!) {
repository(owner:$owner,name:$name) {
milestone(number:$milestoneNumber) {
issues(last:10) {
edges {
node {
title
author {
login
}
}
}
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With