MCPcopy Create free account
hub / github.com/github/gh-aw / resolveTopLevelDiscussionCommentId

Function resolveTopLevelDiscussionCommentId

actions/setup/js/github_api_helpers.cjs:154–176  ·  view source on GitHub ↗

* Resolves the top-level parent comment node ID for GitHub Discussion replies. * GitHub Discussions only supports two nesting levels: top-level comments and one level of replies. * If the given comment is itself a reply (has a replyTo parent), the parent's node ID is returned * so that replyToId

(github, commentNodeId)

Source from the content-addressed store, hash-verified

152 * @returns {Promise<string|null|undefined>} The node ID to use as replyToId (parent if reply, otherwise the original)
153 */
154async function resolveTopLevelDiscussionCommentId(github, commentNodeId) {
155 if (!commentNodeId) {
156 return commentNodeId;
157 }
158 try {
159 const result = await github.graphql(
160 `query($nodeId: ID!) {
161 node(id: $nodeId) {
162 ... on DiscussionComment {
163 replyTo {
164 id
165 }
166 }
167 }
168 }`,
169 { nodeId: commentNodeId }
170 );
171 return result?.node?.replyTo?.id ?? commentNodeId;
172 } catch (error) {
173 logGraphQLError(/** @type {Error & { errors?: Array<{ type?: string, message: string, path?: unknown, locations?: unknown }>, request?: unknown, data?: unknown, status?: number }} */ error, "resolving top-level discussion comment");
174 return commentNodeId;
175 }
176}
177
178module.exports = {
179 fetchAllRepoLabels,

Callers 6

mainFunction · 0.85
mainFunction · 0.85

Calls 1

logGraphQLErrorFunction · 0.85

Tested by

no test coverage detected