Add `issueFieldValues` to `gh issue view --json` fields by owenniblock · Pull Request #13707 · cli/cli · GitHub
Skip to content

Add issueFieldValues to gh issue view --json fields#13707

Draft
owenniblock wants to merge 1 commit into
cli:trunkfrom
owenniblock:owenniblock/issue-field-values
Draft

Add issueFieldValues to gh issue view --json fields#13707
owenniblock wants to merge 1 commit into
cli:trunkfrom
owenniblock:owenniblock/issue-field-values

Conversation

@owenniblock

@owenniblock owenniblock commented Jun 23, 2026

Copy link
Copy Markdown

Summary

Adds support for the new native repository-level issue fields (e.g. Priority, Estimate) to the JSON output of gh issue view, gh issue list, and gh issue status.

These fields live under the issueFieldValues connection on the Issue GraphQL type and are distinct from ProjectV2 custom fields — they're set directly on the issue without a project. Today the CLI has no way to surface them: --json issueFieldValues errors out as unsupported.

Motivation

I hit this while reading a Priority value off an issue. The Priority sidebar widget is clearly populated, but there was no CLI-friendly way to read it. The only workaround was hand-rolling a GraphQL query via gh api graphql. After confirming no existing PR or issue mentioned issueFieldValues in cli/cli, I put this together.

Changes

  • api/queries_issue.go: new IssueFieldValues / IssueFieldValue types covering the four union variants (SingleSelect, Text, Number, Date)
  • api/query_builder.go: register issueFieldValues in issueOnlyFields and emit the GraphQL fragment with inline ...on selections for each variant
  • api/export_pr.go: flatten union members into a clean JSON shape per typename
  • api/export_pr_test.go: unit test for the single-select case (the most common one — Priority/Status/etc.)
  • pkg/cmd/issue/view/view_test.go: add to the supported-fields expectation

Output shape

Each entry carries __typename, the parent field (name + dataType), and the type-specific payload:

{
  "issueFieldValues": [
    {
      "__typename": "IssueFieldSingleSelectValue",
      "color": "BLUE",
      "field": { "dataType": "SINGLE_SELECT", "name": "Priority" },
      "name": "P2",
      "optionId": "IFSSO_kgAC"
    }
  ]
}

Verified end-to-end against a real issue:

$ gh issue view 29 --repo github/local-agent-loop --json title,issueFieldValues
{"issueFieldValues":[{"__typename":"IssueFieldSingleSelectValue","color":"BLUE","field":{"dataType":"SINGLE_SELECT","name":"Priority"},"name":"P2","optionId":"IFSSO_kgAC"}],"title":"Test issue"}

Notes / open questions

  • Draft because I'd like a maintainer to sanity-check the union flattening shape before I invest in tests for the other three variants (Text/Number/Date) and add a section to the gh issue view --help examples.
  • I went with a flattened shape (typename + payload at the top level) rather than nesting under a value key, mirroring the projectItems precedent. Happy to switch if a nested shape is preferred.
  • No human-readable rendering yet — only JSON. Worth a follow-up to surface the values in the default gh issue view output too.
  • Not sure if this needs a feature flag or schema availability check for older GHES versions; pointers welcome.

go test ./api/... ./pkg/cmd/issue/... passes.

@github-actions github-actions Bot added external pull request originating outside of the CLI core team needs-triage needs to be reviewed labels Jun 23, 2026
GitHub now supports native repository-level issue fields (e.g. Priority,
Estimate) — distinct from ProjectV2 custom fields. These live under the
`issueFieldValues` connection on the `Issue` GraphQL type, but
`gh issue view --json` had no way to surface them.

This adds `issueFieldValues` as a supported JSON field on
`gh issue view` (and inherits to `gh issue list`, `gh issue status`).

Each value carries its `__typename`, the parent `field` (name +
dataType), and the type-specific payload:

- IssueFieldSingleSelectValue: name, optionId, color
- IssueFieldTextValue: text
- IssueFieldNumberValue: number
- IssueFieldDateValue: date

Example:

  gh issue view 29 --repo github/local-agent-loop --json issueFieldValues

  {"issueFieldValues":[{"__typename":"IssueFieldSingleSelectValue",
   "color":"BLUE","field":{"dataType":"SINGLE_SELECT",
   "name":"Priority"},"name":"P2",
   "optionId":"IFSSO_kgAC"}]}

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@owenniblock owenniblock force-pushed the owenniblock/issue-field-values branch from fa4c55b to 86a3e7f Compare June 23, 2026 13:02
Cooper-Runstein

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team needs-triage needs to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants