MCPcopy
hub / github.com/github/github-mcp-server / fetchIssueFields

Function fetchIssueFields

pkg/github/issue_fields.go:176–198  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

174// If repo is provided, fields are scoped to that repository (inherited from its
175// organization); otherwise fields are returned directly from the organization.
176func 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.

Callers 3

ListIssuesFunction · 0.85
ListIssueFieldsFunction · 0.85
uiGetIssueFieldsFunction · 0.85

Calls 2

issueFieldsFromNodesFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected