From 34c3b3c809cf4a81428b4acbb5c2a582091a2b29 Mon Sep 17 00:00:00 2001 From: Simon Taranto Date: Wed, 25 Feb 2026 10:22:42 -0500 Subject: [PATCH] Add databaseId to assignees GraphQL fragment 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. --- api/export_pr_test.go | 52 +++++++++++++++++++++++++++++++++++++++ api/query_builder.go | 2 +- api/query_builder_test.go | 4 +-- 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/api/export_pr_test.go b/api/export_pr_test.go index 1f310693e68..ec7b002498c 100644 --- a/api/export_pr_test.go +++ b/api/export_pr_test.go @@ -107,6 +107,32 @@ func TestIssue_ExportData(t *testing.T) { } `), }, + { + name: "assignees", + fields: []string{"assignees"}, + inputJSON: heredoc.Doc(` + { "assignees": { "nodes": [ + { + "id": "MDQ6VXNlcjE=", + "login": "monalisa", + "name": "Mona Lisa", + "databaseId": 1234 + } + ] } } + `), + outputJSON: heredoc.Doc(` + { + "assignees": [ + { + "id": "MDQ6VXNlcjE=", + "login": "monalisa", + "name": "Mona Lisa", + "databaseId": 1234 + } + ] + } + `), + }, { name: "linked pull requests", fields: []string{"closedByPullRequestsReferences"}, @@ -316,6 +342,32 @@ func TestPullRequest_ExportData(t *testing.T) { } `), }, + { + name: "assignees", + fields: []string{"assignees"}, + inputJSON: heredoc.Doc(` + { "assignees": { "nodes": [ + { + "id": "MDQ6VXNlcjE=", + "login": "monalisa", + "name": "Mona Lisa", + "databaseId": 1234 + } + ] } } + `), + outputJSON: heredoc.Doc(` + { + "assignees": [ + { + "id": "MDQ6VXNlcjE=", + "login": "monalisa", + "name": "Mona Lisa", + "databaseId": 1234 + } + ] + } + `), + }, { name: "linked issues", fields: []string{"closingIssuesReferences"}, diff --git a/api/query_builder.go b/api/query_builder.go index 766c2b4aa1b..cb80b595f0c 100644 --- a/api/query_builder.go +++ b/api/query_builder.go @@ -388,7 +388,7 @@ func IssueGraphQL(fields []string) string { case "headRepository": q = append(q, `headRepository{id,name}`) case "assignees": - q = append(q, `assignees(first:100){nodes{id,login,name},totalCount}`) + q = append(q, `assignees(first:100){nodes{id,login,name,databaseId},totalCount}`) case "assignedActors": q = append(q, assignedActors) case "labels": diff --git a/api/query_builder_test.go b/api/query_builder_test.go index e39b0826958..f854cd36ac2 100644 --- a/api/query_builder_test.go +++ b/api/query_builder_test.go @@ -21,7 +21,7 @@ func TestPullRequestGraphQL(t *testing.T) { { name: "fields with nested structures", fields: []string{"author", "assignees"}, - want: "author{login,...on User{id,name}},assignees(first:100){nodes{id,login,name},totalCount}", + want: "author{login,...on User{id,name}},assignees(first:100){nodes{id,login,name,databaseId},totalCount}", }, { name: "compressed query", @@ -67,7 +67,7 @@ func TestIssueGraphQL(t *testing.T) { { name: "fields with nested structures", fields: []string{"author", "assignees"}, - want: "author{login,...on User{id,name}},assignees(first:100){nodes{id,login,name},totalCount}", + want: "author{login,...on User{id,name}},assignees(first:100){nodes{id,login,name,databaseId},totalCount}", }, { name: "compressed query",