@nxgt/graphql-validation 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -6
- package/dist/bad-user-input.d.ts +17 -2
- package/dist/bad-user-input.d.ts.map +1 -1
- package/dist/builder/check-constraints.d.ts +4 -2
- package/dist/builder/check-constraints.d.ts.map +1 -1
- package/dist/builder/declared.d.ts +12 -0
- package/dist/builder/declared.d.ts.map +1 -0
- package/dist/chunks/{index-xcaf9kes.js → index-atwkcfg3.js} +5 -5
- package/dist/chunks/{index-xcaf9kes.js.map → index-atwkcfg3.js.map} +2 -2
- package/dist/chunks/{index-twevz7yc.js → index-w9pw7fsk.js} +68 -34
- package/dist/chunks/{index-twevz7yc.js.map → index-w9pw7fsk.js.map} +6 -5
- package/dist/cli.js +1 -1
- package/dist/codegen.js +2 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +380 -10
- package/dist/index.js.map +10 -5
- package/dist/limits/describe.d.ts +9 -0
- package/dist/limits/describe.d.ts.map +1 -0
- package/dist/limits/introspection.d.ts +12 -0
- package/dist/limits/introspection.d.ts.map +1 -0
- package/dist/limits/list-size.d.ts +15 -0
- package/dist/limits/list-size.d.ts.map +1 -0
- package/dist/limits/max-depth.d.ts +28 -0
- package/dist/limits/max-depth.d.ts.map +1 -0
- package/dist/limits/max-list-cost.d.ts +62 -0
- package/dist/limits/max-list-cost.d.ts.map +1 -0
- package/dist/with-validation.d.ts.map +1 -1
- package/docs/README.md +1 -0
- package/docs/guide/constraints.md +3 -3
- package/docs/guide/errors.md +12 -3
- package/docs/guide/query-limits.md +206 -0
- package/docs/roadmap.md +4 -0
- package/docs/troubleshooting.md +53 -0
- package/package.json +1 -1
package/docs/troubleshooting.md
CHANGED
|
@@ -8,6 +8,7 @@ is the one a client sees.
|
|
|
8
8
|
- [Startup](#startup)
|
|
9
9
|
- [Silent traps](#silent-traps)
|
|
10
10
|
- [Runtime](#runtime)
|
|
11
|
+
- [Query limits](#query-limits)
|
|
11
12
|
- [The bin](#the-bin)
|
|
12
13
|
|
|
13
14
|
## Install
|
|
@@ -405,6 +406,58 @@ every issue. The resolver did not run.
|
|
|
405
406
|
| `Too small: expected number to be >=18` | `min: 18` |
|
|
406
407
|
| `Invalid string: must match pattern /.../` | `pattern` |
|
|
407
408
|
|
|
409
|
+
## Query limits
|
|
410
|
+
|
|
411
|
+
### `Operation "Name" is 9 levels deep, more than the 8 allowed`
|
|
412
|
+
|
|
413
|
+
**When:** an operation is validated with `maxDepth({ depth: 8 })`.
|
|
414
|
+
**Why:** `extensions` is `{ code: 'QUERY_TOO_DEEP', depth: 9, limit: 8 }`. A
|
|
415
|
+
top-level field is depth 1; named fragments are followed, inline fragments add
|
|
416
|
+
nothing, `__typename` does not count. `__schema` and `__type` do: the standard
|
|
417
|
+
introspection query is 15 levels deep (pass `ignoreIntrospection: true` where
|
|
418
|
+
it is trusted). An anonymous operation
|
|
419
|
+
reads `Operation is 9 levels deep, ...`.
|
|
420
|
+
**Fix:** flatten the query, or raise `depth`. See
|
|
421
|
+
[Limiting the depth and cost of a query](guide/query-limits.md).
|
|
422
|
+
|
|
423
|
+
### `Operation "Name" costs 5002, more than the 1000 allowed`
|
|
424
|
+
|
|
425
|
+
**When:** an operation is validated with `maxListCost({ budget: 1000, ... })`.
|
|
426
|
+
**Why:** `extensions` is `{ code: 'QUERY_TOO_COSTLY', cost: 5002, limit: 1000 }`.
|
|
427
|
+
Each field costs 1, times the sizes of the lists enclosing it. A list without a
|
|
428
|
+
usable `first` (a variable, a negative number, nothing) counts for its SDL
|
|
429
|
+
default, else `defaultFirst`, so a query that is cheap with the variable's real
|
|
430
|
+
value can still be refused.
|
|
431
|
+
**Fix:** ask for fewer items with a literal `first`, or raise `budget`. A query
|
|
432
|
+
on an interface or a union is overestimated (every branch is summed).
|
|
433
|
+
|
|
434
|
+
### `maxDepth: depth must be an integer from 1 to 9007199254740990.`
|
|
435
|
+
|
|
436
|
+
**When:** `maxDepth` is called with `0`, a negative or a fractional `depth`.
|
|
437
|
+
**Fix:** pass an integer in range.
|
|
438
|
+
|
|
439
|
+
### `maxListCost: budget must be an integer from 0 to 9007199254740990.`
|
|
440
|
+
|
|
441
|
+
**When:** `maxListCost` is called with a negative, fractional or too large
|
|
442
|
+
`budget`. A cost never exceeds `Number.MAX_SAFE_INTEGER` (9007199254740991), so a
|
|
443
|
+
budget at or over it would refuse nothing.
|
|
444
|
+
**Fix:** pass an integer in range.
|
|
445
|
+
|
|
446
|
+
### `maxListCost: defaultFirst must be an integer from 0 to 9007199254740990.`
|
|
447
|
+
|
|
448
|
+
**When:** `defaultFirst` is negative, fractional or too large.
|
|
449
|
+
**Fix:** pass the size to assume for a list with no usable size argument.
|
|
450
|
+
|
|
451
|
+
### A query refused although its `first` is small, or an introspection query refused
|
|
452
|
+
|
|
453
|
+
**When:** `QUERY_TOO_COSTLY` or `QUERY_TOO_DEEP` for GraphiQL's schema fetch or
|
|
454
|
+
a codegen's introspection query.
|
|
455
|
+
**Why:** `__schema` is counted: the standard introspection query is 15 levels
|
|
456
|
+
deep and costs on the order of 200,000 on a one-field schema.
|
|
457
|
+
**Fix:** `ignoreIntrospection: true` on the rule where introspection is
|
|
458
|
+
disabled or the client is trusted. A `first: $n` variable counts for the SDL
|
|
459
|
+
default, not for the value sent.
|
|
460
|
+
|
|
408
461
|
## The bin
|
|
409
462
|
|
|
410
463
|
### `typedefs failed: <message>`
|
package/package.json
CHANGED