MCPcopy Create free account
hub / github.com/cli/cli / GetCommentReplies

Method GetCommentReplies

pkg/cmd/discussion/client/client.go:643–776  ·  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

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

Callers

nothing calls this directly

Calls 7

mapActorFromListNodeFunction · 0.85
mapReplyFromNodeFunction · 0.85
IDMethod · 0.65
StringMethod · 0.65
QueryMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected