(path string, val any, name string)
| 425 | } |
| 426 | |
| 427 | func (w *gqlWalker) checkScalar(path string, val any, name string) { |
| 428 | switch { |
| 429 | case stringScalars[name]: |
| 430 | if _, ok := val.(string); !ok { |
| 431 | w.addf(path, "should be a string (%s), but is %s", name, describeJSON(val)) |
| 432 | } |
| 433 | case name == "Int": |
| 434 | n, ok := val.(json.Number) |
| 435 | if !ok { |
| 436 | w.addf(path, "should be a whole number (Int), but is %s", describeJSON(val)) |
| 437 | return |
| 438 | } |
| 439 | if i, err := n.Int64(); err != nil || i < math.MinInt32 || i > math.MaxInt32 { |
| 440 | w.addf(path, "%s isn't a 32-bit whole number (Int)", n) |
| 441 | } |
| 442 | case name == "Float": |
| 443 | if _, ok := val.(json.Number); !ok { |
| 444 | w.addf(path, "should be a number (Float), but is %s", describeJSON(val)) |
| 445 | } |
| 446 | case name == "Boolean": |
| 447 | if _, ok := val.(bool); !ok { |
| 448 | w.addf(path, "should be true or false (Boolean), but is %s", describeJSON(val)) |
| 449 | } |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | func possibleTypeNames(schema *ast.Schema, def *ast.Definition) []string { |
| 454 | var names []string |
no test coverage detected