schemaCheck checks resp against GitHub's schema. It returns the problems it found, or, when it couldn't check, a line saying why.
(st *state, chk *checker, name string, resp *response)
| 245 | // schemaCheck checks resp against GitHub's schema. It returns the problems it |
| 246 | // found, or, when it couldn't check, a line saying why. |
| 247 | func schemaCheck(st *state, chk *checker, name string, resp *response) (problems []string, skipped string, err error) { |
| 248 | method, target, _ := strings.Cut(name, " ") |
| 249 | e := loggedRequest{Name: name, Method: method, Host: dotcomAPIHost, Path: target} |
| 250 | if method == "graphql" { |
| 251 | if _, err := chk.graphQL(); err != nil { |
| 252 | return nil, fmt.Sprintf("Schema check: skipped, GraphQL checks are off: %v", err), nil |
| 253 | } |
| 254 | query, err := lastQuery(st, name) |
| 255 | if err != nil { |
| 256 | return nil, "", err |
| 257 | } |
| 258 | if query == "" { |
| 259 | return nil, fmt.Sprintf("Schema check: not yet, because gh hasn't sent %s; the next run checks it", name), nil |
| 260 | } |
| 261 | e = loggedRequest{Name: name, Method: http.MethodPost, Host: dotcomAPIHost, Path: "/graphql", GraphQL: &graphQLRequest{Query: query}} |
| 262 | } else { |
| 263 | if host, path, ok := strings.Cut(target, "/"); ok && host != "" { |
| 264 | e.Host, e.Path = host, "/"+path |
| 265 | } |
| 266 | if isAPIHost(e.Host) { |
| 267 | if _, err := chk.rest(); err != nil { |
| 268 | return nil, fmt.Sprintf("Schema check: skipped, REST checks are off: %v", err), nil |
| 269 | } |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | res := chk.checkResponse(e, resp) |
| 274 | switch { |
| 275 | case len(res.responseProblems) > 0: |
| 276 | return res.responseProblems, "", nil |
| 277 | case res.note != "": |
| 278 | return nil, "Schema check: skipped, " + res.note, nil |
| 279 | default: |
| 280 | return nil, "", nil |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | // lastQuery returns the query gh most recently sent for a GraphQL request |
| 285 | // name, or "" if it hasn't sent one. |
no test coverage detected