MCPcopy
hub / github.com/cli/cli / GetCommentReplies

Method GetCommentReplies

pkg/cmd/discussion/client/client.go:646–779  ·  view source on GitHub ↗

GetCommentReplies fetches a single comment with its paginated replies, along with its parent discussion. It uses the top-level node(id:) query because the comment node ID is self-contained: the parent discussion (number, repository, and detail fields) is resolved from the comment itself rather than

(host string, commentID string, limit int, after string, newest bool)

Source from the content-addressed store, hash-verified

644// separate repository(owner:).discussion(number:) lookup. The host argument
645// selects the GraphQL endpoint.
646func (c *discussionClient) GetCommentReplies(host string, commentID string, limit int, after string, newest bool) (*Discussion, error) {
647 var query struct {
648 Node *struct {
649 DiscussionComment struct {
650 ID string
651 URL string `graphql:"url"`
652 Author actorNode
653 Body string
654 CreatedAt time.Time
655 IsAnswer bool
656 UpvoteCount int
657 ReactionGroups []struct {
658 Content string
659 Users struct {
660 TotalCount int
661 }
662 }
663 Discussion discussionListNode
664 Replies struct {
665 TotalCount int
666 PageInfo struct {
667 EndCursor string
668 HasNextPage bool
669 StartCursor string
670 HasPreviousPage bool
671 }
672 Nodes []discussionReplyNode
673 } `graphql:"replies(first: $first, last: $last, after: $after, before: $before)"`
674 } `graphql:"... on DiscussionComment"`
675 } `graphql:"node(id: $commentID)"`
676 }
677
678 variables := map[string]interface{}{
679 "commentID": githubv4.ID(commentID),
680 "first": (*githubv4.Int)(nil),
681 "last": (*githubv4.Int)(nil),
682 "after": (*githubv4.String)(nil),
683 "before": (*githubv4.String)(nil),
684 }
685
686 if newest {
687 variables["last"] = githubv4.Int(min(limit, maxPageSize))
688 if after != "" {
689 variables["before"] = githubv4.String(after)
690 }
691 } else {
692 variables["first"] = githubv4.Int(min(limit, maxPageSize))
693 if after != "" {
694 variables["after"] = githubv4.String(after)
695 }
696 }
697
698 if err := c.gql.Query(host, "DiscussionCommentReplies", &query, variables); err != nil {
699 return nil, err
700 }
701
702 // The query above should already error for an invalid node ID, but guard against nil.
703 if query.Node == nil {

Callers

nothing calls this directly

Calls 8

mapActorFromListNodeFunction · 0.85
mapReplyFromNodeFunction · 0.85
IDMethod · 0.65
QueryMethod · 0.65
ErrorfMethod · 0.65
minFunction · 0.50
StringMethod · 0.45

Tested by

no test coverage detected