MCPcopy Index your code
hub / github.com/github/github-mcp-server / fetchIssueFieldValuesByNodeID

Function fetchIssueFieldValuesByNodeID

pkg/github/issues.go:1725–1757  ·  view source on GitHub ↗

fetchIssueFieldValuesByNodeID runs one GraphQL nodes() query for the given REST issues and returns a map of node_id -> flattened field values. Issues without a node_id are skipped, and an empty result set short-circuits the round-trip.

(ctx context.Context, gqlClient *githubv4.Client, issues []*github.Issue)

Source from the content-addressed store, hash-verified

1723// returns a map of node_id -> flattened field values. Issues without a node_id are skipped, and
1724// an empty result set short-circuits the round-trip.
1725func fetchIssueFieldValuesByNodeID(ctx context.Context, gqlClient *githubv4.Client, issues []*github.Issue) (map[string][]MinimalFieldValue, error) {
1726 ids := make([]githubv4.ID, 0, len(issues))
1727 for _, iss := range issues {
1728 if iss == nil || iss.NodeID == nil || *iss.NodeID == "" {
1729 continue
1730 }
1731 ids = append(ids, githubv4.ID(*iss.NodeID))
1732 }
1733 if len(ids) == 0 {
1734 return nil, nil
1735 }
1736
1737 var q searchIssuesNodesQuery
1738 if err := gqlClient.Query(ctx, &q, map[string]any{"ids": ids}); err != nil {
1739 return nil, err
1740 }
1741
1742 result := make(map[string][]MinimalFieldValue, len(q.Nodes))
1743 for _, n := range q.Nodes {
1744 idStr, ok := n.Issue.ID.(string)
1745 if !ok || idStr == "" {
1746 continue
1747 }
1748 vals := make([]MinimalFieldValue, 0, len(n.Issue.IssueFieldValues.Nodes))
1749 for _, fv := range n.Issue.IssueFieldValues.Nodes {
1750 if m, ok := fragmentToMinimalFieldValue(fv); ok {
1751 vals = append(vals, m)
1752 }
1753 }
1754 result[idStr] = vals
1755 }
1756 return result, nil
1757}
1758
1759// searchIssuesHandler runs the REST issues search, enriches each hit with custom field values
1760// fetched via a single follow-up GraphQL nodes() query, and applies any post-process options

Callers 2

GetIssueFunction · 0.85
searchIssuesHandlerFunction · 0.85

Calls 1

Tested by

no test coverage detected