-
Notifications
You must be signed in to change notification settings - Fork 17
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
487b470
Add support for discussion comment
khiga8 f8f23d6
Introduce queries helper
khiga8 91013ac
Update code comments
khiga8 ca6d2c6
Update README
khiga8 ad9af45
Combine helpers into one addDiscussionComment
khiga8 438305a
Update queries.sh
khiga8 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Given a node_id for a discussion comment that is a reply in thread, return the parent comment's node ID. | ||
| function getDiscussionReplyToId() { | ||
| local NODE_ID=$1 | ||
| local REPLY_TO_DATA=$(gh api graphql -f query=' | ||
| query($nodeId: ID!) { | ||
| node(id: $nodeId) { | ||
| ... on DiscussionComment { | ||
| replyTo { | ||
| id | ||
| } | ||
| } | ||
| } | ||
| }' -F nodeId=$NODE_ID) | ||
| echo $REPLY_TO_DATA | jq -r '.data.node.replyTo.id' | ||
| } | ||
|
|
||
| # Given a discussion node ID, a message, and an optional reply to node ID, adds a discussion comment. | ||
| function addDiscussionComment() { | ||
| local DISCUSSION_NODE_ID=$1 | ||
| local MESSAGE=$2 | ||
| 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=' | ||
| mutation($discussionId: ID!, $replyToId: ID, $body: String!) { | ||
| addDiscussionComment(input: {discussionId: $discussionId, replyToId: $replyToId, body: $body}) { | ||
| comment { | ||
| id | ||
| } | ||
| } | ||
| } | ||
| ' | ||
| else | ||
| gh api graphql -F discussionId="$discussion_node_id" -F body="$message" -f query=' | ||
| mutation($discussionId: ID!, $body: String!) { | ||
| addDiscussionComment(input: {discussionId: $discussionId, body: $body}) { | ||
| comment { | ||
| id | ||
| } | ||
| } | ||
| } | ||
| ' | ||
| fi | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
^ I think the var can be passed in as
nullon graphqlThere 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
""aroundREPLY_TO_IDif it is not null.Uh oh!
There was an error while loading. Please reload this page.
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.
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.