Skip to content

Commit 34c3b3c

Browse files
committed
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.
1 parent cf862d6 commit 34c3b3c

3 files changed

Lines changed: 55 additions & 3 deletions

File tree

api/export_pr_test.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,32 @@ func TestIssue_ExportData(t *testing.T) {
107107
}
108108
`),
109109
},
110+
{
111+
name: "assignees",
112+
fields: []string{"assignees"},
113+
inputJSON: heredoc.Doc(`
114+
{ "assignees": { "nodes": [
115+
{
116+
"id": "MDQ6VXNlcjE=",
117+
"login": "monalisa",
118+
"name": "Mona Lisa",
119+
"databaseId": 1234
120+
}
121+
] } }
122+
`),
123+
outputJSON: heredoc.Doc(`
124+
{
125+
"assignees": [
126+
{
127+
"id": "MDQ6VXNlcjE=",
128+
"login": "monalisa",
129+
"name": "Mona Lisa",
130+
"databaseId": 1234
131+
}
132+
]
133+
}
134+
`),
135+
},
110136
{
111137
name: "linked pull requests",
112138
fields: []string{"closedByPullRequestsReferences"},
@@ -316,6 +342,32 @@ func TestPullRequest_ExportData(t *testing.T) {
316342
}
317343
`),
318344
},
345+
{
346+
name: "assignees",
347+
fields: []string{"assignees"},
348+
inputJSON: heredoc.Doc(`
349+
{ "assignees": { "nodes": [
350+
{
351+
"id": "MDQ6VXNlcjE=",
352+
"login": "monalisa",
353+
"name": "Mona Lisa",
354+
"databaseId": 1234
355+
}
356+
] } }
357+
`),
358+
outputJSON: heredoc.Doc(`
359+
{
360+
"assignees": [
361+
{
362+
"id": "MDQ6VXNlcjE=",
363+
"login": "monalisa",
364+
"name": "Mona Lisa",
365+
"databaseId": 1234
366+
}
367+
]
368+
}
369+
`),
370+
},
319371
{
320372
name: "linked issues",
321373
fields: []string{"closingIssuesReferences"},

api/query_builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ func IssueGraphQL(fields []string) string {
388388
case "headRepository":
389389
q = append(q, `headRepository{id,name}`)
390390
case "assignees":
391-
q = append(q, `assignees(first:100){nodes{id,login,name},totalCount}`)
391+
q = append(q, `assignees(first:100){nodes{id,login,name,databaseId},totalCount}`)
392392
case "assignedActors":
393393
q = append(q, assignedActors)
394394
case "labels":

api/query_builder_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func TestPullRequestGraphQL(t *testing.T) {
2121
{
2222
name: "fields with nested structures",
2323
fields: []string{"author", "assignees"},
24-
want: "author{login,...on User{id,name}},assignees(first:100){nodes{id,login,name},totalCount}",
24+
want: "author{login,...on User{id,name}},assignees(first:100){nodes{id,login,name,databaseId},totalCount}",
2525
},
2626
{
2727
name: "compressed query",
@@ -67,7 +67,7 @@ func TestIssueGraphQL(t *testing.T) {
6767
{
6868
name: "fields with nested structures",
6969
fields: []string{"author", "assignees"},
70-
want: "author{login,...on User{id,name}},assignees(first:100){nodes{id,login,name},totalCount}",
70+
want: "author{login,...on User{id,name}},assignees(first:100){nodes{id,login,name,databaseId},totalCount}",
7171
},
7272
{
7373
name: "compressed query",

0 commit comments

Comments
 (0)