Add databaseId to assignees GraphQL fragment#12783
Merged
Conversation
The assignees query fragment only requested id, login, and name but the GitHubUser struct includes a DatabaseID field. Since the field was never requested from the API, it always defaulted to Go's zero value (0) in JSON output. This adds databaseId to the fragment so the actual value is returned. Also adds ExportData test cases for assignees on both Issue and PullRequest to verify databaseId round-trips correctly through JSON serialization.
593c8b1 to
34c3b3c
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes databaseId always being 0 for assignees in --json outputs by ensuring the assignees GraphQL fragment requests databaseId, allowing the existing GitHubUser.DatabaseID field to be populated correctly.
Changes:
- Add
databaseIdto theassigneesGraphQL fragment generated byIssueGraphQL(and thereforePullRequestGraphQL). - Update query builder string expectations in unit tests.
- Add export round-trip tests to verify
databaseIdfor assignees survives JSON serialization for both issues and pull requests.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
api/query_builder.go |
Extends the assignees GraphQL selection set to include databaseId. |
api/query_builder_test.go |
Updates expected query fragments to include databaseId for assignees. |
api/export_pr_test.go |
Adds regression tests ensuring assignee databaseId is non-zero and preserved in exported JSON. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
databaseIdalways being0for assignees in--jsonoutput (e.g.gh issue view --json assignees)GitHubUserstruct already has aDatabaseIDfield, but the GraphQL query fragment for assignees never requesteddatabaseIdfrom the API, so it always defaulted to Go's zero valueDetails
The assignees fragment in
query_builder.gorequested onlyid,login, andname:This meant the
DatabaseID int64field onGitHubUserwas never populated, producing"databaseId": 0in JSON output. The fix addsdatabaseIdto the fragment:PullRequestGraphQLdelegates toIssueGraphQL, so both issue and PR queries are fixed by this single change.Behavioral note
This is an additive change to
--json assigneesoutput —databaseIdwill now contain the real value instead of0. This is not breaking for JSON consumers, but downstream scripts doing strict schema validation may notice the corrected field.Testing
query_builder_test.gofor bothTestPullRequestGraphQLandTestIssueGraphQLto expect the new field in the query stringExportDataround-trip test cases inexport_pr_test.gofor bothTestIssue_ExportDataandTestPullRequest_ExportDatathat verify a non-zerodatabaseId(1234) survives JSON serialization