RepoIssueTypes fetches the available issue types for a repository.
(client *Client, repo ghrepo.Interface)
| 746 | |
| 747 | // RepoIssueTypes fetches the available issue types for a repository. |
| 748 | func RepoIssueTypes(client *Client, repo ghrepo.Interface) ([]IssueType, error) { |
| 749 | query := ` |
| 750 | query RepositoryIssueTypes($owner: String!, $name: String!) { |
| 751 | repository(owner: $owner, name: $name) { |
| 752 | issueTypes(first: 50) { |
| 753 | nodes { id, name, description, color } |
| 754 | } |
| 755 | } |
| 756 | }` |
| 757 | variables := map[string]any{ |
| 758 | "owner": repo.RepoOwner(), |
| 759 | "name": repo.RepoName(), |
| 760 | } |
| 761 | var result struct { |
| 762 | Repository struct { |
| 763 | IssueTypes struct { |
| 764 | Nodes []IssueType |
| 765 | } |
| 766 | } |
| 767 | } |
| 768 | err := client.GraphQL(repo.RepoHost(), query, variables, &result) |
| 769 | if err != nil { |
| 770 | return nil, err |
| 771 | } |
| 772 | return result.Repository.IssueTypes.Nodes, nil |
| 773 | } |
| 774 | |
| 775 | // IssueNodeID fetches the node ID for an issue given its number and repository. |
| 776 | func IssueNodeID(client *Client, repo ghrepo.Interface, number int) (string, error) { |
no test coverage detected