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