cli/pkg/cmd/discussion/client/client.go
Babak K. Shandiz b090b4d2fb
feat(discussion/client): add GetCommentReplies with paginated reply fetching
Extract discussionReplyNode and mapReplyFromNode as reusable types for
reply nodes. Add GetCommentReplies to the DiscussionClient interface,
implemented using a combined node(id:) and repository.discussion query
since the Discussion type does not expose a comment(id:) field.

Add ExportReply() for leaf reply nodes (no nested replies) and include
cursor/next pagination fields in the comment Export() replies object.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-27 10:57:45 +01:00

27 lines
1.7 KiB
Go

// Package client provides an abstraction layer for interacting with the
// GitHub Discussions GraphQL API. The DiscussionClient interface defines all
// supported operations and can be replaced with a mock in tests.
package client
import "github.com/cli/cli/v2/internal/ghrepo"
//go:generate moq -rm -out client_mock.go . DiscussionClient
// DiscussionClient defines operations for interacting with the GitHub Discussions API.
type DiscussionClient interface {
List(repo ghrepo.Interface, filters ListFilters, after string, limit int) (*DiscussionListResult, error)
Search(repo ghrepo.Interface, filters SearchFilters, after string, limit int) (*DiscussionListResult, error)
GetByNumber(repo ghrepo.Interface, number int) (*Discussion, error)
GetWithComments(repo ghrepo.Interface, number int, commentLimit int, after string, newest bool) (*Discussion, error)
GetCommentReplies(repo ghrepo.Interface, number int, commentID string, limit int, after string, newest bool) (*Discussion, error)
ListCategories(repo ghrepo.Interface) ([]DiscussionCategory, error)
Create(repo ghrepo.Interface, input CreateDiscussionInput) (*Discussion, error)
Update(repo ghrepo.Interface, input UpdateDiscussionInput) (*Discussion, error)
Close(repo ghrepo.Interface, id string, reason CloseReason) (*Discussion, error)
Reopen(repo ghrepo.Interface, id string) (*Discussion, error)
AddComment(repo ghrepo.Interface, discussionID string, body string, replyToID string) (*DiscussionComment, error)
Lock(repo ghrepo.Interface, id string, reason string) error
Unlock(repo ghrepo.Interface, id string) error
MarkAnswer(repo ghrepo.Interface, commentID string) error
UnmarkAnswer(repo ghrepo.Interface, commentID string) error
}