-
Notifications
You must be signed in to change notification settings - Fork 15
Add support for discussion comment #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
👋 Hello and thanks for pinging us! You've entered our first responder queue. An accessibility first responder will review this soon.
|
queries.sh
Outdated
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to combine addDiscussionComment and addDiscussionCommentAsReply and just leave replyToId as undefined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in ad9af45! :)
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh weird it auto resolves it to an empty string.
Co-authored-by: Kendall Gassner <kendallgassner@github.com>
kendallgassner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
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.