| 482 | } |
| 483 | |
| 484 | func preloadPrComments(client *http.Client, repo ghrepo.Interface, pr *api.PullRequest) error { |
| 485 | if !pr.Comments.PageInfo.HasNextPage { |
| 486 | return nil |
| 487 | } |
| 488 | |
| 489 | type response struct { |
| 490 | Node struct { |
| 491 | PullRequest struct { |
| 492 | Comments api.Comments `graphql:"comments(first: 100, after: $endCursor)"` |
| 493 | } `graphql:"...on PullRequest"` |
| 494 | } `graphql:"node(id: $id)"` |
| 495 | } |
| 496 | |
| 497 | variables := map[string]any{ |
| 498 | "id": githubv4.ID(pr.ID), |
| 499 | "endCursor": githubv4.String(pr.Comments.PageInfo.EndCursor), |
| 500 | } |
| 501 | |
| 502 | gql := api.NewClientFromHTTP(client) |
| 503 | |
| 504 | for { |
| 505 | var query response |
| 506 | err := gql.Query(repo.RepoHost(), "CommentsForPullRequest", &query, variables) |
| 507 | if err != nil { |
| 508 | return err |
| 509 | } |
| 510 | |
| 511 | pr.Comments.Nodes = append(pr.Comments.Nodes, query.Node.PullRequest.Comments.Nodes...) |
| 512 | pr.Comments.TotalCount = len(pr.Comments.Nodes) |
| 513 | |
| 514 | if !query.Node.PullRequest.Comments.PageInfo.HasNextPage { |
| 515 | break |
| 516 | } |
| 517 | variables["endCursor"] = githubv4.String(query.Node.PullRequest.Comments.PageInfo.EndCursor) |
| 518 | } |
| 519 | |
| 520 | pr.Comments.PageInfo.HasNextPage = false |
| 521 | return nil |
| 522 | } |
| 523 | |
| 524 | func preloadPrClosingIssuesReferences(client *http.Client, repo ghrepo.Interface, pr *api.PullRequest) error { |
| 525 | if !pr.ClosingIssuesReferences.PageInfo.HasNextPage { |