Skip to content

Commit a2f0cc6

Browse files
Issue close works
Co-Authored-By: Nate Smith <vilmibm@neongrid.space>
1 parent ad48d8b commit a2f0cc6

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

api/queries_issue.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type IssuesAndTotalCount struct {
2222

2323
// Ref. https://developer.github.com/v4/object/issue/
2424
type Issue struct {
25+
ID string
2526
Number int
2627
Title string
2728
URL string
@@ -298,6 +299,7 @@ func IssueByNumber(client *Client, repo ghrepo.Interface, number int) (*Issue, e
298299
repository(owner: $owner, name: $repo) {
299300
hasIssuesEnabled
300301
issue(number: $issue_number) {
302+
id
301303
title
302304
state
303305
body
@@ -360,22 +362,29 @@ func IssueByNumber(client *Client, repo ghrepo.Interface, number int) (*Issue, e
360362
}
361363

362364
func IssueClose(client *Client, repo ghrepo.Interface, issueNumber int) error {
365+
issue, err := IssueByNumber(client, repo, issueNumber)
366+
if err != nil {
367+
return fmt.Errorf("Faile to find issue #%d: %w", issueNumber, err)
368+
}
369+
363370
var mutation struct {
364-
closeIssue struct {
371+
CloseIssue struct {
372+
Issue struct {
373+
ID githubv4.ID
374+
}
365375
} `graphql:"closeIssue(input: $input)"`
366376
}
367377

368378
input := githubv4.CloseIssueInput{
369-
IssueID: issueNumber,
379+
IssueID: issue.ID,
370380
}
371381

372382
v4 := githubv4.NewClient(client.http)
373-
err := v4.Mutate(context.Background(), &mutation, input, nil)
383+
err = v4.Mutate(context.Background(), &mutation, input, nil)
384+
374385
if err != nil {
375-
return nil
386+
return err
376387
}
377388

378-
fmt.Printf("%v\n", mutation)
379-
380389
return nil
381390
}

0 commit comments

Comments
 (0)