MCPcopy Create free account
hub / github.com/cli/cli / IssueNodeID

Function IssueNodeID

api/queries_issue.go:776–802  ·  view source on GitHub ↗

IssueNodeID fetches the node ID for an issue given its number and repository.

(client *Client, repo ghrepo.Interface, number int)

Source from the content-addressed store, hash-verified

774
775// IssueNodeID fetches the node ID for an issue given its number and repository.
776func IssueNodeID(client *Client, repo ghrepo.Interface, number int) (string, error) {
777 query := `
778 query IssueNodeID($owner: String!, $name: String!, $number: Int!) {
779 repository(owner: $owner, name: $name) {
780 issue(number: $number) {
781 id
782 }
783 }
784 }`
785 variables := map[string]any{
786 "owner": repo.RepoOwner(),
787 "name": repo.RepoName(),
788 "number": number,
789 }
790 var result struct {
791 Repository struct {
792 Issue struct {
793 ID string
794 }
795 }
796 }
797 err := client.GraphQL(repo.RepoHost(), query, variables, &result)
798 if err != nil {
799 return "", err
800 }
801 return result.Repository.Issue.ID, nil
802}

Callers 1

ResolveIssueRefFunction · 0.92

Calls 4

GraphQLMethod · 0.80
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
RepoHostMethod · 0.65

Tested by

no test coverage detected