octokit.graphql.net
octokit.graphql.net copied to clipboard
Dynamically build a query based on collection of values
I have a list of pull request numbers, and I want to build a Graph QL query so that I can get information back for all of them.
So the output being something like this:
query {
repository(owner:"Owner", name:"Repo") {
pr1: pullRequest(number: 36592) {
title
}
pr2: pullRequest(number: 36593) {
title
}
....
prN: pullRequest(number: 99999) {
title
}
}
}
Is this possible with the octokit library?
Edit: For example I can do it this way with a raw GraphQL string:
var prQueries = prNumberList.Select((number, index) => $@"
pr{index}: pullRequest(number: {number}) {{
number,
body
}}
");
var query = $@"
query {{
repository(owner:""{this.repoSettings.Owner}"", name:""{this.repoSettings.Name}"") {{
{string.Join("", prQueries)}
}}
}}
";
👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!
I am also having to generate a raw GraphQL string for this kind of query.