From 02f7ba6e40c4649b66c90cf1f4ae0b32a50ddd18 Mon Sep 17 00:00:00 2001 From: Sean Grove Date: Tue, 7 Jan 2020 17:23:01 -0800 Subject: [PATCH] Given a repository `$repoOwner`/`$repoName`, find the id of an issue by its `$number`. Usually users think of "issue #10", but most GitHub GraphQL mutations refer to issues by their id, so you'll find this query quite helpful! For example, you'll need the issue id if you want to [Delete a GitHub issue](GitHubDeleteIssue). To find the id of issue #3 on the [OneGraph GraphQL Docs Repository](https://github.com/OneGraph/graphql-docs/issues/1), we could pass in the following variables: ```javascript { "repoName": "graphql-docs", "repoOwner": "OneGraph", "number": 3 } ``` --- src/examples/GitHubFindIssueIdByNumber.md | 38 +++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/examples/GitHubFindIssueIdByNumber.md diff --git a/src/examples/GitHubFindIssueIdByNumber.md b/src/examples/GitHubFindIssueIdByNumber.md new file mode 100644 index 0000000..9372105 --- /dev/null +++ b/src/examples/GitHubFindIssueIdByNumber.md @@ -0,0 +1,38 @@ + +--- +description: | + Given a repository `$repoOwner`/`$repoName`, find the id of an issue by its `$number`. + +Usually users think of "issue #10", but most GitHub GraphQL mutations refer to issues by their id, so you'll find this query quite helpful! For example, you'll need the issue id if you want to [Delete a GitHub issue](GitHubDeleteIssue). + + +To find the id of issue #3 on the [OneGraph GraphQL Docs Repository](https://github.com/OneGraph/graphql-docs/issues/1), we could pass in the following variables: + + ```javascript + { + "repoName": "graphql-docs", + "repoOwner": "OneGraph", + "number": 3 + } + ``` + +contributedBy: @sgrove +--- + +```graphql +query GitHubFindIssueIdByNumber( + $repoOwner: String! + $repoName: String! + $number: Int! +) { + gitHub { + repository(owner: $repoOwner, name: $repoName) { + issue(number: $number) { + id + title + } + } + } +} + +```