@@ -91,6 +91,78 @@ suggestion comments, use `gh api`.
9191- A suggestion block replaces exactly ` start_line..line ` ; its body must be a
9292 drop-in replacement for those lines, including indentation.
9393
94+ ## Editing Draft Reviews (API Mechanics)
95+
96+ Only edit pending draft comments/reviews you authored unless the user explicitly
97+ asks for something else. Prefer editing drafts over deleting and recreating them
98+ when anchors are correct.
99+
100+ REST and GraphQL use different IDs:
101+
102+ - REST endpoints use numeric database IDs from URLs and ` databaseId ` .
103+ - GraphQL mutations use opaque node IDs like ` PRRC_... ` and ` PRR_... ` .
104+ - Do not guess node IDs from REST IDs or from adjacent comments. Fetch exact
105+ node IDs before patching.
106+
107+ REST can edit submitted review comments:
108+
109+ ``` bash
110+ gh api -X PATCH \
111+ repos/{owner}/{repo}/pulls/comments/{comment_database_id} \
112+ -f body=" $body "
113+ ```
114+
115+ Pending draft review comments may reject REST patches. Use GraphQL when editing
116+ draft comments:
117+
118+ ``` bash
119+ gh api graphql \
120+ -f query=' mutation($id:ID!, $body:String!) {
121+ updatePullRequestReviewComment(input:{pullRequestReviewCommentId:$id, body:$body}) {
122+ pullRequestReviewComment { id body updatedAt }
123+ }
124+ }' \
125+ -F id=" $comment_node_id " \
126+ -f body=" $body "
127+ ```
128+
129+ Use GraphQL for draft review summary body edits too:
130+
131+ ``` bash
132+ gh api graphql \
133+ -f query=' mutation($id:ID!, $body:String!) {
134+ updatePullRequestReview(input:{pullRequestReviewId:$id, body:$body}) {
135+ pullRequestReview { id body state updatedAt }
136+ }
137+ }' \
138+ -F id=" $review_node_id " \
139+ -f body=" $body "
140+ ```
141+
142+ Fetch exact review/comment node IDs before editing:
143+
144+ ``` bash
145+ gh api graphql \
146+ -f owner=' {owner}' -f repo=' {repo}' -F number=' {pr_number}' \
147+ -f query=' query($owner:String!, $repo:String!, $number:Int!) {
148+ repository(owner:$owner, name:$repo) {
149+ pullRequest(number:$number) {
150+ reviews(last:20) {
151+ nodes {
152+ id databaseId state author { login } body
153+ comments(first:100) {
154+ nodes { id databaseId path body author { login } }
155+ }
156+ }
157+ }
158+ }
159+ }
160+ }'
161+ ```
162+
163+ After mutation, read back the edited node body through GraphQL. For pending
164+ reviews, REST read-back can omit fields or show stale/partial shape.
165+
94166## Conventional Comments
95167
96168Format:
0 commit comments