MCPcopy Create free account
hub / github.com/github/gh-aw / ghAPIGraphQL

Function ghAPIGraphQL

pkg/cli/outcome_eval.go:269–287  ·  view source on GitHub ↗

ghAPIGraphQL calls the GitHub GraphQL API via gh cli and returns the parsed JSON.

(query string, repo string)

Source from the content-addressed store, hash-verified

267
268// ghAPIGraphQL calls the GitHub GraphQL API via gh cli and returns the parsed JSON.
269func ghAPIGraphQL(query string, repo string) (map[string]any, error) {
270 ownerRepo, host := repoutil.NormalizeRepoForAPI(repo)
271 args := []string{"api", "graphql", "-f", "query=" + query}
272 var output []byte
273 var err error
274 if host != "" {
275 output, err = workflow.RunGHWithHost("Checking outcome...", host, args...)
276 } else {
277 output, err = workflow.RunGH("Checking outcome...", args...)
278 }
279 if err != nil {
280 return nil, fmt.Errorf("gh api graphql: %w", err)
281 }
282 var result map[string]any
283 if err := json.Unmarshal(output, &result); err != nil {
284 return nil, fmt.Errorf("parsing graphql response for %s: %w", ownerRepo, err)
285 }
286 return result, nil
287}
288
289// timeBetween computes hours between two ISO timestamps.
290func timeBetween(from, to string) float64 {

Callers

nothing calls this directly

Calls 4

NormalizeRepoForAPIFunction · 0.92
RunGHWithHostFunction · 0.92
RunGHFunction · 0.92
ErrorfMethod · 0.45

Tested by

no test coverage detected