fetchIssueFields returns the issue field definitions for the given owner. If repo is provided, fields are scoped to that repository (inherited from its organization); otherwise fields are returned directly from the organization.
(ctx context.Context, gqlClient *githubv4.Client, owner, repo string)
| 174 | // If repo is provided, fields are scoped to that repository (inherited from its |
| 175 | // organization); otherwise fields are returned directly from the organization. |
| 176 | func fetchIssueFields(ctx context.Context, gqlClient *githubv4.Client, owner, repo string) ([]IssueField, error) { |
| 177 | ctxWithFeatures := ghcontext.WithGraphQLFeatures(ctx, "issue_fields", "repo_issue_fields") |
| 178 | if repo != "" { |
| 179 | var query issueFieldsRepoQuery |
| 180 | vars := map[string]any{ |
| 181 | "owner": githubv4.String(owner), |
| 182 | "name": githubv4.String(repo), |
| 183 | } |
| 184 | if err := gqlClient.Query(ctxWithFeatures, &query, vars); err != nil { |
| 185 | return nil, err |
| 186 | } |
| 187 | return issueFieldsFromNodes(query.Repository.IssueFields.Nodes), nil |
| 188 | } |
| 189 | |
| 190 | var query issueFieldsOrgQuery |
| 191 | vars := map[string]any{ |
| 192 | "login": githubv4.String(owner), |
| 193 | } |
| 194 | if err := gqlClient.Query(ctxWithFeatures, &query, vars); err != nil { |
| 195 | return nil, err |
| 196 | } |
| 197 | return issueFieldsFromNodes(query.Organization.IssueFields.Nodes), nil |
| 198 | } |
| 199 | |
| 200 | // issueFieldsFromNodes converts GraphQL issue field union nodes into IssueField values. |
| 201 | // Read from the fragment matching __typename; the other fragments are zero-valued. |
no test coverage detected