( token: string, discussionId: string, body: string )
| 733 | } |
| 734 | } |
| 735 | |
| 736 | /** |
| 737 | * Get the repository's GraphQL node ID and its discussion categories. |
| 738 | * Returns only answerable (Q&A) categories. |
| 739 | */ |
| 740 | export async function getRepoDiscussionCategories( |
| 741 | token: string, |
| 742 | owner: string, |
| 743 | repo: string |
| 744 | ): Promise<{ repoNodeId: string; categories: DiscussionCategory[]; hasDiscussions: boolean }> { |
| 745 | const query = ` |
| 746 | query($owner: String!, $repo: String!) { |
| 747 | repository(owner: $owner, name: $repo) { |
| 748 | id |
| 749 | hasDiscussionsEnabled |
| 750 | discussionCategories(first: 25) { |
| 751 | nodes { |
| 752 | id |
| 753 | name |
| 754 | isAnswerable |
| 755 | } |
| 756 | } |
| 757 | } |
| 758 | } |
| 759 | `; |
| 760 | const result = await ghGraphQL(token, query, { owner, repo }); |
| 761 | if (result.errors && result.errors.length > 0) { |
| 762 | const msg = result.errors[0].message; |
| 763 | if (msg.includes('Resource not accessible')) { |
| 764 | throw new Error('PERMISSION_DENIED: Token cannot access discussions. Ensure the token has "Discussions" read/write permission.'); |
| 765 | } |
| 766 | throw new Error(`GraphQL error: ${msg}`); |
| 767 | } |
nothing calls this directly
no test coverage detected