ghAPIGraphQL calls the GitHub GraphQL API via gh cli and returns the parsed JSON.
(query string, repo string)
| 267 | |
| 268 | // ghAPIGraphQL calls the GitHub GraphQL API via gh cli and returns the parsed JSON. |
| 269 | func 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. |
| 290 | func timeBetween(from, to string) float64 { |
nothing calls this directly
no test coverage detected