I would like to execute a query for issues in a specific repository using GitHub GraphQL. Here is what I have:
query MyQuery {
search(query: "repo:spring-projects/spring-boot in:title fonts", type: ISSUE, first: 3) {
edges {
node {
... on Issue {
number
title
repository {
name
}
}
}
}
}
}
My problem is that I would like to externalize the actual query, i.e. in:title fonts
and still be able to search for issues only within a specific repo. I tried adding a variable and using it in the query string:
search(query: "repo:spring-projects/spring-boot in:title $query", ...
but it doesn't work.
I can manipulate the query string and replace the variable myself, but I would like to no have to do it.
In other words: how to I query for issues within a specific repository, making the filter part variable but the repository stays the same and is not part of the query? Something like (but this obviously doesn't work, the repo
: "spring-projects/spring-boot" part is invalid):
query MyQuery($query: String!) {
search(repo: "spring-projects/spring-boot", query: $query, type: ISSUE, first: 3) {
edges {
node {
... on Issue {
number
title
repository {
name
}
}
}
}
}
}
and the $query
variable could be set to in:title fonts
at runtime.
Edit: I don't want to list issues by repository, this is easy, e.g.:
query Issues {
repository(owner: "spring-projects", name: "spring-boot") {
issues(last: 3) {
edges {
node {
number
title
}
}
}
}
}```