Fix broken GraphQL queries due to editing Author struct

This commit is contained in:
Mislav Marohnić 2021-05-18 18:35:34 +02:00
parent 42155c7d2d
commit 1440fd81a1
3 changed files with 8 additions and 7 deletions

View file

@ -104,8 +104,9 @@ type Owner struct {
}
type Author struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
// adding these breaks generated GraphQL requests
//ID string `json:"id,omitempty"`
//Name string `json:"name,omitempty"`
Login string `json:"login"`
}

View file

@ -21,7 +21,7 @@ func shortenQuery(q string) string {
var issueComments = shortenQuery(`
comments(first: 100) {
nodes {
author{login,...on User{id,name}},
author{login},
authorAssociation,
body,
createdAt,
@ -177,11 +177,11 @@ func PullRequestGraphQL(fields []string) string {
for _, field := range fields {
switch field {
case "author":
q = append(q, `author{login,...on User{id,name}}`)
q = append(q, `author{login}`)
case "mergedBy":
q = append(q, `mergedBy{login,,...on User{id,name}}`)
q = append(q, `mergedBy{login}`)
case "headRepositoryOwner":
q = append(q, `headRepositoryOwner{id,login,,...on User{name}}`)
q = append(q, `headRepositoryOwner{id,login,...on User{name}}`)
case "headRepository":
q = append(q, `headRepository{id,name}`)
case "assignees":

View file

@ -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},assignees(first:100){nodes{id,login,name},totalCount}",
},
{
name: "compressed query",