Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically build a query based on collection of values #200

Open
hisuwh opened this issue Jul 9, 2019 · 2 comments
Open

Dynamically build a query based on collection of values #200

hisuwh opened this issue Jul 9, 2019 · 2 comments
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Feature New feature or request

Comments

@hisuwh
Copy link

hisuwh commented Jul 9, 2019

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)}
        }}
    }}
";
@github-actions
Copy link

github-actions bot commented Dec 3, 2022

👋 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!

@github-actions github-actions bot added the Status: Stale Used by stalebot to clean house label Dec 3, 2022
@rseanhall
Copy link

I am also having to generate a raw GraphQL string for this kind of query.

@github-actions github-actions bot removed the Status: Stale Used by stalebot to clean house label Dec 4, 2022
@kfcampbell kfcampbell added Priority: Normal Status: Up for grabs Issues that are ready to be worked on by anyone Type: Feature New feature or request labels Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Feature New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants