@alxia/graphql 0.13.3 → 0.15.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.
@@ -37,6 +37,7 @@ symptom.
37
37
  - [`405 {"errors":[{"message":"Can only perform a mutation operation from a POST request."}]}`](#405-errorsmessagecan-only-perform-a-mutation-operation-from-a-post-request)
38
38
  - [`406` with an empty body](#406-with-an-empty-body)
39
39
  - [`413 {"error":"content_too_large", …}`](#413-errorcontent_too_large--on-post-graphql)
40
+ - [`graphqlExecutor runs queries and mutations, not a subscription.`](#graphqlexecutor-runs-queries-and-mutations-not-a-subscription)
40
41
  - [`Syntax Error: Document contains more than 15000 tokens. Parsing aborted.`](#syntax-error-document-contains-more-than-15000-tokens-parsing-aborted)
41
42
  - [`Syntax Error: Document is nested more than 1000 levels deep. Parsing aborted.`](#syntax-error-document-is-nested-more-than-1000-levels-deep-parsing-aborted)
42
43
  - [`Syntax Error: Document is nested too deeply to parse.`](#syntax-error-document-is-nested-too-deeply-to-parse)
@@ -324,6 +325,84 @@ graphql(app, { schema, parseCache: { maxBytes: 16 * 1024 * 1024 } });
324
325
 
325
326
  ## Responses
326
327
 
328
+ ### `graphqlExecutor runs queries and mutations, not a subscription.`
329
+
330
+ **When:** `graphqlExecutor(...)` is given a document whose operation is a
331
+ subscription; the answer is `{ errors: [{ extensions: { code:
332
+ 'SUBSCRIPTION_NOT_SUPPORTED' } }] }`.
333
+
334
+ **Why:** the executor answers once, with the endpoint's JSON body. A
335
+ subscription streams.
336
+
337
+ **Fix:** serve the subscription through `graphql(app, { schema })` (SSE, or
338
+ `ws: true`), and use the executor for queries and mutations
339
+ ([guide](guide/executor.md)).
340
+
341
+ ### `Too many attempts, try again later` (`RATE_LIMITED`, 429)
342
+
343
+ **When:** an operation selects a field given to `fieldRateLimit` more often
344
+ than its limit allows; nothing executed. `extensions.retryAfter` and the
345
+ `Retry-After` header are the wait in seconds. The code is `RATE_LIMITED`
346
+ unless the `code` option says otherwise (`TOO_MANY_ATTEMPTS`, say). Under
347
+ `batching` the refused element is an error in a 200 array with no
348
+ `Retry-After`: read `extensions.retryAfter`.
349
+
350
+ **Why:** every selection counts, aliases and fragments included, so one
351
+ request with 300 aliases costs 300, and the units spent before a refusal stay
352
+ spent.
353
+
354
+ **Fix:** wait, or raise the limit. A client that really needs several
355
+ selections sends them over several requests.
356
+
357
+ ### `<field> may be selected once per operation` (`FIELD_SELECTED_ONCE`, 400)
358
+
359
+ **When:** a field declared `{ limit, single: true }` is written more than once
360
+ in the executed operation, with another response key or other arguments;
361
+ nothing is consumed. The same selection reached twice (through a fragment)
362
+ counts once.
363
+
364
+ **Fix:** select the field once per operation.
365
+
366
+ ### `TypeError: fieldRateLimit({ fields }): fields maps each field name to count to its limit, and holds at least one`
367
+
368
+ **When:** `fieldRateLimit` is declared with no `fields`, or with none inside.
369
+
370
+ **Fix:** name the fields to count: `fieldRateLimit({ fields: { signIn: limit } })`.
371
+
372
+ ### `TypeError: fieldRateLimit({ fields: { signIn } }): a limit has a consume(key, cost) method, or is { limit, single? }`
373
+
374
+ **When:** a field's value is neither a limit nor `{ limit, single? }`, a
375
+ `RateLimitStore` passed as it is, say.
376
+
377
+ **Fix:** adapt the store with `limitFromStore(store, { limit, windowMs })`, or
378
+ give an object with `consume(key, cost)`.
379
+
380
+ ### `TypeError: fieldRateLimit: ipv6Prefix must be a whole number from 0 to 128`
381
+
382
+ **When:** `ipv6Prefix` is not a whole number from 0 to 128.
383
+
384
+ **Fix:** use `64` for a subscriber's network, or leave it out to count each address.
385
+
386
+ ### `TypeError: fieldRateLimit: ipv6Prefix applies to the default key, and a key of your own was given`
387
+
388
+ **When:** `fieldRateLimit` is given both `ipv6Prefix` and `key`.
389
+
390
+ **Fix:** drop one, or group the address in your own key with `ipv6Network` from `@alxia/rate-limit`.
391
+
392
+ ### `TypeError: fieldRateLimit: code is a non-empty string`
393
+
394
+ **When:** `code` is an empty string or not a string.
395
+
396
+ **Fix:** give the `extensions.code` you want, or leave it out for `RATE_LIMITED`.
397
+
398
+ ### `TypeError: limitFromStore: limit must be a whole number of 1 or more` and `… differs from the store's policy …`
399
+
400
+ **When:** `limitFromStore` is given a `limit` or `windowMs` that is not a whole
401
+ number of 1 or more, none with a store that has no policy, or numbers that
402
+ differ from the store's own `policy`.
403
+
404
+ **Fix:** give whole numbers, or leave the policy out for a store that has one.
405
+
327
406
  ### `Syntax Error: Document contains more than 15000 tokens. Parsing aborted.`
328
407
 
329
408
  **When:** a query is answered with `GRAPHQL_PARSE_FAILED` (400 under
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alxia/graphql",
3
- "version": "0.13.3",
3
+ "version": "0.15.0",
4
4
  "description": "GraphQL for alxia with GraphQL Yoga: its plugins, subscriptions over SSE or WebSocket (graphql-ws) and GraphiQL, behind the app's hooks, its resolvers reading the app's typed context",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -47,14 +47,15 @@
47
47
  ]
48
48
  },
49
49
  "devDependencies": {
50
- "@alxia/core": "^0.19.0",
51
- "@alxia/logger": "^0.6.11",
52
- "@alxia/telemetry": "^0.7.9",
50
+ "@alxia/core": "^0.20.0",
51
+ "@alxia/logger": "^0.6.12",
52
+ "@alxia/rate-limit": "^0.6.0",
53
+ "@alxia/telemetry": "^0.8.1",
53
54
  "@envelop/depth-limit": "^7.2.1",
54
55
  "@graphql-hive/logger": "^1.1.1",
55
56
  "@graphql-yoga/plugin-csrf-prevention": "^4.0.1",
56
57
  "@graphql-yoga/plugin-persisted-operations": "^4.0.1",
57
- "@nxgt/telemetry": "^0.2.2",
58
+ "@softistx/telemetry": "^0.3.0",
58
59
  "@types/bun": "^1.4.4",
59
60
  "dataloader": "^2.2.3",
60
61
  "graphql": "^16.11.0",
@@ -62,7 +63,7 @@
62
63
  "graphql-yoga": "^6.0.1"
63
64
  },
64
65
  "peerDependencies": {
65
- "@alxia/core": "^0.19.0",
66
+ "@alxia/core": "^0.20.0",
66
67
  "graphql": "^16.11.0 || ^17.0.0",
67
68
  "graphql-ws": "^6.1.0",
68
69
  "graphql-yoga": "^5.16.0 || ^6.0.0",