Add support for discussion comment#17
Conversation
|
👋 Hello and thanks for pinging us! You've entered our first responder queue. An accessibility first responder will review this soon.
|
| local DISCUSSION_NODE_ID=$1 | ||
| local REPLY_TO_ID=$2 | ||
| local MESSAGE=$3 | ||
| gh api graphql -F discussionId="$DISCUSSION_NODE_ID" -F replyToId="$REPLY_TO_ID" -F body="$MESSAGE" -f query=' |
There was a problem hiding this comment.
Is it possible to combine addDiscussionComment and addDiscussionCommentAsReply and just leave replyToId as undefined.
| local REPLY_TO_ID=$3 | ||
|
|
||
| if [ -n "$REPLY_TO_ID" ]; then | ||
| gh api graphql -F discussionId="$DISCUSSION_NODE_ID" -F replyToId="$REPLY_TO_ID" -F body="$MESSAGE" -f query=' |
There was a problem hiding this comment.
Sorry! I meant could you do something like this:
if [ -n $REPLY_TO_ID ]; then; else REPLY="$REPLY_TO_ID"; fi
gh api graphql -F discussionId="$DISCUSSION_NODE_ID" -F replyToId=$REPLY -F body="$MESSAGE" -f query='
mutation($discussionId: ID!, , $replyToId: ID, $body: String!) {
addDiscussionComment(input: {discussionId: $discussionId, replyToId: $replyToId, body: $body}) {
comment {
id
}
}
}
'^ I think the var can be passed in as null on graphql
There was a problem hiding this comment.
note: the if statement only is used to add "" around REPLY_TO_ID if it is not null.
There was a problem hiding this comment.
Oh I see. I think I tried this before and ran into a GraphQL error. Let me try again to confirm.
There was a problem hiding this comment.
We run into the following error, so I think we need to stick with two separate calls.
gh: Could not resolve to a node with the global id of ''
{"data":{"addDiscussionComment":null},"errors":[{"type":"NOT_FOUND","path":["addDiscussionComment"],"locations":[{"line":3,"column":9}],"message":"Could not resolve to a node with the global id of ''"}]}There was a problem hiding this comment.
Oh weird it auto resolves it to an empty string.
Co-authored-by: Kendall Gassner <kendallgassner@github.com>
Fixes: #11
This PR adds support for discussion comments. Because the
action.ymlis getting big, I introduced aqueries.shfile to move the GraphQL calls into, including the mutation call we introduced in #14.We are using the
addDiscussionCommentand setting thereplyToIdto post a comment as a reply in a thread.When replying to a top-level discussion comment, we're able to use
github.event.comment.node_idas thereplyToIdto post a reply successfully.However, I ran into issues making the same call when replying to a discussion comment inside of a thread. I kept running into the error:
gh: Parent comment is already in a thread, cannot reply to itI discovered that
replyToIdhas to be a top-level/parent comment node id. Since thegithub.event.comment.node_idonly contains the node ID of the comment we're replying to, we must make a GraphQL query to get the parent comment node ID. We do that in the functiongetDiscussionReplyToId.