cli/pkg/cmd/discussion/client
Max Beizer 9f3a31ddb3
fix(discussion view): use GraphQL variables for cursor, fix --json comments
Fix two issues in the discussion view command:

1. GraphQL injection via cursor interpolation: The --after cursor value
   was interpolated directly into the raw GraphQL query string using
   fmt.Sprintf, which is unsafe since cursor values come from user input.
   Now uses GraphQL variables ($cursor: String) instead, matching the
   pattern used by issue list, pr list, and other commands.

2. Incomplete --json comments output: Running `gh discussion view N
   --json comments` silently returned only totalCount with no comment
   nodes, because the data fetch was gated solely on the --comments flag.
   Now checks if the JSON exporter requests the comments field and
   fetches full comment data accordingly, matching how issue view and
   pr view drive data loading from exporter fields.

Also fixes example text that said "newest" but showed --order oldest.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-25 12:19:04 -05:00
..
client.go feat(discussion view): add cursor-based pagination to comments 2026-04-24 23:50:04 +01:00
client_impl.go fix(discussion view): use GraphQL variables for cursor, fix --json comments 2026-04-25 12:19:04 -05:00
client_impl_test.go refactor(discussion/client): convert tests to httpStubs pattern 2026-04-24 14:19:19 +01:00
client_mock.go feat(discussion view): add cursor-based pagination to comments 2026-04-24 23:50:04 +01:00
types.go feat(discussion view): add cursor-based pagination to comments 2026-04-24 23:50:04 +01:00